-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[RFC] TableGen-erate SDNode descriptions #119709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
2a57488 to
b90b16f
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
| /// Test if this node has a target-specific | ||
| /// memory-referencing opcode (in the \<target\>ISD namespace and | ||
| /// greater than FIRST_TARGET_MEMORY_OPCODE). | ||
| bool isTargetMemoryOpcode() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need isTargetMemoryOpcode(). It doesn't have any callers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has one use in the assert in SelectionDAG::getMemIntrinsicNode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. I was looking in my local repo and should have checked for FIRST_TARGET_MEMORY_OPCODE to see that assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If nothing else is checking it, does that assert provide any value? Can we just allow any target opcode to be a memory opcode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered it has one more "use". Before this patch it is implicitly checked here. isTargetStrictFPOpcode returns true for memory opcodes as well. mayRaiseFPException is then used here to decide whether the resulting MachineInstr needs NoFPExcept flag. IIUC it will not set this flag on MachineInstrs if the matched SDNode(s) were flagged as memory accessing (or having strict-fp semantics).
This behavior was introduced in 6333679. I couldn't conclude if it is safe to return false for memory opcodes so I left it as is.
After this patch the check is explicit, please see SelectionDAGTargetInfo.cpp:mayRaiseFPException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran CodeGen tests with the memory opcode check disabled and there was one failure in
X86/fp-intrinsics-flags.ll. The following diff resolves it:
There was a discussion in https://reviews.llvm.org/D72466 that can be related to this. Can you confirm that this is a safe change? If so, then quoting @uweigand from https://reviews.llvm.org/D71841 I assume the check for memory opcode can be dropped:
Note that there a bit of a quirk in identifying target nodes that are both memory nodes and strict FP nodes. To simplify the logic, right now all target memory nodes are automatically also considered strict FP nodes -- this could be fixed by adding one more range.
b90b16f to
ad38786
Compare
A future patch adds a couple of new methods to this class, which will need to be overridden by these targets. Part of llvm#119709.
ad38786 to
7ed14ef
Compare
…de (#119969) With this change, targets are no longer required to put memory / strict-fp opcodes after special `ISD::FIRST_TARGET_MEMORY_OPCODE`/`ISD::FIRST_TARGET_STRICTFP_OPCODE` markers. This will also allow autogenerating `isTargetMemoryOpcode`/`isTargetStrictFPOpcode (#119709). Pull Request: #119969
7dd3721 to
c315879
Compare
5d1058f to
3ba779a
Compare
This patch adds a simplistic backend that gathers all target-specific SelectionDAG nodes and emits descriptions for most of them. This includes generating node enumeration, node names, and information about node "prototype" that can be used to verify that a node is valid. The patch also extends SDNode by adding target-specific flags, which are also included in the generated tables. Part of llvm#119709, [RFC](https://discourse.llvm.org/t/rfc-tablegen-erating-sdnode-descriptions/83627).
This patch adds a simplistic backend that gathers all target-specific SelectionDAG nodes and emits descriptions for most of them. This includes generating node enumeration, node names, and information about node "prototype" that can be used to verify that a node is valid. The patch also extends SDNode by adding target-specific flags, which are also included in the generated tables. Part of llvm#119709, [RFC](https://discourse.llvm.org/t/rfc-tablegen-erating-sdnode-descriptions/83627).
This patch adds a simplistic backend that gathers all target-specific SelectionDAG nodes and emits descriptions for most of them. This includes generating node enumeration, node names, and information about node "prototype" that can be used to verify that a node is valid. The patch also extends SDNode by adding target-specific flags, which are also included in the generated tables. Part of #119709, [RFC](https://discourse.llvm.org/t/rfc-tablegen-erating-sdnode-descriptions/83627). Pull Request: #123002
3ba779a to
4c7893b
Compare
4c7893b to
ae89705
Compare
This patch introduces SelectionDAGGenTargetInfo and SDNodeInfo classes, which provide methods for accessing the generated SDNode descriptions. RFC: https://discourse.llvm.org/t/rfc-tablegen-erating-sdnode-descriptions Draft PR: llvm#119709
f425081 to
38d2191
Compare
🐧 Linux x64 Test Results
|
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The validation functionality has detected several issues, see `PPCSelectionDAGInfo::verifyTargetNode()`. Most of the nodes have a description in `*.td` files and were successfully "imported". Those that don't have a description are listed in the enum in `PPCSelectionDAGInfo.td`. These nodes are not validated. Part of #119709. Pull Request: #168108
38d2191 to
5fd7c92
Compare
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Some nodes fail validation, those are enumerated in `ARMSelectionDAGInfo::verifyTargetNode()`. Some of the bugs are easy to fix, but probably they should be fixed separately, this patch is already big. Part of #119709. Pull Request: #168212
5fd7c92 to
eba3dc9
Compare
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The verification functionality detected a few issues, two of them were fixed (missing `SDNPMemOperand` property on `TCGEN05_MMA` nodes and extra glue operand/result on `CallPrototype`), the one remaining is with `ProxyReg` node, see `NVPTXSelectionDAGInfo::verifyTargetNode()`. Part of #119709. Pull Request: #168367
eba3dc9 to
38ecac7
Compare
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. I had to split `VSHUF4I` into two variants (`VSHUF4I` and `VSHUF4I_D`) since `loongarch_vshuf4i` and `loongarch_vshuf4i_d` have different number of operands, and this prevented the node from being imported. There is just one node that currently fails validation, see `LoongArchSelectionDAGInfo::verifyTargetNode()`. Part of #119709. Pull Request: #168129
38ecac7 to
d8dbcb0
Compare
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Autogenerated node names start with "AMDGPUISD::", hence the changes in the tests. The few nodes defined in R600.td are *not* imported because TableGen processes AMDGPU.td that doesn't include R600.td. Ideally, we would have two sets of nodes, but that would require careful reorganization of td files since some nodes are shared between AMDGPU/R600. Not sure if it something worth looking into. Some nodes fail validation, those are listed in `AMDGPUSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168248
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. There is only one node that is missing a description -- `GET_CCMASK`, others were successfully imported. Part of llvm#119709. Pull Request: llvm#168113
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The validation functionality has detected several issues, see `PPCSelectionDAGInfo::verifyTargetNode()`. Most of the nodes have a description in `*.td` files and were successfully "imported". Those that don't have a description are listed in the enum in `PPCSelectionDAGInfo.td`. These nodes are not validated. Part of llvm#119709. Pull Request: llvm#168108
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Some nodes fail validation, those are enumerated in `ARMSelectionDAGInfo::verifyTargetNode()`. Some of the bugs are easy to fix, but probably they should be fixed separately, this patch is already big. Part of llvm#119709. Pull Request: llvm#168212
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The verification functionality detected a few issues, two of them were fixed (missing `SDNPMemOperand` property on `TCGEN05_MMA` nodes and extra glue operand/result on `CallPrototype`), the one remaining is with `ProxyReg` node, see `NVPTXSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168367
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. I had to split `VSHUF4I` into two variants (`VSHUF4I` and `VSHUF4I_D`) since `loongarch_vshuf4i` and `loongarch_vshuf4i_d` have different number of operands, and this prevented the node from being imported. There is just one node that currently fails validation, see `LoongArchSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168129
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Some nodes fail validation, those are enumerated in `ARMSelectionDAGInfo::verifyTargetNode()`. Some of the bugs are easy to fix, but probably they should be fixed separately, this patch is already big. Part of llvm#119709. Pull Request: llvm#168212
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. The verification functionality detected a few issues, two of them were fixed (missing `SDNPMemOperand` property on `TCGEN05_MMA` nodes and extra glue operand/result on `CallPrototype`), the one remaining is with `ProxyReg` node, see `NVPTXSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168367
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. I had to split `VSHUF4I` into two variants (`VSHUF4I` and `VSHUF4I_D`) since `loongarch_vshuf4i` and `loongarch_vshuf4i_d` have different number of operands, and this prevented the node from being imported. There is just one node that currently fails validation, see `LoongArchSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168129
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. I had to split `VSHUF4I` into two variants (`VSHUF4I` and `VSHUF4I_D`) since `loongarch_vshuf4i` and `loongarch_vshuf4i_d` have different number of operands, and this prevented the node from being imported. There is just one node that currently fails validation, see `LoongArchSelectionDAGInfo::verifyTargetNode()`. Part of llvm#119709. Pull Request: llvm#168129
This allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Many DSP nodes were failing validation, this is fixed as part of this PR. Part of llvm#119709. Pull Request: llvm#168307

RFC
Landed changes:
#138381 RISCV
#138450 Sparc
#138869 XCore
#138874 ARC, CSKY, Lanai
#138878 MSP430
#139407 AVR
#139449 M68k
#140472 AArch64
#166253 Xtensa
#166259 WebAssembly
#166499 BPF
#168108 PowerPC
#168113 SystemZ
#168120 VE
#168129 LoongArch
#168212 ARM
#168248 AMDGPU
#168367 NVPTX