[llvm] [TableGen] Eliminate the dependency on SDNode definition order (PR #168745)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 10:21:03 PST 2025
atrosinenko wrote:
The example error output was produced by defining `unexpected_node` in `llvm/include/llvm/Target/TargetSelectionDAG.td` like this:
```diff
diff --git a/llvm/include/llvm/Target/TargetSelectionDAG.td b/llvm/include/llvm/Target/TargetSelectionDAG.td
index a9750a5ab03f..1143b749f6e1 100644
--- a/llvm/include/llvm/Target/TargetSelectionDAG.td
+++ b/llvm/include/llvm/Target/TargetSelectionDAG.td
@@ -371,6 +371,8 @@ def set;
def node;
def srcvalue;
+def unexpected_node : SDNode<"ISD::Unexpected", SDTIntShiftOp, []>;
+
def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
def timm : SDNode<"ISD::TargetConstant",SDTIntLeaf, [], "ConstantSDNode">;
def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
```
Unfortunately, it is non-trivial to add a test case, as it is impossible to put `def unexpected_node : ...` into one of the TableGen tests before its `include "llvm/Target/Target.td"` line, as this would result in `Couldn't find class 'SDNode'` error.
https://github.com/llvm/llvm-project/pull/168745
More information about the llvm-commits
mailing list