Rename Record::getValueAsListDef to getValueAsListOfDefs, to more accurately
authorChris Lattner <sabre@nondot.org>
Fri, 28 Oct 2005 22:49:02 +0000 (22:49 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 28 Oct 2005 22:49:02 +0000 (22:49 +0000)
reflect what it is.
Convert some more code over to use it.

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

utils/TableGen/CodeGenTarget.cpp
utils/TableGen/DAGISelEmitter.cpp
utils/TableGen/Record.cpp
utils/TableGen/Record.h
utils/TableGen/SubtargetEmitter.cpp

index 1b3605a273c06300ee911807165f78911de008bb..e85170d5a6e11ece7d58beb7937fe5de9f629a79 100644 (file)
@@ -84,15 +84,8 @@ CodeGenTarget::CodeGenTarget() : PointerType(MVT::Other) {
     throw std::string("ERROR: Multiple subclasses of Target defined!");
   TargetRec = Targets[0];
 
-  // Read in all of the CalleeSavedRegisters...
-  ListInit *LI = TargetRec->getValueAsListInit("CalleeSavedRegisters");
-  for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
-    if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)))
-      CalleeSavedRegisters.push_back(DI->getDef());
-    else
-      throw "Target: " + TargetRec->getName() +
-            " expected register definition in CalleeSavedRegisters list!";
-
+  // Read in all of the CalleeSavedRegisters.
+  CalleeSavedRegisters =TargetRec->getValueAsListOfDefs("CalleeSavedRegisters");
   PointerType = getValueType(TargetRec->getValueAsDef("PointerType"));
 }
 
