Fix generation of certain scheduler itineraries.
[oota-llvm.git] / utils / TableGen / SubtargetEmitter.cpp
index cf2c5b4a0b40e79827b0faaed9493e3113ee6d32..f6c7a44f347e7f531fcf388cdb1aa08e7538842d 100644 (file)
@@ -87,7 +87,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
      << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n";
   
   // For each feature
-  for (unsigned i = 0, N = FeatureList.size(); i < N;) {
+  for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) {
     // Next feature
     Record *Feature = FeatureList[i];
 
@@ -95,6 +95,8 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
     std::string CommandLineName = Feature->getValueAsString("Name");
     std::string Desc = Feature->getValueAsString("Desc");
     
+    if (CommandLineName.empty()) continue;
+    
     // Emit as { "feature", "decription", feactureEnum }
     OS << "  { "
        << "\"" << CommandLineName << "\", "
@@ -103,7 +105,7 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
        << " }";
     
     // Depending on 'if more in the list' emit comma
-    if (++i < N) OS << ",";
+    if ((i + 1) < N) OS << ",";
     
     OS << "\n";
   }
@@ -216,7 +218,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
 
   // For each stage
   unsigned N = NStages = StageList.size();
-  for (unsigned i = 0; i < N; i++) {
+  for (unsigned i = 0; i < N;) {
     // Next stage
     Record *Stage = StageList[i];
   
@@ -239,6 +241,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
     
     // Close off stage
     ItinString += " }";
+    if (++i < N) ItinString += ", ";
   }
 }
 
@@ -355,7 +358,6 @@ void SubtargetEmitter::EmitProcessorData(std::ostream &OS,
     
     // For each itinerary class
     std::vector<InstrItinerary> &ItinList = *ProcListIter++;
-    unsigned ItinIndex = 0;
     for (unsigned j = 0, M = ItinList.size(); j < M;) {
       InstrItinerary &Intinerary = ItinList[j];
       
@@ -375,9 +377,6 @@ void SubtargetEmitter::EmitProcessorData(std::ostream &OS,
     // End processor itinerary table
     OS << "};\n";
   }
-  
-    OS << "\n";
-    OS << "static llvm::InstrItinerary NoItineraries[] = { {0, 0} };\n";
 }
 
 //