Home | History | Annotate | Download | only in TableGen
      1 // RUN: llvm-tblgen %s | FileCheck %s
      2 // XFAIL: vg_leak
      3 
      4 // CHECK: --- Defs ---
      5 
      6 // CHECK: def Sum {
      7 // CHECK:   int x = 712;
      8 // CHECK: }
      9 
     10 // CHECK: def yyy_A0
     11 // CHECK: def yyy_A1
     12 // CHECK: def yyy_A2
     13 // CHECK: def yyy_B0A0
     14 // CHECK: def yyy_B0A1
     15 // CHECK: def yyy_C0B0A0
     16 // CHECK: def yyy_C0B0A1
     17 // CHECK: def yyy_C0B1A0
     18 // CHECK: def yyy_C0B1A1
     19 // CHECK-NOT: def zzz_A0
     20 // CHECK: def zzz_B0A0
     21 // CHECK: def zzz_B0A1
     22 // CHECK: def zzz_C0B0A0
     23 // CHECK: def zzz_C0B0A1
     24 // CHECK: def zzz_C0B1A0
     25 // CHECK: def zzz_C0B1A1
     26 
     27 class A<int a> {
     28   int Num = a;
     29 }
     30 
     31 multiclass B<int b> {
     32   def A0 : A<!add(10, b)>;
     33   def A1 : A<!add(20, b)>;
     34 }
     35 
     36 multiclass C<int c> {
     37   defm B0 : B<!add(100, c)>;
     38   defm B1 : B<!add(200, c)>;
     39 }
     40 
     41 defset list<A> As = {
     42   def A0 : A<1>;
     43   foreach i = 1-2 in {
     44     def A#i : A<!add(i, 1)>;
     45   }
     46   defset list<A> SubAs = {
     47     defm B0 : B<2>;
     48     defm C0 : C<3>;
     49   }
     50 }
     51 
     52 def Sum {
     53   int x = !foldl(0, As, a, b, !add(a, b.Num));
     54 }
     55 
     56 foreach a = As in {
     57   def yyy_ # !cast<string>(a);
     58 }
     59 
     60 foreach a = SubAs in {
     61   def zzz_ # !cast<string>(a);
     62 }
     63