aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/CodeEmitterGen.cpp9
-rw-r--r--support/tools/TableGen/CodeEmitterGen.h2
-rw-r--r--support/tools/TableGen/TableGen.cpp6
-rw-r--r--utils/TableGen/CodeEmitterGen.cpp9
-rw-r--r--utils/TableGen/CodeEmitterGen.h2
-rw-r--r--utils/TableGen/TableGen.cpp6
6 files changed, 24 insertions, 10 deletions
diff --git a/support/tools/TableGen/CodeEmitterGen.cpp b/support/tools/TableGen/CodeEmitterGen.cpp
index 90497cc..8805c7c 100644
--- a/support/tools/TableGen/CodeEmitterGen.cpp
+++ b/support/tools/TableGen/CodeEmitterGen.cpp
@@ -2,7 +2,7 @@
#include "Record.h"
#include "CodeEmitterGen.h"
-void CodeEmitterGen::createEmitter(std::ostream &o) {
+int CodeEmitterGen::createEmitter(std::ostream &o) {
std::vector<Record*> Insts;
const std::map<std::string, Record*> &Defs = Records.getDefs();
@@ -31,8 +31,12 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
<< " DEBUG(std::cerr << \"Emitting " << R->getName() << "\\n\");\n";
const RecordVal *InstVal = R->getValue("Inst");
- Init *InitVal = InstVal->getValue();
+ if (!InstVal) {
+ std::cerr << "No 'Inst' record found in target description file!\n";
+ return 1;
+ }
+ Init *InitVal = InstVal->getValue();
assert(dynamic_cast<BitsInit*>(InitVal) &&
"Can only handle undefined bits<> types!");
BitsInit *BI = (BitsInit*)InitVal;
@@ -225,4 +229,5 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
<< " }\n"
<< " return Value;\n"
<< "}\n";
+ return 0;
}
diff --git a/support/tools/TableGen/CodeEmitterGen.h b/support/tools/TableGen/CodeEmitterGen.h
index 098816a..cf000c4 100644
--- a/support/tools/TableGen/CodeEmitterGen.h
+++ b/support/tools/TableGen/CodeEmitterGen.h
@@ -15,7 +15,7 @@ struct CodeEmitterGen {
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
- void createEmitter(std::ostream &o);
+ int createEmitter(std::ostream &o);
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
};
diff --git a/support/tools/TableGen/TableGen.cpp b/support/tools/TableGen/TableGen.cpp
index 81529f0..17f2b2e 100644
--- a/support/tools/TableGen/TableGen.cpp
+++ b/support/tools/TableGen/TableGen.cpp
@@ -394,10 +394,12 @@ int main(int argc, char **argv) {
RemoveFileOnSignal(OutputFilename);
}
+ int ErrorCode = 0;
+
switch (Action) {
case Parse: ParseMachineCode(); break;
case GenEmitter:
- CodeEmitterGen(Records).createEmitter(*Out);
+ ErrorCode = CodeEmitterGen(Records).createEmitter(*Out);
break;
case PrintRecords:
*Out << Records; // No argument, dump all contents
@@ -421,5 +423,5 @@ int main(int argc, char **argv) {
}
if (Out != &std::cout) delete Out;
- return 0;
+ return ErrorCode;
}
diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp
index 90497cc..8805c7c 100644
--- a/utils/TableGen/CodeEmitterGen.cpp
+++ b/utils/TableGen/CodeEmitterGen.cpp
@@ -2,7 +2,7 @@
#include "Record.h"
#include "CodeEmitterGen.h"
-void CodeEmitterGen::createEmitter(std::ostream &o) {
+int CodeEmitterGen::createEmitter(std::ostream &o) {
std::vector<Record*> Insts;
const std::map<std::string, Record*> &Defs = Records.getDefs();
@@ -31,8 +31,12 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
<< " DEBUG(std::cerr << \"Emitting " << R->getName() << "\\n\");\n";
const RecordVal *InstVal = R->getValue("Inst");
- Init *InitVal = InstVal->getValue();
+ if (!InstVal) {
+ std::cerr << "No 'Inst' record found in target description file!\n";
+ return 1;
+ }
+ Init *InitVal = InstVal->getValue();
assert(dynamic_cast<BitsInit*>(InitVal) &&
"Can only handle undefined bits<> types!");
BitsInit *BI = (BitsInit*)InitVal;
@@ -225,4 +229,5 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
<< " }\n"
<< " return Value;\n"
<< "}\n";
+ return 0;
}
diff --git a/utils/TableGen/CodeEmitterGen.h b/utils/TableGen/CodeEmitterGen.h
index 098816a..cf000c4 100644
--- a/utils/TableGen/CodeEmitterGen.h
+++ b/utils/TableGen/CodeEmitterGen.h
@@ -15,7 +15,7 @@ struct CodeEmitterGen {
public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {}
- void createEmitter(std::ostream &o);
+ int createEmitter(std::ostream &o);
void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
void emitGetValueBit(std::ostream &o, const std::string &Namespace);
};
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index 81529f0..17f2b2e 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -394,10 +394,12 @@ int main(int argc, char **argv) {
RemoveFileOnSignal(OutputFilename);
}
+ int ErrorCode = 0;
+
switch (Action) {
case Parse: ParseMachineCode(); break;
case GenEmitter:
- CodeEmitterGen(Records).createEmitter(*Out);
+ ErrorCode = CodeEmitterGen(Records).createEmitter(*Out);
break;
case PrintRecords:
*Out << Records; // No argument, dump all contents
@@ -421,5 +423,5 @@ int main(int argc, char **argv) {
}
if (Out != &std::cout) delete Out;
- return 0;
+ return ErrorCode;
}