Skip to content

Commit

Permalink
pulley: Remove unwind metadata from Cranelift backend
Browse files Browse the repository at this point in the history
This is a copy/paste from the riscv64 backend originally but there's no
need to integrate with native unwinders on Pulley so there's no need to
track this information. This removes the `Unwind` pseudo-inst entirely.
  • Loading branch information
alexcrichton committed Dec 18, 2024
1 parent ab325dc commit 196c1f5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 46 deletions.
42 changes: 3 additions & 39 deletions cranelift/codegen/src/isa/pulley_shared/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{inst::*, PulleyFlags, PulleyTargetKind};
use crate::isa::pulley_shared::{PointerWidth, PulleyBackend};
use crate::{
ir::{self, types::*, MemFlags, Signature},
isa::{self, unwind::UnwindInst},
isa::{self},
machinst::*,
settings, CodegenResult,
};
Expand Down Expand Up @@ -290,24 +290,14 @@ where

fn gen_prologue_frame_setup(
_call_conv: isa::CallConv,
flags: &settings::Flags,
_flags: &settings::Flags,
_isa_flags: &PulleyFlags,
frame_layout: &FrameLayout,
) -> SmallInstVec<Self::I> {
let mut insts = SmallVec::new();

if frame_layout.setup_area_size > 0 {
insts.push(RawInst::PushFrame.into());
if flags.unwind_info() {
insts.push(
Inst::Unwind {
inst: UnwindInst::PushFrameRegs {
offset_upward_to_caller_sp: frame_layout.setup_area_size,
},
}
.into(),
);
}
}

insts
Expand Down Expand Up @@ -350,7 +340,7 @@ where

fn gen_clobber_save(
_call_conv: isa::CallConv,
flags: &settings::Flags,
_flags: &settings::Flags,
frame_layout: &FrameLayout,
) -> SmallVec<[Self::I; 16]> {
let mut insts = SmallVec::new();
Expand Down Expand Up @@ -379,20 +369,6 @@ where
}
}

if flags.unwind_info() && setup_frame {
// The *unwind* frame (but not the actual frame) starts at the
// clobbers, just below the saved FP/LR pair.
insts.push(
Inst::Unwind {
inst: UnwindInst::DefineNewFrame {
offset_downward_to_clobbers: frame_layout.clobber_size,
offset_upward_to_caller_sp: frame_layout.setup_area_size,
},
}
.into(),
);
}

// Adjust the stack pointer downward for clobbers, the function fixed
// frame (spillslots and storage slots), and outgoing arguments.
let stack_size = frame_layout.clobber_size
Expand Down Expand Up @@ -424,18 +400,6 @@ where
.into(),
);

if flags.unwind_info() {
insts.push(
Inst::Unwind {
inst: UnwindInst::SaveReg {
clobber_offset: frame_layout.clobber_size - cur_offset,
reg: r_reg,
},
}
.into(),
);
}

cur_offset += 8
}
}
Expand Down
3 changes: 0 additions & 3 deletions cranelift/codegen/src/isa/pulley_shared/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
;; A pseudo-instruction that moves vregs to return registers.
(Rets (rets VecRetPair))

;; A pseudo-instruction to update unwind info.
(Unwind (inst UnwindInst))

;; Implementation of `br_table`, uses `idx` to jump to one of `targets` or
;; jumps to `default` if it's out-of-bounds.
(BrTable
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/pulley_shared/inst/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn pulley_emit<P>(
{
match inst {
// Pseduo-instructions that don't actually encode to anything.
Inst::Args { .. } | Inst::Rets { .. } | Inst::Unwind { .. } => {}
Inst::Args { .. } | Inst::Rets { .. } => {}

Inst::TrapIf { cond, code } => {
let trap = sink.defer_trap(*code);
Expand Down
4 changes: 1 addition & 3 deletions cranelift/codegen/src/isa/pulley_shared/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn pulley_get_operands(inst: &mut Inst, collector: &mut impl OperandVisitor) {
}
}

Inst::Unwind { .. } | Inst::Nop => {}
Inst::Nop => {}

Inst::TrapIf { cond, code: _ } => {
cond.get_operands(collector);
Expand Down Expand Up @@ -578,8 +578,6 @@ impl Inst {
s
}

Inst::Unwind { inst } => format!("unwind {inst:?}"),

Inst::TrapIf { cond, code } => {
format!("trap_{cond} // code = {code:?}")
}
Expand Down

0 comments on commit 196c1f5

Please sign in to comment.