diff options
| author | Anatoly Trosinenko <atrosinenko@accesssoftek.com> | 2025-11-19 19:37:26 +0300 |
|---|---|---|
| committer | Anatoly Trosinenko <atrosinenko@accesssoftek.com> | 2025-11-19 21:10:06 +0300 |
| commit | 869f0858f59edc480a53bec70f2bf182c24baa40 (patch) | |
| tree | 7c075caec75d8a99deba150ed6767abd2d7b70c1 /llvm/utils/TableGen/Common/CodeGenDAGPatterns.h | |
| parent | 550522d07e7481bf74255a014745f0f9c739ff8a (diff) | |
[TableGen] Eliminate the dependency on SDNode definition orderusers/atrosinenko/tablegen-fix-operandwithdefaultops
Fix CodeGenDAGPatterns::ParseDefaultOperands() not to depend on the
first SDNode defined being usable as an output pattern operator.
Presently, each `OperandWithDefaultOps` record is processed by
constructing an instance of TreePattern from its `DefaultOps` argument
that has the form `(ops ...)`. Nevertheless the result of processing
the root operator of that DAG is not inspected by `ParseDefaultOperands()`
function itself, that operator has to be parseable by the underlying
`TreePattern::ParseTreePattern()` function. For that reason, a temporary
DAG is created by replacing the root operator of `DefaultOps` argument
from `ops` to the first SDNode defined, which is usually `def imm : ...`
defined in `TargetSelectionDAG.td` file.
This results in misleading errors being reported when defining 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 if one of the targets
being built inherits its operand type 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.
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.h')
| -rw-r--r-- | llvm/utils/TableGen/Common/CodeGenDAGPatterns.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h index aa9a0a442424..f69a606a8406 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h @@ -925,6 +925,9 @@ public: CodeGenDAGPatterns &ise); TreePattern(const Record *TheRec, const DagInit *Pat, bool isInput, CodeGenDAGPatterns &ise); + TreePattern(const Record *TheRec, ArrayRef<const Init *> Args, + ArrayRef<const StringInit *> ArgNames, bool isInput, + CodeGenDAGPatterns &ise); TreePattern(const Record *TheRec, TreePatternNodePtr Pat, bool isInput, CodeGenDAGPatterns &ise); @@ -989,6 +992,9 @@ public: private: TreePatternNodePtr ParseTreePattern(const Init *DI, StringRef OpName); + TreePatternNodePtr + ParseRootlessTreePattern(ArrayRef<const Init *> Args, + ArrayRef<const StringInit *> ArgNames); void ComputeNamedNodes(); void ComputeNamedNodes(TreePatternNode &N); }; |
