Add compile_function method to TargetIsa

This commit is contained in:
bjorn3
2022-01-04 19:36:49 +01:00
parent d50f27e8f9
commit 9eba87a6c8
3 changed files with 19 additions and 4 deletions

View File

@@ -167,8 +167,7 @@ impl Context {
self.remove_constant_phis(isa)?;
let backend = isa.get_mach_backend();
let result = backend.compile_function(&self.func, self.want_disasm)?;
let result = isa.compile_function(&self.func, self.want_disasm)?;
let info = result.code_info();
self.mach_compile_result = Some(result);
Ok(info)

View File

@@ -46,12 +46,13 @@
pub use crate::isa::call_conv::CallConv;
use crate::flowgraph;
use crate::ir;
use crate::ir::{self, Function};
#[cfg(feature = "unwind")]
use crate::isa::unwind::systemv::RegisterMappingError;
use crate::machinst::{MachBackend, UnwindInfoKind};
use crate::machinst::{MachBackend, MachCompileResult, UnwindInfoKind};
use crate::settings;
use crate::settings::SetResult;
use crate::CodegenResult;
use alloc::{boxed::Box, vec::Vec};
use core::fmt;
use core::fmt::{Debug, Formatter};
@@ -227,6 +228,13 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
/// Get the ISA-dependent flag values that were used to make this trait object.
fn isa_flags(&self) -> Vec<settings::Value>;
/// Compile the given function.
fn compile_function(
&self,
func: &Function,
want_disasm: bool,
) -> CodegenResult<MachCompileResult>;
#[cfg(feature = "unwind")]
/// Map a regalloc::Reg to its corresponding DWARF register.
fn map_regalloc_reg_to_dwarf(&self, _: ::regalloc::Reg) -> Result<u16, RegisterMappingError> {

View File

@@ -52,6 +52,14 @@ impl TargetIsa for TargetIsaAdapter {
self.backend.isa_flags()
}
fn compile_function(
&self,
func: &Function,
want_disasm: bool,
) -> CodegenResult<MachCompileResult> {
self.backend.compile_function(func, want_disasm)
}
fn get_mach_backend(&self) -> &dyn MachBackend {
&*self.backend
}