Derive MDNode from MetadataBase instead of Constant. Emit MDNodes into METADATA_BLOCK...
[oota-llvm.git] / include / llvm / MC / MCInst.h
index 11b5c797e2702807cb66f4a179966a58e8b9e8e0..8b638d4c743ee7f3fbdd1a06fc32657cea78613e 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifndef LLVM_MC_MCINST_H
 #define LLVM_MC_MCINST_H
 
+#include "llvm/MC/MCValue.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/DebugLoc.h"
@@ -30,13 +30,15 @@ class MCOperand {
     kInvalid,                 ///< Uninitialized.
     kRegister,                ///< Register operand.
     kImmediate,               ///< Immediate operand.
-    kMBBLabel                 ///< Basic block label.
+    kMBBLabel,                ///< Basic block label.
+    kMCValue                  ///< Relocatable immediate operand.
   };
   unsigned char Kind;
   
   union {
     unsigned RegVal;
     int64_t ImmVal;
+    MCValue MCValueVal;
     struct {
       unsigned FunctionNo;
       unsigned BlockNo;
@@ -47,9 +49,11 @@ public:
   MCOperand() : Kind(kInvalid) {}
   MCOperand(const MCOperand &RHS) { *this = RHS; }
 
+  bool isValid() const { return Kind != kInvalid; }
   bool isReg() const { return Kind == kRegister; }
   bool isImm() const { return Kind == kImmediate; }
   bool isMBBLabel() const { return Kind == kMBBLabel; }
+  bool isMCValue() const { return Kind == kMCValue; }
   
   /// getReg - Returns the register number.
   unsigned getReg() const {
@@ -80,6 +84,15 @@ public:
     assert(isMBBLabel() && "Wrong accessor");
     return MBBLabel.BlockNo; 
   }
+
+  const MCValue &getMCValue() const {
+    assert(isMCValue() && "This is not an MCValue");
+    return MCValueVal;
+  }
+  void setMCValue(const MCValue &Val) {
+    assert(isMCValue() && "This is not an MCValue");
+    MCValueVal = Val;
+  }
   
   void MakeReg(unsigned Reg) {
     Kind = kRegister;
@@ -94,6 +107,10 @@ public:
     MBBLabel.FunctionNo = Fn;
     MBBLabel.BlockNo = MBB;
   }
+  void MakeMCValue(const MCValue &Val) {
+    Kind = kMCValue;
+    MCValueVal = Val;
+  }
 };
 
   
@@ -117,7 +134,6 @@ public:
   void addOperand(const MCOperand &Op) {
     Operands.push_back(Op);
   }
-  
 };