aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-01 05:58:58 +0000
committerChris Lattner <sabre@nondot.org>2003-08-01 05:58:58 +0000
commit24151a6888c752ff1d7fc80b500f5a836c9ac528 (patch)
treef4900d9f18d605e9d8f7c36eb66e9ed5c2aaf9f8 /utils/TableGen
parentde04dd746fce692a56a5fe6ce8532b2dc13756b6 (diff)
downloadexternal_llvm-24151a6888c752ff1d7fc80b500f5a836c9ac528.zip
external_llvm-24151a6888c752ff1d7fc80b500f5a836c9ac528.tar.gz
external_llvm-24151a6888c752ff1d7fc80b500f5a836c9ac528.tar.bz2
Fix the way field bit references are resolved, also allow resolution of field references overall!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r--utils/TableGen/Record.cpp26
-rw-r--r--utils/TableGen/Record.h2
2 files changed, 19 insertions, 9 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index acb61ec..fc035ac 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 130bf5a..5dbd9b9 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;
}