[PATCH] D126181: [RISCV] Add ISD::EH_DWARF_CFA
Shao-Ce SUN via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 22 22:56:31 PDT 2022
sunshaoce updated this revision to Diff 431286.
sunshaoce marked an inline comment as done.
sunshaoce added a comment.
Address comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126181/new/
https://reviews.llvm.org/D126181
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/eh-dwarf-cfa.ll
Index: llvm/test/CodeGen/RISCV/eh-dwarf-cfa.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/eh-dwarf-cfa.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 < %s | FileCheck -check-prefix=RV32 %s
+; RUN: llc -mtriple=riscv64 < %s | FileCheck -check-prefix=RV64 %s
+
+define void @_Z1fv() {
+; RV32-LABEL: _Z1fv:
+; RV32: # %bb.0: # %entry
+; RV32-NEXT: addi sp, sp, -16
+; RV32-NEXT: .cfi_def_cfa_offset 16
+; RV32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; RV32-NEXT: .cfi_offset ra, -4
+; RV32-NEXT: addi a0, sp, 16
+; RV32-NEXT: call _Z1gPv at plt
+; RV32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
+; RV32-NEXT: addi sp, sp, 16
+; RV32-NEXT: ret
+;
+; RV64-LABEL: _Z1fv:
+; RV64: # %bb.0: # %entry
+; RV64-NEXT: addi sp, sp, -16
+; RV64-NEXT: .cfi_def_cfa_offset 16
+; RV64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
+; RV64-NEXT: .cfi_offset ra, -8
+; RV64-NEXT: addi a0, sp, 16
+; RV64-NEXT: call _Z1gPv at plt
+; RV64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
+; RV64-NEXT: addi sp, sp, 16
+; RV64-NEXT: ret
+entry:
+ %0 = call i8* @llvm.eh.dwarf.cfa(i32 0)
+ call void @_Z1gPv(i8* %0)
+ ret void
+}
+
+declare void @_Z1gPv(i8*)
+
+declare i8* @llvm.eh.dwarf.cfa(i32)
Index: llvm/lib/Target/RISCV/RISCVISelLowering.h
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -664,6 +664,8 @@
SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
+ SDValue lowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
+
SDValue expandUnalignedRVVLoad(SDValue Op, SelectionDAG &DAG) const;
SDValue expandUnalignedRVVStore(SDValue Op, SelectionDAG &DAG) const;
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -187,6 +187,10 @@
setOperationAction({ISD::VAARG, ISD::VACOPY, ISD::VAEND}, MVT::Other, Expand);
setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand);
+
+ setOperationAction(ISD::EH_DWARF_CFA, MVT::i32, Custom);
+ setOperationAction(ISD::EH_DWARF_CFA, MVT::i64, Custom);
+
if (!Subtarget.hasStdExtZbb())
setOperationAction(ISD::SIGN_EXTEND_INREG, {MVT::i8, MVT::i16}, Expand);
@@ -3422,6 +3426,8 @@
return lowerGET_ROUNDING(Op, DAG);
case ISD::SET_ROUNDING:
return lowerSET_ROUNDING(Op, DAG);
+ case ISD::EH_DWARF_CFA:
+ return lowerEH_DWARF_CFA(Op, DAG);
case ISD::VP_SELECT:
return lowerVPOp(Op, DAG, RISCVISD::VSELECT_VL);
case ISD::VP_MERGE:
@@ -6606,6 +6612,16 @@
RMValue);
}
+SDValue RISCVTargetLowering::lowerEH_DWARF_CFA(SDValue Op,
+ SelectionDAG &DAG) const {
+ // Return a fixed StackObject with offset 0 which points to the old stack
+ // pointer.
+ MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
+ EVT ValTy = Op->getValueType(0);
+ int FI = MFI.CreateFixedObject(Op.getValueSizeInBits() / 8, 0, false);
+ return DAG.getFrameIndex(FI, ValTy);
+}
+
static RISCVISD::NodeType getRISCVWOpcodeByIntr(unsigned IntNo) {
switch (IntNo) {
default:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126181.431286.patch
Type: text/x-patch
Size: 3488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220523/e3d2dc1b/attachment.bin>
More information about the llvm-commits
mailing list