diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h index 22435e9ff16..eaa87dbba61 100644 --- a/include/llvm/CodeGen/MachineOperand.h +++ b/include/llvm/CodeGen/MachineOperand.h @@ -20,6 +20,7 @@ namespace llvm { class ConstantFP; +class BlockAddress; class MachineBasicBlock; class GlobalValue; class MDNode; @@ -42,6 +43,7 @@ public: MO_JumpTableIndex, ///< Address of indexed Jump Table for switch MO_ExternalSymbol, ///< Name of external global symbol MO_GlobalAddress, ///< Address of a global value + MO_BlockAddress, ///< Address of a basic block MO_Metadata ///< Metadata info }; @@ -108,6 +110,7 @@ private: int Index; // For MO_*Index - The index itself. const char *SymbolName; // For MO_ExternalSymbol. GlobalValue *GV; // For MO_GlobalAddress. + BlockAddress *BA; // For MO_BlockAddress. MDNode *Node; // For MO_Metadata. } Val; int64_t Offset; // An offset from the object. @@ -156,6 +159,8 @@ public: bool isGlobal() const { return OpKind == MO_GlobalAddress; } /// isSymbol - Tests if this is a MO_ExternalSymbol operand. bool isSymbol() const { return OpKind == MO_ExternalSymbol; } + /// isBlockAddress - Tests if this is a MO_BlockAddress operand. + bool isBlockAddress() const { return OpKind == MO_BlockAddress; } /// isMetadata - Tests if this is a MO_Metadata operand. bool isMetadata() const { return OpKind == MO_Metadata; } @@ -293,6 +298,11 @@ public: assert(isGlobal() && "Wrong MachineOperand accessor"); return Contents.OffsetedInfo.Val.GV; } + + BlockAddress *getBlockAddress() const { + assert(isBlockAddress() && "Wrong MachineOperand accessor"); + return Contents.OffsetedInfo.Val.BA; + } MDNode *getMDNode() const { return Contents.OffsetedInfo.Val.Node; @@ -301,7 +311,7 @@ public: /// getOffset - Return the offset from the symbol in this operand. This always /// returns 0 for ExternalSymbol operands. int64_t getOffset() const { - assert((isGlobal() || isSymbol() || isCPI()) && + assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress()) && "Wrong MachineOperand accessor"); return Contents.OffsetedInfo.Offset; } @@ -321,7 +331,8 @@ public: } void setOffset(int64_t Offset) { - assert((isGlobal() || isSymbol() || isCPI() || isMetadata()) && + assert((isGlobal() || isSymbol() || isCPI() || isBlockAddress() || + isMetadata()) && "Wrong MachineOperand accessor"); Contents.OffsetedInfo.Offset = Offset; } @@ -426,14 +437,6 @@ public: Op.setTargetFlags(TargetFlags); return Op; } - static MachineOperand CreateMDNode(MDNode *N, int64_t Offset, - unsigned char TargetFlags = 0) { - MachineOperand Op(MachineOperand::MO_Metadata); - Op.Contents.OffsetedInfo.Val.Node = N; - Op.setOffset(Offset); - Op.setTargetFlags(TargetFlags); - return Op; - } static MachineOperand CreateES(const char *SymName, unsigned char TargetFlags = 0) { MachineOperand Op(MachineOperand::MO_ExternalSymbol); @@ -442,6 +445,20 @@ public: Op.setTargetFlags(TargetFlags); return Op; } + static MachineOperand CreateBA(BlockAddress *BA) { + MachineOperand Op(MachineOperand::MO_BlockAddress); + Op.Contents.OffsetedInfo.Val.BA = BA; + Op.setOffset(0); // Offset is always 0. + return Op; + } + static MachineOperand CreateMDNode(MDNode *N, int64_t Offset, + unsigned char TargetFlags = 0) { + MachineOperand Op(MachineOperand::MO_Metadata); + Op.Contents.OffsetedInfo.Val.Node = N; + Op.setOffset(Offset); + Op.setTargetFlags(TargetFlags); + return Op; + } friend class MachineInstr; friend class MachineRegisterInfo;