[llvm-commits] CVS: llvm/utils/TableGen/RegisterInfoEmitter.cpp
Evan Cheng
evan.cheng at apple.com
Thu May 11 00:30:39 PDT 2006
Changes in directory llvm/utils/TableGen:
RegisterInfoEmitter.cpp updated: 1.41 -> 1.42
---
Log message:
Also add super- register classes info.
---
Diffs of the changes: (+38 -0)
RegisterInfoEmitter.cpp | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+)
Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
diff -u llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.41 llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.42
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.41 Tue May 9 01:34:26 2006
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp Thu May 11 02:30:26 2006
@@ -166,6 +166,7 @@
OS << " " << RegisterClasses[i].getName() << "Class\t"
<< RegisterClasses[i].getName() << "RegClass;\n";
+ std::map<unsigned, std::set<unsigned> > SuperClassMap;
OS << "\n";
// Emit the sub-classes array for each RegisterClass
for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
@@ -194,12 +195,48 @@
if (!Empty) OS << ", ";
OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
Empty = false;
+
+ std::map<unsigned, std::set<unsigned> >::iterator SCMI =
+ SuperClassMap.find(rc2);
+ if (SCMI == SuperClassMap.end()) {
+ SuperClassMap.insert(std::make_pair(rc2, std::set<unsigned>()));
+ SCMI = SuperClassMap.find(rc2);
+ }
+ SCMI->second.insert(rc);
}
OS << (!Empty ? ", " : "") << "NULL";
OS << "\n };\n\n";
}
+ for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
+ const CodeGenRegisterClass &RC = RegisterClasses[rc];
+
+ // Give the register class a legal C name if it's anonymous.
+ std::string Name = RC.TheDef->getName();
+
+ OS << " // " << Name
+ << " Register Class super-classes...\n const TargetRegisterClass* "
+ << Name << "Superclasses [] = {\n ";
+
+ bool Empty = true;
+ std::map<unsigned, std::set<unsigned> >::iterator I =
+ SuperClassMap.find(rc);
+ if (I != SuperClassMap.end()) {
+ for (std::set<unsigned>::iterator II = I->second.begin(),
+ EE = I->second.end(); II != EE; ++II) {
+ const CodeGenRegisterClass &RC2 = RegisterClasses[*II];
+ if (!Empty) OS << ", ";
+ OS << "&" << getQualifiedName(RC2.TheDef) << "RegClass";
+ Empty = false;
+ }
+ }
+
+ OS << (!Empty ? ", " : "") << "NULL";
+ OS << "\n };\n\n";
+ }
+
+
for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
const CodeGenRegisterClass &RC = RegisterClasses[i];
OS << RC.MethodBodies << "\n";
@@ -207,6 +244,7 @@
<< "Class() : TargetRegisterClass("
<< RC.getName() + "VTs" << ", "
<< RC.getName() + "Subclasses" << ", "
+ << RC.getName() + "Superclasses" << ", "
<< RC.SpillSize/8 << ", "
<< RC.SpillAlignment/8 << ", " << RC.getName() << ", "
<< RC.getName() << " + " << RC.Elements.size() << ") {}\n";
More information about the llvm-commits
mailing list