aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/Record.cpp16
-rw-r--r--support/tools/TableGen/Record.h7
-rw-r--r--utils/TableGen/Record.cpp16
-rw-r--r--utils/TableGen/Record.h7
4 files changed, 44 insertions, 2 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index 2aabef408d..72c5a230e5 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -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());
diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h
index 72123cb520..356d131ae9 100644
--- a/support/tools/TableGen/Record.h
+++ b/support/tools/TableGen/Record.h
@@ -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; }
};
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 2aabef408d..72c5a230e5 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -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());
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index 72123cb520..356d131ae9 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -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; }
};