summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-10-04 18:55:36 +0000
committerDavid Greene <greened@obbligato.org>2011-10-04 18:55:36 +0000
commita8b8ab6b20da91ef4ace7311b8980e5654458a22 (patch)
treedc4013914841bfdc4be35ac5fe222d3307d86a51 /llvm/lib/TableGen
parentf2a7b0eade7bf3a0ab18c7bf550030a196f74ad3 (diff)
downloadbcm5719-llvm-a8b8ab6b20da91ef4ace7311b8980e5654458a22.tar.gz
bcm5719-llvm-a8b8ab6b20da91ef4ace7311b8980e5654458a22.zip
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<int a, int b> { ... } class C<list<int> A> : D<A[0], A[1]>; class B<list<int> b> : C<!foreach(...,b)>; Now it is. llvm-svn: 141101
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r--llvm/lib/TableGen/Record.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index b4277973b57..44945e3adb6 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/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<OpInit *>(Resolved);
+ if (OResolved) {
+ Resolved = OResolved->Fold(&R, 0);
+ }
- if (Folded != this) {
- TypedInit *Typed = dynamic_cast<TypedInit *>(Folded);
+ if (Resolved != this) {
+ TypedInit *Typed = dynamic_cast<TypedInit *>(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<ListInit*>(RV->getValue());
if (!LI) {
- VarInit *VI = dynamic_cast<VarInit*>(RV->getValue());
+ TypedInit *VI = dynamic_cast<TypedInit*>(RV->getValue());
assert(VI && "Invalid list element!");
return VarListElementInit::get(VI, Elt);
}
OpenPOWER on IntegriCloud