[llvm] r193625 - [AArch64] Implement FrameAddr and ReturnAddr
mcrosier at codeaurora.org
mcrosier at codeaurora.org
Tue Oct 29 10:19:07 PDT 2013
Hi Weiming,
Is there any way we could test this?
Chad
> Author: weimingz
> Date: Tue Oct 29 12:00:25 2013
> New Revision: 193625
>
> URL: http://llvm.org/viewvc/llvm-project?rev=193625&view=rev
> Log:
> [AArch64] Implement FrameAddr and ReturnAddr
>
> Fixes PR17690
>
> Modified:
> llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
> llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.h
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=193625&r1=193624&r2=193625&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Tue Oct 29
> 12:00:25 2013
> @@ -1958,6 +1958,45 @@ AArch64TargetLowering::LowerFP_TO_INT(SD
> return LowerF128ToCall(Op, DAG, LC);
> }
>
> +SDValue AArch64TargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG
> &DAG) const{
> + MachineFunction &MF = DAG.getMachineFunction();
> + MachineFrameInfo *MFI = MF.getFrameInfo();
> + MFI->setReturnAddressIsTaken(true);
> +
> + EVT VT = Op.getValueType();
> + SDLoc dl(Op);
> + unsigned Depth =
> cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
> + if (Depth) {
> + SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
> + SDValue Offset = DAG.getConstant(8, MVT::i64);
> + return DAG.getLoad(VT, dl, DAG.getEntryNode(),
> + DAG.getNode(ISD::ADD, dl, VT, FrameAddr, Offset),
> + MachinePointerInfo(), false, false, false, 0);
> + }
> +
> + // Return X30, which contains the return address. Mark it an implicit
> live-in.
> + unsigned Reg = MF.addLiveIn(AArch64::X30, getRegClassFor(MVT::i64));
> + return DAG.getCopyFromReg(DAG.getEntryNode(), dl, Reg, MVT::i64);
> +}
> +
> +
> +SDValue AArch64TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG
> &DAG)
> + const {
> + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
> + MFI->setFrameAddressIsTaken(true);
> +
> + EVT VT = Op.getValueType();
> + SDLoc dl(Op);
> + unsigned Depth =
> cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
> + unsigned FrameReg = AArch64::X29;
> + SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl,
> FrameReg, VT);
> + while (Depth--)
> + FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr,
> + MachinePointerInfo(),
> + false, false, false, 0);
> + return FrameAddr;
> +}
> +
> SDValue
> AArch64TargetLowering::LowerGlobalAddressELFLarge(SDValue Op,
> SelectionDAG &DAG)
> const {
> @@ -2703,6 +2742,8 @@ AArch64TargetLowering::LowerOperation(SD
> case ISD::UINT_TO_FP: return LowerINT_TO_FP(Op, DAG, false);
> case ISD::FP_ROUND: return LowerFP_ROUND(Op, DAG);
> case ISD::FP_EXTEND: return LowerFP_EXTEND(Op, DAG);
> + case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG);
> + case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG);
>
> case ISD::BlockAddress: return LowerBlockAddress(Op, DAG);
> case ISD::BRCOND: return LowerBRCOND(Op, DAG);
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.h?rev=193625&r1=193624&r2=193625&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.h (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.h Tue Oct 29
> 12:00:25 2013
> @@ -246,6 +246,8 @@ public:
> SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const;
> SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
> SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, bool IsSigned)
> const;
> + SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
> + SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
>
> SDValue LowerGlobalAddressELFSmall(SDValue Op, SelectionDAG &DAG)
> const;
> SDValue LowerGlobalAddressELFLarge(SDValue Op, SelectionDAG &DAG)
> const;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list