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

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 11:12:43 PDT 2023


nhaehnle added a comment.

In D157492#4577657 <https://reviews.llvm.org/D157492#4577657>, @tra wrote:

> 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.

I like this idea.



================
Comment at: llvm/docs/TableGen/ProgRef.rst:1252-1253
+
+Example: the following statements will print ``The value of X is 0``
+to standard output.
+
----------------
tra wrote:
> 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.
> 
Is this part of the documentation still correct? It doesn't appear to match the test cases.


================
Comment at: llvm/lib/TableGen/Record.cpp:805
+      else
+        errs() << LHS->getAsString() << "\n";
+      return LHS;
----------------
Use `'\n'` for single-character output.


================
Comment at: llvm/lib/TableGen/TGParser.cpp:3857
+  if (!RHS) {
+    Error(Lex.getLoc(), "Exepcted value as second operand");
+    return true;
----------------
Typo: Expected

Also: why "second" operand?


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