From 60200e5d32f63b4e54575f5cbec348f3f9baeb5d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 19 Aug 2005 20:23:42 +0000 Subject: [PATCH] Expose the derived register classes to the public header, allowing them to be accessed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22930 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/RegisterInfoEmitter.cpp | 45 +++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 3b5789f9a62..caae2f0b4cf 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -69,7 +69,17 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) { << " { // Register classes\n"; for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) { const std::string &Name = RegisterClasses[i].getName(); - OS << " extern TargetRegisterClass * const "<< Name <<"RegisterClass;\n"; + + // Output the register class definition. + OS << " struct " << Name << "Class : public TargetRegisterClass {\n" + << " " << Name << "Class();\n" + << RegisterClasses[i].MethodProtos << " };\n"; + + // Output the extern for the instance. + OS << " extern " << Name << "Class\t" << Name << "RegClass;\n"; + // Output the extern for the pointer to the instance (should remove). + OS << " static TargetRegisterClass * const "<< Name <<"RegisterClass = &" + << Name << "RegClass;\n"; } OS << "} // end of namespace " << TargetName << "\n\n"; } @@ -121,13 +131,6 @@ void RegisterInfoEmitter::run(std::ostream &OS) { RegClassesBelongedTo.insert(std::make_pair(Reg, &RC)); } OS << "\n };\n\n"; - - OS << " struct " << Name << "Class : public TargetRegisterClass {\n" - << " " << Name << "Class() : TargetRegisterClass(" - << RC.SpillSize/8 << ", " << RC.SpillAlignment/8 << ", " << Name << ", " - << Name << " + " << RC.Elements.size() << ") {}\n" - << RC.MethodProtos << " };\n"; - OS << RC.MethodBodies << "\n"; } OS << "} // end anonymous namespace\n\n"; @@ -137,7 +140,17 @@ void RegisterInfoEmitter::run(std::ostream &OS) { << " { // Register class instances\n"; for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) OS << " " << RegisterClasses[i].getName() << "Class\t" - << RegisterClasses[i].getName() << "RegClassInstance;\n"; + << RegisterClasses[i].getName() << "RegClass;\n"; + + for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) { + const CodeGenRegisterClass &RC = RegisterClasses[i]; + OS << RC.MethodBodies << "\n"; + OS << RC.getName() << "Class::" << RC.getName() + << "Class() : TargetRegisterClass(" << RC.SpillSize/8 << ", " + << RC.SpillAlignment/8 << ", " << RC.getName() << ", " + << RC.getName() << " + " << RC.Elements.size() << ") {}\n"; + } + OS << "}\n"; } @@ -145,7 +158,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) { OS << " const TargetRegisterClass* const RegisterClasses[] = {\n"; for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) OS << " &" << getQualifiedName(RegisterClasses[i].TheDef) - << "RegClassInstance,\n"; + << "RegClass,\n"; OS << " };\n"; // Emit register class aliases... @@ -238,18 +251,6 @@ void RegisterInfoEmitter::run(std::ostream &OS) { OS << " };\n"; // End of register descriptors... OS << "}\n\n"; // End of anonymous namespace... - if (!RegisterClasses.empty()) { - OS << "namespace " << RegisterClasses[0].Namespace - << " { // Register classes\n"; - for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) { - OS << " TargetRegisterClass * const " << RegisterClasses[i].getName() - << "RegisterClass = &" << getQualifiedName(RegisterClasses[i].TheDef) - << "RegClassInstance;\n"; - } - OS << "} // end of namespace " << RegisterClasses[0].Namespace << "\n\n"; - } - - std::string ClassName = Target.getName() + "GenRegisterInfo"; // Emit the constructor of the class... -- 2.34.1