[llvm] [Docs] Improve Target TableGen Docs (PR #178518)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 10:56:59 PST 2026


================
@@ -371,11 +371,32 @@ class SDNode<string opcode, SDTypeProfile typeprof,
   bits<32> TSFlags = 0;
 }
 
-// Special TableGen-recognized dag nodes
+/// Special TableGen-recognized dag nodes
+
+// `set` is used to name outputs of a match pattern. For instance, in:
+//   `(set GPR:$out, (add GPR:$in1, GPR:$in2))`.
+//
+// `set` has to be used for patterns defined directly on Instructions, where the
+// `(outs)` have names which need to match something in the pattern.
+//
+// `set` can also be used for Nodes which create multiple values (though chain
+// and glue do not need to be handled with this, and are handled with node
+// properties). A pattern with multiple outputs might look like:
+//   `(set GPR:$RdLo, GPR:$RdHi, (smullohi GPR:$Rn, GPR:$Rm))`
 def set;
+
+// `node` is used when defining pattern fragments, to represent "holes" in the
+// fragment that should be instantiated with dags when the fragment is used. For
+// instance in the `def fmul_contract` below.
 def node;
+
+// `srcvalue` is used in patterns when an argument of the pattern is not needed
----------------
topperc wrote:

I did the archaeology. I think they were originally related, =at least in name.

When `srcvalue` was added, loads had a ISD::SRCVALUE operand instead of a MemOperand. When zextload was added it had operands: ptr, srcvalue, vt. Non-extending loads only had: ptr, srcvalue.

Isel patterns for non-extending loads exploited the fact that isel doesn't ever count the operands so the load patterns were (load ptr). But a zextload pattern needed to check the VT so the pattern needed to skip the ISD::SRCVALUE so it could check the vt. The name was copied from the node it was skipping. 683d8515b1f5ba71cf15250f9268306018404226 The tablegen code was added in the next commit 6a31777c8e7a64bb1fb9a96a25b1d7417fdb42c6

So it guess it was always intended to represent operands that should be ignored, it just has a bad name.

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


More information about the llvm-commits mailing list