From 17c3c1813f4ab9b29f5da09a409ec765a525c51a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Jan 2022 20:43:35 +0100 Subject: [PATCH] Remove MachInstEmitInfo --- cranelift/codegen/src/isa/aarch64/inst/emit.rs | 8 +------- cranelift/codegen/src/isa/arm32/inst/emit.rs | 6 ------ cranelift/codegen/src/isa/s390x/inst/emit.rs | 8 +------- cranelift/codegen/src/isa/x64/encoding/rex.rs | 6 +++--- cranelift/codegen/src/isa/x64/inst/emit.rs | 10 +++++----- cranelift/codegen/src/isa/x64/inst/mod.rs | 8 +------- cranelift/codegen/src/machinst/mod.rs | 9 +-------- 7 files changed, 12 insertions(+), 43 deletions(-) diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs index 19c2764e94..b60ed37239 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs @@ -669,12 +669,6 @@ impl EmitInfo { } } -impl MachInstEmitInfo for EmitInfo { - fn flags(&self) -> &settings::Flags { - &self.0 - } -} - impl MachInstEmit for Inst { type State = EmitState; type Info = EmitInfo; @@ -2699,7 +2693,7 @@ impl MachInstEmit for Inst { inst.emit(sink, emit_info, state); let srcloc = state.cur_srcloc(); sink.add_reloc(srcloc, Reloc::Abs8, name, offset); - if emit_info.flags().emit_all_ones_funcaddrs() { + if emit_info.0.emit_all_ones_funcaddrs() { sink.put8(u64::max_value()); } else { sink.put8(0); diff --git a/cranelift/codegen/src/isa/arm32/inst/emit.rs b/cranelift/codegen/src/isa/arm32/inst/emit.rs index f07284a687..7f6aa6ba62 100644 --- a/cranelift/codegen/src/isa/arm32/inst/emit.rs +++ b/cranelift/codegen/src/isa/arm32/inst/emit.rs @@ -276,12 +276,6 @@ impl EmitInfo { } } -impl MachInstEmitInfo for EmitInfo { - fn flags(&self) -> &settings::Flags { - &self.flags - } -} - impl MachInstEmit for Inst { type Info = EmitInfo; type State = EmitState; diff --git a/cranelift/codegen/src/isa/s390x/inst/emit.rs b/cranelift/codegen/src/isa/s390x/inst/emit.rs index 9c60699279..1d7134d7f3 100644 --- a/cranelift/codegen/src/isa/s390x/inst/emit.rs +++ b/cranelift/codegen/src/isa/s390x/inst/emit.rs @@ -916,12 +916,6 @@ impl EmitInfo { } } -impl MachInstEmitInfo for EmitInfo { - fn flags(&self) -> &settings::Flags { - &self.flags - } -} - impl MachInstEmit for Inst { type State = EmitState; type Info = EmitInfo; @@ -1703,7 +1697,7 @@ impl MachInstEmit for Inst { let reg = writable_spilltmp_reg().to_reg(); put(sink, &enc_ri_b(opcode, reg, 12)); sink.add_reloc(srcloc, Reloc::Abs8, name, offset); - if emit_info.flags().emit_all_ones_funcaddrs() { + if emit_info.flags.emit_all_ones_funcaddrs() { sink.put8(u64::max_value()); } else { sink.put8(0); diff --git a/cranelift/codegen/src/isa/x64/encoding/rex.rs b/cranelift/codegen/src/isa/x64/encoding/rex.rs index 51016fa39e..17e5408cc1 100644 --- a/cranelift/codegen/src/isa/x64/encoding/rex.rs +++ b/cranelift/codegen/src/isa/x64/encoding/rex.rs @@ -14,7 +14,7 @@ use crate::{ args::{Amode, OperandSize}, regs, EmitInfo, EmitState, Inst, LabelUse, }, - machinst::{MachBuffer, MachInstEmitInfo}, + machinst::MachBuffer, }; use regalloc::{Reg, RegClass}; @@ -299,7 +299,7 @@ pub(crate) fn emit_std_enc_mem( Amode::ImmReg { simm32, base, .. } => { // If this is an access based off of RSP, it may trap with a stack overflow if it's the // first touch of a new stack page. - if *base == regs::rsp() && !can_trap && info.flags().enable_probestack() { + if *base == regs::rsp() && !can_trap && info.flags.enable_probestack() { sink.add_trap(srcloc, TrapCode::StackOverflow); } @@ -365,7 +365,7 @@ pub(crate) fn emit_std_enc_mem( } => { // If this is an access based off of RSP, it may trap with a stack overflow if it's the // first touch of a new stack page. - if *reg_base == regs::rsp() && !can_trap && info.flags().enable_probestack() { + if *reg_base == regs::rsp() && !can_trap && info.flags.enable_probestack() { sink.add_trap(srcloc, TrapCode::StackOverflow); } diff --git a/cranelift/codegen/src/isa/x64/inst/emit.rs b/cranelift/codegen/src/isa/x64/inst/emit.rs index 53f67d7346..c4dc3f3d7a 100644 --- a/cranelift/codegen/src/isa/x64/inst/emit.rs +++ b/cranelift/codegen/src/isa/x64/inst/emit.rs @@ -1088,7 +1088,7 @@ pub(crate) fn emit( } Inst::Push64 { src } => { - if info.flags().enable_probestack() { + if info.flags.enable_probestack() { sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow); } @@ -1139,7 +1139,7 @@ pub(crate) fn emit( } Inst::CallKnown { dest, opcode, .. } => { - if info.flags().enable_probestack() { + if info.flags.enable_probestack() { sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow); } if let Some(s) = state.take_stack_map() { @@ -1157,7 +1157,7 @@ pub(crate) fn emit( } Inst::CallUnknown { dest, opcode, .. } => { - if info.flags().enable_probestack() { + if info.flags.enable_probestack() { sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow); } let start_offset = sink.cur_offset(); @@ -2412,7 +2412,7 @@ pub(crate) fn emit( } Inst::LoadExtName { dst, name, offset } => { - if info.flags().is_pic() { + if info.flags.is_pic() { // Generates: movq symbol@GOTPCREL(%rip), %dst let enc_dst = int_reg_enc(dst.to_reg()); sink.put1(0x48 | ((enc_dst >> 3) & 1) << 2); @@ -2442,7 +2442,7 @@ pub(crate) fn emit( sink.put1(0x48 | ((enc_dst >> 3) & 1)); sink.put1(0xB8 | (enc_dst & 7)); emit_reloc(sink, state, Reloc::Abs8, name, *offset); - if info.flags().emit_all_ones_funcaddrs() { + if info.flags.emit_all_ones_funcaddrs() { sink.put8(u64::max_value()); } else { sink.put8(0); diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs index c65c3c7523..3ab8f89b12 100644 --- a/cranelift/codegen/src/isa/x64/inst/mod.rs +++ b/cranelift/codegen/src/isa/x64/inst/mod.rs @@ -3298,7 +3298,7 @@ pub struct EmitState { /// Constant state used during emissions of a sequence of instructions. pub struct EmitInfo { - flags: settings::Flags, + pub(super) flags: settings::Flags, isa_flags: x64_settings::Flags, } @@ -3308,12 +3308,6 @@ impl EmitInfo { } } -impl MachInstEmitInfo for EmitInfo { - fn flags(&self) -> &Flags { - &self.flags - } -} - impl MachInstEmit for Inst { type State = EmitState; type Info = EmitInfo; diff --git a/cranelift/codegen/src/machinst/mod.rs b/cranelift/codegen/src/machinst/mod.rs index 7ea2eb6f7b..de491f2ace 100644 --- a/cranelift/codegen/src/machinst/mod.rs +++ b/cranelift/codegen/src/machinst/mod.rs @@ -310,20 +310,13 @@ pub trait MachInstEmit: MachInst { /// Persistent state carried across `emit` invocations. type State: MachInstEmitState; /// Constant information used in `emit` invocations. - type Info: MachInstEmitInfo; + type Info; /// Emit the instruction. fn emit(&self, code: &mut MachBuffer, info: &Self::Info, state: &mut Self::State); /// Pretty-print the instruction. fn pretty_print(&self, mb_rru: Option<&RealRegUniverse>, state: &mut Self::State) -> String; } -/// Constant information used to emit an instruction. -pub trait MachInstEmitInfo { - /// Return the target-independent settings used for the compilation of this - /// particular function. - fn flags(&self) -> &Flags; -} - /// A trait describing the emission state carried between MachInsts when /// emitting a function body. pub trait MachInstEmitState: Default + Clone + Debug {