14 #ifndef LLVM_CODEGEN_MACHINEOPERAND_H
15 #define LLVM_CODEGEN_MACHINEOPERAND_H
17 #include "llvm/Support/DataTypes.h"
26 class MachineBasicBlock;
28 class MachineRegisterInfo;
30 class ModuleSlotTracker;
32 class TargetRegisterInfo;
75 unsigned SubReg_TargetFlags : 12;
80 unsigned char TiedTo : 4;
129 bool IsInternalRead : 1;
134 bool IsEarlyClobber : 1;
185 : OpKind(K), SubReg_TargetFlags(0), ParentMI(nullptr) {}
192 return isReg() ? 0 : SubReg_TargetFlags;
195 assert(!
isReg() &&
"Register operands can't have target flags");
196 SubReg_TargetFlags =
F;
197 assert(SubReg_TargetFlags == F &&
"Target flags out of range");
200 assert(!
isReg() &&
"Register operands can't have target flags");
201 SubReg_TargetFlags |=
F;
202 assert((SubReg_TargetFlags & F) &&
"Target flags out of range");
268 assert(
isReg() &&
"This is not a register operand!");
269 return SmallContents.RegNo;
273 assert(
isReg() &&
"Wrong MachineOperand accessor");
274 return SubReg_TargetFlags;
278 assert(
isReg() &&
"Wrong MachineOperand accessor");
283 assert(
isReg() &&
"Wrong MachineOperand accessor");
288 assert(
isReg() &&
"Wrong MachineOperand accessor");
293 assert(
isReg() &&
"Wrong MachineOperand accessor");
298 assert(
isReg() &&
"Wrong MachineOperand accessor");
303 assert(
isReg() &&
"Wrong MachineOperand accessor");
308 assert(
isReg() &&
"Wrong MachineOperand accessor");
309 return IsInternalRead;
313 assert(
isReg() &&
"Wrong MachineOperand accessor");
314 return IsEarlyClobber;
318 assert(
isReg() &&
"Wrong MachineOperand accessor");
323 assert(
isReg() &&
"Wrong MachineOperand accessor");
335 assert(
isReg() &&
"Wrong MachineOperand accessor");
348 assert(
isReg() &&
"Wrong MachineOperand accessor");
349 SubReg_TargetFlags = subReg;
350 assert(SubReg_TargetFlags == subReg &&
"SubReg out of range");
371 assert(
isReg() &&
"Wrong MachineOperand accessor");
376 assert(
isReg() && !IsDef &&
"Wrong MachineOperand accessor");
377 assert((!
Val || !
isDebug()) &&
"Marking a debug operation as kill");
382 assert(
isReg() && IsDef &&
"Wrong MachineOperand accessor");
387 assert(
isReg() &&
"Wrong MachineOperand accessor");
392 assert(
isReg() &&
"Wrong MachineOperand accessor");
393 IsInternalRead =
Val;
397 assert(
isReg() && IsDef &&
"Wrong MachineOperand accessor");
398 IsEarlyClobber =
Val;
402 assert(
isReg() && !IsDef &&
"Wrong MachineOperand accessor");
411 assert(
isImm() &&
"Wrong MachineOperand accessor");
412 return Contents.ImmVal;
416 assert(
isCImm() &&
"Wrong MachineOperand accessor");
421 assert(
isFPImm() &&
"Wrong MachineOperand accessor");
426 assert(
isMBB() &&
"Wrong MachineOperand accessor");
432 "Wrong MachineOperand accessor");
433 return Contents.OffsetedInfo.Val.Index;
437 assert(
isGlobal() &&
"Wrong MachineOperand accessor");
438 return Contents.OffsetedInfo.Val.GV;
443 return Contents.OffsetedInfo.Val.BA;
447 assert(
isMCSymbol() &&
"Wrong MachineOperand accessor");
452 assert(
isCFIIndex() &&
"Wrong MachineOperand accessor");
453 return Contents.CFIIndex;
461 "Wrong MachineOperand accessor");
462 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
463 SmallContents.OffsetLo;
467 assert(
isSymbol() &&
"Wrong MachineOperand accessor");
468 return Contents.OffsetedInfo.Val.SymbolName;
477 assert(PhysReg < (1u << 30) &&
"Not a physical register");
478 return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
489 assert(
isRegMask() &&
"Wrong MachineOperand accessor");
490 return Contents.RegMask;
495 assert(
isRegLiveOut() &&
"Wrong MachineOperand accessor");
496 return Contents.RegMask;
500 assert(
isMetadata() &&
"Wrong MachineOperand accessor");
509 assert(
isImm() &&
"Wrong MachineOperand mutator");
510 Contents.ImmVal = immVal;
514 assert(
isFPImm() &&
"Wrong MachineOperand mutator");
521 "Wrong MachineOperand accessor");
522 SmallContents.OffsetLo =
unsigned(Offset);
523 Contents.OffsetedInfo.OffsetHi =
int(Offset >> 32);
528 "Wrong MachineOperand accessor");
529 Contents.OffsetedInfo.Val.Index = Idx;
533 assert(
isMBB() &&
"Wrong MachineOperand accessor");
563 void ChangeToES(
const char *SymName,
unsigned char TargetFlags = 0);
604 assert(!(
isDead && !isDef) &&
"Dead flag on non-def");
605 assert(!(
isKill && isDef) &&
"Kill flag on def");
617 Op.Contents.
Reg.Prev =
nullptr;
618 Op.Contents.
Reg.Next =
nullptr;
623 unsigned char TargetFlags = 0) {
635 unsigned char TargetFlags = 0) {
643 unsigned char TargetFlags = 0) {
651 unsigned char TargetFlags = 0) {
658 unsigned char TargetFlags = 0) {
666 unsigned char TargetFlags = 0) {
674 unsigned char TargetFlags = 0) {
694 assert(Mask &&
"Missing register mask");
700 assert(Mask &&
"Missing live-out register mask");
707 Op.Contents.
MD = Meta;
712 unsigned char TargetFlags = 0) {
729 void removeRegFromUses();
738 bool isOnRegUseList()
const {
739 assert(
isReg() &&
"Can only add reg operand to use lists");
740 return Contents.Reg.Prev !=
nullptr;
745 MO.
print(OS,
nullptr);
751 hash_code
hash_value(
const MachineOperand &MO);
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
const GlobalValue * getGlobal() const
static MachineOperand CreateCImm(const ConstantInt *CI)
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...
const ConstantFP * getFPImm() const
MachineBasicBlock * getMBB() const
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void setFPImm(const ConstantFP *CFP)
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.
void setIsUndef(bool Val=true)
Address of indexed Jump Table for switch.
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
MachineBasicBlock reference.
const char * getSymbolName() const
void setIsDead(bool Val=true)
union llvm::MachineOperand::@33::@35::@36 Val
Manage lifetime of a slot tracker for printing IR.
const MDNode * getMetadata() const
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 isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
Mask of preserved registers.
void ChangeToMCSymbol(MCSymbol *Sym)
ChangeToMCSymbol - Replace this operand with a new MC symbol operand.
BlockAddress - The address of a basic block.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
unsigned getCFIIndex() const
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 isImm() const
isImm - Tests if this is a MO_Immediate operand.
void ChangeToES(const char *SymName, unsigned char TargetFlags=0)
ChangeToES - Replace this operand with a new external symbol operand.
Target-dependent index+offset operand.
bool isReg() const
isReg - Tests if this is a MO_Register 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.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
void setIsEarlyClobber(bool Val=true)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
Immediate >64bit operand.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
void clearParent()
clearParent - Reset the parent pointer.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
bool isEarlyClobber() const
Address of a global value.
unsigned getTargetFlags() const
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr) const
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char TargetFlags=0)
static MachineOperand CreateFPImm(const ConstantFP *CFP)
ConstantFP - Floating Point Values [float, double].
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void setMBB(MachineBasicBlock *MBB)
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned char TargetFlags=0)
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
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)
int64_t getOffset() const
Return the offset from the symbol in this operand.
void setOffset(int64_t Offset)
unsigned getSubReg() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool clobbersPhysReg(unsigned PhysReg) const
clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
struct llvm::MachineOperand::@33::@34 Reg
void setIsKill(bool Val=true)
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
static MachineOperand CreateMetadata(const MDNode *Meta)
This is the shared class of boolean and integer constants.
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
struct llvm::MachineOperand::@33::@35 OffsetedInfo
OffsetedInfo - This struct contains the offset and an object identifier.
MachineOperand class - Representation of each machine instruction operand.
void ChangeToFPImmediate(const ConstantFP *FPImm)
ChangeToFPImmediate - Replace this operand with a new FP immediate operand of the specified value...
bool isRegLiveOut() const
isRegLiveOut - Tests if this is a MO_RegisterLiveOut operand.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
const MachineInstr * getParent() const
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.
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
const ConstantInt * getCImm() const
static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags=0)
An opaque object representing a hash code.
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.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void addTargetFlag(unsigned F)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
const uint32_t * getRegLiveOut() const
getRegLiveOut - Returns a bit mask of live-out registers.
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
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)
MCSymbol * getMCSymbol() const
Abstract Stack Frame Index.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
unsigned getReg() const
getReg - Returns the register number.
Floating-point immediate operand.
This class implements an extremely fast bulk output stream that can only output to a stream...
const BlockAddress * getBlockAddress() const
Address of indexed Constant in Constant Pool.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
bool isIdenticalTo(const MachineOperand &Other) const
isIdenticalTo - Return true if this operand is identical to the specified operand.
void setIsDebug(bool Val=true)
static MachineOperand CreateFI(int Idx)
bool isInternalRead() const
Metadata reference (for debug info)