Remove exception handling usage from tblgen.

Most places can use PrintFatalError as the unwinding mechanism was not
used for anything other than printing the error. The single exception
was CodeGenDAGPatterns.cpp, where intermediate errors during type
resolution were ignored to simplify incremental platform development.
This use is replaced by an error flag in TreePattern and bailout earlier
in various places if it is set. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Joerg Sonnenberger
2012-10-25 20:33:17 +00:00
parent e5a7a68dfa
commit 61131ab15f
32 changed files with 488 additions and 452 deletions

View File

@ -78,6 +78,7 @@
#include "CodeGenTarget.h"
#include "llvm/Support/Format.h"
#include "llvm/TableGen/Error.h"
using namespace llvm;
typedef std::map<std::string, std::vector<Record*> > InstrRelMapTy;
@ -128,20 +129,19 @@ public:
// Each instruction map must specify at least one column for it to be valid.
if (ColValList->getSize() == 0)
throw "InstrMapping record `" + MapRec->getName() + "' has empty " +
"`ValueCols' field!";
PrintFatalError(MapRec->getLoc(), "InstrMapping record `" +
MapRec->getName() + "' has empty " + "`ValueCols' field!");
for (unsigned i = 0, e = ColValList->getSize(); i < e; i++) {
ListInit *ColI = dyn_cast<ListInit>(ColValList->getElement(i));
// Make sure that all the sub-lists in 'ValueCols' have same number of
// elements as the fields in 'ColFields'.
if (ColI->getSize() == ColFields->getSize())
ValueCols.push_back(ColI);
else {
throw "Record `" + MapRec->getName() + "', field `" + "ValueCols" +
"' entries don't match with the entries in 'ColFields'!";
}
if (ColI->getSize() != ColFields->getSize())
PrintFatalError(MapRec->getLoc(), "Record `" + MapRec->getName() +
"', field `ValueCols' entries don't match with " +
" the entries in 'ColFields'!");
ValueCols.push_back(ColI);
}
}
@ -344,10 +344,9 @@ Record *MapTableEmitter::getInstrForColumn(Record *KeyInstr,
if (MatchFound) {
if (MatchInstr) // Already had a match
// Error if multiple matches are found for a column.
throw "Multiple matches found for `" + KeyInstr->getName() +
"', for the relation `" + InstrMapDesc.getName();
else
MatchInstr = CurInstr;
PrintFatalError("Multiple matches found for `" + KeyInstr->getName() +
"', for the relation `" + InstrMapDesc.getName());
MatchInstr = CurInstr;
}
}
return MatchInstr;
@ -516,10 +515,9 @@ static void emitEnums(raw_ostream &OS, RecordKeeper &Records) {
for (unsigned j = 0; j < ListSize; j++) {
ListInit *ListJ = dyn_cast<ListInit>(List->getElement(j));
if (ListJ->getSize() != ColFields->getSize()) {
throw "Record `" + CurMap->getName() + "', field `" + "ValueCols" +
"' entries don't match with the entries in 'ColFields' !";
}
if (ListJ->getSize() != ColFields->getSize())
PrintFatalError("Record `" + CurMap->getName() + "', field "
"`ValueCols' entries don't match with the entries in 'ColFields' !");
ValueCols.push_back(ListJ);
}