Files
llvm/test/TableGen/cond-subclass.td
T
Javed Absar c4ce20752b [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




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352185 91177308-0d34-0410-b5e6-96231b3b80d8
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: }