1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 04:52:54 +02:00
llvm-mirror/test/TableGen/self-reference.td
Nicolai Haehnle 74a4d54f41 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

llvm-svn: 327848
2018-03-19 14:14:10 +00:00

45 lines
921 B
TableGen

// RUN: llvm-tblgen %s | FileCheck %s
// XFAIL: vg_leak
// CHECK: --- Defs ---
// CHECK: def A0 {
// CHECK: dag a = (ops A0);
// CHECK: }
// CHECK: def B0 {
// CHECK: dag a = (ops);
// CHECK: A b = B0;
// CHECK: }
// CHECK: def C0 {
// CHECK: dag q = (ops C0);
// CHECK: }
def ops;
class A<dag d> {
dag a = d;
}
// This type of self-reference is used in various places defining register
// classes.
def A0 : A<(ops A0)>;
class B<string self> {
A b = !cast<A>(self);
}
// A stronger form of this type of self-reference is used at least in the
// SystemZ backend to define a record which is a ComplexPattern and an Operand
// at the same time.
def B0 : A<(ops)>, B<"B0">;
// Casting C0 to C by name here is tricky, because it happens while (or rather:
// before) adding C as a superclass. However, SystemZ uses this pattern.
class C<string self> {
dag q = (ops !cast<C>(self));
}
def C0 : C<"C0">;