llvm.org GIT mirror llvm / 0715b9e
TableGen: Explicitly test some cases of self-references and !cast errors Summary: These are cases of self-references that exist today in practice. Let's add tests for them to avoid regressions. The self-references in PPCInstrInfo.td can be expressed in a simpler way. Allowing this type of self-reference while at the same time consistently doing late-resolve even for self-references is problematic because there are references to fields that aren't in any class. Since there's no need for this type of self-reference anyway, let's just remove it. Change-Id: I914e0b3e1ae7adae33855fac409b536879bc3f62 Reviewers: arsenm, craig.topper, tra, MartinO Subscribers: nemanjai, wdng, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D44474 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327848 91177308-0d34-0410-b5e6-96231b3b80d8 Nicolai Haehnle 1 year, 7 months ago
5 changed file(s) with 78 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
18861886 PrintFatalError(getLoc(), Twine("Invalid value ") + Type +
18871887 "is found when setting '" +
18881888 Value.getNameInitAsString() +
1889 " of type '" +
1889 "' of type '" +
18901890 Value.getType()->getAsString() +
18911891 "' after resolving references: " +
18921892 VR->getAsUnquotedString() + "\n");
46944694 def DWSwapInByte {
46954695 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
46964696 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4697 dag Swap2 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap1, 62, 2), DWMaskValues.Lo2),
4698 (AND8 (RLDICR DWSwapInByte.Swap1, 2, 61), DWMaskValues.Hi2));
4699 dag Swap4 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap2, 60, 4), DWMaskValues.Lo4),
4700 (AND8 (RLDICR DWSwapInByte.Swap2, 4, 59), DWMaskValues.Hi4));
4697 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4698 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4699 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4700 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
47014701 }
47024702
47034703 // Intra-byte swap is done, now start inter-byte swap.
47174717 def DWBytes7654 {
47184718 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
47194719 dag DWord =
4720 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes7654.Word, sub_32));
4720 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
47214721 }
47224722
47234723 def DWBytes0123 {
47364736 def DWBytes3210 {
47374737 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
47384738 dag DWord =
4739 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes3210.Word, sub_32));
4739 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
47404740 }
47414741
47424742 // Now both high word and low word are reversed, next
0 // RUN: not llvm-tblgen %s 2>&1 | FileCheck %s
1 // XFAIL: vg_leak
2
3 class A;
4 class B;
5
6 def A0 : A;
7
8 class C {
9 B b = !cast(name);
10 }
11
12 // CHECK: error: Invalid value of type 'A' is found when setting 'b' of type 'B'
13 def Test : C<"A0">;
0 // RUN: not llvm-tblgen %s 2>&1 | FileCheck %s
1 // XFAIL: vg_leak
2
3 class A {
4 A a = x;
5 }
6
7 // At the time A0 is referenced, A has not yet been established as a superclass.
8 // This kind of self-reference is discourage, but if you *really* want it, you
9 // can force it with !cast.
10 //
11 // CHECK: Value 'A:x' of type 'A' is incompatible with initializer
12 def A0 : A;
0 // RUN: llvm-tblgen %s | FileCheck %s
1 // XFAIL: vg_leak
2
3 // CHECK: --- Defs ---
4
5 // CHECK: def A0 {
6 // CHECK: dag a = (ops A0);
7 // CHECK: }
8
9 // CHECK: def B0 {
10 // CHECK: dag a = (ops);
11 // CHECK: A b = B0;
12 // CHECK: }
13
14 // CHECK: def C0 {
15 // CHECK: dag q = (ops C0);
16 // CHECK: }
17
18 def ops;
19
20 class A {
21 dag a = d;
22 }
23
24 // This type of self-reference is used in various places defining register
25 // classes.
26 def A0 : A<(ops A0)>;
27
28 class B {
29 A b = !cast(self);
30 }
31
32 // A stronger form of this type of self-reference is used at least in the
33 // SystemZ backend to define a record which is a ComplexPattern and an Operand
34 // at the same time.
35 def B0 : A<(ops)>, B<"B0">;
36
37 // Casting C0 to C by name here is tricky, because it happens while (or rather:
38 // before) adding C as a superclass. However, SystemZ uses this pattern.
39 class C {
40 dag q = (ops !cast(self));
41 }
42
43 def C0 : C<"C0">;