cranelift_codegen/isa/x64/inst/
emit_state.rs1use super::*;
2use crate::ir;
3use cranelift_control::ControlPlane;
4
5#[derive(Default, Clone, Debug)]
7pub struct EmitState {
8 user_stack_map: Option<ir::UserStackMap>,
11
12 ctrl_plane: ControlPlane,
15
16 frame_layout: FrameLayout,
19}
20
21impl MachInstEmitState<Inst> for EmitState {
22 fn new(abi: &Callee<X64ABIMachineSpec>, ctrl_plane: ControlPlane) -> Self {
23 EmitState {
24 user_stack_map: None,
25 ctrl_plane,
26 frame_layout: abi.frame_layout().clone(),
27 }
28 }
29
30 fn pre_safepoint(&mut self, user_stack_map: Option<ir::UserStackMap>) {
31 self.user_stack_map = user_stack_map;
32 }
33
34 fn ctrl_plane_mut(&mut self) -> &mut ControlPlane {
35 &mut self.ctrl_plane
36 }
37
38 fn take_ctrl_plane(self) -> ControlPlane {
39 self.ctrl_plane
40 }
41
42 fn frame_layout(&self) -> &FrameLayout {
43 &self.frame_layout
44 }
45}
46
47impl EmitState {
48 pub(crate) fn take_stack_map(&mut self) -> Option<ir::UserStackMap> {
49 self.user_stack_map.take()
50 }
51
52 pub(crate) fn clear_post_insn(&mut self) {
53 self.user_stack_map = None;
54 }
55}