Make LLVM command-line tools overwrite their output files without -f.
[oota-llvm.git] / utils / TableGen / CodeGenInstruction.cpp
index ea01d1b0e29a1c6e151a61e18783c2745693806c..4650b88fd5174f676f6e15c6aba419f9e11452e7 100644 (file)
@@ -21,7 +21,8 @@ static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
   // FIXME: Only supports TIED_TO for now.
   std::string::size_type pos = CStr.find_first_of('=');
   assert(pos != std::string::npos && "Unrecognized constraint");
-  std::string Name = CStr.substr(0, pos);
+  std::string::size_type start = CStr.find_first_not_of(" \t");
+  std::string Name = CStr.substr(start, pos);
   
   // TIED_TO: $src1 = $dst
   std::string::size_type wpos = Name.find_first_of(" \t");
@@ -83,9 +84,9 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
   isIndirectBranch = R->getValueAsBit("isIndirectBranch");
   isBarrier    = R->getValueAsBit("isBarrier");
   isCall       = R->getValueAsBit("isCall");
-  isSimpleLoad = R->getValueAsBit("isSimpleLoad");
+  canFoldAsLoad = R->getValueAsBit("canFoldAsLoad");
+  mayLoad      = R->getValueAsBit("mayLoad");
   mayStore     = R->getValueAsBit("mayStore");
-  isImplicitDef= R->getValueAsBit("isImplicitDef");
   bool isTwoAddress = R->getValueAsBit("isTwoAddress");
   isPredicable = R->getValueAsBit("isPredicable");
   isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress");
@@ -96,14 +97,15 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
   usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
   hasCtrlDep   = R->getValueAsBit("hasCtrlDep");
   isNotDuplicable = R->getValueAsBit("isNotDuplicable");
+  hasSideEffects = R->getValueAsBit("hasSideEffects");
   mayHaveSideEffects = R->getValueAsBit("mayHaveSideEffects");
   neverHasSideEffects = R->getValueAsBit("neverHasSideEffects");
+  isAsCheapAsAMove = R->getValueAsBit("isAsCheapAsAMove");
   hasOptionalDef = false;
-  hasVariableNumberOfOperands = false;
+  isVariadic = false;
 
-  if (mayHaveSideEffects && neverHasSideEffects)
-    throw R->getName() +
-      ": cannot have both 'mayHaveSideEffects' and 'neverHasSideEffects' set!";
+  if (mayHaveSideEffects + neverHasSideEffects + hasSideEffects > 1)
+    throw R->getName() + ": multiple conflicting side-effect flags set!";
 
   DagInit *DI;
   try {
@@ -125,7 +127,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
     OperandList.clear();
     return;
   }
-  DI = (DagInit*)(new BinOpInit(BinOpInit::CONCAT, DI, IDI))->Fold();
+  DI = (DagInit*)(new BinOpInit(BinOpInit::CONCAT, DI, IDI, new DagRecTy))->Fold(R, 0);
 
   unsigned MIOperandNo = 0;
   std::set<std::string> OperandNames;
@@ -159,12 +161,12 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
       else if (Rec->isSubClassOf("OptionalDefOperand"))
         hasOptionalDef = true;
     } else if (Rec->getName() == "variable_ops") {
-      hasVariableNumberOfOperands = true;
+      isVariadic = true;
       continue;
     } else if (!Rec->isSubClassOf("RegisterClass") && 
-               Rec->getName() != "ptr_rc")
+               Rec->getName() != "ptr_rc" && Rec->getName() != "unknown")
       throw "Unknown operand class '" + Rec->getName() +
-            "' in instruction '" + R->getName() + "' instruction!";
+            "' in '" + R->getName() + "' instruction!";
 
     // Check that the operand has a name and that it's unique.
     if (DI->getArgName(i).empty())