13 #ifndef LLVM_CODEGEN_MACHINEOPERAND_H 14 #define LLVM_CODEGEN_MACHINEOPERAND_H 30 class MachineBasicBlock;
32 class MachineRegisterInfo;
33 class MCCFIInstruction;
35 class ModuleSlotTracker;
37 class TargetIntrinsicInfo;
38 class TargetRegisterInfo;
85 unsigned SubReg_TargetFlags : 12;
108 unsigned IsDeadOrKill : 1;
111 unsigned IsRenamable : 1;
130 unsigned IsUndef : 1;
141 unsigned IsInternalRead : 1;
146 unsigned IsEarlyClobber : 1;
150 unsigned IsDebug : 1;
166 union ContentsUnion {
201 : OpKind(K), SubReg_TargetFlags(0), ParentMI(
nullptr) {
204 "MachineOperand shouldn't be more than 8 byte aligned");
205 static_assert(
sizeof(Contents) <= 2 *
sizeof(
void *),
206 "Contents should be at most two pointers");
208 alignTo<
alignof(int64_t)>(2 *
sizeof(
unsigned) +
210 "MachineOperand too big. Should be Kind, SmallContents, " 211 "ParentMI, and Contents");
220 return isReg() ? 0 : SubReg_TargetFlags;
223 assert(!
isReg() &&
"Register operands can't have target flags");
224 SubReg_TargetFlags =
F;
225 assert(SubReg_TargetFlags == F &&
"Target flags out of range");
228 assert(!
isReg() &&
"Register operands can't have target flags");
229 SubReg_TargetFlags |=
F;
230 assert((SubReg_TargetFlags & F) &&
"Target flags out of range");
302 bool ShouldPrintRegisterTies,
unsigned TiedOperandIdx,
359 assert(
isReg() &&
"This is not a register operand!");
360 return Register(SmallContents.RegNo);
364 assert(
isReg() &&
"Wrong MachineOperand accessor");
365 return SubReg_TargetFlags;
369 assert(
isReg() &&
"Wrong MachineOperand accessor");
374 assert(
isReg() &&
"Wrong MachineOperand accessor");
379 assert(
isReg() &&
"Wrong MachineOperand accessor");
384 assert(
isReg() &&
"Wrong MachineOperand accessor");
385 return IsDeadOrKill & IsDef;
389 assert(
isReg() &&
"Wrong MachineOperand accessor");
390 return IsDeadOrKill & !IsDef;
394 assert(
isReg() &&
"Wrong MachineOperand accessor");
430 assert(
isReg() &&
"Wrong MachineOperand accessor");
431 return IsInternalRead;
435 assert(
isReg() &&
"Wrong MachineOperand accessor");
436 return IsEarlyClobber;
440 assert(
isReg() &&
"Wrong MachineOperand accessor");
445 assert(
isReg() &&
"Wrong MachineOperand accessor");
457 assert(
isReg() &&
"Wrong MachineOperand accessor");
471 SubReg_TargetFlags = subReg;
472 assert(SubReg_TargetFlags == subReg &&
"SubReg out of range");
499 assert(
isReg() && !IsDef &&
"Wrong MachineOperand mutator");
500 assert((!Val || !
isDebug()) &&
"Marking a debug operation as kill");
505 assert(
isReg() && IsDef &&
"Wrong MachineOperand mutator");
518 IsInternalRead = Val;
522 assert(
isReg() && IsDef &&
"Wrong MachineOperand mutator");
523 IsEarlyClobber = Val;
527 assert(
isReg() && !IsDef &&
"Wrong MachineOperand mutator");
536 assert(
isImm() &&
"Wrong MachineOperand accessor");
537 return Contents.ImmVal;
551 assert(
isMBB() &&
"Wrong MachineOperand accessor");
557 "Wrong MachineOperand accessor");
558 return Contents.OffsetedInfo.Val.Index;
563 return Contents.OffsetedInfo.Val.GV;
568 return Contents.OffsetedInfo.Val.BA;
578 return Contents.CFIIndex;
583 return Contents.IntrinsicID;
588 return Contents.Pred;
593 return Contents.ShuffleMask;
601 "Wrong MachineOperand accessor");
602 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
603 SmallContents.OffsetLo;
608 return Contents.OffsetedInfo.Val.SymbolName;
617 assert(PhysReg < (1u << 30) &&
"Not a physical register");
618 return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
630 return Contents.RegMask;
635 return (NumRegs + 31) / 32;
641 return Contents.RegMask;
655 Contents.ImmVal = immVal;
671 "Wrong MachineOperand mutator");
672 SmallContents.OffsetLo =
unsigned(Offset);
673 Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
678 "Wrong MachineOperand mutator");
679 Contents.OffsetedInfo.Val.Index = Idx;
698 Contents.RegMask = RegMaskPtr;
734 void ChangeToES(
const char *SymName,
unsigned TargetFlags = 0);
738 unsigned TargetFlags = 0);
748 unsigned TargetFlags = 0);
775 Op.Contents.CFP = CFP;
785 bool isRenamable =
false) {
799 Op.Contents.Reg.Prev =
nullptr;
800 Op.Contents.Reg.Next =
nullptr;
805 unsigned TargetFlags = 0) {
817 unsigned TargetFlags = 0) {
825 unsigned TargetFlags = 0) {
839 unsigned TargetFlags = 0) {
841 Op.Contents.OffsetedInfo.Val.GV = GV;
847 unsigned TargetFlags = 0) {
849 Op.Contents.OffsetedInfo.Val.SymbolName = SymName;
855 unsigned TargetFlags = 0) {
857 Op.Contents.OffsetedInfo.Val.BA = BA;
875 assert(Mask &&
"Missing register mask");
877 Op.Contents.RegMask =
Mask;
881 assert(Mask &&
"Missing live-out register mask");
883 Op.Contents.RegMask =
Mask;
888 Op.Contents.MD = Meta;
893 unsigned TargetFlags = 0) {
895 Op.Contents.Sym = Sym;
903 Op.Contents.CFIIndex = CFIIndex;
909 Op.Contents.IntrinsicID =
ID;
915 Op.Contents.Pred = Pred;
921 Op.Contents.ShuffleMask =
Mask;
931 void removeRegFromUses();
934 enum :
unsigned char {
948 bool isOnRegUseList()
const {
949 assert(
isReg() &&
"Can only add reg operand to use lists");
950 return Contents.Reg.Prev !=
nullptr;
956 return MachineOperand(static_cast<MachineOperand::MachineOperandType>(
957 MachineOperand::MO_Empty));
960 return MachineOperand(static_cast<MachineOperand::MachineOperandType>(
961 MachineOperand::MO_Tombstone));
968 MachineOperand::MO_Empty) ||
970 MachineOperand::MO_Tombstone))
ArrayRef< int > getShuffleMask() const
unsigned getTargetFlags() const
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
static MachineOperand getTombstoneKey()
static void printOperandOffset(raw_ostream &OS, int64_t Offset)
Print the offset with explicit +/- signs.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static MachineOperand CreateCImm(const ConstantInt *CI)
Wrapper class representing physical registers. Should be passed by value.
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
void setTargetFlags(unsigned F)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void setFPImm(const ConstantFP *CFP)
bool isRegLiveOut() const
isRegLiveOut - Tests if this is a MO_RegisterLiveOut operand.
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
bool isShuffleMask() const
void ChangeToES(const char *SymName, unsigned TargetFlags=0)
ChangeToES - Replace this operand with a new external symbol operand.
static void printTargetFlags(raw_ostream &OS, const MachineOperand &Op)
Print operand target flags.
void setIsDef(bool Val=true)
Change a def to a use, or a use to a def.
void setIsUndef(bool Val=true)
Address of indexed Jump Table for switch.
unsigned getSubReg() const
void substVirtReg(Register Reg, unsigned SubIdx, const TargetRegisterInfo &)
substVirtReg - Substitute the current register with the virtual subregister Reg:SubReg.
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
MachineBasicBlock reference.
void ChangeToGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
ChangeToGA - Replace this operand with a new global address operand.
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
Manage lifetime of a slot tracker for printing IR.
Mask of live-out registers.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsRenamable(bool Val=true)
bool isInternalRead() const
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
Mask of preserved registers.
bool isEarlyClobber() const
void ChangeToMCSymbol(MCSymbol *Sym)
ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
bool isIntrinsicID() const
The address of a basic block.
void substPhysReg(MCRegister Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
const uint32_t * getRegLiveOut() const
getRegLiveOut - Returns a bit mask of live-out registers.
const ConstantFP * getFPImm() const
Target-dependent index+offset operand.
void setImplicit(bool Val=true)
Name of external global symbol.
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
const char * getSymbolName() const
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
unsigned getCFIIndex() const
void setIsEarlyClobber(bool Val=true)
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
Immediate >64bit operand.
void setRegMask(const uint32_t *RegMaskPtr)
Sets value of register mask operand referencing Mask.
void clearParent()
clearParent - Reset the parent pointer.
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
void setReg(Register Reg)
Change the register this operand corresponds to.
static MachineOperand CreatePredicate(unsigned Pred)
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
Address of a global value.
static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags=0)
static MachineOperand CreateFPImm(const ConstantFP *CFP)
const GlobalValue * getGlobal() const
ConstantFP - Floating Point Values [float, double].
void setMBB(MachineBasicBlock *MBB)
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
static void printStackObjectReference(raw_ostream &OS, unsigned FrameIndex, bool IsFixed, StringRef Name)
Print a stack object reference.
Address of a basic block.
void setImm(int64_t immVal)
void setIsInternalRead(bool Val=true)
static bool isEqual(const MachineOperand &LHS, const MachineOperand &RHS)
void setOffset(int64_t Offset)
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
bool clobbersPhysReg(unsigned PhysReg) const
clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static void printSymbol(raw_ostream &OS, MCSymbol &Sym)
Print a MCSymbol as an operand.
static void printIRSlotNumber(raw_ostream &OS, int Slot)
Print an IRSlotNumber.
void setIsKill(bool Val=true)
static MachineOperand CreateES(const char *SymName, unsigned TargetFlags=0)
TargetIntrinsicInfo - Interface to description of machine instruction set.
static MachineOperand getEmptyKey()
static MachineOperand CreateMetadata(const MDNode *Meta)
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
This is the shared class of boolean and integer constants.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
Generic predicate for ISel.
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr, const TargetIntrinsicInfo *IntrinsicInfo=nullptr) const
Print the MachineOperand to os.
MachineOperand class - Representation of each machine instruction operand.
Intrinsic::ID getIntrinsicID() const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
void ChangeToFPImmediate(const ConstantFP *FPImm)
ChangeToFPImmediate - Replace this operand with a new FP immediate operand of the specified value...
Promote Memory to Register
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
void setMetadata(const MDNode *MD)
friend hash_code hash_value(const MachineOperand &MO)
MachineOperand hash_value overload.
MCSymbol reference (for debug/eh info)
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
An opaque object representing a hash code.
static void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)
Print a subreg index operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void setPredicate(unsigned Predicate)
Representation of each machine instruction.
void addTargetFlag(unsigned F)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
static unsigned getHashValue(const MachineOperand &MO)
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
int64_t getOffset() const
Return the offset from the symbol in this operand.
const BlockAddress * getBlockAddress() const
static MachineOperand CreateImm(int64_t Val)
void setIsUse(bool Val=true)
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
void setSubReg(unsigned subReg)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
static MachineOperand CreateShuffleMask(ArrayRef< int > Mask)
void ChangeToTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
Replace this operand with a target index.
void setCImm(const ConstantInt *CI)
Abstract Stack Frame Index.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getMCSymbol() const
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
Floating-point immediate operand.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void ChangeToFrameIndex(int Idx)
Replace this operand with a frame index.
This class implements an extremely fast bulk output stream that can only output to a stream...
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
StringRef - Represent a constant reference to a string, i.e.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
Address of indexed Constant in Constant Pool.
Register getReg() const
getReg - Returns the register number.
void setIsDebug(bool Val=true)
const ConstantInt * getCImm() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Other IR Constant for ISel (shuffle masks)
static MachineOperand CreateFI(int Idx)
const MDNode * getMetadata() const
Wrapper class representing virtual and physical registers.
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned TargetFlags=0)
Metadata reference (for debug info)
const MachineInstr * getParent() const
unsigned getPredicate() const