diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-07 05:39:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-07 05:39:09 +0000 |
commit | 7884b750c33b750177b3f22af75c874c97f728d8 (patch) | |
tree | f9142d6bcea24679fc28a067e51992b6cfd6a5cf /utils | |
parent | 45872079672a4fb500fdcb9c77b23e3e550c8f97 (diff) | |
download | external_llvm-7884b750c33b750177b3f22af75c874c97f728d8.zip external_llvm-7884b750c33b750177b3f22af75c874c97f728d8.tar.gz external_llvm-7884b750c33b750177b3f22af75c874c97f728d8.tar.bz2 |
Start using the CodeGeneratorWrappers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 12 | ||||
-rw-r--r-- | utils/TableGen/RegisterInfoEmitter.cpp | 20 |
2 files changed, 16 insertions, 16 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index ad501dc..c794cd0 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -6,6 +6,7 @@ //===----------------------------------------------------------------------===// #include "InstrInfoEmitter.h" +#include "CodeGenWrappers.h" #include "Record.h" // runEnums - Print out enum values for all of the instructions. @@ -23,9 +24,10 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { OS << "namespace " << Namespace << " {\n"; OS << " enum {\n"; + CodeGenTarget Target; + // We must emit the PHI opcode first... - Record *Target = getTarget(Records); - Record *InstrInfo = Target->getValueAsDef("InstructionSet"); + Record *InstrInfo = Target.getInstructionSet(); Record *PHI = InstrInfo->getValueAsDef("PHIInst"); OS << " " << PHI->getName() << ", \t// 0 (fixed for all targets)\n"; @@ -55,9 +57,9 @@ void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name, // run - Emit the main instruction description records for the target... void InstrInfoEmitter::run(std::ostream &OS) { EmitSourceFileHeader("Target Instruction Descriptors", OS); - Record *Target = getTarget(Records); - const std::string &TargetName = Target->getName(); - Record *InstrInfo = Target->getValueAsDef("InstructionSet"); + CodeGenTarget Target; + const std::string &TargetName = Target.getName(); + Record *InstrInfo = Target.getInstructionSet(); Record *PHI = InstrInfo->getValueAsDef("PHIInst"); std::vector<Record*> Instructions = diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 396f340..f1f8a86 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "RegisterInfoEmitter.h" +#include "CodeGenWrappers.h" #include "Record.h" #include "Support/StringExtras.h" #include <set> @@ -36,7 +37,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) { void RegisterInfoEmitter::runHeader(std::ostream &OS) { EmitSourceFileHeader("Register Information Header Fragment", OS); - const std::string &TargetName = getTarget(Records)->getName(); + const std::string &TargetName = CodeGenTarget().getName(); std::string ClassName = TargetName + "GenRegisterInfo"; OS << "#include \"llvm/Target/MRegisterInfo.h\"\n\n"; @@ -193,20 +194,20 @@ void RegisterInfoEmitter::run(std::ostream &OS) { OS << " };\n"; // End of register descriptors... OS << "}\n\n"; // End of anonymous namespace... - Record *Target = getTarget(Records); + CodeGenTarget Target; - OS << "namespace " << Target->getName() << " { // Register classes\n"; + OS << "namespace " << Target.getName() << " { // Register classes\n"; for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) { const std::string &Name = RegisterClasses[i]->getName(); if (Name.size() < 9 || Name[9] != '.') // Ignore anonymous classes OS << " TargetRegisterClass *" << Name << "RegisterClass = &" << Name << "Instance;\n"; } - OS << "} // end of namespace " << Target->getName() << "\n\n"; + OS << "} // end of namespace " << Target.getName() << "\n\n"; - std::string ClassName = Target->getName() + "GenRegisterInfo"; + std::string ClassName = Target.getName() + "GenRegisterInfo"; // Emit the constructor of the class... OS << ClassName << "::" << ClassName @@ -219,11 +220,8 @@ void RegisterInfoEmitter::run(std::ostream &OS) { OS << "const unsigned* " << ClassName << "::getCalleeSaveRegs() const {\n" << " static const unsigned CalleeSaveRegs[] = {\n "; - ListInit *LI = Target->getValueAsListInit("CalleeSavedRegisters"); - for (unsigned i = 0, e = LI->getSize(); i != e; ++i) - if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i))) - OS << getQualifiedName(DI->getDef()) << ", "; - else - throw "Expected register definition in CalleeSavedRegisters list!"; + const std::vector<Record*> &CSR = Target.getCalleeSavedRegisters(); + for (unsigned i = 0, e = CSR.size(); i != e; ++i) + OS << getQualifiedName(CSR[i]) << ", "; OS << " 0\n };\n return CalleeSaveRegs;\n}\n\n"; } |