[llvm-branch-commits] [llvm-branch] r119226 - in /llvm/branches/Apple/whitney/utils/TableGen: AsmMatcherEmitter.cpp CodeGenInstruction.cpp CodeGenInstruction.h

Daniel Dunbar daniel at zuster.org
Mon Nov 15 13:44:35 PST 2010


Author: ddunbar
Date: Mon Nov 15 15:44:35 2010
New Revision: 119226

URL: http://llvm.org/viewvc/llvm-project?rev=119226&view=rev
Log:
Merge r117892:
--
Author: Chris Lattner <clattner at apple.com>
Date:   Mon Nov 1 03:19:09 2010 +0000

    avoid needless throw/catch/rethrow, stringref'ize some simple stuff.

Modified:
    llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
    llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.cpp
    llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.h

Modified: llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp?rev=119226&r1=119225&r2=119226&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp Mon Nov 15 15:44:35 2010
@@ -945,7 +945,7 @@
 
     Instructions.push_back(II.take());
   }
-  
+ 
   // Build info for the register classes.
   BuildRegisterClasses(SingletonRegisters);
 
@@ -998,12 +998,9 @@
 
       // 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

Modified: llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.cpp?rev=119226&r1=119225&r2=119226&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.cpp Mon Nov 15 15:44:35 2010
@@ -237,17 +237,17 @@
 /// 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)

Modified: llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.h?rev=119226&r1=119225&r2=119226&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.h (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/CodeGenInstruction.h Mon Nov 15 15:44:35 2010
@@ -190,12 +190,12 @@
     /// 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





More information about the llvm-branch-commits mailing list