-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[BPF] TableGen-erate SDNode descriptions #166499
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 allows SDNodes to be validated against their expected type profiles and reduces the number of changes required to add a new node. Fix BR_CC/MEMCPY descriptions to match C++ code that creates the nodes. Part of llvm#119709.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
I tested by building bpf selftest with this change and everything is okay. I compared to XCore change (#138869) and they are very similar to each other. You mentioned below: Do you know why we do not have problems before for BR_CC/MRMCPY? I checked a few targets, e.g. and Looks like WASM is correct and the other three need update... |
| [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; | ||
| def BPFbrcc : SDNode<"BPFISD::BR_CC", SDT_BPFBrCC, | ||
| [SDNPHasChain, SDNPOutGlue, SDNPInGlue]>; | ||
| def BPFbrcc : SDNode<"BPFISD::BR_CC", SDT_BPFBrCC, [SDNPHasChain]>; |
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.
Could you please comment a bit on removing SDNPOutGlue, SDNPInGlue and SDNPInGlue below?
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.
Glue operands/results are used when there is a copy to/from a physical register that needs be scheduled right before / next to the node. This isn't the case for BR_CC, BPFTargetLowering::LowerBR_CC() creates it without glue operands/results:
return DAG.getNode(BPFISD::BR_CC, DL, Op.getValueType(), Chain, LHS, RHS,
DAG.getConstant(CC, DL, LHS.getValueType()), Dest);Removing these properties here is just syncing with C++ code to make SDNodeInfo::verifyNode() happy.
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.
Indeed, for BPFISD::BR_CC, we do not have in/out glue so it makes sense to remove it.
SelectionDAG is very permissive about such inconsistencies. Fixing it to be more robust is my end goal.
LanaiISD::BR_CC uses SDNPInGlue because it "glues" a comparison to the branch. In BPF comparison and branch a fused into one BPFISD::BR_CC node (same as LoongArch). ARMISD::MEMCPY is indeed incorrect in that it shouldn't have SDNPInGlue. I'm not sure if it needs an out glue, but at least its presence is consistent with C++ code. Whether or not to use glue operands/results is really target-dependent. |
But for BPFmemcpy, currently we have It is used in custom inserter: This patch only removes SNDPInGlue, I think we should remove SNDPOutGlue as well. WDYT? |
Done |
3ceb022 to
5513f77
Compare
5513f77 to
84fb333
Compare
This allows SDNodes to be validated against their expected type profiles
and reduces the number of changes required to add a new node.
Fix BR_CC/MEMCPY descriptions to match C++ code that creates the nodes
(an error detected by the enabled verification functionality).
Also remove redundant
SDNPOutGlueonBPFISD::MEMCPY.Part of #119709.