[PATCH] D157492: [TableGen] Add `!dump` and `dump`.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 11:07:11 PDT 2023


tra added a comment.

I think we're commingling two different things here.

- representing a value as a string
- printing something out for debugging purposes.

While for debugging we may usually want to do both, it would be very useful to be able to use them independently. That would allow doing things like `dump("got a pair of values [" # !repr(value_A) # " : " # !repr(value_B # "]"))`.

We could add some glue to `dump/!dump()` so that they wrap non-string arguments into `!repr()` automatically.



================
Comment at: llvm/docs/TableGen/ProgRef.rst:1252-1253
+
+Example: the following statements will print ``The value of X is 0``
+to standard output.
+
----------------
I'm still not fun of `dump` or `!dump` printing anything other than what the user passed to it. The `The value of X is` part should not be hardcoded and should be up to the user what they may want to print in addition to the value itself. If they need something extra, they are free to add more dump statements.



================
Comment at: llvm/docs/TableGen/ProgRef.rst:1695
+     string ``0`` to standard output: ``class X<int n> {...} def :
+     X<!dump("n = ", 0)>;``
+
----------------
This may need updating as dump only accepts a single value argument w/o prefix.


================
Comment at: llvm/lib/TableGen/TGParser.cpp:1345
+  case tgtok::XDump: {
+    // Value ::= !dump '(' String ','  Value ')'
+    Lex.Lex(); // eat the operation
----------------
No more `String`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157492/new/

https://reviews.llvm.org/D157492



More information about the llvm-commits mailing list