From: David Greene Date: Tue, 4 Oct 2011 18:55:36 +0000 (+0000) Subject: Allow Operator Arguments X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cedaae125e26d4d98072ed04017ddaebcfa468f8;p=oota-llvm.git Allow Operator Arguments When resolving an operator list element reference, resolve all operator operands and try to fold the operator first. This allows the operator to collapse to a list which may then be indexed. Before, it was not possible to do this: class D { ... } class C A> : D; class B b> : C; Now it is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141101 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index b4277973b57..44945e3adb6 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -700,12 +700,20 @@ Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, unsigned Elt) const { - Init *Folded = Fold(&R, 0); + Init *Resolved = resolveReferences(R, IRV); + OpInit *OResolved = dynamic_cast(Resolved); + if (OResolved) { + Resolved = OResolved->Fold(&R, 0); + } - if (Folded != this) { - TypedInit *Typed = dynamic_cast(Folded); + if (Resolved != this) { + TypedInit *Typed = dynamic_cast(Resolved); + assert(Typed && "Expected typed init for list reference"); if (Typed) { - return Typed->resolveListElementReference(R, IRV, Elt); + Init *New = Typed->resolveListElementReference(R, IRV, Elt); + if (New) + return New; + return VarListElementInit::get(Typed, Elt); } } @@ -1332,7 +1340,7 @@ Init *VarInit::resolveListElementReference(Record &R, assert(RV && "Reference to a non-existent variable?"); ListInit *LI = dynamic_cast(RV->getValue()); if (!LI) { - VarInit *VI = dynamic_cast(RV->getValue()); + TypedInit *VI = dynamic_cast(RV->getValue()); assert(VI && "Invalid list element!"); return VarListElementInit::get(VI, Elt); }