Remove MachInstEmitInfo
This commit is contained in:
@@ -669,12 +669,6 @@ impl EmitInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MachInstEmitInfo for EmitInfo {
|
|
||||||
fn flags(&self) -> &settings::Flags {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MachInstEmit for Inst {
|
impl MachInstEmit for Inst {
|
||||||
type State = EmitState;
|
type State = EmitState;
|
||||||
type Info = EmitInfo;
|
type Info = EmitInfo;
|
||||||
@@ -2699,7 +2693,7 @@ impl MachInstEmit for Inst {
|
|||||||
inst.emit(sink, emit_info, state);
|
inst.emit(sink, emit_info, state);
|
||||||
let srcloc = state.cur_srcloc();
|
let srcloc = state.cur_srcloc();
|
||||||
sink.add_reloc(srcloc, Reloc::Abs8, name, offset);
|
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());
|
sink.put8(u64::max_value());
|
||||||
} else {
|
} else {
|
||||||
sink.put8(0);
|
sink.put8(0);
|
||||||
|
|||||||
@@ -276,12 +276,6 @@ impl EmitInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MachInstEmitInfo for EmitInfo {
|
|
||||||
fn flags(&self) -> &settings::Flags {
|
|
||||||
&self.flags
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MachInstEmit for Inst {
|
impl MachInstEmit for Inst {
|
||||||
type Info = EmitInfo;
|
type Info = EmitInfo;
|
||||||
type State = EmitState;
|
type State = EmitState;
|
||||||
|
|||||||
@@ -916,12 +916,6 @@ impl EmitInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MachInstEmitInfo for EmitInfo {
|
|
||||||
fn flags(&self) -> &settings::Flags {
|
|
||||||
&self.flags
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MachInstEmit for Inst {
|
impl MachInstEmit for Inst {
|
||||||
type State = EmitState;
|
type State = EmitState;
|
||||||
type Info = EmitInfo;
|
type Info = EmitInfo;
|
||||||
@@ -1703,7 +1697,7 @@ impl MachInstEmit for Inst {
|
|||||||
let reg = writable_spilltmp_reg().to_reg();
|
let reg = writable_spilltmp_reg().to_reg();
|
||||||
put(sink, &enc_ri_b(opcode, reg, 12));
|
put(sink, &enc_ri_b(opcode, reg, 12));
|
||||||
sink.add_reloc(srcloc, Reloc::Abs8, name, offset);
|
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());
|
sink.put8(u64::max_value());
|
||||||
} else {
|
} else {
|
||||||
sink.put8(0);
|
sink.put8(0);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
args::{Amode, OperandSize},
|
args::{Amode, OperandSize},
|
||||||
regs, EmitInfo, EmitState, Inst, LabelUse,
|
regs, EmitInfo, EmitState, Inst, LabelUse,
|
||||||
},
|
},
|
||||||
machinst::{MachBuffer, MachInstEmitInfo},
|
machinst::MachBuffer,
|
||||||
};
|
};
|
||||||
use regalloc::{Reg, RegClass};
|
use regalloc::{Reg, RegClass};
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ pub(crate) fn emit_std_enc_mem(
|
|||||||
Amode::ImmReg { simm32, base, .. } => {
|
Amode::ImmReg { simm32, base, .. } => {
|
||||||
// If this is an access based off of RSP, it may trap with a stack overflow if it's the
|
// 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.
|
// 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);
|
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
|
// 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.
|
// 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);
|
sink.add_trap(srcloc, TrapCode::StackOverflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1088,7 +1088,7 @@ pub(crate) fn emit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inst::Push64 { src } => {
|
Inst::Push64 { src } => {
|
||||||
if info.flags().enable_probestack() {
|
if info.flags.enable_probestack() {
|
||||||
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1139,7 +1139,7 @@ pub(crate) fn emit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inst::CallKnown { dest, opcode, .. } => {
|
Inst::CallKnown { dest, opcode, .. } => {
|
||||||
if info.flags().enable_probestack() {
|
if info.flags.enable_probestack() {
|
||||||
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
||||||
}
|
}
|
||||||
if let Some(s) = state.take_stack_map() {
|
if let Some(s) = state.take_stack_map() {
|
||||||
@@ -1157,7 +1157,7 @@ pub(crate) fn emit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inst::CallUnknown { dest, opcode, .. } => {
|
Inst::CallUnknown { dest, opcode, .. } => {
|
||||||
if info.flags().enable_probestack() {
|
if info.flags.enable_probestack() {
|
||||||
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
sink.add_trap(state.cur_srcloc(), TrapCode::StackOverflow);
|
||||||
}
|
}
|
||||||
let start_offset = sink.cur_offset();
|
let start_offset = sink.cur_offset();
|
||||||
@@ -2412,7 +2412,7 @@ pub(crate) fn emit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inst::LoadExtName { dst, name, offset } => {
|
Inst::LoadExtName { dst, name, offset } => {
|
||||||
if info.flags().is_pic() {
|
if info.flags.is_pic() {
|
||||||
// Generates: movq symbol@GOTPCREL(%rip), %dst
|
// Generates: movq symbol@GOTPCREL(%rip), %dst
|
||||||
let enc_dst = int_reg_enc(dst.to_reg());
|
let enc_dst = int_reg_enc(dst.to_reg());
|
||||||
sink.put1(0x48 | ((enc_dst >> 3) & 1) << 2);
|
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(0x48 | ((enc_dst >> 3) & 1));
|
||||||
sink.put1(0xB8 | (enc_dst & 7));
|
sink.put1(0xB8 | (enc_dst & 7));
|
||||||
emit_reloc(sink, state, Reloc::Abs8, name, *offset);
|
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());
|
sink.put8(u64::max_value());
|
||||||
} else {
|
} else {
|
||||||
sink.put8(0);
|
sink.put8(0);
|
||||||
|
|||||||
@@ -3298,7 +3298,7 @@ pub struct EmitState {
|
|||||||
|
|
||||||
/// Constant state used during emissions of a sequence of instructions.
|
/// Constant state used during emissions of a sequence of instructions.
|
||||||
pub struct EmitInfo {
|
pub struct EmitInfo {
|
||||||
flags: settings::Flags,
|
pub(super) flags: settings::Flags,
|
||||||
isa_flags: x64_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 {
|
impl MachInstEmit for Inst {
|
||||||
type State = EmitState;
|
type State = EmitState;
|
||||||
type Info = EmitInfo;
|
type Info = EmitInfo;
|
||||||
|
|||||||
@@ -310,20 +310,13 @@ pub trait MachInstEmit: MachInst {
|
|||||||
/// Persistent state carried across `emit` invocations.
|
/// Persistent state carried across `emit` invocations.
|
||||||
type State: MachInstEmitState<Self>;
|
type State: MachInstEmitState<Self>;
|
||||||
/// Constant information used in `emit` invocations.
|
/// Constant information used in `emit` invocations.
|
||||||
type Info: MachInstEmitInfo;
|
type Info;
|
||||||
/// Emit the instruction.
|
/// Emit the instruction.
|
||||||
fn emit(&self, code: &mut MachBuffer<Self>, info: &Self::Info, state: &mut Self::State);
|
fn emit(&self, code: &mut MachBuffer<Self>, info: &Self::Info, state: &mut Self::State);
|
||||||
/// Pretty-print the instruction.
|
/// Pretty-print the instruction.
|
||||||
fn pretty_print(&self, mb_rru: Option<&RealRegUniverse>, state: &mut Self::State) -> String;
|
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
|
/// A trait describing the emission state carried between MachInsts when
|
||||||
/// emitting a function body.
|
/// emitting a function body.
|
||||||
pub trait MachInstEmitState<I: MachInst>: Default + Clone + Debug {
|
pub trait MachInstEmitState<I: MachInst>: Default + Clone + Debug {
|
||||||
|
|||||||
Reference in New Issue
Block a user