[all-commits] [llvm/llvm-project] d41628: [TableGen] Eliminate the dependency on SDNode defi...

Anatoly Trosinenko via All-commits all-commits at lists.llvm.org
Mon Nov 24 03:59:53 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d41628941743b778432e30d93f25028ffb375fbc
      https://github.com/llvm/llvm-project/commit/d41628941743b778432e30d93f25028ffb375fbc
  Author: Anatoly Trosinenko <atrosinenko at accesssoftek.com>
  Date:   2025-11-24 (Mon, 24 Nov 2025)

  Changed paths:
    M llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
    M llvm/utils/TableGen/Common/CodeGenDAGPatterns.h

  Log Message:
  -----------
  [TableGen] Eliminate the dependency on SDNode definition order (#168745)

Fix the dependency of `CodeGenDAGPatterns::ParseDefaultOperands()` on
the particular order of SDNode definitions. Implicit usage of the first
definition as a placeholder makes `llvm-tblgen -gen-dag-isel` fail if
that SDNode is not usable as an output pattern operator and an instance
of `OperandWithDefaultOps` is used in a pattern.

Presently, each `OperandWithDefaultOps` record is processed by
constructing an instance of TreePattern from its `DefaultOps` argument
that has the form `(ops ...)`. Even though the result of processing the
root operator of that DAG is not inspected by `ParseDefaultOperands()`
function itself, that operator has to be supported by the underlying
`TreePattern::ParseTreePattern()` function. For that reason, a temporary
DAG is created by replacing the root operator of `DefaultOps` argument
with the first SDNode defined, which is usually `def imm : ...` defined
in `TargetSelectionDAG.td` file.

This results in misleading errors being reported when implementing new
`SDNode` types, if the new definition happens to be added before the
`def imm : ...` line. The error is reported by several test cases
executed by `check-llvm` target, as well as by the regular build, if one
of the enabled targets inherit one of its operand types from
`OperandWithDefaultOps`:

    OptionalIntOperand: ../llvm/test/TableGen/DAGDefaultOps.td:28:5: error: In OptionalIntOperand: Cannot use 'unexpected_node' in an output pattern!
    def OptionalIntOperand: OperandWithDefaultOps<i32, (ops (i32 0))>;

This commit implements a dedicated constructor of `TreePattern` to be
used if the caller does not care about the particular root operator of
the pattern being processed.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list