Implement resolution of variables to the value of the variable once it gets a value
authorChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 04:05:07 +0000 (04:05 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Jul 2003 04:05:07 +0000 (04:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7406 91177308-0d34-0410-b5e6-96231b3b80d8

support/tools/TableGen/Record.cpp
support/tools/TableGen/Record.h
utils/TableGen/Record.cpp
utils/TableGen/Record.h

index 2aabef408ddda5503b8509e1b85af6fc8736de67..72c5a230e5bebb55c6c89745fd385eac713fea81 100644 (file)
@@ -215,6 +215,9 @@ bool BitsInit::printAsUnset(std::ostream &OS) const {
   return false;
 }
 
+// resolveReferences - If there are any field references that refer to fields
+// that have been filled in, we can propagate the values now.
+//
 Init *BitsInit::resolveReferences(Record &R) {
   bool Changed = false;
   BitsInit *New = new BitsInit(getNumBits());
@@ -309,7 +312,18 @@ Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
   return 0;
 }
 
-
+/// resolveReferences - This method is used by classes that refer to other
+/// variables which may not be defined at the time they expression is formed.
+/// If a value is set for the variable later, this method will be called on
+/// users of the value to allow the value to propagate out.
+///
+Init *VarInit::resolveReferences(Record &R) {
+  if (RecordVal *Val = R.getValue(VarName))
+    if (!dynamic_cast<UnsetInit*>(Val->getValue()))
+      return Val->getValue();
+  return this;
+}
+  
 
 Init *VarBitInit::resolveReferences(Record &R) {
   Init *I = getVariable()->resolveBitReference(R, getBitNum());
index 72123cb52057079cbb2791faf52948ce7c2fff2d..356d131ae9ee90ccf3e55f58bbd8b12d11d5b78b 100644 (file)
@@ -365,6 +365,13 @@ public:
 
   virtual RecTy *getFieldType(const std::string &FieldName) const;
   virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
+
+  /// resolveReferences - This method is used by classes that refer to other
+  /// variables which may not be defined at the time they expression is formed.
+  /// If a value is set for the variable later, this method will be called on
+  /// users of the value to allow the value to propagate out.
+  ///
+  virtual Init *resolveReferences(Record &R);
   
   virtual void print(std::ostream &OS) const { OS << VarName; }
 };
index 2aabef408ddda5503b8509e1b85af6fc8736de67..72c5a230e5bebb55c6c89745fd385eac713fea81 100644 (file)
@@ -215,6 +215,9 @@ bool BitsInit::printAsUnset(std::ostream &OS) const {
   return false;
 }
 
+// resolveReferences - If there are any field references that refer to fields
+// that have been filled in, we can propagate the values now.
+//
 Init *BitsInit::resolveReferences(Record &R) {
   bool Changed = false;
   BitsInit *New = new BitsInit(getNumBits());
@@ -309,7 +312,18 @@ Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
   return 0;
 }
 
-
+/// resolveReferences - This method is used by classes that refer to other
+/// variables which may not be defined at the time they expression is formed.
+/// If a value is set for the variable later, this method will be called on
+/// users of the value to allow the value to propagate out.
+///
+Init *VarInit::resolveReferences(Record &R) {
+  if (RecordVal *Val = R.getValue(VarName))
+    if (!dynamic_cast<UnsetInit*>(Val->getValue()))
+      return Val->getValue();
+  return this;
+}
+  
 
 Init *VarBitInit::resolveReferences(Record &R) {
   Init *I = getVariable()->resolveBitReference(R, getBitNum());
index 72123cb52057079cbb2791faf52948ce7c2fff2d..356d131ae9ee90ccf3e55f58bbd8b12d11d5b78b 100644 (file)
@@ -365,6 +365,13 @@ public:
 
   virtual RecTy *getFieldType(const std::string &FieldName) const;
   virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
+
+  /// resolveReferences - This method is used by classes that refer to other
+  /// variables which may not be defined at the time they expression is formed.
+  /// If a value is set for the variable later, this method will be called on
+  /// users of the value to allow the value to propagate out.
+  ///
+  virtual Init *resolveReferences(Record &R);
   
   virtual void print(std::ostream &OS) const { OS << VarName; }
 };