Commit d416289
authored
[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.1 parent 1dc6ad0 commit d416289
File tree
2 files changed
+29
-10
lines changed- llvm/utils/TableGen/Common
2 files changed
+29
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2922 | 2922 | | |
2923 | 2923 | | |
2924 | 2924 | | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
2925 | 2933 | | |
2926 | 2934 | | |
2927 | 2935 | | |
| |||
2950 | 2958 | | |
2951 | 2959 | | |
2952 | 2960 | | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
2953 | 2974 | | |
2954 | 2975 | | |
2955 | 2976 | | |
| |||
3487 | 3508 | | |
3488 | 3509 | | |
3489 | 3510 | | |
3490 | | - | |
3491 | | - | |
3492 | | - | |
3493 | | - | |
3494 | 3511 | | |
3495 | 3512 | | |
3496 | 3513 | | |
3497 | | - | |
3498 | | - | |
3499 | | - | |
3500 | | - | |
3501 | | - | |
3502 | 3514 | | |
3503 | | - | |
| 3515 | + | |
| 3516 | + | |
3504 | 3517 | | |
3505 | 3518 | | |
3506 | 3519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
920 | 923 | | |
921 | 924 | | |
922 | 925 | | |
| |||
981 | 984 | | |
982 | 985 | | |
983 | 986 | | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
984 | 990 | | |
985 | 991 | | |
986 | 992 | | |
| |||
0 commit comments