[llvm-branch-commits] [llvm] 6972265 - [VE] Support FRAMEADDR
Kazushi Marukawa via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 15 06:36:18 PST 2020
Author: Kazushi (Jam) Marukawa
Date: 2020-12-15T23:31:19+09:00
New Revision: 697226550e369e7e736411508d7d2589a2aff764
URL: https://github.com/llvm/llvm-project/commit/697226550e369e7e736411508d7d2589a2aff764
DIFF: https://github.com/llvm/llvm-project/commit/697226550e369e7e736411508d7d2589a2aff764.diff
LOG: [VE] Support FRAMEADDR
Implement FRAMEADDR for VE. Add a regression test also.
Reviewed By: simoll
Differential Revision: https://reviews.llvm.org/D93295
Added:
llvm/test/CodeGen/VE/Scalar/frameaddr.ll
Modified:
llvm/lib/Target/VE/VEISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp
index d15158f4f4d2..408c28205aa2 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -1489,6 +1489,27 @@ SDValue VETargetLowering::lowerDYNAMIC_STACKALLOC(SDValue Op,
return DAG.getMergeValues(Ops, DL);
}
+static SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG,
+ const VETargetLowering &TLI,
+ const VESubtarget *Subtarget) {
+ SDLoc DL(Op);
+ MachineFunction &MF = DAG.getMachineFunction();
+ EVT PtrVT = TLI.getPointerTy(MF.getDataLayout());
+
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+ MFI.setFrameAddressIsTaken(true);
+
+ unsigned Depth = Op.getConstantOperandVal(0);
+ const VERegisterInfo *RegInfo = Subtarget->getRegisterInfo();
+ unsigned FrameReg = RegInfo->getFrameRegister(MF);
+ SDValue FrameAddr =
+ DAG.getCopyFromReg(DAG.getEntryNode(), DL, FrameReg, PtrVT);
+ while (Depth--)
+ FrameAddr = DAG.getLoad(Op.getValueType(), DL, DAG.getEntryNode(),
+ FrameAddr, MachinePointerInfo());
+ return FrameAddr;
+}
+
static SDValue getSplatValue(SDNode *N) {
if (auto *BuildVec = dyn_cast<BuildVectorSDNode>(N)) {
return BuildVec->getSplatValue();
@@ -1529,6 +1550,8 @@ SDValue VETargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
return lowerConstantPool(Op, DAG);
case ISD::DYNAMIC_STACKALLOC:
return lowerDYNAMIC_STACKALLOC(Op, DAG);
+ case ISD::FRAMEADDR:
+ return lowerFRAMEADDR(Op, DAG, *this, Subtarget);
case ISD::GlobalAddress:
return lowerGlobalAddress(Op, DAG);
case ISD::GlobalTLSAddress:
diff --git a/llvm/test/CodeGen/VE/Scalar/frameaddr.ll b/llvm/test/CodeGen/VE/Scalar/frameaddr.ll
new file mode 100644
index 000000000000..117ae90b6ccc
--- /dev/null
+++ b/llvm/test/CodeGen/VE/Scalar/frameaddr.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s -mtriple=ve | FileCheck %s
+
+define i8* @test1() nounwind {
+; CHECK-LABEL: test1:
+; CHECK: .LBB{{[0-9]+}}_2:
+; CHECK-NEXT: or %s0, 0, %s9
+; CHECK-NEXT: or %s11, 0, %s9
+entry:
+ %ret = tail call i8* @llvm.frameaddress(i32 0)
+ ret i8* %ret
+}
+
+define i8* @test2() nounwind {
+; CHECK-LABEL: test2:
+; CHECK: .LBB{{[0-9]+}}_2:
+; CHECK-NEXT: ld %s0, (, %s9)
+; CHECK-NEXT: ld %s0, (, %s0)
+; CHECK-NEXT: or %s11, 0, %s9
+entry:
+ %ret = tail call i8* @llvm.frameaddress(i32 2)
+ ret i8* %ret
+}
+
+declare i8* @llvm.frameaddress(i32) nounwind readnone
More information about the llvm-branch-commits
mailing list