brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · a49b2de Raw
134 lines · plain
1// RUN: llvm-tblgen %s | FileCheck %s2// RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s3// RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s4// RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s5// XFAIL: vg_leak6 7class A;8def a0 : A;9def a1 : A;10 11class B : A;12def b0 : B;13def b1 : B;14 15// CHECK-LABEL: def test0_instances_A {16// CHECK-NEXT:    list<A> instances = [a0, a1, b0, b1];17// CHECK-NEXT:  }18def test0_instances_A {19  list<A> instances = !instances<A>();20}21 22// CHECK-LABEL: def test1_instances_A_x0 {23// CHECK-NEXT:    list<A> instances = [a0, b0];24// CHECK-NEXT:  }25def test1_instances_A_x0 {26  list<A> instances = !instances<A>(".*0");27}28 29// CHECK-LABEL: def test2_instances_A_x1 {30// CHECK-NEXT:    list<A> instances = [a1, b1];31// CHECK-NEXT:  }32def test2_instances_A_x1 {33  list<A> instances = !instances<A>(".*1");34}35 36// CHECK-LABEL: def test3_instances_B {37// CHECK-NEXT:    list<B> instances = [b0, b1];38// CHECK-NEXT:  }39def test3_instances_B {40  list<B> instances = !instances<B>();41}42 43//-----------------------------------------------------------------------------//44 45def a2 : A;46def b2 : B;47 48class ClassTest {49   list<A> instances_A = !instances<A>();50   list<B> instances_B = !instances<B>();51}52 53def a3 : A;54def b3 : B;55 56def test4_in_class_def : ClassTest;57// CHECK-LABEL: def test4_in_class_def {58// CHECK-NEXT:    list<A> instances_A = [a0, a1, a2, a3, b0, b1, b2, b3];59// CHECK-NEXT:    list<B> instances_B = [b0, b1, b2, b3];60// CHECK-NEXT:  }61 62//-----------------------------------------------------------------------------//63// Self-recurrence is not supported, so it won't be count in.64 65// CHECK-LABEL: def test5_self_recurrence {66// CHECK-NEXT:    list<A> instances_A = [a0, a1, a2, a3, b0, b1, b2, b3];67// CHECK-NEXT:  }68def test5_self_recurrence : A {69   list<A> instances_A = !instances<A>();70}71 72//-----------------------------------------------------------------------------//73// Test these in multiclasses/loops.74 75class C {76  list<C> instances_C = !instances<C>();77}78 79multiclass MultiClassTest {80  foreach i = 0-2 in {81    def "c"#i : C;82  }83}84 85// CHECK-LABEL: def test6_in_multiclass_def_c0 {86// CHECK-NEXT:    list<C> instances_C = [];87// CHECK-NEXT:  }88// CHECK-LABEL: def test6_in_multiclass_def_c1 {89// CHECK-NEXT:    list<C> instances_C = [test6_in_multiclass_def_c0];90// CHECK-NEXT:  }91// CHECK-LABEL: def test6_in_multiclass_def_c2 {92// CHECK-NEXT:    list<C> instances_C = [test6_in_multiclass_def_c0, test6_in_multiclass_def_c1];93// CHECK-NEXT:  }94defm test6_in_multiclass_def_ : MultiClassTest;95 96//-----------------------------------------------------------------------------//97// Default argument/temporary actual parameter will be considered as well.98class D<int n>;99 100class TestArgument<D d = D<0>> {101  list<D> instances_D = !instances<D>();102}103 104// CHECK-LABEL: def test7_default_arg {105// CHECK-NEXT:    list<D> instances_D = [anonymous_0];106// CHECK-NEXT:  }107def test7_default_arg : TestArgument;108 109// CHECK-LABEL: def test8_anonymous0_arg {110// CHECK-NEXT:    list<D> instances_D = [anonymous_0, anonymous_1];111// CHECK-NEXT:  }112// CHECK-LABEL: def test8_anonymous1_arg {113// CHECK-NEXT:    list<D> instances_D = [anonymous_0, anonymous_1, anonymous_2];114// CHECK-NEXT:  }115def test8_anonymous0_arg : TestArgument<D<1>>;116def test8_anonymous1_arg : TestArgument<D<2>>;117 118//-----------------------------------------------------------------------------//119 120#ifdef ERROR1121defvar error1 = !instances<A>(123);122// ERROR1: error: expected string type argument in !instances operator123#endif124 125#ifdef ERROR2126defvar error2 = !instances<1>("");127// ERROR2: error: Unknown token when expecting a type128#endif129 130#ifdef ERROR3131defvar error3 = !instances<A>("([)]");132// ERROR3: error: invalid regex '([)]'133#endif134