various cleanups to tblgen, patch by Garrison Venn!
authorChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 04:48:22 +0000 (04:48 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Dec 2010 04:48:22 +0000 (04:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121837 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmMatcherEmitter.cpp
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/LLVMCConfigurationEmitter.h
utils/TableGen/Record.h
utils/TableGen/TGParser.cpp
utils/TableGen/TGParser.h
utils/TableGen/TableGen.cpp

index 4fcd3e211bbad2e35ce874b6ac1e3d1ad246b460..48766d1c4d6e569d0cf34f8aac004ed778ce260c 100644 (file)
@@ -493,7 +493,7 @@ struct SubtargetFeatureInfo {
 class AsmMatcherInfo {
 public:
   /// Tracked Records
-  RecordKeeperRecords;
+  RecordKeeper &Records;
 
   /// The tablegen AsmParser record.
   Record *AsmParser;
@@ -551,7 +551,7 @@ private:
 public:
   AsmMatcherInfo(Record *AsmParser, 
                  CodeGenTarget &Target, 
-                 RecordKeeperRecords);
+                 RecordKeeper &Records);
 
   /// BuildInfo - Construct the various tables used during matching.
   void BuildInfo();
@@ -565,12 +565,8 @@ public:
     return I == SubtargetFeatures.end() ? 0 : I->second;
   }
 
-  RecordKeeper& getRecords() {
-    return(Records);
-  }
-
-  RecordKeeper& getRecords() const {
-    return(Records);
+  RecordKeeper &getRecords() const {
+    return Records;
   }
 };
 
@@ -1004,7 +1000,7 @@ void AsmMatcherInfo::BuildOperandClasses() {
 
 AsmMatcherInfo::AsmMatcherInfo(Record *asmParser, 
                                CodeGenTarget &target, 
-                               RecordKeeperrecords)
+                               RecordKeeper &records)
   : Records(records), AsmParser(asmParser), Target(target),
     RegisterPrefix(AsmParser->getValueAsString("RegisterPrefix")) {
 }
index 69c55b81a4b69eccdc314331d9a0a09bb16bad8f..13e44803e5590954c4a1f7b8d57b97ed8209e473 100644 (file)
@@ -108,7 +108,7 @@ std::string llvm::getQualifiedName(const Record *R) {
 
 /// getTarget - Return the current instance of the Target class.
 ///
-CodeGenTarget::CodeGenTarget(RecordKeeperrecords) : Records(records) {
+CodeGenTarget::CodeGenTarget(RecordKeeper &records) : Records(records) {
   std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
   if (Targets.size() == 0)
     throw std::string("ERROR: No 'Target' subclasses defined!");
index d7e4371ca2aa4b269574898629228cf10ace94f3..0f2ff3719678d7000ea547c523615504f5177b7b 100644 (file)
@@ -23,7 +23,7 @@ namespace llvm {
   class LLVMCConfigurationEmitter : public TableGenBackend {
     RecordKeeper &Records;
   public:
-    explicit LLVMCConfigurationEmitter(RecordKeeperrecords) : 
+    explicit LLVMCConfigurationEmitter(RecordKeeper &records) : 
       Records(records) {}
 
     // run - Output the asmwriter, returning true on failure.
index f8873cf43cb8e78762984104fc3bfb3680208413..307594f8ec4eca8982144b41a9f5b372c95eb4c7 100644 (file)
@@ -1236,8 +1236,8 @@ class Record {
 
 public:
 
-  // Constructs a record. See also RecordKeeper::createRecord.
-  explicit Record(const std::string &N, SMLoc loc, RecordKeeperrecords) :
+  // Constructs a record.
+  explicit Record(const std::string &N, SMLoc loc, RecordKeeper &records) :
     ID(LastID++), Name(N), Loc(loc), TrackedRecords(records) {}
   ~Record() {}
 
@@ -1324,7 +1324,7 @@ public:
   void resolveReferencesTo(const RecordVal *RV);
 
   RecordKeeper &getRecords() const {
-    return(TrackedRecords);
+    return TrackedRecords;
   }
 
   void dump() const;
@@ -1466,12 +1466,6 @@ public:
   std::vector<Record*>
   getAllDerivedDefinitions(const std::string &ClassName) const;
 
-  // allocates and returns a record. 
-  Record *createRecord(const std::string &N, SMLoc loc) {
-    return(new Record(N, loc, *this));
-  }
-
-
   void dump() const;
 };
 
index 57e9f8333930d538ede3358e3f13bca65bd70f9e..d0a474958cc59d130ac1e470e3a63faeca87977c 100644 (file)
@@ -1096,8 +1096,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
 
     // Create the new record, set it as CurRec temporarily.
     static unsigned AnonCounter = 0;
-    Record *NewRec = Records.createRecord(
-                        "anonymous.val."+utostr(AnonCounter++),NameLoc);
+    Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),
+                                NameLoc,
+                                Records);
     SubClassReference SCRef;
     SCRef.RefLoc = NameLoc;
     SCRef.Rec = Class;
@@ -1661,7 +1662,7 @@ bool TGParser::ParseDef(MultiClass *CurMultiClass) {
   Lex.Lex();  // Eat the 'def' token.
 
   // Parse ObjectName and make a record for it.
-  Record *CurRec = Records.createRecord(ParseObjectName(), DefLoc);
+  Record *CurRec = new Record(ParseObjectName(), DefLoc, Records);
 
   if (!CurMultiClass) {
     // Top-level def definition.
@@ -1728,7 +1729,7 @@ bool TGParser::ParseClass() {
       return TokError("Class '" + CurRec->getName() + "' already defined");
   } else {
     // If this is the first reference to this class, create and add it.
-    CurRec = Records.createRecord(Lex.getCurStrVal(), Lex.getLoc());
+    CurRec = new Record(Lex.getCurStrVal(), Lex.getLoc(), Records);
     Records.addClass(CurRec);
   }
   Lex.Lex(); // eat the name.
@@ -1975,7 +1976,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) {
         }
       }
 
-      Record *CurRec = Records.createRecord(DefName, DefmPrefixLoc);
+      Record *CurRec = new Record(DefName, DefmPrefixLoc, Records);
 
       SubClassReference Ref;
       Ref.RefLoc = DefmPrefixLoc;
index 0c74bbfc7e2e6a751e1744b76e7399a1714dabbe..9cdf68ff974947e43409d62981461d59e919702b 100644 (file)
@@ -50,9 +50,9 @@ class TGParser {
   MultiClass *CurMultiClass;
 
   // Record tracker
-  RecordKeeperRecords;
+  RecordKeeper &Records;
 public:
-  TGParser(SourceMgr &SrcMgr, RecordKeeperrecords) : 
+  TGParser(SourceMgr &SrcMgr, RecordKeeper &records) : 
     Lex(SrcMgr), CurMultiClass(0), Records(records) {}
   
   /// ParseFile - Main entrypoint for parsing a tblgen file.  These parser
index 50543781eccc0af5f1180e7d3f9ff8f017ef9b9a..ab724af7d7549d8b1b07ba2e90593cb81ab78633 100644 (file)
@@ -186,7 +186,7 @@ void llvm::PrintError(SMLoc ErrorLoc, const Twine &Msg) {
 static bool ParseFile(const std::string &Filename,
                       const std::vector<std::string> &IncludeDirs,
                       SourceMgr &SrcMgr,
-                      RecordKeeperRecords) {
+                      RecordKeeper &Records) {
   error_code ec;
   MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), ec);
   if (F == 0) {