[llvm] [Tablegen] Add keyword `dump`. (PR #68793)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 10:44:27 PDT 2023


================
@@ -1275,6 +1275,37 @@ be nested.
 This loop defines records named ``R0``, ``R1``, ``R2``, and ``R3``, along
 with ``F0``, ``F1``, ``F2``, and ``F3``.
 
+``dump`` --- print messages to stderr
+-------------------------------------
+
+A ``dump`` statement prints the input string to standard error
+output. It is intended for debugging purpose.
+
+* At top level, the message is printed immediately.
+
+* In a record definition, the message is saved and all messages are
+  printed after the record is completely built.
+
+* In a class definition, the messages are saved and inherited by all
+  the subclasses and records that inherit from the class. The messages
+  are then printed when the records are completely built.
+
+* In a multiclass definition, the messages are saved with the other
+  components of the multiclass and then printed each time the
+  multiclass is instantiated with ``defm``.
----------------
Artem-B wrote:

`message is saved` may not be the best way to describe things here.
When we use `dump()` in a class/multiclass, we do not have the "message" at that point, as we have no instances yet. It's when we instantiate the record, the dump and its argument get evaluated and, presumably, printed.

You may want to rephrase the doc accordingly.

It may actually collapse to something like "dump() within record/class/multiclass gets evaluated at each instantiation point of the containing record" which would cover all three cases here.

https://github.com/llvm/llvm-project/pull/68793


More information about the llvm-commits mailing list