convert a bunch of std::strings to use StringRef. This should eliminate
[oota-llvm.git] / include / llvm / CodeGen / MachineInstrBuilder.h
index 4adb84604440c86e523fe344bcc9858cdcff641c..65d82019dc4971c58ccc429abd2fe560bba6b0b3 100644 (file)
@@ -29,7 +29,8 @@ namespace RegState {
     Implicit       = 0x4,
     Kill           = 0x8,
     Dead           = 0x10,
-    EarlyClobber   = 0x20,
+    Undef          = 0x20,
+    EarlyClobber   = 0x40,
     ImplicitDefine = Implicit | Define,
     ImplicitKill   = Implicit | Kill
   };
@@ -38,6 +39,7 @@ namespace RegState {
 class MachineInstrBuilder {
   MachineInstr *MI;
 public:
+  MachineInstrBuilder() : MI(0) {}
   explicit MachineInstrBuilder(MachineInstr *mi) : MI(mi) {}
 
   /// Allow automatic conversion to the machine instruction we are working on.
@@ -57,8 +59,9 @@ public:
                                              flags & RegState::Implicit,
                                              flags & RegState::Kill,
                                              flags & RegState::Dead,
-                                             SubReg,
-                                             flags & RegState::EarlyClobber));
+                                             flags & RegState::Undef,
+                                             flags & RegState::EarlyClobber,
+                                             SubReg));
     return *this;
   }
 
@@ -105,10 +108,16 @@ 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 {
-    MI->addOperand(MachineOperand::CreateES(FnName, Offset, TargetFlags));
+    MI->addOperand(MachineOperand::CreateES(FnName, TargetFlags));
     return *this;
   }
 
@@ -118,32 +127,7 @@ public:
   }
 
   const MachineInstrBuilder &addOperand(const MachineOperand &MO) const {
-    if (MO.isReg())
-      return addReg(MO.getReg(),
-                    (MO.isDef() ? RegState::Define : 0) |
-                    (MO.isImplicit() ? RegState::Implicit : 0) |
-                    (MO.isKill() ? RegState::Kill : 0) |
-                    (MO.isDead() ? RegState::Dead : 0) |
-                    (MO.isEarlyClobber() ? RegState::EarlyClobber : 0),
-                    MO.getSubReg());
-    if (MO.isImm())
-      return addImm(MO.getImm());
-    if (MO.isFI())
-      return addFrameIndex(MO.getIndex());
-    if (MO.isGlobal())
-      return addGlobalAddress(MO.getGlobal(), MO.getOffset(),
-                              MO.getTargetFlags());
-    if (MO.isCPI())
-      return addConstantPoolIndex(MO.getIndex(), MO.getOffset(),
-                                  MO.getTargetFlags());
-    if (MO.isSymbol())
-      return addExternalSymbol(MO.getSymbolName(), MO.getOffset(),
-                               MO.getTargetFlags());
-    if (MO.isJTI())
-      return addJumpTableIndex(MO.getIndex(),
-                               MO.getTargetFlags());
-
-    assert(0 && "Unknown operand for MachineInstrBuilder::AddOperand!");
+    MI->addOperand(MO);
     return *this;
   }
 };
@@ -228,6 +212,9 @@ inline unsigned getKillRegState(bool B) {
 inline unsigned getDeadRegState(bool B) {
   return B ? RegState::Dead : 0;
 }
+inline unsigned getUndefRegState(bool B) {
+  return B ? RegState::Undef : 0;
+}
 
 } // End llvm namespace