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

Wang Pengcheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 01:46:54 PDT 2023


wangpc added a comment.

In D156420#4541511 <https://reviews.llvm.org/D156420#4541511>, @fpetrogalli wrote:

> In D156420#4541117 <https://reviews.llvm.org/D156420#4541117>, @wangpc wrote:
>
>> Thanks! The implementation is just what I have imagined before!
>
> Good good! Thank you for the review.
>
>> One suggestion: can we accept variable-length arguments (at least one) and the first needn't to be a string? The output is just concatenation of all arguments and we make current implementation a special case.  So that we can dump multiple values in a single line.
>
> I'd keep it simple and avoid having to deal with variable-length args, because  once D156429 <https://reviews.llvm.org/D156429> is in, we can achieve the same with `!dump("the concat is = ", !format("{0} {1}...", vars...))`

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.
By doing this, it won't be imcompatible if we want to extend it to be with variable-length arguments in the future.



================
Comment at: llvm/lib/TableGen/Record.cpp:1189
+  case DUMP: {
+    if (isa<StringInit>(LHS) && RHS->isConcrete()) {
+      errs() << LHS->getAsUnquotedString();
----------------
Can we print it in debug mode and mute it in release mode?
A CLI option may be added to control it and set it via cmake build type.


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