[TableGen] Add a backend generating SDNode descriptions#123002
[TableGen] Add a backend generating SDNode descriptions#123002s-barannikov merged 8 commits intollvm:mainfrom
Conversation
|
@llvm/pr-subscribers-tablegen @llvm/pr-subscribers-llvm-selectiondag Author: Sergei Barannikov (s-barannikov) ChangesThis 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. Patch is 38.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/123002.diff 9 Files Affected:
|
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).
06d6890 to
9ec5e48
Compare
|
|
||
| SmallVector<StringRef> SkippedNodes; | ||
| for (const auto &[EnumName, Nodes] : TargetNodesByName) { | ||
| ArrayRef Constraints = Nodes.front()->getTypeConstraints(); |
There was a problem hiding this comment.
Missing template parameter on the ArrayRef. I feel like I've seen something like this were it didn't work with all compilers.
There was a problem hiding this comment.
I've seen it used in other places, but it's uncommon. I'll add the parameter.
| let Properties = props; | ||
| SDTypeProfile TypeProfile = typeprof; | ||
| bit IsStrictFP = false; | ||
| bits<64> TSFlags = 0; |
There was a problem hiding this comment.
TSFlags in SDNodeDesc in #119709 is declared as uint32_t. Are you going to enlarge that or should this be 32?
There was a problem hiding this comment.
Thanks for spotting this. I think 32 bits should be more than enough, at least for now.
* Add missing template parameter to ArrayRef * Shrink TSFlags to 32 bits
| constexpr unsigned PropMask = (1 << SDNPHasChain) | (1 << SDNPOutGlue) | | ||
| (1 << SDNPInGlue) | (1 << SDNPOptInGlue) | | ||
| (1 << SDNPMemOperand) | (1 << SDNPVariadic); |
There was a problem hiding this comment.
At some point we should probably upgrade the enum to a bitmask enum
|
|
||
| for (StringRef EnumName : make_first_range(TargetNodesByName)) { | ||
| SmallString<64> DebugName; | ||
| (TargetSDNodeNamespace + "::" + EnumName).toVector(DebugName); |
| NameTable.EmitStringLiteralDef( | ||
| OS, "static const char " + Target.getName() + "SDNodeNames[]", | ||
| /*Indent=*/""); | ||
| OS << "\n"; |
There was a problem hiding this comment.
| OS << "\n"; | |
| OS << '\n'; |
…123002) 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: llvm/llvm-project#123002
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.