Add machine operand for MDNodes. This will be used to communicate debug info.
authorDevang Patel <dpatel@apple.com>
Wed, 1 Jul 2009 19:08:07 +0000 (19:08 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 1 Jul 2009 19:08:07 +0000 (19:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74628 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstrBuilder.h
include/llvm/CodeGen/MachineOperand.h

index 29e90098c957b0468c4d6869b290fac70e402e05..c6a6679c1b69b0d0b4b3e178e3d71deab46667ea 100644 (file)
@@ -107,6 +107,13 @@ public:
     return *this;
   }
 
+  const MachineInstrBuilder &addMetadata(MDNode *N,
+                                        int64_t Offset = 0,
+                                        unsigned char TargetFlags = 0) const {
+    MI->addOperand(MachineOperand::CreateMDNode(N, Offset, TargetFlags));
+    return *this;
+  }
+
   const MachineInstrBuilder &addExternalSymbol(const char *FnName,
                                                int64_t Offset = 0,
                                           unsigned char TargetFlags = 0) const {
index 08739a267356ef38ad73927830d2453392bb5765..0eb204ad4c0975d136f56a6fdc8ba1eb1fd8345e 100644 (file)
@@ -23,6 +23,7 @@ namespace llvm {
 class ConstantFP;
 class MachineBasicBlock;
 class GlobalValue;
+class MDNode;
 class MachineInstr;
 class TargetMachine;
 class MachineRegisterInfo;
@@ -41,7 +42,8 @@ public:
     MO_ConstantPoolIndex,      ///< Address of indexed Constant in Constant Pool
     MO_JumpTableIndex,         ///< Address of indexed Jump Table for switch
     MO_ExternalSymbol,         ///< Name of external global symbol
-    MO_GlobalAddress           ///< Address of a global value
+    MO_GlobalAddress,          ///< Address of a global value
+    MO_Metadata                ///< Metadata info
   };
 
 private:
@@ -107,6 +109,7 @@ private:
         int Index;                // For MO_*Index - The index itself.
         const char *SymbolName;   // For MO_ExternalSymbol.
         GlobalValue *GV;          // For MO_GlobalAddress.
+       MDNode *Node;             // For MO_Metadata.
       } Val;
       int64_t Offset;   // An offset from the object.
     } OffsetedInfo;
@@ -423,6 +426,14 @@ 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, int64_t Offset = 0,
                                  unsigned char TargetFlags = 0) {
     MachineOperand Op(MachineOperand::MO_ExternalSymbol);