aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--support/tools/TableGen/Record.cpp26
-rw-r--r--support/tools/TableGen/Record.h2
-rw-r--r--utils/TableGen/Record.cpp26
-rw-r--r--utils/TableGen/Record.h2
4 files changed, 38 insertions, 18 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index acb61ec185..fc035aceb3 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -316,7 +316,7 @@ Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
if (Init *I = RV->getValue()->getFieldInit(R, FieldName))
return I;
else
- return (Init*)this;
+ return 0;
return 0;
}
@@ -373,14 +373,22 @@ Init *FieldInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
Init *FieldInit::resolveBitReference(Record &R, unsigned Bit) {
Init *BitsVal = Rec->getFieldInit(R, FieldName);
- assert(BitsVal && "No initializer found!");
-
- if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
- assert(Bit < BI->getNumBits() && "Bit reference out of range!");
- Init *B = BI->getBit(Bit);
-
- if (dynamic_cast<BitInit*>(B)) // If the bit is set...
- return B; // Replace the VarBitInit with it.
+ if (BitsVal)
+ if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
+ assert(Bit < BI->getNumBits() && "Bit reference out of range!");
+ Init *B = BI->getBit(Bit);
+
+ if (dynamic_cast<BitInit*>(B)) // If the bit is set...
+ return B; // Replace the VarBitInit with it.
+ }
+ return this;
+}
+
+Init *FieldInit::resolveReferences(Record &R) {
+ Init *BitsVal = Rec->getFieldInit(R, FieldName);
+ if (BitsVal) {
+ Init *BVR = BitsVal->resolveReferences(R);
+ return BVR->isComplete() ? BVR : this;
}
return this;
}
diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h
index 130bf5aa36..5dbd9b9c56 100644
--- a/support/tools/TableGen/Record.h
+++ b/support/tools/TableGen/Record.h
@@ -480,6 +480,8 @@ public:
virtual Init *resolveBitReference(Record &R, unsigned Bit);
+ virtual Init *resolveReferences(Record &R);
+
virtual void print(std::ostream &OS) const {
Rec->print(OS); OS << "." << FieldName;
}
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index acb61ec185..fc035aceb3 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -316,7 +316,7 @@ Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
if (Init *I = RV->getValue()->getFieldInit(R, FieldName))
return I;
else
- return (Init*)this;
+ return 0;
return 0;
}
@@ -373,14 +373,22 @@ Init *FieldInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
Init *FieldInit::resolveBitReference(Record &R, unsigned Bit) {
Init *BitsVal = Rec->getFieldInit(R, FieldName);
- assert(BitsVal && "No initializer found!");
-
- if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
- assert(Bit < BI->getNumBits() && "Bit reference out of range!");
- Init *B = BI->getBit(Bit);
-
- if (dynamic_cast<BitInit*>(B)) // If the bit is set...
- return B; // Replace the VarBitInit with it.
+ if (BitsVal)
+ if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
+ assert(Bit < BI->getNumBits() && "Bit reference out of range!");
+ Init *B = BI->getBit(Bit);
+
+ if (dynamic_cast<BitInit*>(B)) // If the bit is set...
+ return B; // Replace the VarBitInit with it.
+ }
+ return this;
+}
+
+Init *FieldInit::resolveReferences(Record &R) {
+ Init *BitsVal = Rec->getFieldInit(R, FieldName);
+ if (BitsVal) {
+ Init *BVR = BitsVal->resolveReferences(R);
+ return BVR->isComplete() ? BVR : this;
}
return this;
}
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index 130bf5aa36..5dbd9b9c56 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -480,6 +480,8 @@ public:
virtual Init *resolveBitReference(Record &R, unsigned Bit);
+ virtual Init *resolveReferences(Record &R);
+
virtual void print(std::ostream &OS) const {
Rec->print(OS); OS << "." << FieldName;
}