106 lines · plain
1// RUN: llvm-tblgen %s -o - 2>&1 >/dev/null | FileCheck %s -DFILE=%s2 3// CHECK: [[FILE]]:[[@LINE+1]]:1: note: Debug message4dump "Debug message";5 6def op;7class A {8 string A = "some text";9 dag X =(op op);10}11def a : A;12// CHECK: [[FILE]]:[[@LINE+5]]:1: note: The Value of A is:13// CHECK-NEXT: a { // A14// CHECK-NEXT: string A = "some text";15// CHECK-NEXT: dag X = (op op);16// CHECK-NEXT: }17dump "The Value of A is: \n" # !repr(a);18 19def b : A;20// CHECK: [[FILE]]:[[@LINE+4]]:1: note: b { // A21// CHECK-NEXT: string A = "some text";22// CHECK-NEXT: dag X = (op op);23// CHECK-NEXT: }24dump b;25 26defvar value_A = "some other text";27// CHECK: [[FILE]]:[[@LINE+1]]:1: note: some other text28dump value_A;29 30defvar value_B = 12;31def X;32// CHECK: [[FILE]]:[[@LINE+3]]:1: note: got a pair of values ["some other text" : 12], and an empty record:33// CHECK-NEXT: X {34// CHECK-NEXT: }35dump "got a pair of values [" # !repr(value_A) # " : " # !repr(value_B) # "], " # "and an empty record:\n" # !repr(X);36 37multiclass MC<dag s> {38// CHECK: [[FILE]]:[[@LINE+1]]:3: note: s = (op a)39 dump "s = " # !repr(s);40// CHECK: [[FILE]]:[[@LINE+4]]:3: note: args[0] = a { // A41// CHECK-NEXT: string A = "some text";42// CHECK-NEXT: dag X = (op op);43// CHECK-NEXT: }44 dump "args[0] = " # !repr(!getdagarg<A>(s,0));45 def A;46}47defm X : MC<(op a)>;48 49multiclass MMC<dag s> {50// CHECK: [[FILE]]:[[@LINE+1]]:3: note: the operand of s is op51 dump "the operand of s is " # !getdagop(s);52// CHECK: [[FILE]]:[[@LINE-13]]:3: note: s = (op a, a)53// CHECK: [[FILE]]:[[@LINE-9]]:3: note: args[0] = a { // A54// CHECK-NEXT: string A = "some text";55// CHECK-NEXT: dag X = (op op);56// CHECK-NEXT: }57 defm : MC<s>;58}59 60defm XX : MMC<(op a, a)>;61 62 63foreach i = [-1, 2] in {64// CHECK: [[FILE]]:[[@LINE+4]]:3: note: i = -1 (negative)65// CHECK: [[FILE]]:[[@LINE+8]]:5: note: i + 1 <= 066// CHECK: [[FILE]]:[[@LINE+2]]:3: note: i = 2 (positive)67// CHECK: [[FILE]]:[[@LINE+4]]:5: note: i + 1 > 0 (i + 1 = 3)68 dump "i = " # !repr(i) # !if(!ge(i,0), " (positive)", " (negative)");69 defvar ip1 = !add(i, 1);70 if !gt(ip1,0) then {71 dump "i + 1 > 0 (i + 1 = " # !repr(ip1) # ")";72 } else {73 dump "i + 1 <= 0" ;74 }75}76 77class Code<code val> {78 dump "val = " # !repr(val);79 code Val = val;80 int number = 0;81}82// CHECK: [[FILE]]:[[@LINE-4]]:3: note: val = [{a = a +1;}]83def IncrementA : Code<[{a = a +1;}]>;84class InheritFromCode : Code<[{f(x);}]>{85 let number = 33;86 dump "number = " # !repr(number);87}88// CHECK: [[FILE]]:[[@LINE-10]]:3: note: val = [{f(x);}]89// CHECK: [[FILE]]:[[@LINE-3]]:3: note: number = 3390def ModeCode : InheritFromCode;91 92 93class BaseClassForSet;94multiclass DefineSubSet {95 def _One : BaseClassForSet;96 def _Two : BaseClassForSet;97}98defset list<BaseClassForSet> TheSet = {99defm Subset: DefineSubSet;100def Three : BaseClassForSet;101}102// CHECK: [[FILE]]:[[@LINE+1]]:1: note: TheSet = [Subset_One, Subset_Two, Three]103dump "TheSet = " # !repr(TheSet);104 105// CHECK: [[FILE]]:[[@LINE+1]]:1: note: 0106dump !repr(!exists<BaseClassForSet>("non-existent-record"));