14 #ifndef LLVM_CODEGEN_MACHINEOPERAND_H
15 #define LLVM_CODEGEN_MACHINEOPERAND_H
17 #include "llvm/Support/DataTypes.h"
26 class MachineBasicBlock;
28 class MachineRegisterInfo;
31 class TargetRegisterInfo;
72 unsigned SubReg_TargetFlags : 12;
77 unsigned char TiedTo : 4;
126 bool IsInternalRead : 1;
131 bool IsEarlyClobber : 1;
181 : OpKind(K), SubReg_TargetFlags(0), ParentMI(0) {}
188 return isReg() ? 0 : SubReg_TargetFlags;
191 assert(!
isReg() &&
"Register operands can't have target flags");
192 SubReg_TargetFlags =
F;
193 assert(SubReg_TargetFlags == F &&
"Target flags out of range");
196 assert(!
isReg() &&
"Register operands can't have target flags");
197 SubReg_TargetFlags |=
F;
198 assert((SubReg_TargetFlags & F) &&
"Target flags out of range");
260 assert(
isReg() &&
"This is not a register operand!");
261 return SmallContents.RegNo;
265 assert(
isReg() &&
"Wrong MachineOperand accessor");
266 return SubReg_TargetFlags;
270 assert(
isReg() &&
"Wrong MachineOperand accessor");
275 assert(
isReg() &&
"Wrong MachineOperand accessor");
280 assert(
isReg() &&
"Wrong MachineOperand accessor");
285 assert(
isReg() &&
"Wrong MachineOperand accessor");
290 assert(
isReg() &&
"Wrong MachineOperand accessor");
295 assert(
isReg() &&
"Wrong MachineOperand accessor");
300 assert(
isReg() &&
"Wrong MachineOperand accessor");
301 return IsInternalRead;
305 assert(
isReg() &&
"Wrong MachineOperand accessor");
306 return IsEarlyClobber;
310 assert(
isReg() &&
"Wrong MachineOperand accessor");
315 assert(
isReg() &&
"Wrong MachineOperand accessor");
327 assert(
isReg() &&
"Wrong MachineOperand accessor");
340 assert(
isReg() &&
"Wrong MachineOperand accessor");
341 SubReg_TargetFlags = subReg;
342 assert(SubReg_TargetFlags == subReg &&
"SubReg out of range");
363 assert(
isReg() &&
"Wrong MachineOperand accessor");
368 assert(
isReg() && !IsDef &&
"Wrong MachineOperand accessor");
369 assert((!
Val || !
isDebug()) &&
"Marking a debug operation as kill");
374 assert(
isReg() && IsDef &&
"Wrong MachineOperand accessor");
379 assert(
isReg() &&
"Wrong MachineOperand accessor");
384 assert(
isReg() &&
"Wrong MachineOperand accessor");
385 IsInternalRead =
Val;
389 assert(
isReg() && IsDef &&
"Wrong MachineOperand accessor");
390 IsEarlyClobber =
Val;
394 assert(
isReg() && !IsDef &&
"Wrong MachineOperand accessor");
403 assert(
isImm() &&
"Wrong MachineOperand accessor");
404 return Contents.ImmVal;
408 assert(
isCImm() &&
"Wrong MachineOperand accessor");
413 assert(
isFPImm() &&
"Wrong MachineOperand accessor");
418 assert(
isMBB() &&
"Wrong MachineOperand accessor");
424 "Wrong MachineOperand accessor");
425 return Contents.OffsetedInfo.Val.Index;
429 assert(
isGlobal() &&
"Wrong MachineOperand accessor");
430 return Contents.OffsetedInfo.Val.GV;
435 return Contents.OffsetedInfo.Val.BA;
439 assert(
isMCSymbol() &&
"Wrong MachineOperand accessor");
448 return int64_t(uint64_t(Contents.OffsetedInfo.OffsetHi) << 32) |
449 SmallContents.OffsetLo;
453 assert(
isSymbol() &&
"Wrong MachineOperand accessor");
454 return Contents.OffsetedInfo.Val.SymbolName;
463 assert(PhysReg < (1u << 30) &&
"Not a physical register");
464 return !(RegMask[PhysReg / 32] & (1u << PhysReg % 32));
475 assert(
isRegMask() &&
"Wrong MachineOperand accessor");
476 return Contents.RegMask;
480 assert(
isMetadata() &&
"Wrong MachineOperand accessor");
489 assert(
isImm() &&
"Wrong MachineOperand mutator");
490 Contents.ImmVal = immVal;
496 SmallContents.OffsetLo =
unsigned(Offset);
497 Contents.OffsetedInfo.OffsetHi = int(Offset >> 32);
502 "Wrong MachineOperand accessor");
503 Contents.OffsetedInfo.Val.Index = Idx;
507 assert(
isMBB() &&
"Wrong MachineOperand accessor");
578 Op.Contents.
Reg.Prev = 0;
579 Op.Contents.
Reg.Next = 0;
584 unsigned char TargetFlags = 0) {
596 unsigned char TargetFlags = 0) {
604 unsigned char TargetFlags = 0) {
612 unsigned char TargetFlags = 0) {
619 unsigned char TargetFlags = 0) {
627 unsigned char TargetFlags = 0) {
635 unsigned char TargetFlags = 0) {
655 assert(Mask &&
"Missing register mask");
662 Op.Contents.
MD = Meta;
682 bool isOnRegUseList()
const {
683 assert(
isReg() &&
"Can only add reg operand to use lists");
684 return Contents.Reg.Prev != 0;
695 hash_code
hash_value(
const MachineOperand &MO);
static MachineOperand CreateMCSymbol(MCSymbol *Sym)
MachineInstr * getParent()
const GlobalValue * getGlobal() const
static MachineOperand CreateCImm(const ConstantInt *CI)
struct llvm::MachineOperand::@32::@33 Reg
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)
const ConstantFP * getFPImm() const
MachineBasicBlock * getMBB() const
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
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)
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
const char * getSymbolName() const
MDNode - a tuple of other values.
void setIsDead(bool Val=true)
const MDNode * getMetadata() const
void substVirtReg(unsigned Reg, unsigned SubIdx, const TargetRegisterInfo &)
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
Target-dependent index+offset operand.
Address of indexed Jump Table for switch.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
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.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setImplicit(bool Val=true)
static MachineOperand CreateRegMask(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.
hash_code hash_value(const APFloat &Arg)
Address of indexed Constant in Constant Pool.
void ChangeToImmediate(int64_t ImmVal)
MCSymbol reference (for debug/eh info)
bool isEarlyClobber() const
unsigned getTargetFlags() const
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned char TargetFlags=0)
Metadata reference (for debug info)
static MachineOperand CreateFPImm(const ConstantFP *CFP)
Abstract Stack Frame Index.
union llvm::MachineOperand::@32::@34::@35 Val
bool isCImm() const
isCImm - Test if t his 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.
Immediate >64bit operand.
void substPhysReg(unsigned Reg, const TargetRegisterInfo &)
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
Floating-point immediate operand.
void setOffset(int64_t Offset)
unsigned getSubReg() const
bool clobbersPhysReg(unsigned PhysReg) const
clobbersPhysReg - Returns true if this RegMask operand clobbers PhysReg.
void setIsKill(bool Val=true)
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
static MachineOperand CreateMetadata(const MDNode *Meta)
Class for constant integers.
const uint32_t * getRegMask() const
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.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned 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.
MachineOperandType getType() const
void addTargetFlag(unsigned F)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0)
void print(raw_ostream &os, const TargetMachine *TM=0) const
void setReg(unsigned Reg)
static MachineOperand CreateImm(int64_t Val)
void setIsUse(bool Val=true)
void setSubReg(unsigned subReg)
MCSymbol * getMCSymbol() const
Mask of preserved registers.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
unsigned getReg() const
getReg - Returns the register number.
Address of a basic block.
const BlockAddress * getBlockAddress() const
struct llvm::MachineOperand::@32::@34 OffsetedInfo
bool isIdenticalTo(const MachineOperand &Other) const
void setIsDebug(bool Val=true)
static MachineOperand CreateFI(int Idx)
MachineBasicBlock reference.
bool isInternalRead() const
Address of a global value.
Name of external global symbol.