Home | History | Annotate | Download | only in TableGen
      1 // RUN: llvm-tblgen %s | FileCheck %s
      2 // XFAIL: vg_leak
      3 
      4 // CHECK: WorldHelloCC
      5 // CHECK-NOT: WorldHelloCC
      6 
      7 class C<string n> {
      8   string name = n;
      9 }
     10 
     11 multiclass Names<string n, string m> {
     12    def CC : C<n>;
     13    def World#NAME#CC : C<m>;
     14 }
     15 
     16 defm Hello : Names<"hello", "world">;
     17 
     18 // Ensure that the same anonymous name is used as the prefix for all defs in an
     19 // anonymous multiclass.
     20 
     21 class Outer<C i> {
     22   C Inner = i;
     23 }
     24 
     25 multiclass MC<string name> {
     26   def hi : C<name>;
     27   def there : Outer<!cast<C>(!strconcat(NAME, "hi"))>;
     28 }
     29 
     30 defm : MC<"foo">;
     31 
     32 multiclass MC2<string name> {
     33   def there : Outer<C<name> >;
     34 }
     35 
     36 // Ensure that we've correctly captured the reference to name from the implicit
     37 // anonymous C def in the template parameter list of Outer.
     38 // CHECK-NOT: MC2::name
     39 
     40 defm : MC2<"bar">;
     41 
     42 multiclass MC3<string s> {
     43   def ZFizz#s : C<s>;
     44 }
     45 
     46 defm : MC3<"Buzz">;
     47 
     48 // CHECK: def ZFizzBuzz
     49 // CHECK: string name = "Buzz";
     50 // CHECK-NOT: MC3::s
     51 
     52 multiclass MC4<string s> {
     53   def NAME#s : C<s>;
     54 }
     55 
     56 defm ZTagazok : MC4<"AToi">;
     57 
     58 // CHECK: def ZTagazokAToi
     59 // CHECK: string name = "AToi";
     60 // CHECK-NOT: MC4::s
     61 
     62 multiclass MC5<C c> {
     63   def NAME#c.name : C<c.name>;
     64 }
     65 
     66 def CTiger : C<"Tiger">;
     67 defm Zebra : MC5<CTiger>;
     68 
     69 // CHECK: def ZebraTiger
     70 // CHECK: string name = "Tiger";
     71 // CHECK-NOT: MC5::c
     72 
     73 multiclass MC6<C c> {
     74   def NAME#Tiger#c.name : C<c.name>;
     75 }
     76 
     77 def CAligator : C<"Aligator">;
     78 defm Zebra : MC6<CAligator>;
     79 
     80 // CHECK: def ZebraTigerAligator
     81 // CHECK: string name = "Aligator";
     82 // CHECK-NOT: MC6::c
     83 
     84