This allows dumping expressions `(Init *)` as soon as they become concrete. Both of these take a string as the first operand that prefixes the dump of the expression. `!dump` can be used in a expression/functional context. For example: !foreach(i, lst, !dump(i)) `dump` can be used in a "statement" context: def c: C<3>; dump c; `dump` is implemented as a syntactic sugar. The above `dump` is parsed into: assert 1, !cast<string>(!dump(c)); Original patch from Adam Nemet <anemet@apple.com>
Details
- Reviewers
tra wangpc simon_tatham nhaehnle
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Following the decision to abandon D156420, I have updated this patch with the correct docs, comments and tests.
Update some of the test cases to show how dump can be used to produce the labels that can be useful for tracking the dump of a variable in debugging
sessions.
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.
llvm/docs/TableGen/ProgRef.rst | ||
---|---|---|
1252–1253 | 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. | |
1695 | This may need updating as dump only accepts a single value argument w/o prefix. | |
llvm/lib/TableGen/TGParser.cpp | ||
1345 | No more String. |
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.