diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/TableGen/MultiClass-defm-fail.td | 4 | ||||
-rw-r--r-- | llvm/test/TableGen/foreach-multiclass.td | 24 | ||||
-rw-r--r-- | llvm/test/TableGen/name-resolution-consistency.td | 84 | ||||
-rw-r--r-- | llvm/test/TableGen/self-reference.td | 23 |
4 files changed, 133 insertions, 2 deletions
diff --git a/llvm/test/TableGen/MultiClass-defm-fail.td b/llvm/test/TableGen/MultiClass-defm-fail.td index 2f399e5e2af..921e4857e49 100644 --- a/llvm/test/TableGen/MultiClass-defm-fail.td +++ b/llvm/test/TableGen/MultiClass-defm-fail.td @@ -24,9 +24,9 @@ multiclass M1<string s> { defm _m1: M0<s # "_r1">; } -// CHECK: defm d1: M1 +// CHECK: def _m01: B // CHECK: note: instantiated from multiclass // CHECK: defm _m1: M0 // CHECK: note: instantiated from multiclass -// CHECK: def _m01: B +// CHECK: defm d1: M1 defm d1: M1<"d1">; diff --git a/llvm/test/TableGen/foreach-multiclass.td b/llvm/test/TableGen/foreach-multiclass.td new file mode 100644 index 00000000000..38be10f2112 --- /dev/null +++ b/llvm/test/TableGen/foreach-multiclass.td @@ -0,0 +1,24 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +// CHECK: --- Defs --- + +// CHECK: def A00 { +// CHECK: int sum = 7; +// CHECK: } + +// CHECK: def A01 { +// CHECK: int sum = 8; +// CHECK: } + +multiclass A<int x> { + // Allow foreach in multiclass as long as the list does not depend on + // template args. + foreach i = [0, 1] in { + def NAME#i { + int sum = !add(x, i); + } + } +} + +defm A0 : A<7>; diff --git a/llvm/test/TableGen/name-resolution-consistency.td b/llvm/test/TableGen/name-resolution-consistency.td new file mode 100644 index 00000000000..25cd6cd68e2 --- /dev/null +++ b/llvm/test/TableGen/name-resolution-consistency.td @@ -0,0 +1,84 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +// This test demonstrates a number of inconsistencies in how NAME is resolved +// and record names are constructed. +// +// The TODO lines describe a suggested consistent behavior that would result +// from: +// (1) Treating NAME as an implicit multiclass template argument and +// (2) always storing the name of (non-anonymous) prototype records in +// multiclasses with at least one explicit reference to NAME. +// +// Unfortunately, several backends (including X86) rely quite heavily on the +// current inconsistent behavior and would have to be fixed. + +// CHECK: def B0a { +// CHECK: string e = "B0"; +// CHECK: } + +// CHECK: def B0ba { +// TODO: expect "B0b" here +// CHECK: string a = "B0"; +// CHECK: string b = "B0"; +// CHECK: } + +// CHECK: def B0cza { +// TODO: expect "B0cz" here +// CHECK: string a = "B0"; +// CHECK: string b = "B0"; +// CHECK: } + +// TODO: expect this to be named 'xB0b' +// CHECK: def B0xb { +// TODO: expect "B0b" here +// CHECK: string c = "b"; +// CHECK: string d = "b"; +// CHECK: } + +// TODO: expect this to be named B0bys +// CHECK: def B0ys { +// TODO: expect "B0b" here +// CHECK: string f = "b"; +// CHECK: string g = "b"; +// CHECK: } + +// CHECK: def xB0cz { +// CHECK: string c = "B0cz"; +// CHECK: string d = "B0cz"; +// CHECK: } + +// TODO: expect this to be named B0czyt +// CHECK: def yt { +// CHECK: string f = "B0cz"; +// CHECK: string g = "B0cz"; +// CHECK: } + +multiclass A<string p, string q> { + def a { + string a = NAME; + string b = p; + } + + def x # NAME { + string c = NAME; + string d = p; + } + + def y # q { + string f = NAME; + string g = p; + } +} + +multiclass B<string name, string t> { + def a { + string e = NAME; + } + + defm b : A<NAME, "s">; + + defm NAME # c # name : A<NAME, t>; +} + +defm B0 : B<"z", "t">; diff --git a/llvm/test/TableGen/self-reference.td b/llvm/test/TableGen/self-reference.td index 89d72343047..5789d3ba570 100644 --- a/llvm/test/TableGen/self-reference.td +++ b/llvm/test/TableGen/self-reference.td @@ -24,6 +24,14 @@ // CHECK: E e = E0; // CHECK: } +// CHECK: def F0 { +// CHECK: Fa as_a = F0; +// CHECK: Fb as_b = F0; +// CHECK: } +// CHECK: def F0x { +// CHECK: Fc as_c = F0; +// CHECK: } + def ops; class A<dag d> { @@ -73,3 +81,18 @@ class E<E x> { // work here because E0 does not yet have E as a superclass while the template // arguments are being parsed. def E0 : E<!cast<E>("E0")>; + +// Ensure that records end up with the correct type even when direct self- +// references are involved. +class Fa; +class Fb<Fa x> { + Fa as_a = x; +} +class Fc<Fb x> { + Fb as_b = x; +} + +def F0 : Fa, Fb<F0>, Fc<F0>; +def F0x { + Fc as_c = F0; +} |