Fix generation of certain scheduler itineraries.
[oota-llvm.git] / utils / TableGen / SubtargetEmitter.cpp
index a70dbc972878020476b70d9ce442655f96054012..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 += ", ";
   }
 }