diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-06 04:32:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-06 04:32:07 +0000 |
commit | bc01723605de979e67b1aea67385a029f851de34 (patch) | |
tree | 782135308f0fbd600844d81afc2e5434f9f8685c /support | |
parent | 18a6a94e1fc5cd10d50a91598b1465f31e307266 (diff) | |
download | external_llvm-bc01723605de979e67b1aea67385a029f851de34.zip external_llvm-bc01723605de979e67b1aea67385a029f851de34.tar.gz external_llvm-bc01723605de979e67b1aea67385a029f851de34.tar.bz2 |
Switch code over to being a TableGenBackend
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support')
-rw-r--r-- | support/tools/TableGen/InstrInfoEmitter.cpp | 29 | ||||
-rw-r--r-- | support/tools/TableGen/InstrInfoEmitter.h | 9 |
2 files changed, 9 insertions, 29 deletions
diff --git a/support/tools/TableGen/InstrInfoEmitter.cpp b/support/tools/TableGen/InstrInfoEmitter.cpp index 761bdee..ad501dc 100644 --- a/support/tools/TableGen/InstrInfoEmitter.cpp +++ b/support/tools/TableGen/InstrInfoEmitter.cpp @@ -8,27 +8,6 @@ #include "InstrInfoEmitter.h" #include "Record.h" -static void EmitSourceHeader(const std::string &Desc, std::ostream &o) { - o << "//===- TableGen'erated file -------------------------------------*-" - " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate" - "d file, do not edit!\n//\n//===------------------------------------" - "----------------------------------===//\n\n"; -} - -static std::string getQualifiedName(Record *R) { - std::string Namespace = R->getValueAsString("Namespace"); - if (Namespace.empty()) return R->getName(); - return Namespace + "::" + R->getName(); -} - -static Record *getTarget(RecordKeeper &RC) { - std::vector<Record*> Targets = RC.getAllDerivedDefinitions("Target"); - - if (Targets.size() != 1) - throw std::string("ERROR: Multiple subclasses of Target defined!"); - return Targets[0]; -} - // runEnums - Print out enum values for all of the instructions. void InstrInfoEmitter::runEnums(std::ostream &OS) { std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction"); @@ -38,7 +17,7 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { std::string Namespace = Insts[0]->getValueAsString("Namespace"); - EmitSourceHeader("Target Instruction Enum Values", OS); + EmitSourceFileHeader("Target Instruction Enum Values", OS); if (!Namespace.empty()) OS << "namespace " << Namespace << " {\n"; @@ -61,8 +40,8 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { OS << "}\n"; } -static void printDefList(ListInit *LI, const std::string &Name, - std::ostream &OS) { +void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name, + std::ostream &OS) const { OS << "static const unsigned " << Name << "[] = { "; for (unsigned j = 0, e = LI->getSize(); j != e; ++j) if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(j))) @@ -75,7 +54,7 @@ static void printDefList(ListInit *LI, const std::string &Name, // run - Emit the main instruction description records for the target... void InstrInfoEmitter::run(std::ostream &OS) { - EmitSourceHeader("Target Instruction Descriptors", OS); + EmitSourceFileHeader("Target Instruction Descriptors", OS); Record *Target = getTarget(Records); const std::string &TargetName = Target->getName(); Record *InstrInfo = Target->getValueAsDef("InstructionSet"); diff --git a/support/tools/TableGen/InstrInfoEmitter.h b/support/tools/TableGen/InstrInfoEmitter.h index 0415f04..400c0db 100644 --- a/support/tools/TableGen/InstrInfoEmitter.h +++ b/support/tools/TableGen/InstrInfoEmitter.h @@ -8,13 +8,12 @@ #ifndef INSTRINFO_EMITTER_H #define INSTRINFO_EMITTER_H -#include <iosfwd> -class RecordKeeper; -class Record; +#include "TableGenBackend.h" class StringInit; class IntInit; +class ListInit; -class InstrInfoEmitter { +class InstrInfoEmitter : public TableGenBackend { RecordKeeper &Records; public: InstrInfoEmitter(RecordKeeper &R) : Records(R) {} @@ -25,6 +24,8 @@ public: // runEnums - Print out enum values for all of the instructions. void runEnums(std::ostream &OS); private: + void printDefList(ListInit *LI, const std::string &Name, + std::ostream &OS) const; void emitRecord(Record *R, unsigned Num, Record *InstrInfo, std::ostream &OS); void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift, std::ostream &OS); |