Merge pull request #3639 from bjorn3/machinst_cleanups

Various cleanups around machinst
This commit is contained in:
Chris Fallin
2022-01-05 10:01:27 -08:00
committed by GitHub
25 changed files with 62 additions and 245 deletions

View File

@@ -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);

View File

@@ -98,8 +98,8 @@ impl MachBackend for AArch64Backend {
"aarch64"
}
fn triple(&self) -> Triple {
self.triple.clone()
fn triple(&self) -> &Triple {
&self.triple
}
fn flags(&self) -> &shared_settings::Flags {

View File

@@ -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;

View File

@@ -88,8 +88,8 @@ impl MachBackend for Arm32Backend {
"arm32"
}
fn triple(&self) -> Triple {
self.triple.clone()
fn triple(&self) -> &Triple {
&self.triple
}
fn flags(&self) -> &settings::Flags {

View File

@@ -50,7 +50,6 @@ use crate::ir;
#[cfg(feature = "unwind")]
use crate::isa::unwind::systemv::RegisterMappingError;
use crate::machinst::{MachBackend, UnwindInfoKind};
use crate::result::CodegenResult;
use crate::settings;
use crate::settings::SetResult;
use alloc::{boxed::Box, vec::Vec};
@@ -237,18 +236,6 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
/// IntCC condition for Unsigned Addition Overflow (Carry).
fn unsigned_add_overflow_condition(&self) -> ir::condcodes::IntCC;
/// Creates unwind information for the function.
///
/// Returns `None` if there is no unwind information for the function.
#[cfg(feature = "unwind")]
fn create_unwind_info(
&self,
_func: &ir::Function,
) -> CodegenResult<Option<unwind::UnwindInfo>> {
// By default, an ISA has no unwind information
Ok(None)
}
/// Creates a new System V Common Information Entry for the ISA.
///
/// Returns `None` if the ISA does not support System V unwind information.
@@ -258,10 +245,8 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
None
}
/// Get the new-style MachBackend, if this is an adapter around one.
fn get_mach_backend(&self) -> Option<&dyn MachBackend> {
None
}
/// Get the new-style MachBackend.
fn get_mach_backend(&self) -> &dyn MachBackend;
}
/// Methods implemented for free for target ISA!

View File

@@ -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);

View File

@@ -101,8 +101,8 @@ impl MachBackend for S390xBackend {
"s390x"
}
fn triple(&self) -> Triple {
self.triple.clone()
fn triple(&self) -> &Triple {
&self.triple
}
fn flags(&self) -> &shared_settings::Flags {

View File

@@ -68,10 +68,6 @@ impl CodeSink for TestCodeSink {
fn trap(&mut self, _code: TrapCode, _srcloc: SourceLoc) {}
fn begin_jumptables(&mut self) {}
fn begin_rodata(&mut self) {}
fn end_codegen(&mut self) {}
fn add_call_site(&mut self, _opcode: Opcode, _srcloc: SourceLoc) {}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -98,8 +98,8 @@ impl MachBackend for X64Backend {
"x64"
}
fn triple(&self) -> Triple {
self.triple.clone()
fn triple(&self) -> &Triple {
&self.triple
}
fn reg_universe(&self) -> &RealRegUniverse {