[Xtensa] Lowering FRAMEADDR/RETURNADDR operations.#107363
Merged
[Xtensa] Lowering FRAMEADDR/RETURNADDR operations.#107363
Conversation
35d700d to
a210ae9
Compare
Contributor
Author
|
@arsenm , @s-barannikov , PTAL to this PR whenever you have the time. |
arsenm
reviewed
Sep 6, 2024
| MachineFunction &MF = DAG.getMachineFunction(); | ||
| MachineFrameInfo &MFI = MF.getFrameInfo(); | ||
| EVT VT = Op.getValueType(); | ||
| unsigned RA = Xtensa::A0; |
Contributor
There was a problem hiding this comment.
No reason to use this variable (but it should be Register/MCRegister)
Contributor
Author
There was a problem hiding this comment.
Thank you for comments. Fixed.
| // check the depth | ||
| // TODO: xtensa-gcc can handle this, by navigating through the stack, we | ||
| // should be able to do this too | ||
| assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && |
Contributor
There was a problem hiding this comment.
Shouldn't assert on this, it's not invalid IR. Langref states it returns "zero if it cannot be identified"
Contributor
Author
There was a problem hiding this comment.
Fixed. I hope that I understand correctly your comment,
| SDValue XtensaTargetLowering::LowerFRAMEADDR(SDValue Op, | ||
| SelectionDAG &DAG) const { | ||
| // check the depth | ||
| assert((cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && |
| ; CHECK-NEXT: ret | ||
| %1 = call ptr @llvm.returnaddress(i32 0) | ||
| ret ptr %1 | ||
| } |
| ; CHECK-LABEL: test_frameaddress_0: | ||
| ; CHECK: or a2, a1, a1 | ||
| ; CHECK-NEXT: ret | ||
| %1 = call ptr @llvm.frameaddress(i32 0) |
| @@ -0,0 +1,22 @@ | |||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | |||
| ; RUN: llc -mtriple=xtensa -verify-machineinstrs < %s \ | |||
Contributor
There was a problem hiding this comment.
Don't need -verify-machineinstrs
| EVT VT = Op.getValueType(); | ||
| SDLoc DL(Op); | ||
|
|
||
| unsigned FrameRegister = Subtarget.getRegisterInfo()->getFrameRegister(MF); |
arsenm
approved these changes
Sep 11, 2024
| return SDValue(); | ||
|
|
||
| MachineFunction &MF = DAG.getMachineFunction(); | ||
| MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); |
Contributor
There was a problem hiding this comment.
Suggested change
| MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); | |
| MachineFrameInfo &MFI = MF.getFrameInfo(); |
| // An index of one to the parent's return address, and so on. | ||
| // Depths > 0 not supported yet! | ||
| if (Op.getConstantOperandVal(0) > 0) | ||
| return SDValue(); |
| // An index of zero corresponds to the current function's frame address. | ||
| // An index of one to the parent's frame address, and so on. | ||
| // Depths > 0 not supported yet! | ||
| if (Op.getConstantOperandVal(0) > 0) |
arsenm
approved these changes
Sep 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.