Rename isSimpleLoad to canFoldAsLoad, to better reflect its meaning.
[oota-llvm.git] / utils / TableGen / SubtargetEmitter.cpp
index a0dc96787d1a0f018b19163c300d30ae51ef75d5..b05b9968a2e83a149f09152e63f82c2a5a44d601 100644 (file)
 #include <algorithm>
 using namespace llvm;
 
-//
-// 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");
-  }
-};
-
 //
 // Enumeration - Emit the specified class as an enumeration.
 //
@@ -79,7 +61,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
   // Gather and sort all the features
   std::vector<Record*> FeatureList =
                            Records.getAllDerivedDefinitions("SubtargetFeature");
-  std::sort(FeatureList.begin(), FeatureList.end(), LessRecord());
+  std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName());
 
   // Begin feature table
   OS << "// Sorted (by key) array of values for CPU features.\n"
@@ -272,6 +254,7 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
   OS << "static const llvm::InstrStage Stages[] = {\n"
         "  { 0, 0 }, // No itinerary\n";
         
+  unsigned StageCount = 1;
   unsigned ItinEnum = 1;
   std::map<std::string, unsigned> ItinMap;
   for (unsigned i = 0, N = ProcItinList.size(); i < N; i++) {
@@ -308,8 +291,10 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
       if (Find == 0) {
         // Emit as { cycles, u1 | u2 | ... | un }, // index
         OS << ItinString << ", // " << ItinEnum << "\n";
-        // Record Itin class number
-        ItinMap[ItinString] = Find = ItinEnum++;
+        // Record Itin class number.
+        ItinMap[ItinString] = Find = StageCount;
+        StageCount += NStages;
+        ItinEnum++;
       }
       
       // Set up itinerary as location and location + stage count