[llvm-commits] CVS: llvm/utils/TableGen/SubtargetEmitter.cpp

Jim Laskey jlaskey at apple.com
Sat Oct 22 01:00:14 PDT 2005



Changes in directory llvm/utils/TableGen:

SubtargetEmitter.cpp updated: 1.1 -> 1.2
---
Log message:

Sort the features and processor lists for the sake of search (and maintainers.)



---
Diffs of the changes:  (+27 -2)

 SubtargetEmitter.cpp |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)


Index: llvm/utils/TableGen/SubtargetEmitter.cpp
diff -u llvm/utils/TableGen/SubtargetEmitter.cpp:1.1 llvm/utils/TableGen/SubtargetEmitter.cpp:1.2
--- llvm/utils/TableGen/SubtargetEmitter.cpp:1.1	Fri Oct 21 14:00:04 2005
+++ llvm/utils/TableGen/SubtargetEmitter.cpp	Sat Oct 22 02:59:56 2005
@@ -20,17 +20,42 @@
 #include <set>
 using namespace llvm;
 
-// Convenience types
+//
+// Convenience types.
+//
 typedef std::vector<Record*> RecordList;
 typedef std::vector<Record*>::iterator RecordListIter;
 
+//
+// Record sort by name function.
+//
+struct LessRecord {
+  bool operator()(const Record *Rec1, const Record *Rec2) const {
+    return Rec1->getName() < Rec2->getName();
+  }
+};
 
+//
+// Record sort by field "Name" function.
+//
+struct LessRecordFieldName {
+  bool operator()(const Record *Rec1, const Record *Rec2) const {
+    return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
+  }
+};
+
+
+// 
 // SubtargetEmitter::run - Main subtarget enumeration emitter.
 //
 void SubtargetEmitter::run(std::ostream &OS) {
   EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
+  
   RecordList Features = Records.getAllDerivedDefinitions("SubtargetFeature");
+  sort(Features.begin(), Features.end(), LessRecord());
+  
   RecordList Processors = Records.getAllDerivedDefinitions("Processor");
+  sort(Processors.begin(), Processors.end(), LessRecordFieldName());
 
   OS << "namespace llvm {\n\n";
   
@@ -70,7 +95,7 @@
     OS << "};\n";
   }
   
-  { // Feature key values
+  { // CPU key values
     OS << "\n\n"
        << "/// Sorted (by key) array of values for CPU subtype.\n"
        << "static const SubtargetFeatureKV SubTypeKV[] = {\n";






More information about the llvm-commits mailing list