[llvm-commits] [llvm] r117892 - in /llvm/trunk/utils/TableGen: AsmMatcherEmitter.cpp CodeGenInstruction.cpp CodeGenInstruction.h
Chris Lattner
sabre at nondot.org
Sun Oct 31 20:19:10 PDT 2010
Author: lattner
Date: Sun Oct 31 22:19:09 2010
New Revision: 117892
URL: http://llvm.org/viewvc/llvm-project?rev=117892&view=rev
Log:
avoid needless throw/catch/rethrow, stringref'ize some simple stuff.
Modified:
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
llvm/trunk/utils/TableGen/CodeGenInstruction.h
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=117892&r1=117891&r2=117892&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Sun Oct 31 22:19:09 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/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=117892&r1=117891&r2=117892&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Sun Oct 31 22:19:09 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/trunk/utils/TableGen/CodeGenInstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=117892&r1=117891&r2=117892&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Sun Oct 31 22:19:09 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-commits
mailing list