diff options
| author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-25 20:50:11 +0000 |
|---|---|---|
| committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-25 20:50:11 +0000 |
| commit | 85e4e95e6cc6c27033999ca94d3c2e32606afdff (patch) | |
| tree | c34d2d15500d2d22f78eb4abaa4053383afe076b /llvm/lib/TableGen | |
| parent | 801403acb358d3388636d3b36f28839758507306 (diff) | |
| download | bcm5719-llvm-85e4e95e6cc6c27033999ca94d3c2e32606afdff.tar.gz bcm5719-llvm-85e4e95e6cc6c27033999ca94d3c2e32606afdff.zip | |
TableGen: Get rid of Init::getFieldInit
Summary:
FieldInit will just rely on the standardized resolving mechanism to give
us DefInits for folding, thus simplifying the code.
Unlike the removal of resolveListElementReference, this shouldn't have
performance implications, because DefInits do not recurse inside their
record.
Change-Id: Id4544c774c9d9ee92f293615af6ecff706453f21
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43563
llvm-svn: 326060
Diffstat (limited to 'llvm/lib/TableGen')
| -rw-r--r-- | llvm/lib/TableGen/Record.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 2650eca2cc0..46868414c10 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1255,21 +1255,6 @@ RecTy *VarInit::getFieldType(StringInit *FieldName) const { return nullptr; } -Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, - StringInit *FieldName) const { - if (isa<RecordRecTy>(getType())) - if (const RecordVal *Val = R.getValue(VarName)) { - if (RV != Val && (RV || isa<UnsetInit>(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<UnsetInit>(Val->getValue()))) @@ -1361,11 +1346,6 @@ RecTy *DefInit::getFieldType(StringInit *FieldName) const { 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::getBit(unsigned Bit) const { } 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<FieldInit *>(this); + if (DefInit *DI = dyn_cast<DefInit>(NewRec)) { + Init *FieldVal = DI->getDef()->getValue(FieldName)->getValue(); + Init *BVR = FieldVal->resolveReferences(R, RV); + if (BVR->isComplete()) + return BVR; } if (NewRec != Rec) |

