avoid needless throw/catch/rethrow, stringref'ize some simple stuff.
authorChris Lattner <sabre@nondot.org>
Mon, 1 Nov 2010 03:19:09 +0000 (03:19 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 1 Nov 2010 03:19:09 +0000 (03:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117892 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmMatcherEmitter.cpp
utils/TableGen/CodeGenInstruction.cpp
utils/TableGen/CodeGenInstruction.h

index 37a8c8f79bbbac2c308e538184191c8f45825f6a..3f4594c4e3e679ca052ca2ac62d51cf84923826a 100644 (file)
@@ -945,7 +945,7 @@ void AsmMatcherInfo::BuildInfo() {
 
     Instructions.push_back(II.take());
   }
-  
   // Build info for the register classes.
   BuildRegisterClasses(SingletonRegisters);
 
@@ -998,12 +998,9 @@ void AsmMatcherInfo::BuildInfo() {
 
       // Map this token to an operand. FIXME: Move elsewhere.
       unsigned Idx;
-      try {
-        Idx = II->Instr->getOperandNamed(OperandName);
-      } catch(...) {
+      if (!II->Instr->hasOperandNamed(OperandName, Idx))
         throw std::string("error: unable to find operand: '" +
                           OperandName.str() + "'");
-      }
 
       // FIXME: This is annoying, the named operand may be tied (e.g.,
       // XCHG8rm). What we want is the untied operand, which we now have to
index 41a27cea3ddf557b3cb2494de6657535cf01f225..259e7c36a4c5ae87677e8687406868957b02d88d 100644 (file)
@@ -237,17 +237,17 @@ CodeGenInstruction::CodeGenInstruction(Record *R) : TheDef(R) {
 /// non-empty name.  If the instruction does not have an operand with the
 /// specified name, throw an exception.
 ///
-unsigned CodeGenInstruction::getOperandNamed(const std::string &Name) const {
+unsigned CodeGenInstruction::getOperandNamed(StringRef Name) const {
   unsigned OpIdx;
   if (hasOperandNamed(Name, OpIdx)) return OpIdx;
   throw "Instruction '" + TheDef->getName() +
-        "' does not have an operand named '$" + Name + "'!";
+        "' does not have an operand named '$" + Name.str() + "'!";
 }
 
 /// hasOperandNamed - Query whether the instruction has an operand of the
 /// given name. If so, return true and set OpIdx to the index of the
 /// operand. Otherwise, return false.
-bool CodeGenInstruction::hasOperandNamed(const std::string &Name,
+bool CodeGenInstruction::hasOperandNamed(StringRef Name,
                                          unsigned &OpIdx) const {
   assert(!Name.empty() && "Cannot search for operand with no name!");
   for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
index 33701ec0110ad737ee75061c38e94b0d045a6696..7f9d24925cc66e2f57a00e645f6213ec975917f7 100644 (file)
@@ -190,12 +190,12 @@ namespace llvm {
     /// getOperandNamed - Return the index of the operand with the specified
     /// non-empty name.  If the instruction does not have an operand with the
     /// specified name, throw an exception.
-    unsigned getOperandNamed(const std::string &Name) const;
+    unsigned getOperandNamed(StringRef Name) const;
 
     /// hasOperandNamed - Query whether the instruction has an operand of the
     /// given name. If so, return true and set OpIdx to the index of the
     /// operand. Otherwise, return false.
-    bool hasOperandNamed(const std::string &Name, unsigned &OpIdx) const;
+    bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const;
 
     /// HasOneImplicitDefWithKnownVT - If the instruction has at least one
     /// implicit def and it has a known VT, return the VT, otherwise return