1 // RUN: llvm-tblgen %s | FileCheck %s
7 // CHECK: dag a = (ops A0);
11 // CHECK: dag a = (ops);
16 // CHECK: dag q = (ops C0);
28 // CHECK: Fa as_a = F0;
29 // CHECK: Fb as_b = F0;
32 // CHECK: Fc as_c = F0;
35 // CHECK: def anonymous_0 {
36 // CHECK: G g = anonymous_0;
38 // CHECK: def anonymous_1 {
39 // CHECK: G g = anonymous_1;
41 // CHECK: def anonymous_2 {
42 // CHECK: G g = anonymous_2;
44 // CHECK: def anonymous_5 {
45 // CHECK: G g = anonymous_5;
54 // This type of self-reference is used in various places defining register
58 class B<string self> {
62 // A stronger form of this type of self-reference is used at least in the
63 // SystemZ backend to define a record which is a ComplexPattern and an Operand
65 def B0 : A<(ops)>, B<"B0">;
67 // Casting C0 to C by name here is tricky, because it happens while (or rather:
68 // before) adding C as a superclass. However, SystemZ uses this pattern.
69 class C<string self> {
70 dag q = (ops !cast<C>(self));
75 // Explore some unused corner cases.
77 // A self-reference within a class may seem icky, but it unavoidably falls out
78 // orthogonally of having forward class declarations and late resolve of self
80 class D<string self> {
90 // Putting the !cast directly in the def should work as well: we shouldn't
91 // depend on implementation details of when exactly the record is looked up.
93 // Note the difference between !cast<E>("E0") and plain E0: the latter wouldn't
94 // work here because E0 does not yet have E as a superclass while the template
95 // arguments are being parsed.
96 def E0 : E<!cast<E>("E0")>;
98 // Ensure that records end up with the correct type even when direct self-
99 // references are involved.
108 def F0 : Fa, Fb<F0>, Fc<F0>;
113 // anonymous record self-reference in foreach and multiclass
115 G g = !cast<G>(NAME);
118 foreach _ = [1, 2] in