Merge pull request #3639 from bjorn3/machinst_cleanups
Various cleanups around machinst
This commit is contained in:
@@ -14,16 +14,13 @@ use target_lexicon::Triple;
|
||||
/// A wrapper around a `MachBackend` that provides a `TargetIsa` impl.
|
||||
pub struct TargetIsaAdapter {
|
||||
backend: Box<dyn MachBackend + Send + Sync + 'static>,
|
||||
triple: Triple,
|
||||
}
|
||||
|
||||
impl TargetIsaAdapter {
|
||||
/// Create a new `TargetIsa` wrapper around a `MachBackend`.
|
||||
pub fn new<B: MachBackend + Send + Sync + 'static>(backend: B) -> TargetIsaAdapter {
|
||||
let triple = backend.triple();
|
||||
TargetIsaAdapter {
|
||||
backend: Box::new(backend),
|
||||
triple,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +41,7 @@ impl TargetIsa for TargetIsaAdapter {
|
||||
}
|
||||
|
||||
fn triple(&self) -> &Triple {
|
||||
&self.triple
|
||||
self.backend.triple()
|
||||
}
|
||||
|
||||
fn flags(&self) -> &Flags {
|
||||
@@ -55,8 +52,8 @@ impl TargetIsa for TargetIsaAdapter {
|
||||
self.backend.isa_flags()
|
||||
}
|
||||
|
||||
fn get_mach_backend(&self) -> Option<&dyn MachBackend> {
|
||||
Some(&*self.backend)
|
||||
fn get_mach_backend(&self) -> &dyn MachBackend {
|
||||
&*self.backend
|
||||
}
|
||||
|
||||
fn unsigned_add_overflow_condition(&self) -> ir::condcodes::IntCC {
|
||||
|
||||
@@ -1460,8 +1460,6 @@ impl MachBufferFinalized {
|
||||
sink.put1(*byte);
|
||||
}
|
||||
|
||||
sink.begin_jumptables();
|
||||
sink.begin_rodata();
|
||||
sink.end_codegen();
|
||||
}
|
||||
|
||||
@@ -2091,8 +2089,6 @@ mod test {
|
||||
fn trap(&mut self, t: TrapCode, _: SourceLoc) {
|
||||
self.traps.push((self.offset, t));
|
||||
}
|
||||
fn begin_jumptables(&mut self) {}
|
||||
fn begin_rodata(&mut self) {}
|
||||
fn end_codegen(&mut self) {}
|
||||
fn add_call_site(&mut self, op: Opcode, _: SourceLoc) {
|
||||
self.callsites.push((self.offset, op));
|
||||
|
||||
@@ -310,20 +310,13 @@ pub trait MachInstEmit: MachInst {
|
||||
/// Persistent state carried across `emit` invocations.
|
||||
type State: MachInstEmitState<Self>;
|
||||
/// Constant information used in `emit` invocations.
|
||||
type Info: MachInstEmitInfo;
|
||||
type Info;
|
||||
/// Emit the instruction.
|
||||
fn emit(&self, code: &mut MachBuffer<Self>, info: &Self::Info, state: &mut Self::State);
|
||||
/// Pretty-print the instruction.
|
||||
fn pretty_print(&self, mb_rru: Option<&RealRegUniverse>, state: &mut Self::State) -> String;
|
||||
}
|
||||
|
||||
/// Constant information used to emit an instruction.
|
||||
pub trait MachInstEmitInfo {
|
||||
/// Return the target-independent settings used for the compilation of this
|
||||
/// particular function.
|
||||
fn flags(&self) -> &Flags;
|
||||
}
|
||||
|
||||
/// A trait describing the emission state carried between MachInsts when
|
||||
/// emitting a function body.
|
||||
pub trait MachInstEmitState<I: MachInst>: Default + Clone + Debug {
|
||||
@@ -367,12 +360,8 @@ pub struct MachCompileResult {
|
||||
impl MachCompileResult {
|
||||
/// Get a `CodeInfo` describing section sizes from this compilation result.
|
||||
pub fn code_info(&self) -> CodeInfo {
|
||||
let code_size = self.buffer.total_size();
|
||||
CodeInfo {
|
||||
code_size,
|
||||
jumptables_size: 0,
|
||||
rodata_size: 0,
|
||||
total_size: code_size,
|
||||
total_size: self.buffer.total_size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,7 +383,7 @@ pub trait MachBackend {
|
||||
fn isa_flags(&self) -> Vec<settings::Value>;
|
||||
|
||||
/// Return triple for this backend.
|
||||
fn triple(&self) -> Triple;
|
||||
fn triple(&self) -> &Triple;
|
||||
|
||||
/// Return name for this backend.
|
||||
fn name(&self) -> &'static str;
|
||||
|
||||
Reference in New Issue
Block a user