From 7884b750c33b750177b3f22af75c874c97f728d8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 Aug 2003 05:39:09 +0000 Subject: Start using the CodeGeneratorWrappers git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7666 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/InstrInfoEmitter.cpp | 12 +++++++----- support/tools/TableGen/RegisterInfoEmitter.cpp | 20 +++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'support/tools') diff --git a/support/tools/TableGen/InstrInfoEmitter.cpp b/support/tools/TableGen/InstrInfoEmitter.cpp index ad501dc426..c794cd0441 100644 --- a/support/tools/TableGen/InstrInfoEmitter.cpp +++ b/support/tools/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 Instructions = diff --git a/support/tools/TableGen/RegisterInfoEmitter.cpp b/support/tools/TableGen/RegisterInfoEmitter.cpp index 396f340949..f1f8a86bd4 100644 --- a/support/tools/TableGen/RegisterInfoEmitter.cpp +++ b/support/tools/TableGen/RegisterInfoEmitter.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "RegisterInfoEmitter.h" +#include "CodeGenWrappers.h" #include "Record.h" #include "Support/StringExtras.h" #include @@ -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(LI->getElement(i))) - OS << getQualifiedName(DI->getDef()) << ", "; - else - throw "Expected register definition in CalleeSavedRegisters list!"; + const std::vector &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"; } -- cgit v1.2.3