Fix the way field bit references are resolved, also allow resolution of field references overall!

llvm-svn: 7470
This commit is contained in:
Chris Lattner 2003-08-01 05:58:58 +00:00
parent 75c817a482
commit cf268a5060
2 changed files with 18 additions and 8 deletions

View File

@ -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,8 +373,7 @@ 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 (BitsVal)
if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
assert(Bit < BI->getNumBits() && "Bit reference out of range!");
Init *B = BI->getBit(Bit);
@ -385,6 +384,15 @@ Init *FieldInit::resolveBitReference(Record &R, unsigned Bit) {
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;
}
//===----------------------------------------------------------------------===//
// Other implementations

View File

@ -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;
}