1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/test/TableGen/cond-subclass.td
Javed Absar 173ca6da08 [TblGen] Extend !if semantics through new feature !cond
This patch extends TableGen language with !cond operator.
Instead of embedding !if inside !if which can get cumbersome,
one can now use !cond.
Below is an example to convert an integer 'x' into a string:

    !cond(!lt(x,0) : "Negative",
          !eq(x,0) : "Zero",
          !eq(x,1) : "One,
          1        : "MoreThanOne")

Reviewed By: hfinkel, simon_tatham, greened
Differential Revision: https://reviews.llvm.org/D55758

llvm-svn: 352185
2019-01-25 10:25:25 +00:00

28 lines
515 B
TableGen

// Check that !cond with operands of different subtypes can
// initialize a supertype variable.
// RUN: llvm-tblgen %s | FileCheck %s
// XFAIL: vg_leak
class E<int dummy> {}
class E1<int dummy> : E<dummy> {}
class E2<int dummy> : E<dummy> {}
class EX<int cc, E1 b, E2 c> {
E x = !cond(cc: b, 1 : c);
}
def E1d : E1<0>;
def E2d : E2<0>;
def EXd1 : EX<1, E1d, E2d>;
def EXd2 : EX<0, E1d, E2d>;
// CHECK: def EXd1 {
// CHECK: E x = E1d;
// CHECK: }
//
// CHECK: def EXd2 {
// CHECK: E x = E2d;
// CHECK: }