Add clif-util compile option to output object file (#5493)
* add clif-util compile option to output object file * switch from a box to a borrow * update objectmodule tests to use borrowed isa * put targetisa into an arc
This commit is contained in:
@@ -53,7 +53,7 @@ use crate::machinst::{CompiledCode, CompiledCodeStencil, TextSectionBuilder, Unw
|
||||
use crate::settings;
|
||||
use crate::settings::SetResult;
|
||||
use crate::CodegenResult;
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
use core::fmt;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
use target_lexicon::{triple, Architecture, PointerWidth, Triple};
|
||||
@@ -142,14 +142,16 @@ impl fmt::Display for LookupError {
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of a polymorphic TargetISA object which is 'static.
|
||||
pub type OwnedTargetIsa = Arc<dyn TargetIsa>;
|
||||
|
||||
/// Builder for a `TargetIsa`.
|
||||
/// Modify the ISA-specific settings before creating the `TargetIsa` trait object with `finish`.
|
||||
#[derive(Clone)]
|
||||
pub struct Builder {
|
||||
triple: Triple,
|
||||
setup: settings::Builder,
|
||||
constructor:
|
||||
fn(Triple, settings::Flags, settings::Builder) -> CodegenResult<Box<dyn TargetIsa>>,
|
||||
constructor: fn(Triple, settings::Flags, settings::Builder) -> CodegenResult<OwnedTargetIsa>,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
@@ -169,7 +171,7 @@ impl Builder {
|
||||
/// flags are inconsistent or incompatible: for example, some
|
||||
/// platform-independent features, like general SIMD support, may
|
||||
/// need certain ISA extensions to be enabled.
|
||||
pub fn finish(self, shared_flags: settings::Flags) -> CodegenResult<Box<dyn TargetIsa>> {
|
||||
pub fn finish(self, shared_flags: settings::Flags) -> CodegenResult<OwnedTargetIsa> {
|
||||
(self.constructor)(self.triple, shared_flags, self.setup)
|
||||
}
|
||||
}
|
||||
@@ -297,6 +299,14 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
|
||||
|
||||
/// The function alignment required by this ISA.
|
||||
fn function_alignment(&self) -> u32;
|
||||
|
||||
/// Create a polymorphic TargetIsa from this specific implementation.
|
||||
fn wrapped(self) -> OwnedTargetIsa
|
||||
where
|
||||
Self: Sized + 'static,
|
||||
{
|
||||
Arc::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Methods implemented for free for target ISA!
|
||||
|
||||
Reference in New Issue
Block a user