[llvm-commits] CVS: llvm/utils/TableGen/SubtargetEmitter.cpp SubtargetEmitter.h
Jim Laskey
jlaskey at apple.com
Tue Oct 25 08:16:47 PDT 2005
Changes in directory llvm/utils/TableGen:
SubtargetEmitter.cpp updated: 1.3 -> 1.4
SubtargetEmitter.h updated: 1.1 -> 1.2
---
Log message:
Refactored to make room for more stuff (scheduling info.)
---
Diffs of the changes: (+102 -77)
SubtargetEmitter.cpp | 174 ++++++++++++++++++++++++++++-----------------------
SubtargetEmitter.h | 5 +
2 files changed, 102 insertions(+), 77 deletions(-)
Index: llvm/utils/TableGen/SubtargetEmitter.cpp
diff -u llvm/utils/TableGen/SubtargetEmitter.cpp:1.3 llvm/utils/TableGen/SubtargetEmitter.cpp:1.4
--- llvm/utils/TableGen/SubtargetEmitter.cpp:1.3 Sun Oct 23 17:33:08 2005
+++ llvm/utils/TableGen/SubtargetEmitter.cpp Tue Oct 25 10:16:36 2005
@@ -44,96 +44,116 @@
}
};
-
-//
-// SubtargetEmitter::run - Main subtarget enumeration emitter.
//
-void SubtargetEmitter::run(std::ostream &OS) {
- EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
-
+// FeatureEnumeration - Emit an enumeration of all the subtarget features.
+//
+void SubtargetEmitter::FeatureEnumeration(std::ostream &OS) {
RecordList Features = Records.getAllDerivedDefinitions("SubtargetFeature");
sort(Features.begin(), Features.end(), LessRecord());
-
- RecordList Processors = Records.getAllDerivedDefinitions("Processor");
- sort(Processors.begin(), Processors.end(), LessRecordFieldName());
- OS << "#include \"llvm/Target/SubtargetFeature.h\"\n\n";
+ int i = 0;
- { // Feature enumeration
- int i = 0;
-
- OS << "enum {\n";
-
- for (RecordListIter RI = Features.begin(), E = Features.end(); RI != E;){
- Record *R = *RI++;
- std::string Instance = R->getName();
- OS << " "
- << Instance
- << " = "
- << " 1 << " << i++
- << ((RI != E) ? ",\n" : "\n");
- }
-
- OS << "};\n";
- }
+ OS << "enum {\n";
- { // Feature key values
- OS << "\n"
- << "// Sorted (by key) array of values for CPU features.\n"
- << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n";
- for (RecordListIter RI = Features.begin(), E = Features.end(); RI != E;) {
- Record *R = *RI++;
- std::string Instance = R->getName();
- std::string Name = R->getValueAsString("Name");
- std::string Desc = R->getValueAsString("Desc");
- OS << " { "
- << "\"" << Name << "\", "
- << "\"" << Desc << "\", "
- << Instance
- << ((RI != E) ? " },\n" : " }\n");
- }
- OS << "};\n";
+ for (RecordListIter RI = Features.begin(), E = Features.end(); RI != E;){
+ Record *R = *RI++;
+ std::string Instance = R->getName();
+ OS << " "
+ << Instance
+ << " = "
+ << " 1 << " << i++
+ << ((RI != E) ? ",\n" : "\n");
}
- { // CPU key values
- OS << "\n"
- << "// Sorted (by key) array of values for CPU subtype.\n"
- << "static const llvm::SubtargetFeatureKV SubTypeKV[] = {\n";
- for (RecordListIter RI = Processors.begin(), E = Processors.end();
- RI != E;) {
- Record *R = *RI++;
- std::string Name = R->getValueAsString("Name");
- Record *ProcItin = R->getValueAsDef("ProcItin");
- ListInit *Features = R->getValueAsListInit("Features");
- unsigned N = Features->getSize();
- OS << " { "
- << "\"" << Name << "\", "
- << "\"Select the " << Name << " processor\", ";
-
-
- if (N == 0) {
- OS << "0";
- } else {
- for (unsigned i = 0; i < N; ) {
- if (DefInit *DI = dynamic_cast<DefInit*>(Features->getElement(i++))) {
- Record *Feature = DI->getDef();
- std::string Name = Feature->getName();
- OS << Name;
- if (i != N) OS << " | ";
- } else {
- throw "Feature: " + Name +
- " expected feature in processor feature list!";
- }
+ OS << "};\n";
+}
+
+//
+// FeatureKeyValues - Emit data of all the subtarget features. Used by command
+// line.
+//
+void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
+ RecordList Features = Records.getAllDerivedDefinitions("SubtargetFeature");
+ sort(Features.begin(), Features.end(), LessRecord());
+
+ OS << "\n"
+ << "// Sorted (by key) array of values for CPU features.\n"
+ << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n";
+ for (RecordListIter RI = Features.begin(), E = Features.end(); RI != E;) {
+ Record *R = *RI++;
+ std::string Instance = R->getName();
+ std::string Name = R->getValueAsString("Name");
+ std::string Desc = R->getValueAsString("Desc");
+ OS << " { "
+ << "\"" << Name << "\", "
+ << "\"" << Desc << "\", "
+ << Instance
+ << ((RI != E) ? " },\n" : " }\n");
+ }
+ OS << "};\n";
+
+ OS<<"\nenum {\n";
+ OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV)\n";
+ OS<<"};\n";
+}
+
+//
+// CPUKeyValues - Emit data of all the subtarget processors. Used by command
+// line.
+//
+void SubtargetEmitter::CPUKeyValues(std::ostream &OS) {
+ RecordList Processors = Records.getAllDerivedDefinitions("Processor");
+ sort(Processors.begin(), Processors.end(), LessRecordFieldName());
+
+ OS << "\n"
+ << "// Sorted (by key) array of values for CPU subtype.\n"
+ << "static const llvm::SubtargetFeatureKV SubTypeKV[] = {\n";
+ for (RecordListIter RI = Processors.begin(), E = Processors.end();
+ RI != E;) {
+ Record *R = *RI++;
+ std::string Name = R->getValueAsString("Name");
+ Record *ProcItin = R->getValueAsDef("ProcItin");
+ ListInit *Features = R->getValueAsListInit("Features");
+ unsigned N = Features->getSize();
+ OS << " { "
+ << "\"" << Name << "\", "
+ << "\"Select the " << Name << " processor\", ";
+
+
+ if (N == 0) {
+ OS << "0";
+ } else {
+ for (unsigned i = 0; i < N; ) {
+ if (DefInit *DI = dynamic_cast<DefInit*>(Features->getElement(i++))) {
+ Record *Feature = DI->getDef();
+ std::string Name = Feature->getName();
+ OS << Name;
+ if (i != N) OS << " | ";
+ } else {
+ throw "Feature: " + Name +
+ " expected feature in processor feature list!";
}
}
-
- OS << ((RI != E) ? " },\n" : " }\n");
}
- OS << "};\n";
+
+ OS << ((RI != E) ? " },\n" : " }\n");
}
-
+ OS << "};\n";
+
OS<<"\nenum {\n";
- OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV),\n";
OS<<" SubTypeKVSize = sizeof(SubTypeKV)/sizeof(llvm::SubtargetFeatureKV)\n";
OS<<"};\n";
}
+
+//
+// SubtargetEmitter::run - Main subtarget enumeration emitter.
+//
+void SubtargetEmitter::run(std::ostream &OS) {
+ EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
+
+ OS << "#include \"llvm/Target/SubtargetFeature.h\"\n\n";
+
+ FeatureEnumeration(OS);
+ FeatureKeyValues(OS);
+ CPUKeyValues(OS);
+}
Index: llvm/utils/TableGen/SubtargetEmitter.h
diff -u llvm/utils/TableGen/SubtargetEmitter.h:1.1 llvm/utils/TableGen/SubtargetEmitter.h:1.2
--- llvm/utils/TableGen/SubtargetEmitter.h:1.1 Fri Oct 21 14:00:04 2005
+++ llvm/utils/TableGen/SubtargetEmitter.h Tue Oct 25 10:16:36 2005
@@ -20,6 +20,11 @@
class SubtargetEmitter : public TableGenBackend {
RecordKeeper &Records;
+
+ void FeatureEnumeration(std::ostream &OS);
+ void FeatureKeyValues(std::ostream &OS);
+ void CPUKeyValues(std::ostream &OS);
+
public:
SubtargetEmitter(RecordKeeper &R) : Records(R) {}
More information about the llvm-commits
mailing list