// RUN: llvm-tblgen %s | FileCheck %s // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s // XFAIL: vg_leak class A; def a0 : A; def a1 : A; class B : A; def b0 : B; def b1 : B; // CHECK-LABEL: def test0_instances_A { // CHECK-NEXT: list instances = [a0, a1, b0, b1]; // CHECK-NEXT: } def test0_instances_A { list instances = !instances(); } // CHECK-LABEL: def test1_instances_A_x0 { // CHECK-NEXT: list instances = [a0, b0]; // CHECK-NEXT: } def test1_instances_A_x0 { list instances = !instances(".*0"); } // CHECK-LABEL: def test2_instances_A_x1 { // CHECK-NEXT: list instances = [a1, b1]; // CHECK-NEXT: } def test2_instances_A_x1 { list instances = !instances(".*1"); } // CHECK-LABEL: def test3_instances_B { // CHECK-NEXT: list instances = [b0, b1]; // CHECK-NEXT: } def test3_instances_B { list instances = !instances(); } //-----------------------------------------------------------------------------// def a2 : A; def b2 : B; class ClassTest { list instances_A = !instances(); list instances_B = !instances(); } def a3 : A; def b3 : B; def test4_in_class_def : ClassTest; // CHECK-LABEL: def test4_in_class_def { // CHECK-NEXT: list instances_A = [a0, a1, a2, a3, b0, b1, b2, b3]; // CHECK-NEXT: list instances_B = [b0, b1, b2, b3]; // CHECK-NEXT: } //-----------------------------------------------------------------------------// // Self-recurrence is not supported, so it won't be count in. // CHECK-LABEL: def test5_self_recurrence { // CHECK-NEXT: list instances_A = [a0, a1, a2, a3, b0, b1, b2, b3]; // CHECK-NEXT: } def test5_self_recurrence : A { list instances_A = !instances(); } //-----------------------------------------------------------------------------// // Test these in multiclasses/loops. class C { list instances_C = !instances(); } multiclass MultiClassTest { foreach i = 0-2 in { def "c"#i : C; } } // CHECK-LABEL: def test6_in_multiclass_def_c0 { // CHECK-NEXT: list instances_C = []; // CHECK-NEXT: } // CHECK-LABEL: def test6_in_multiclass_def_c1 { // CHECK-NEXT: list instances_C = [test6_in_multiclass_def_c0]; // CHECK-NEXT: } // CHECK-LABEL: def test6_in_multiclass_def_c2 { // CHECK-NEXT: list instances_C = [test6_in_multiclass_def_c0, test6_in_multiclass_def_c1]; // CHECK-NEXT: } defm test6_in_multiclass_def_ : MultiClassTest; //-----------------------------------------------------------------------------// // Default argument/temporary actual parameter will be considered as well. class D; class TestArgument> { list instances_D = !instances(); } // CHECK-LABEL: def test7_default_arg { // CHECK-NEXT: list instances_D = [anonymous_0]; // CHECK-NEXT: } def test7_default_arg : TestArgument; // CHECK-LABEL: def test8_anonymous0_arg { // CHECK-NEXT: list instances_D = [anonymous_0, anonymous_1]; // CHECK-NEXT: } // CHECK-LABEL: def test8_anonymous1_arg { // CHECK-NEXT: list instances_D = [anonymous_0, anonymous_1, anonymous_2]; // CHECK-NEXT: } def test8_anonymous0_arg : TestArgument>; def test8_anonymous1_arg : TestArgument>; //-----------------------------------------------------------------------------// #ifdef ERROR1 defvar error1 = !instances(123); // ERROR1: error: expected string type argument in !instances operator #endif #ifdef ERROR2 defvar error2 = !instances<1>(""); // ERROR2: error: Unknown token when expecting a type #endif #ifdef ERROR3 defvar error3 = !instances("([)]"); // ERROR3: error: invalid regex '([)]' #endif