Add the needed #include, emit enums with the sizes of tables, remove
authorChris Lattner <sabre@nondot.org>
Sun, 23 Oct 2005 22:33:08 +0000 (22:33 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 23 Oct 2005 22:33:08 +0000 (22:33 +0000)
definitions from the LLVM namespace, since they are all static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23907 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/SubtargetEmitter.cpp

index 5318173b0d36470c667217f27098c8065bba5f85..6d3542ea3e59a4f706790ca3c68151d321c70960 100644 (file)
@@ -57,7 +57,7 @@ void SubtargetEmitter::run(std::ostream &OS) {
   RecordList Processors = Records.getAllDerivedDefinitions("Processor");
   sort(Processors.begin(), Processors.end(), LessRecordFieldName());
 
-  OS << "namespace llvm {\n\n";
+  OS << "#include \"llvm/Target/SubtargetFeature.h\"\n\n";
   
   { // Feature enumeration
     int i = 0;
@@ -78,9 +78,9 @@ void SubtargetEmitter::run(std::ostream &OS) {
   }
   
   { // Feature key values
-    OS << "\n\n"
-       << "/// Sorted (by key) array of values for CPU features.\n"
-       << "static SubtargetFeatureKV FeatureKV[] = {\n";
+    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();
@@ -96,9 +96,9 @@ void SubtargetEmitter::run(std::ostream &OS) {
   }
   
   { // CPU key values
-    OS << "\n\n"
-       << "/// Sorted (by key) array of values for CPU subtype.\n"
-       << "static const SubtargetFeatureKV SubTypeKV[] = {\n";
+    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++;
@@ -131,6 +131,9 @@ void SubtargetEmitter::run(std::ostream &OS) {
     }
     OS << "};\n";
   }
-
-  OS << "\n} // End llvm namespace \n";
+  
+  OS<<"\nenum {\n";
+  OS<<"  FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV),\n";
+  OS<<"  SubTypeKVSize = sizeof(SubTypeKV)/sizeof(llvm::SubtargetFeatureKV)\n";
+  OS<<"};\n";
 }