[llvm-commits] [llvm] r141101 - /llvm/trunk/lib/TableGen/Record.cpp
David Greene
greened at obbligato.org
Tue Oct 4 11:55:37 PDT 2011
Author: greened
Date: Tue Oct 4 13:55:36 2011
New Revision: 141101
URL: http://llvm.org/viewvc/llvm-project?rev=141101&view=rev
Log:
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.
Modified:
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=141101&r1=141100&r2=141101&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Tue Oct 4 13:55:36 2011
@@ -700,12 +700,20 @@
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 @@
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);
}
More information about the llvm-commits
mailing list