[llvm] [Tablegen] Add keyword `dump`. (PR #68793)

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 13 04:35:17 PDT 2023


================
@@ -0,0 +1,86 @@
+// RUN: llvm-tblgen %s -o -  2>&1 >/dev/null | FileCheck %s -DFILE=%s
+
+// CHECK: [[FILE]]:[[@LINE+1]]:1: note: Debug message
+dump "Debug message";
+
+def op;
+class A {
+  string A = "some text";
+  dag X =(op op);
+}
+def a : A;
+// CHECK: [[FILE]]:[[@LINE+5]]:1: note: The Value of A is:
+// CHECK-NEXT: a {     // A
+// CHECK-NEXT: string A = "some text";
+// CHECK-NEXT: dag X = (op op);
+// CHECK-NEXT: }
+dump "The Value of A is: \n" # !repr(a);
+
+def b : A;
+// CHECK: [[FILE]]:[[@LINE+4]]:1: note: b {     // A
+// CHECK-NEXT: string A = "some text";
+// CHECK-NEXT: dag X = (op op);
+// CHECK-NEXT: }
+dump !repr(b) ;
+
+defvar value_A = "some other text";
+defvar value_B = 12;
+def X;
+// CHECK: [[FILE]]:[[@LINE+3]]:1: note: got a pair of values ["some other text" : 12], and an empty record:
+// CHECK-NEXT: X {
+// CHECK-NEXT: }
+dump "got a pair of values [" # !repr(value_A) # " : " # !repr(value_B) # "], " # "and an empty record:\n" # !repr(X);
+
+multiclass MC<dag s> {
+// CHECK: [[FILE]]:[[@LINE+1]]:3: note: s = (op a)
+  dump "s = " # !repr(s);
+// CHECK: [[FILE]]:[[@LINE+4]]:3: note: args[0] = a {        // A
+// CHECK-NEXT:   string A = "some text";
+// CHECK-NEXT: dag X = (op op);
+// CHECK-NEXT: }
+  dump "args[0] = " # !repr(!getdagarg<A>(s,0));
+  def A;
+}
+defm X : MC<(op a)>;
+
----------------
fpetrogalli wrote:

Done (more on order of dump  and defs in a separate comment).

https://github.com/llvm/llvm-project/pull/68793


More information about the llvm-commits mailing list