@@ -108,12 +101,10 @@ Record *CodeGenTarget::getInstructionSet() const {
 /// getAsmWriter - Return the AssemblyWriter definition for this target.
 ///
 Record *CodeGenTarget::getAsmWriter() const {
-  ListInit *LI = TargetRec->getValueAsListInit("AssemblyWriters");
-  if (AsmWriterNum >= LI->getSize())
+  std::vector<Record*> LI = TargetRec->getValueAsListOfDefs("AssemblyWriters");
+  if (AsmWriterNum >= LI.size())
     throw "Target does not have an AsmWriter #" + utostr(AsmWriterNum) + "!";
-  DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(AsmWriterNum));
-  if (!DI) throw std::string("AssemblyWriter list should be a list of defs!");
-  return DI->getDef();
+  return LI[AsmWriterNum];
 }
 
 void CodeGenTarget::ReadRegisters() const {
@@ -159,12 +150,9 @@ CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) {
   MethodBodies = R->getValueAsCode("MethodBodies");
   MethodProtos = R->getValueAsCode("MethodProtos");
   
-  ListInit *RegList = R->getValueAsListInit("MemberList");
-  for (unsigned i = 0, e = RegList->getSize(); i != e; ++i) {
-    DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));
-    if (!RegDef) throw "Register class member is not a record!";
-    Record *Reg = RegDef->getDef();
-
+  std::vector<Record*> RegList = R->getValueAsListOfDefs("MemberList");
+  for (unsigned i = 0, e = RegList.size(); i != e; ++i) {
+    Record *Reg = RegList[i];
     if (!Reg->isSubClassOf("Register"))
       throw "Register Class member '" + Reg->getName() +
             "' does not derive from the Register class!";
index 590a5badd46fb3c3ea248c73d0ea33103431a674..fb52355bee121095b989270170ac8124e6261942 100644 (file)
@@ -228,7 +228,7 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) {
   
   // Parse the properties.
   Properties = 0;
-  std::vector<Record*> PropList = R->getValueAsListDef("Properties");
+  std::vector<Record*> PropList = R->getValueAsListOfDefs("Properties");
   for (unsigned i = 0, e = PropList.size(); i != e; ++i) {
     if (PropList[i]->getName() == "SDNPCommutative") {
       Properties |= 1 << SDNPCommutative;
@@ -243,8 +243,9 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) {
   
   
   // Parse the type constraints.
-  std::vector<Record*> ConstList =TypeProfile->getValueAsListDef("Constraints");
-  TypeConstraints.assign(ConstList.begin(), ConstList.end());
+  std::vector<Record*> ConstraintList =
+    TypeProfile->getValueAsListOfDefs("Constraints");
+  TypeConstraints.assign(ConstraintList.begin(), ConstraintList.end());
 }
 
 //===----------------------------------------------------------------------===//
index 109ed392513c20f40d350487a48fbdeaa86b5b31..3bbb2d9116e2d5105e6291d8f6dcd38055b57da3 100644 (file)
@@ -709,12 +709,12 @@ ListInit *Record::getValueAsListInit(const std::string &FieldName) const {
         "' does not have a list initializer!";
 }
 
-/// getValueAsListDef - This method looks up the specified field and returns
+/// getValueAsListOfDefs - This method looks up the specified field and returns
 /// its value as a vector of records, throwing an exception if the field does
 /// not exist or if the value is not the right type.
 ///
-std::vector<Record*>  Record::getValueAsListDef(const std::string &FieldName)
-                                                                         const {
+std::vector<Record*> 
+Record::getValueAsListOfDefs(const std::string &FieldName) const {
   ListInit *List = getValueAsListInit(FieldName);
   std::vector<Record*> Defs;
   for (unsigned i = 0; i < List->getSize(); i++) {
index ecd6d7020a8f65f1f1067ded70d2b1dff2635d37..9f300041671738624b3c7f9b16fb49bbc852014a 100644 (file)
@@ -1000,11 +1000,11 @@ public:
   ///
   ListInit *getValueAsListInit(const std::string &FieldName) const;
 
-  /// getValueAsListDef - This method looks up the specified field and returns
-  /// its value as a vector of records, throwing an exception if the field does
-  /// not exist or if the value is not the right type.
+  /// getValueAsListOfDefs - This method looks up the specified field and
+  /// returnsits value as a vector of records, throwing an exception if the
+  /// field does not exist or if the value is not the right type.
   ///
-  std::vector<Record*> getValueAsListDef(const std::string &FieldName) const;
+  std::vector<Record*> getValueAsListOfDefs(const std::string &FieldName) const;
 
   /// getValueAsDef - This method looks up the specified field and returns its
   /// value as a Record, throwing an exception if the field does not exist or if
index e6429eaecb848500a899f47e1aae97bae78dd296..86b5201d5446fe75559bc430e1a90c5ba3fff5ba 100644 (file)
@@ -137,7 +137,8 @@ void SubtargetEmitter::CPUKeyValues(std::ostream &OS) {
     Record *Processor = ProcessorList[i];
 
     std::string Name = Processor->getValueAsString("Name");
-    std::vector<Record*> FeatureList = Processor->getValueAsListDef("Features");
+    std::vector<Record*> FeatureList = 
+      Processor->getValueAsListOfDefs("Features");
     
     // Emit as { "cpu", "description", f1 | f2 | ... fn },
     OS << "  { "
@@ -206,7 +207,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
                                            std::string &ItinString,
                                            unsigned &NStages) {
   // Get states list
-  std::vector<Record*> StageList = ItinData->getValueAsListDef("Stages");
+  std::vector<Record*> StageList = ItinData->getValueAsListOfDefs("Stages");
 
   // For each stage
   unsigned N = NStages = StageList.size();
@@ -219,7 +220,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
     ItinString += "  ,{ " + itostr(Cycles) + ", ";
     
     // Get unit list
-    std::vector<Record*> UnitList = Stage->getValueAsListDef("Units");
+    std::vector<Record*> UnitList = Stage->getValueAsListOfDefs("Units");
     
     // For each unit
     for (unsigned j = 0, M = UnitList.size(); j < M;) {
@@ -272,7 +273,7 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
     ItinList.resize(NItinClasses);
     
     // Get itinerary data list
-    std::vector<Record*> ItinDataList = Proc->getValueAsListDef("IID");
+    std::vector<Record*> ItinDataList = Proc->getValueAsListOfDefs("IID");
     
     // For each itinerary data
     for (unsigned j = 0, M = ItinDataList.size(); j < M; j++) {