Remove MachBackend
It is identical to TargetIsa
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
use crate::ir::condcodes::IntCC;
|
||||
use crate::ir::Function;
|
||||
use crate::isa::aarch64::settings as aarch64_settings;
|
||||
use crate::isa::Builder as IsaBuilder;
|
||||
use crate::isa::{Builder as IsaBuilder, TargetIsa};
|
||||
use crate::machinst::{
|
||||
compile, MachBackend, MachCompileResult, MachTextSectionBuilder, TargetIsaAdapter,
|
||||
TextSectionBuilder, VCode,
|
||||
compile, MachCompileResult, MachTextSectionBuilder, TextSectionBuilder, VCode,
|
||||
};
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings as shared_settings;
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::fmt;
|
||||
use regalloc::{PrettyPrint, RealRegUniverse};
|
||||
use target_lexicon::{Aarch64Architecture, Architecture, Triple};
|
||||
|
||||
@@ -62,7 +62,7 @@ impl AArch64Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl MachBackend for AArch64Backend {
|
||||
impl TargetIsa for AArch64Backend {
|
||||
fn compile_function(
|
||||
&self,
|
||||
func: &Function,
|
||||
@@ -153,6 +153,16 @@ impl MachBackend for AArch64Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for AArch64Backend {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("MachBackend")
|
||||
.field("name", &self.name())
|
||||
.field("triple", &self.triple())
|
||||
.field("flags", &format!("{}", self.flags()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `isa::Builder`.
|
||||
pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
assert!(triple.architecture == Architecture::Aarch64(Aarch64Architecture::Aarch64));
|
||||
@@ -162,7 +172,7 @@ pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
constructor: |triple, shared_flags, builder| {
|
||||
let isa_flags = aarch64_settings::Flags::new(&shared_flags, builder);
|
||||
let backend = AArch64Backend::new_with_flags(triple, shared_flags, isa_flags);
|
||||
Box::new(TargetIsaAdapter::new(backend))
|
||||
Box::new(backend)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
use crate::ir::condcodes::IntCC;
|
||||
use crate::ir::Function;
|
||||
use crate::isa::Builder as IsaBuilder;
|
||||
use crate::isa::{Builder as IsaBuilder, TargetIsa};
|
||||
use crate::machinst::{
|
||||
compile, MachBackend, MachCompileResult, MachTextSectionBuilder, TargetIsaAdapter,
|
||||
TextSectionBuilder, VCode,
|
||||
compile, MachCompileResult, MachTextSectionBuilder, TextSectionBuilder, VCode,
|
||||
};
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings;
|
||||
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::fmt;
|
||||
use regalloc::{PrettyPrint, RealRegUniverse};
|
||||
use target_lexicon::{Architecture, ArmArchitecture, Triple};
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Arm32Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl MachBackend for Arm32Backend {
|
||||
impl TargetIsa for Arm32Backend {
|
||||
fn compile_function(
|
||||
&self,
|
||||
func: &Function,
|
||||
@@ -100,6 +100,15 @@ impl MachBackend for Arm32Backend {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
fn emit_unwind_info(
|
||||
&self,
|
||||
_result: &MachCompileResult,
|
||||
_kind: crate::machinst::UnwindInfoKind,
|
||||
) -> CodegenResult<Option<crate::isa::unwind::UnwindInfo>> {
|
||||
Ok(None) // FIXME implement this
|
||||
}
|
||||
|
||||
fn unsigned_add_overflow_condition(&self) -> IntCC {
|
||||
// Carry flag set.
|
||||
IntCC::UnsignedGreaterThanOrEqual
|
||||
@@ -110,6 +119,16 @@ impl MachBackend for Arm32Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Arm32Backend {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("MachBackend")
|
||||
.field("name", &self.name())
|
||||
.field("triple", &self.triple())
|
||||
.field("flags", &format!("{}", self.flags()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `isa::Builder`.
|
||||
pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
assert!(match triple.architecture {
|
||||
@@ -123,7 +142,7 @@ pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
setup: settings::builder(),
|
||||
constructor: |triple, shared_flags, _| {
|
||||
let backend = Arm32Backend::new_with_flags(triple, shared_flags);
|
||||
Box::new(TargetIsaAdapter::new(backend))
|
||||
Box::new(backend)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ use crate::flowgraph;
|
||||
use crate::ir::{self, Function};
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::isa::unwind::systemv::RegisterMappingError;
|
||||
use crate::machinst::{MachBackend, MachCompileResult, TextSectionBuilder, UnwindInfoKind};
|
||||
use crate::machinst::{MachCompileResult, TextSectionBuilder, UnwindInfoKind};
|
||||
use crate::settings;
|
||||
use crate::settings::SetResult;
|
||||
use crate::CodegenResult;
|
||||
@@ -273,9 +273,6 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
|
||||
/// will be "labeled" or might have calls between them, typically the number
|
||||
/// of defined functions in the object file.
|
||||
fn text_section_builder(&self, num_labeled_funcs: u32) -> Box<dyn TextSectionBuilder>;
|
||||
|
||||
/// Get the new-style MachBackend.
|
||||
fn get_mach_backend(&self) -> &dyn MachBackend;
|
||||
}
|
||||
|
||||
/// Methods implemented for free for target ISA!
|
||||
|
||||
@@ -5,15 +5,15 @@ use crate::ir::Function;
|
||||
use crate::isa::s390x::settings as s390x_settings;
|
||||
#[cfg(feature = "unwind")]
|
||||
use crate::isa::unwind::systemv::RegisterMappingError;
|
||||
use crate::isa::Builder as IsaBuilder;
|
||||
use crate::isa::{Builder as IsaBuilder, TargetIsa};
|
||||
use crate::machinst::{
|
||||
compile, MachBackend, MachCompileResult, MachTextSectionBuilder, TargetIsaAdapter,
|
||||
TextSectionBuilder, VCode,
|
||||
compile, MachCompileResult, MachTextSectionBuilder, TextSectionBuilder, VCode,
|
||||
};
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings as shared_settings;
|
||||
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::fmt;
|
||||
|
||||
use regalloc::{PrettyPrint, RealRegUniverse, Reg};
|
||||
use target_lexicon::{Architecture, Triple};
|
||||
@@ -65,7 +65,7 @@ impl S390xBackend {
|
||||
}
|
||||
}
|
||||
|
||||
impl MachBackend for S390xBackend {
|
||||
impl TargetIsa for S390xBackend {
|
||||
fn compile_function(
|
||||
&self,
|
||||
func: &Function,
|
||||
@@ -151,7 +151,7 @@ impl MachBackend for S390xBackend {
|
||||
}
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
fn map_reg_to_dwarf(&self, reg: Reg) -> Result<u16, RegisterMappingError> {
|
||||
fn map_regalloc_reg_to_dwarf(&self, reg: Reg) -> Result<u16, RegisterMappingError> {
|
||||
inst::unwind::systemv::map_reg(reg).map(|reg| reg.0)
|
||||
}
|
||||
|
||||
@@ -160,6 +160,16 @@ impl MachBackend for S390xBackend {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for S390xBackend {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("MachBackend")
|
||||
.field("name", &self.name())
|
||||
.field("triple", &self.triple())
|
||||
.field("flags", &format!("{}", self.flags()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `isa::Builder`.
|
||||
pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
assert!(triple.architecture == Architecture::S390x);
|
||||
@@ -169,7 +179,7 @@ pub fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
constructor: |triple, shared_flags, builder| {
|
||||
let isa_flags = s390x_settings::Flags::new(&shared_flags, builder);
|
||||
let backend = S390xBackend::new_with_flags(triple, shared_flags, isa_flags);
|
||||
Box::new(TargetIsaAdapter::new(backend))
|
||||
Box::new(backend)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ use crate::isa::unwind::systemv;
|
||||
use crate::isa::x64::{inst::regs::create_reg_universe_systemv, settings as x64_settings};
|
||||
use crate::isa::Builder as IsaBuilder;
|
||||
use crate::machinst::{
|
||||
compile, MachBackend, MachCompileResult, MachTextSectionBuilder, TargetIsaAdapter,
|
||||
TextSectionBuilder, VCode,
|
||||
compile, MachCompileResult, MachTextSectionBuilder, TextSectionBuilder, VCode,
|
||||
};
|
||||
use crate::result::CodegenResult;
|
||||
use crate::settings::{self as shared_settings, Flags};
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::fmt;
|
||||
|
||||
use regalloc::{PrettyPrint, RealRegUniverse, Reg};
|
||||
use target_lexicon::Triple;
|
||||
@@ -54,7 +54,7 @@ impl X64Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl MachBackend for X64Backend {
|
||||
impl TargetIsa for X64Backend {
|
||||
fn compile_function(
|
||||
&self,
|
||||
func: &Function,
|
||||
@@ -142,7 +142,7 @@ impl MachBackend for X64Backend {
|
||||
}
|
||||
|
||||
#[cfg(feature = "unwind")]
|
||||
fn map_reg_to_dwarf(&self, reg: Reg) -> Result<u16, systemv::RegisterMappingError> {
|
||||
fn map_regalloc_reg_to_dwarf(&self, reg: Reg) -> Result<u16, systemv::RegisterMappingError> {
|
||||
inst::unwind::systemv::map_reg(reg).map(|reg| reg.0)
|
||||
}
|
||||
|
||||
@@ -151,6 +151,16 @@ impl MachBackend for X64Backend {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for X64Backend {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("MachBackend")
|
||||
.field("name", &self.name())
|
||||
.field("triple", &self.triple())
|
||||
.field("flags", &format!("{}", self.flags()))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `isa::Builder`.
|
||||
pub(crate) fn isa_builder(triple: Triple) -> IsaBuilder {
|
||||
IsaBuilder {
|
||||
@@ -167,5 +177,5 @@ fn isa_constructor(
|
||||
) -> Box<dyn TargetIsa> {
|
||||
let isa_flags = x64_settings::Flags::new(&shared_flags, builder);
|
||||
let backend = X64Backend::new_with_flags(triple, shared_flags, isa_flags);
|
||||
Box::new(TargetIsaAdapter::new(backend))
|
||||
Box::new(backend)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user