mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
173ca6da08
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
30 lines
844 B
TableGen
30 lines
844 B
TableGen
// RUN: llvm-tblgen %s | FileCheck %s
|
|
// XFAIL: vg_leak
|
|
|
|
// Check that !cond picks the first true value
|
|
// CHECK: class A
|
|
// CHECK-NEXT: string S = !cond(!eq(A:x, 10): "ten", !eq(A:x, 11): "eleven", !eq(A:x, 10): "TEN", !gt(A:x, 9): "MoreThanNine", 1: "unknown");
|
|
// CHECK: B1
|
|
// CHECK-NEXT: string S = "unknown"
|
|
// CHECK: B10
|
|
// CHECK-NEXT: string S = "ten";
|
|
// CHECK: def B11
|
|
// CHECK-NEXT: string S = "eleven";
|
|
// CHECK: def B12
|
|
// CHECK-NEXT: string S = "MoreThanNine";
|
|
// CHECK: def B9
|
|
// CHECK-NEXT: string S = "unknown"
|
|
|
|
class A<int x> {
|
|
string S = !cond(!eq(x,10) : "ten",
|
|
!eq(x,11) : "eleven",
|
|
!eq(x,10) : "TEN",
|
|
!gt(x,9) : "MoreThanNine",
|
|
!eq(1,1) : "unknown");
|
|
}
|
|
def B1 : A<1>;
|
|
def B9 : A<9>;
|
|
def B10 : A<10>;
|
|
def B11 : A<11>;
|
|
def B12 : A<12>;
|