14 #ifndef LLVM_CODEGEN_MACHINEOPERAND_H 15 #define LLVM_CODEGEN_MACHINEOPERAND_H 29 class MachineBasicBlock;
31 class MachineRegisterInfo;
32 class MCCFIInstruction;
34 class ModuleSlotTracker;
36 class TargetIntrinsicInfo;
37 class TargetRegisterInfo;
83 unsigned SubReg_TargetFlags : 12;
106 unsigned IsDeadOrKill : 1;
109 unsigned IsRenamable : 1;
128 unsigned IsUndef : 1;
139 unsigned IsInternalRead : 1;
144 unsigned IsEarlyClobber : 1;
148 unsigned IsDebug : 1;
197 : OpKind(K), SubReg_TargetFlags(0), ParentMI(nullptr) {
200 "MachineOperand shouldn't be more than 8 byte aligned");
201 static_assert(
sizeof(Contents) <= 2 *
sizeof(
void *),
202 "Contents should be at most two pointers");
204 alignTo<
alignof(int64_t)>(2 *
sizeof(
unsigned) +
206 "MachineOperand too big. Should be Kind, SmallContents, " 207 "ParentMI, and Contents");
216 return isReg() ? 0 : SubReg_TargetFlags;
219 assert(!
isReg() &&
"Register operands can't have target flags");
220 SubReg_TargetFlags =
F;
221 assert(SubReg_TargetFlags == F &&
"Target flags out of range");
224 assert(!
isReg() &&
"Register operands can't have target flags");
225 SubReg_TargetFlags |=
F;
226 assert((SubReg_TargetFlags & F) &&
"Target flags out of range");
294 bool PrintDef,
bool IsStandalone,
bool ShouldPrintRegisterTies,
350 assert(
isReg() &&
"This is not a register operand!");
351 return SmallContents.RegNo;
355 assert(
isReg() &&
"Wrong MachineOperand accessor");
356 return SubReg_TargetFlags;
360 assert(
isReg() &&
"Wrong MachineOperand accessor");
365 assert(
isReg() &&
"Wrong MachineOperand accessor");
370 assert(
isReg() &&
"Wrong MachineOperand accessor");
375 assert(
isReg() &&
"Wrong MachineOperand accessor");
376 return IsDeadOrKill & IsDef;
380 assert(
isReg() &&
"Wrong MachineOperand accessor");
381 return IsDeadOrKill & !IsDef;
385 assert(
isReg() &&
"Wrong MachineOperand accessor");
421 assert(
isReg() &&
"Wrong MachineOperand accessor");
422 return IsInternalRead;
426 assert(
isReg() &&
"Wrong MachineOperand accessor");
427 return IsEarlyClobber;
431 assert(
isReg() &&
"Wrong MachineOperand accessor");
436 assert(
isReg() &&
"Wrong MachineOperand accessor");
448 assert(
isReg() &&
"Wrong MachineOperand accessor");
462 SubReg_TargetFlags = subReg;
463 assert(SubReg_TargetFlags == subReg &&
"SubReg out of range");
490 assert(
isReg() && !IsDef &&
"Wrong MachineOperand mutator");
496 assert(
isReg() && IsDef &&
"Wrong MachineOperand mutator");
509 IsInternalRead =
Val;
513 assert(
isReg() && IsDef &&
"Wrong MachineOperand mutator");
514 IsEarlyClobber =
Val;
518 assert(
isReg() && !IsDef &&
"Wrong MachineOperand mutator");
527 assert(
isImm() &&
"Wrong MachineOperand accessor");
528 return Contents.ImmVal;
542 assert(
isMBB() &&
"Wrong MachineOperand accessor");
548 "Wrong MachineOperand accessor");
549 return Contents.OffsetedInfo.Val.Index;
554 return Contents.OffsetedInfo.Val.GV;
559 return Contents.OffsetedInfo.Val.BA;
569 return Contents.CFIIndex;
574 return Contents.IntrinsicID;
579 return Contents.Pred;
587 "Wrong MachineOperand accessor");
588 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
589 SmallContents.OffsetLo;
594 return Contents.OffsetedInfo.Val.SymbolName;
603 assert(PhysReg < (1u << 30) &&
"Not a physical register");
604 return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
616 return Contents.RegMask;
621 return (NumRegs + 31) / 32;
627 return Contents.RegMask;
641 Contents.ImmVal = immVal;
657 "Wrong MachineOperand mutator");
658 SmallContents.OffsetLo =
unsigned(Offset);
659 Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
664 "Wrong MachineOperand mutator");
665 Contents.OffsetedInfo.Val.Index = Idx;
684 Contents.RegMask = RegMaskPtr;
762 bool isRenamable =
false) {
776 Op.Contents.
Reg.Prev =
nullptr;
777 Op.Contents.
Reg.Next =
nullptr;
852 assert(Mask &&
"Missing register mask");
858 assert(Mask &&
"Missing live-out register mask");
865 Op.Contents.
MD = Meta;
902 void removeRegFromUses();
905 enum :
unsigned char {
919 bool isOnRegUseList()
const {
920 assert(
isReg() &&
"Can only add reg operand to use lists");
921 return Contents.Reg.Prev !=
nullptr;
927 return MachineOperand(static_cast<MachineOperand::MachineOperandType>(
928 MachineOperand::MO_Empty));
931 return MachineOperand(static_cast<MachineOperand::MachineOperandType>(
932 MachineOperand::MO_Tombstone));
939 MachineOperand::MO_Empty) ||
941 MachineOperand::MO_Tombstone))
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)
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned char TargetFlags=0)
void setTargetFlags(unsigned F)
void ChangeToRegister(unsigned 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...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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.
static void printTargetFlags(raw_ostream &OS, const MachineOperand &Op)
Print operand target flags.
static MachineOperand CreateJTI(unsigned Idx, unsigned char TargetFlags=0)
void setIsDef(bool Val=true)
Change a def to a use, or a use to a def.
unsigned getReg() const
getReg - Returns the register number.
void setIsUndef(bool Val=true)
Intrinsic::ID IntrinsicID
Address of indexed Jump Table for switch.
unsigned getSubReg() const
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
MachineBasicBlock reference.
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Manage lifetime of a slot tracker for printing IR.
Mask of live-out registers.
void substVirtReg(unsigned Reg, unsigned SubIdx, const TargetRegisterInfo &)
substVirtReg - Substitute the current register with the virtual subregister Reg:SubReg.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsRenamable(bool Val=true)
struct llvm::MachineOperand::@164::@167 OffsetedInfo
OffsetedInfo - This struct contains the offset and an object identifier.
bool isInternalRead() const
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
static MachineOperand CreateReg(unsigned 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)
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.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
const uint32_t * getRegLiveOut() const
getRegLiveOut - Returns a bit mask of live-out registers.
const ConstantFP * getFPImm() const
void ChangeToES(const char *SymName, unsigned char TargetFlags=0)
ChangeToES - Replace this operand with a new external symbol operand.
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)
unsigned getCFIIndex() const
union llvm::MachineOperand::@164::@167::@168 Val
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.
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 ...
struct llvm::MachineOperand::@164::@166 Reg
Address of a global value.
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char 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 CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char 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 substPhysReg(unsigned Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
void setImm(int64_t immVal)
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned char TargetFlags=0)
void setIsInternalRead(bool Val=true)
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned char TargetFlags=0)
static bool isEqual(const MachineOperand &LHS, const MachineOperand &RHS)
void setOffset(int64_t Offset)
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)
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
void ChangeToFPImmediate(const ConstantFP *FPImm)
ChangeToFPImmediate - Replace this operand with a new FP immediate operand of the specified value...
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.
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
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.
Representation of each machine instruction.
void addTargetFlag(unsigned F)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
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
void setReg(unsigned Reg)
Change the register this operand corresponds to.
static MachineOperand CreateImm(int64_t Val)
void setIsUse(bool Val=true)
void setSubReg(unsigned subReg)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
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.
void ChangeToTargetIndex(unsigned Idx, int64_t Offset, unsigned char TargetFlags=0)
Replace this operand with a target index.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getMCSymbol() const
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...
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.
void setIsDebug(bool Val=true)
const ConstantInt * getCImm() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MachineOperand CreateFI(int Idx)
const MDNode * getMetadata() const
Metadata reference (for debug info)
const MachineInstr * getParent() const
unsigned getPredicate() const