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

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