[PATCH] D93811: [VE] Support llvm.eh.sjlj.lsda
Kazushi Marukawa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 25 04:05:55 PST 2020
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: LLVM, VE.
Herald added a subscriber: hiraditya.
kaz7 requested review of this revision.
Herald added a subscriber: llvm-commits.
In order to support SJLJ exception, implement llvm.eh.sjlj.lsda first.
Add regression test also.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93811
Files:
llvm/lib/Target/VE/VEISelLowering.cpp
llvm/lib/Target/VE/VEISelLowering.h
llvm/test/CodeGen/VE/Scalar/builtin_sjlj_lsda.ll
Index: llvm/test/CodeGen/VE/Scalar/builtin_sjlj_lsda.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/VE/Scalar/builtin_sjlj_lsda.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=ve -exception-model sjlj | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone
+define i8* @test_lsda() {
+; CHECK-LABEL: test_lsda:
+; CHECK: # %bb.0:
+; CHECK-NEXT: lea %s0, GCC_except_table0 at lo
+; CHECK-NEXT: and %s0, %s0, (32)0
+; CHECK-NEXT: lea.sl %s0, GCC_except_table0 at hi(, %s0)
+; CHECK-NEXT: b.l.t (, %s10)
+ %ret = call i8* @llvm.eh.sjlj.lsda()
+ ret i8* %ret
+}
+
+; Function Attrs: nounwind
+declare i8* @llvm.eh.sjlj.lsda()
Index: llvm/lib/Target/VE/VEISelLowering.h
===================================================================
--- llvm/lib/Target/VE/VEISelLowering.h
+++ llvm/lib/Target/VE/VEISelLowering.h
@@ -115,6 +115,7 @@
SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
+ SDValue lowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerLOAD(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerSTORE(SDValue Op, SelectionDAG &DAG) const;
Index: llvm/lib/Target/VE/VEISelLowering.cpp
===================================================================
--- llvm/lib/Target/VE/VEISelLowering.cpp
+++ llvm/lib/Target/VE/VEISelLowering.cpp
@@ -275,6 +275,9 @@
}
/// } Atomic isntructions
+
+ // Intrinsic instructions
+ setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
}
void VETargetLowering::initVPUActions() {
@@ -1534,6 +1537,40 @@
MachinePointerInfo());
}
+SDValue VETargetLowering::lowerINTRINSIC_WO_CHAIN(SDValue Op,
+ SelectionDAG &DAG) const {
+ SDLoc DL(Op);
+ unsigned IntNo = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
+ switch (IntNo) {
+ default: // Don't custom lower most intrinsics.
+ return SDValue();
+ case Intrinsic::eh_sjlj_lsda: {
+ MachineFunction &MF = DAG.getMachineFunction();
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ MVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
+ const VETargetMachine *TM =
+ static_cast<const VETargetMachine *>(&DAG.getTarget());
+
+ // Creat GCC_except_tableXX string. The real symbol for that will be
+ // generated in EHStreamer::emitExceptionTable() later. So, we just
+ // borrow it's name here.
+ TM->getStrList()->push_back(std::string(
+ (Twine("GCC_except_table") + Twine(MF.getFunctionNumber())).str()));
+ SDValue Addr =
+ DAG.getTargetExternalSymbol(TM->getStrList()->back().c_str(), PtrVT, 0);
+ if (isPositionIndependent()) {
+ Addr = makeHiLoPair(Addr, VEMCExpr::VK_VE_GOTOFF_HI32,
+ VEMCExpr::VK_VE_GOTOFF_LO32, DAG);
+ SDValue GlobalBase = DAG.getNode(VEISD::GLOBAL_BASE_REG, DL, PtrVT);
+ return DAG.getNode(ISD::ADD, DL, PtrVT, GlobalBase, Addr);
+ } else {
+ return makeHiLoPair(Addr, VEMCExpr::VK_VE_HI32, VEMCExpr::VK_VE_LO32,
+ DAG);
+ }
+ }
+ }
+}
+
static SDValue getSplatValue(SDNode *N) {
if (auto *BuildVec = dyn_cast<BuildVectorSDNode>(N)) {
return BuildVec->getSplatValue();
@@ -1580,6 +1617,8 @@
return lowerGlobalAddress(Op, DAG);
case ISD::GlobalTLSAddress:
return lowerGlobalTLSAddress(Op, DAG);
+ case ISD::INTRINSIC_WO_CHAIN:
+ return lowerINTRINSIC_WO_CHAIN(Op, DAG);
case ISD::JumpTable:
return lowerJumpTable(Op, DAG);
case ISD::LOAD:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93811.313725.patch
Type: text/x-patch
Size: 3777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201225/30746741/attachment.bin>
More information about the llvm-commits
mailing list