Path: blob/main/cranelift/codegen/src/isa/x64/inst/emit_state.rs
1693 views
use super::*;1use crate::ir;2use cranelift_control::ControlPlane;34/// State carried between emissions of a sequence of instructions.5#[derive(Default, Clone, Debug)]6pub struct EmitState {7/// The user stack map for the upcoming instruction, as provided to8/// `pre_safepoint()`.9user_stack_map: Option<ir::UserStackMap>,1011/// Only used during fuzz-testing. Otherwise, it is a zero-sized struct and12/// optimized away at compiletime. See [cranelift_control].13ctrl_plane: ControlPlane,1415/// A copy of the frame layout, used during the emission of `Inst::ReturnCallKnown` and16/// `Inst::ReturnCallUnknown` instructions and exception callsites.17pub frame_layout: FrameLayout,18}1920impl MachInstEmitState<Inst> for EmitState {21fn new(abi: &Callee<X64ABIMachineSpec>, ctrl_plane: ControlPlane) -> Self {22EmitState {23user_stack_map: None,24ctrl_plane,25frame_layout: abi.frame_layout().clone(),26}27}2829fn pre_safepoint(&mut self, user_stack_map: Option<ir::UserStackMap>) {30self.user_stack_map = user_stack_map;31}3233fn ctrl_plane_mut(&mut self) -> &mut ControlPlane {34&mut self.ctrl_plane35}3637fn take_ctrl_plane(self) -> ControlPlane {38self.ctrl_plane39}4041fn frame_layout(&self) -> &FrameLayout {42&self.frame_layout43}44}4546impl EmitState {47pub(crate) fn take_stack_map(&mut self) -> Option<ir::UserStackMap> {48self.user_stack_map.take()49}5051pub(crate) fn clear_post_insn(&mut self) {52self.user_stack_map = None;53}54}555657