diff options
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 7 | ||||
-rw-r--r-- | utils/TableGen/CodeGenInstruction.cpp | 6 | ||||
-rw-r--r-- | utils/TableGen/CodeGenInstruction.h | 4 |
3 files changed, 7 insertions, 10 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index 37a8c8f79b..3f4594c4e3 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -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 diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 41a27cea3d..259e7c36a4 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -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) diff --git a/utils/TableGen/CodeGenInstruction.h b/utils/TableGen/CodeGenInstruction.h index 33701ec011..7f9d24925c 100644 --- a/utils/TableGen/CodeGenInstruction.h +++ b/utils/TableGen/CodeGenInstruction.h @@ -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 |