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

Francesco Petrogalli via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 03:31:18 PDT 2023


fpetrogalli added a comment.

In D156420#4566944 <https://reviews.llvm.org/D156420#4566944>, @tra wrote:

> Sorry about the silence -- I was away for the last couple of weeks.

No worries, it is that time of the year for everybody!

> Thank you very much for the patch!
>
> In D156420#4541608 <https://reviews.llvm.org/D156420#4541608>, @wangpc wrote:
>
>> Or loose the constraint that first operand shoule be a string? for your example, it can be simpler: `!dump(!format("the concat is = {0} {1}...", vars...))`. `XDump` can still be a binary operator and set second operand to `StringInit("")` when only one operand is provided.
>
> In general the `dump(string, value)` API looks a bit too specialized. I would rather have a single-argument `!dump(value)` and, if a value needs some annotation, just use `!dump("annotation string"); !dump(value)`. Once we have `!format()` it would be a straightforward to transition to `!dump(!format("annotation...", value))`.

I see your point, and I have actually created an implementation for it...

However, I have the following considerations:

1. `!dump` is a debugging facility that is not supposed to be used in production code
2. `!format` is a formatting facility that is supposed to be used in production code for generating strings out of values.

In particular, the use of 1 requires to be able to quickly find in the output of tablegen that prints the variable. It might be just my personal preference, but think it is more efficient to just type `dump("a=", myvar)` than `!dump(!format("a=...", myvar))`, especially given the fact that such use case is there as a one-off, just for debugging.

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156420



More information about the llvm-commits mailing list