Index: llvm/trunk/include/llvm/TableGen/Record.h =================================================================== --- llvm/trunk/include/llvm/TableGen/Record.h +++ llvm/trunk/include/llvm/TableGen/Record.h @@ -356,14 +356,6 @@ return nullptr; } - /// This method complements getFieldType to return the - /// initializer for the specified field. If getFieldType returns non-null - /// this method should return non-null, otherwise it returns null. - virtual Init *getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const { - return nullptr; - } - /// This method is used by classes that refer to other /// variables which may not be defined at the time the expression is formed. /// If a value is set for the variable later, this method will be called on @@ -901,8 +893,6 @@ } RecTy *getFieldType(StringInit *FieldName) const override; - Init *getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const override; /// This method is used by classes that refer to other /// variables which may not be defined at the time they expression is formed. @@ -1012,8 +1002,6 @@ //virtual Init *convertInitializerBitRange(ArrayRef Bits); RecTy *getFieldType(StringInit *FieldName) const override; - Init *getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const override; std::string getAsString() const override; Index: llvm/trunk/lib/TableGen/Record.cpp =================================================================== --- llvm/trunk/lib/TableGen/Record.cpp +++ llvm/trunk/lib/TableGen/Record.cpp @@ -1255,21 +1255,6 @@ return nullptr; } -Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const { - if (isa(getType())) - if (const RecordVal *Val = R.getValue(VarName)) { - if (RV != Val && (RV || isa(Val->getValue()))) - return nullptr; - Init *TheInit = Val->getValue(); - assert(TheInit != this && "Infinite loop detected!"); - if (Init *I = TheInit->getFieldInit(R, RV, FieldName)) - return I; - return nullptr; - } - return nullptr; -} - Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) const { if (RecordVal *Val = R.getValue(VarName)) if (RV == Val || (!RV && !isa(Val->getValue()))) @@ -1361,11 +1346,6 @@ return nullptr; } -Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const { - return Def->getValue(FieldName)->getValue(); -} - std::string DefInit::getAsString() const { return Def->getName(); } @@ -1388,11 +1368,13 @@ } Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) const { - Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; + Init *NewRec = Rec->resolveReferences(R, RV); - if (Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName)) { - Init *BVR = BitsVal->resolveReferences(R, RV); - return BVR->isComplete() ? BVR : const_cast(this); + if (DefInit *DI = dyn_cast(NewRec)) { + Init *FieldVal = DI->getDef()->getValue(FieldName)->getValue(); + Init *BVR = FieldVal->resolveReferences(R, RV); + if (BVR->isComplete()) + return BVR; } if (NewRec != Rec)