diff --git a/cranelift/bforest/src/path.rs b/cranelift/bforest/src/path.rs index 1df66b7ef7..a55de6b2ae 100644 --- a/cranelift/bforest/src/path.rs +++ b/cranelift/bforest/src/path.rs @@ -49,7 +49,7 @@ impl Path { key: F::Key, root: Node, pool: &NodePool, - comp: &Comparator, + comp: &dyn Comparator, ) -> Option { let mut node = root; for level in 0.. { diff --git a/cranelift/codegen/meta/src/gen_legalizer.rs b/cranelift/codegen/meta/src/gen_legalizer.rs index 45221b1ffd..149e29f926 100644 --- a/cranelift/codegen/meta/src/gen_legalizer.rs +++ b/cranelift/codegen/meta/src/gen_legalizer.rs @@ -410,7 +410,7 @@ fn gen_transform_group<'a>( fmt.line("inst: crate::ir::Inst,"); fmt.line("func: &mut crate::ir::Function,"); fmt.line("cfg: &mut crate::flowgraph::ControlFlowGraph,"); - fmt.line("isa: &crate::isa::TargetIsa,"); + fmt.line("isa: &dyn crate::isa::TargetIsa,"); }); fmtln!(fmt, ") -> bool {"); diff --git a/cranelift/codegen/src/binemit/memorysink.rs b/cranelift/codegen/src/binemit/memorysink.rs index 170e1a95e9..b70b4a2c86 100644 --- a/cranelift/codegen/src/binemit/memorysink.rs +++ b/cranelift/codegen/src/binemit/memorysink.rs @@ -34,8 +34,8 @@ pub struct MemoryCodeSink<'a> { data: *mut u8, /// Offset is isize because its major consumer needs it in that form. offset: isize, - relocs: &'a mut RelocSink, - traps: &'a mut TrapSink, + relocs: &'a mut dyn RelocSink, + traps: &'a mut dyn TrapSink, /// Information about the generated code and read-only data. pub info: CodeInfo, } @@ -45,7 +45,11 @@ impl<'a> MemoryCodeSink<'a> { /// /// This function is unsafe since `MemoryCodeSink` does not perform bounds checking on the /// memory buffer, and it can't guarantee that the `data` pointer is valid. - pub unsafe fn new(data: *mut u8, relocs: &'a mut RelocSink, traps: &'a mut TrapSink) -> Self { + pub unsafe fn new( + data: *mut u8, + relocs: &'a mut dyn RelocSink, + traps: &'a mut dyn TrapSink, + ) -> Self { Self { data, offset: 0, diff --git a/cranelift/codegen/src/binemit/relaxation.rs b/cranelift/codegen/src/binemit/relaxation.rs index d1b5815e7c..1e84f2f4b9 100644 --- a/cranelift/codegen/src/binemit/relaxation.rs +++ b/cranelift/codegen/src/binemit/relaxation.rs @@ -40,7 +40,7 @@ use log::debug; /// Relax branches and compute the final layout of EBB headers in `func`. /// /// Fill in the `func.offsets` table so the function is ready for binary emission. -pub fn relax_branches(func: &mut Function, isa: &TargetIsa) -> CodegenResult { +pub fn relax_branches(func: &mut Function, isa: &dyn TargetIsa) -> CodegenResult { let _tt = timing::relax_branches(); let encinfo = isa.encoding_info(); @@ -174,7 +174,7 @@ fn relax_branch( offset: CodeOffset, dest_offset: CodeOffset, encinfo: &EncInfo, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> CodeOffset { let inst = cur.current_inst().unwrap(); debug!( diff --git a/cranelift/codegen/src/binemit/shrink.rs b/cranelift/codegen/src/binemit/shrink.rs index b3cfdfa6d1..281a93ae31 100644 --- a/cranelift/codegen/src/binemit/shrink.rs +++ b/cranelift/codegen/src/binemit/shrink.rs @@ -13,7 +13,7 @@ use crate::timing; use log::debug; /// Pick the smallest valid encodings for instructions. -pub fn shrink_instructions(func: &mut Function, isa: &TargetIsa) { +pub fn shrink_instructions(func: &mut Function, isa: &dyn TargetIsa) { let _tt = timing::shrink_instructions(); let encinfo = isa.encoding_info(); diff --git a/cranelift/codegen/src/cfg_printer.rs b/cranelift/codegen/src/cfg_printer.rs index 6a9932febe..e3ce37e731 100644 --- a/cranelift/codegen/src/cfg_printer.rs +++ b/cranelift/codegen/src/cfg_printer.rs @@ -23,14 +23,14 @@ impl<'a> CFGPrinter<'a> { } /// Write the CFG for this function to `w`. - pub fn write(&self, w: &mut Write) -> Result { + pub fn write(&self, w: &mut dyn Write) -> Result { self.header(w)?; self.ebb_nodes(w)?; self.cfg_connections(w)?; writeln!(w, "}}") } - fn header(&self, w: &mut Write) -> Result { + fn header(&self, w: &mut dyn Write) -> Result { writeln!(w, "digraph \"{}\" {{", self.func.name)?; if let Some(entry) = self.func.layout.entry_block() { writeln!(w, " {{rank=min; {}}}", entry)?; @@ -38,7 +38,7 @@ impl<'a> CFGPrinter<'a> { Ok(()) } - fn ebb_nodes(&self, w: &mut Write) -> Result { + fn ebb_nodes(&self, w: &mut dyn Write) -> Result { for ebb in &self.func.layout { write!(w, " {} [shape=record, label=\"{{{}", ebb, ebb)?; // Add all outgoing branch instructions to the label. @@ -62,7 +62,7 @@ impl<'a> CFGPrinter<'a> { Ok(()) } - fn cfg_connections(&self, w: &mut Write) -> Result { + fn cfg_connections(&self, w: &mut dyn Write) -> Result { for ebb in &self.func.layout { for BasicBlock { ebb: parent, inst } in self.cfg.pred_iter(ebb) { writeln!(w, " {}:{} -> {}", parent, inst, ebb)?; diff --git a/cranelift/codegen/src/context.rs b/cranelift/codegen/src/context.rs index 369b956a67..64c382cb23 100644 --- a/cranelift/codegen/src/context.rs +++ b/cranelift/codegen/src/context.rs @@ -96,10 +96,10 @@ impl Context { /// Returns information about the function's code and read-only data. pub fn compile_and_emit( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, mem: &mut Vec, - relocs: &mut RelocSink, - traps: &mut TrapSink, + relocs: &mut dyn RelocSink, + traps: &mut dyn TrapSink, ) -> CodegenResult { let info = self.compile(isa)?; let old_len = mem.len(); @@ -117,7 +117,7 @@ impl Context { /// code sink. /// /// Returns information about the function's code and read-only data. - pub fn compile(&mut self, isa: &TargetIsa) -> CodegenResult { + pub fn compile(&mut self, isa: &dyn TargetIsa) -> CodegenResult { let _tt = timing::compile(); self.verify_if(isa)?; @@ -164,10 +164,10 @@ impl Context { /// Returns information about the emitted code and data. pub unsafe fn emit_to_memory( &self, - isa: &TargetIsa, + isa: &dyn TargetIsa, mem: *mut u8, - relocs: &mut RelocSink, - traps: &mut TrapSink, + relocs: &mut dyn RelocSink, + traps: &mut dyn TrapSink, ) -> CodeInfo { let _tt = timing::binemit(); let mut sink = MemoryCodeSink::new(mem, relocs, traps); @@ -199,7 +199,7 @@ impl Context { } /// Run the locations verifier on the function. - pub fn verify_locations(&self, isa: &TargetIsa) -> VerifierResult<()> { + pub fn verify_locations(&self, isa: &dyn TargetIsa) -> VerifierResult<()> { let mut errors = VerifierErrors::default(); let _ = verify_locations(isa, &self.func, None, &mut errors); @@ -211,7 +211,7 @@ impl Context { } /// Run the locations verifier only if the `enable_verifier` setting is true. - pub fn verify_locations_if(&self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn verify_locations_if(&self, isa: &dyn TargetIsa) -> CodegenResult<()> { if isa.flags().enable_verifier() { self.verify_locations(isa)?; } @@ -226,20 +226,20 @@ impl Context { } /// Perform pre-legalization rewrites on the function. - pub fn preopt(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn preopt(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { do_preopt(&mut self.func, &mut self.cfg); self.verify_if(isa)?; Ok(()) } /// Perform NaN canonicalizing rewrites on the function. - pub fn canonicalize_nans(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn canonicalize_nans(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { do_nan_canonicalization(&mut self.func); self.verify_if(isa) } /// Run the legalizer for `isa` on the function. - pub fn legalize(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn legalize(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { // Legalization invalidates the domtree and loop_analysis by mutating the CFG. // TODO: Avoid doing this when legalization doesn't actually mutate the CFG. self.domtree.clear(); @@ -249,7 +249,7 @@ impl Context { } /// Perform post-legalization rewrites on the function. - pub fn postopt(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn postopt(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { do_postopt(&mut self.func, isa); self.verify_if(isa)?; Ok(()) @@ -284,7 +284,7 @@ impl Context { } /// Perform LICM on the function. - pub fn licm(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn licm(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { do_licm( isa, &mut self.func, @@ -305,13 +305,13 @@ impl Context { } /// Run the register allocator. - pub fn regalloc(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn regalloc(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { self.regalloc .run(isa, &mut self.func, &self.cfg, &mut self.domtree) } /// Insert prologue and epilogues after computing the stack frame layout. - pub fn prologue_epilogue(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn prologue_epilogue(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { isa.prologue_epilogue(&mut self.func)?; self.verify_if(isa)?; self.verify_locations_if(isa)?; @@ -319,7 +319,7 @@ impl Context { } /// Run the instruction shrinking pass. - pub fn shrink_instructions(&mut self, isa: &TargetIsa) -> CodegenResult<()> { + pub fn shrink_instructions(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> { shrink_instructions(&mut self.func, isa); self.verify_if(isa)?; self.verify_locations_if(isa)?; @@ -328,7 +328,7 @@ impl Context { /// Run the branch relaxation pass and return information about the function's code and /// read-only data. - pub fn relax_branches(&mut self, isa: &TargetIsa) -> CodegenResult { + pub fn relax_branches(&mut self, isa: &dyn TargetIsa) -> CodegenResult { let info = relax_branches(&mut self.func, isa)?; self.verify_if(isa)?; self.verify_locations_if(isa)?; @@ -336,7 +336,10 @@ impl Context { } /// Builds ranges and location for specified value labels. - pub fn build_value_labels_ranges(&self, isa: &TargetIsa) -> CodegenResult { + pub fn build_value_labels_ranges( + &self, + isa: &dyn TargetIsa, + ) -> CodegenResult { Ok(build_value_labels_ranges::( &self.func, &self.regalloc, diff --git a/cranelift/codegen/src/cursor.rs b/cranelift/codegen/src/cursor.rs index ba7bc92b13..dbb459ed7a 100644 --- a/cranelift/codegen/src/cursor.rs +++ b/cranelift/codegen/src/cursor.rs @@ -657,12 +657,12 @@ pub struct EncCursor<'f> { pub func: &'f mut ir::Function, /// The target ISA that will be used to encode instructions. - pub isa: &'f TargetIsa, + pub isa: &'f dyn TargetIsa, } impl<'f> EncCursor<'f> { /// Create a new `EncCursor` pointing nowhere. - pub fn new(func: &'f mut ir::Function, isa: &'f TargetIsa) -> Self { + pub fn new(func: &'f mut ir::Function, isa: &'f dyn TargetIsa) -> Self { Self { pos: CursorPosition::Nowhere, srcloc: Default::default(), diff --git a/cranelift/codegen/src/ir/dfg.rs b/cranelift/codegen/src/ir/dfg.rs index 362a6cd772..d26abaa3e7 100644 --- a/cranelift/codegen/src/ir/dfg.rs +++ b/cranelift/codegen/src/ir/dfg.rs @@ -426,7 +426,7 @@ impl DataFlowGraph { } /// Returns an object that displays `inst`. - pub fn display_inst<'a, I: Into>>( + pub fn display_inst<'a, I: Into>>( &'a self, inst: Inst, isa: I, @@ -909,7 +909,7 @@ impl EbbData { } /// Object that can display an instruction. -pub struct DisplayInst<'a>(&'a DataFlowGraph, Option<&'a TargetIsa>, Inst); +pub struct DisplayInst<'a>(&'a DataFlowGraph, Option<&'a dyn TargetIsa>, Inst); impl<'a> fmt::Display for DisplayInst<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/cranelift/codegen/src/ir/entities.rs b/cranelift/codegen/src/ir/entities.rs index a0b694ad84..2c05fbc84b 100644 --- a/cranelift/codegen/src/ir/entities.rs +++ b/cranelift/codegen/src/ir/entities.rs @@ -238,7 +238,7 @@ impl fmt::Display for AnyEntity { impl fmt::Debug for AnyEntity { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (self as &fmt::Display).fmt(f) + (self as &dyn fmt::Display).fmt(f) } } diff --git a/cranelift/codegen/src/ir/function.rs b/cranelift/codegen/src/ir/function.rs index 6a1d4cdd0d..f4b62dc59c 100644 --- a/cranelift/codegen/src/ir/function.rs +++ b/cranelift/codegen/src/ir/function.rs @@ -155,7 +155,10 @@ impl Function { } /// Return an object that can display this function with correct ISA-specific annotations. - pub fn display<'a, I: Into>>(&'a self, isa: I) -> DisplayFunction<'a> { + pub fn display<'a, I: Into>>( + &'a self, + isa: I, + ) -> DisplayFunction<'a> { DisplayFunction(self, isa.into().into()) } @@ -202,13 +205,13 @@ impl Function { } /// Wrapper around `encode` which assigns `inst` the resulting encoding. - pub fn update_encoding(&mut self, inst: ir::Inst, isa: &TargetIsa) -> Result<(), Legalize> { + pub fn update_encoding(&mut self, inst: ir::Inst, isa: &dyn TargetIsa) -> Result<(), Legalize> { self.encode(inst, isa).map(|e| self.encodings[inst] = e) } /// Wrapper around `TargetIsa::encode` for encoding an existing instruction /// in the `Function`. - pub fn encode(&self, inst: ir::Inst, isa: &TargetIsa) -> Result { + pub fn encode(&self, inst: ir::Inst, isa: &dyn TargetIsa) -> Result { isa.encode(&self, &self.dfg[inst], self.dfg.ctrl_typevar(inst)) } @@ -221,7 +224,7 @@ impl Function { /// Additional annotations for function display. pub struct DisplayFunctionAnnotations<'a> { /// Enable ISA annotations. - pub isa: Option<&'a TargetIsa>, + pub isa: Option<&'a dyn TargetIsa>, /// Enable value labels annotations. pub value_ranges: Option<&'a ValueLabelsRanges>, @@ -237,8 +240,8 @@ impl<'a> DisplayFunctionAnnotations<'a> { } } -impl<'a> From> for DisplayFunctionAnnotations<'a> { - fn from(isa: Option<&'a TargetIsa>) -> DisplayFunctionAnnotations { +impl<'a> From> for DisplayFunctionAnnotations<'a> { + fn from(isa: Option<&'a dyn TargetIsa>) -> DisplayFunctionAnnotations { DisplayFunctionAnnotations { isa, value_ranges: None, diff --git a/cranelift/codegen/src/ir/globalvalue.rs b/cranelift/codegen/src/ir/globalvalue.rs index b67c26e1a2..6c7b62aab9 100644 --- a/cranelift/codegen/src/ir/globalvalue.rs +++ b/cranelift/codegen/src/ir/globalvalue.rs @@ -76,7 +76,7 @@ impl GlobalValueData { } /// Return the type of this global. - pub fn global_type(&self, isa: &TargetIsa) -> Type { + pub fn global_type(&self, isa: &dyn TargetIsa) -> Type { match *self { GlobalValueData::VMContext { .. } | GlobalValueData::Symbol { .. } => { isa.pointer_type() diff --git a/cranelift/codegen/src/ir/libcall.rs b/cranelift/codegen/src/ir/libcall.rs index 3617f906d6..275e22a91f 100644 --- a/cranelift/codegen/src/ir/libcall.rs +++ b/cranelift/codegen/src/ir/libcall.rs @@ -107,7 +107,7 @@ pub fn get_libcall_funcref( libcall: LibCall, func: &mut Function, inst: Inst, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> FuncRef { find_funcref(libcall, func).unwrap_or_else(|| make_funcref_for_inst(libcall, func, inst, isa)) } @@ -119,7 +119,7 @@ pub fn get_probestack_funcref( func: &mut Function, reg_type: Type, arg_reg: RegUnit, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> FuncRef { find_funcref(LibCall::Probestack, func) .unwrap_or_else(|| make_funcref_for_probestack(func, reg_type, arg_reg, isa)) @@ -147,7 +147,7 @@ fn make_funcref_for_probestack( func: &mut Function, reg_type: Type, arg_reg: RegUnit, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> FuncRef { let mut sig = Signature::new(CallConv::Probestack); let rax = AbiParam::special_reg(reg_type, ArgumentPurpose::Normal, arg_reg); @@ -163,7 +163,7 @@ fn make_funcref_for_inst( libcall: LibCall, func: &mut Function, inst: Inst, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> FuncRef { let mut sig = Signature::new(isa.default_call_conv()); for &v in func.dfg.inst_args(inst) { @@ -177,7 +177,12 @@ fn make_funcref_for_inst( } /// Create a funcref for `libcall`. -fn make_funcref(libcall: LibCall, func: &mut Function, sig: Signature, isa: &TargetIsa) -> FuncRef { +fn make_funcref( + libcall: LibCall, + func: &mut Function, + sig: Signature, + isa: &dyn TargetIsa, +) -> FuncRef { let sigref = func.import_signature(sig); func.import_function(ExtFuncData { diff --git a/cranelift/codegen/src/isa/arm32/mod.rs b/cranelift/codegen/src/isa/arm32/mod.rs index 7bede88f3c..d4e2f32255 100644 --- a/cranelift/codegen/src/isa/arm32/mod.rs +++ b/cranelift/codegen/src/isa/arm32/mod.rs @@ -40,7 +40,7 @@ fn isa_constructor( triple: Triple, shared_flags: shared_settings::Flags, builder: shared_settings::Builder, -) -> Box { +) -> Box { let level1 = match triple.architecture { Architecture::Thumbv6m | Architecture::Thumbv7em | Architecture::Thumbv7m => { &enc_tables::LEVEL1_T32[..] @@ -119,7 +119,7 @@ impl TargetIsa for Isa { func: &ir::Function, inst: ir::Inst, divert: &mut regalloc::RegDiversions, - sink: &mut CodeSink, + sink: &mut dyn CodeSink, ) { binemit::emit_inst(func, inst, divert, sink) } diff --git a/cranelift/codegen/src/isa/arm64/mod.rs b/cranelift/codegen/src/isa/arm64/mod.rs index 84277301c3..c24be19f69 100644 --- a/cranelift/codegen/src/isa/arm64/mod.rs +++ b/cranelift/codegen/src/isa/arm64/mod.rs @@ -39,7 +39,7 @@ fn isa_constructor( triple: Triple, shared_flags: shared_settings::Flags, builder: shared_settings::Builder, -) -> Box { +) -> Box { Box::new(Isa { triple, isa_flags: settings::Flags::new(&shared_flags, builder), @@ -106,7 +106,7 @@ impl TargetIsa for Isa { func: &ir::Function, inst: ir::Inst, divert: &mut regalloc::RegDiversions, - sink: &mut CodeSink, + sink: &mut dyn CodeSink, ) { binemit::emit_inst(func, inst, divert, sink) } diff --git a/cranelift/codegen/src/isa/mod.rs b/cranelift/codegen/src/isa/mod.rs index b3e4d81421..eb6b4d2650 100644 --- a/cranelift/codegen/src/isa/mod.rs +++ b/cranelift/codegen/src/isa/mod.rs @@ -141,13 +141,13 @@ pub enum LookupError { pub struct Builder { triple: Triple, setup: settings::Builder, - constructor: fn(Triple, settings::Flags, settings::Builder) -> Box, + constructor: fn(Triple, settings::Flags, settings::Builder) -> Box, } impl Builder { /// Combine the ISA-specific settings with the provided ISA-independent settings and allocate a /// fully configured `TargetIsa` trait object. - pub fn finish(self, shared_flags: settings::Flags) -> Box { + pub fn finish(self, shared_flags: settings::Flags) -> Box { (self.constructor)(self.triple, shared_flags, self.setup) } } @@ -167,7 +167,7 @@ impl settings::Configurable for Builder { /// /// The `Encodings` iterator returns a legalization function to call. pub type Legalize = - fn(ir::Inst, &mut ir::Function, &mut flowgraph::ControlFlowGraph, &TargetIsa) -> bool; + fn(ir::Inst, &mut ir::Function, &mut flowgraph::ControlFlowGraph, &dyn TargetIsa) -> bool; /// This struct provides information that a frontend may need to know about a target to /// produce Cranelift IR for the target. @@ -367,7 +367,7 @@ pub trait TargetIsa: fmt::Display + Sync { func: &ir::Function, inst: ir::Inst, divert: &mut regalloc::RegDiversions, - sink: &mut binemit::CodeSink, + sink: &mut dyn binemit::CodeSink, ); /// Emit a whole function into memory. diff --git a/cranelift/codegen/src/isa/riscv/mod.rs b/cranelift/codegen/src/isa/riscv/mod.rs index 60154cf162..3096ff69aa 100644 --- a/cranelift/codegen/src/isa/riscv/mod.rs +++ b/cranelift/codegen/src/isa/riscv/mod.rs @@ -40,7 +40,7 @@ fn isa_constructor( triple: Triple, shared_flags: shared_settings::Flags, builder: shared_settings::Builder, -) -> Box { +) -> Box { let level1 = match triple.pointer_width().unwrap() { PointerWidth::U16 => panic!("16-bit RISC-V unrecognized"), PointerWidth::U32 => &enc_tables::LEVEL1_RV32[..], @@ -113,7 +113,7 @@ impl TargetIsa for Isa { func: &ir::Function, inst: ir::Inst, divert: &mut regalloc::RegDiversions, - sink: &mut CodeSink, + sink: &mut dyn CodeSink, ) { binemit::emit_inst(func, inst, divert, sink) } @@ -133,7 +133,7 @@ mod tests { use std::string::{String, ToString}; use target_lexicon::triple; - fn encstr(isa: &isa::TargetIsa, enc: Result) -> String { + fn encstr(isa: &dyn isa::TargetIsa, enc: Result) -> String { match enc { Ok(e) => isa.encoding_info().display(e).to_string(), Err(_) => "no encoding".to_string(), diff --git a/cranelift/codegen/src/isa/x86/abi.rs b/cranelift/codegen/src/isa/x86/abi.rs index 37d9ffb257..549ec644c7 100644 --- a/cranelift/codegen/src/isa/x86/abi.rs +++ b/cranelift/codegen/src/isa/x86/abi.rs @@ -199,7 +199,7 @@ pub fn allocatable_registers(_func: &ir::Function, triple: &Triple) -> RegisterS } /// Get the set of callee-saved registers. -fn callee_saved_gprs(isa: &TargetIsa, call_conv: CallConv) -> &'static [RU] { +fn callee_saved_gprs(isa: &dyn TargetIsa, call_conv: CallConv) -> &'static [RU] { match isa.triple().pointer_width().unwrap() { PointerWidth::U16 => panic!(), PointerWidth::U32 => &[RU::rbx, RU::rsi, RU::rdi], @@ -227,7 +227,7 @@ fn callee_saved_gprs(isa: &TargetIsa, call_conv: CallConv) -> &'static [RU] { } /// Get the set of callee-saved registers that are used. -fn callee_saved_gprs_used(isa: &TargetIsa, func: &ir::Function) -> RegisterSet { +fn callee_saved_gprs_used(isa: &dyn TargetIsa, func: &ir::Function) -> RegisterSet { let mut all_callee_saved = RegisterSet::empty(); for reg in callee_saved_gprs(isa, func.signature.call_conv) { all_callee_saved.free(GPR, *reg as RegUnit); @@ -269,7 +269,7 @@ fn callee_saved_gprs_used(isa: &TargetIsa, func: &ir::Function) -> RegisterSet { used } -pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenResult<()> { +pub fn prologue_epilogue(func: &mut ir::Function, isa: &dyn TargetIsa) -> CodegenResult<()> { match func.signature.call_conv { // For now, just translate fast and cold as system_v. CallConv::Fast | CallConv::Cold | CallConv::SystemV => { @@ -281,7 +281,7 @@ pub fn prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenRes } } -fn baldrdash_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenResult<()> { +fn baldrdash_prologue_epilogue(func: &mut ir::Function, isa: &dyn TargetIsa) -> CodegenResult<()> { debug_assert!( !isa.flags().probestack_enabled(), "baldrdash does not expect cranelift to emit stack probes" @@ -302,7 +302,7 @@ fn baldrdash_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> Code /// Implementation of the fastcall-based Win64 calling convention described at [1] /// [1] https://msdn.microsoft.com/en-us/library/ms235286.aspx -fn fastcall_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenResult<()> { +fn fastcall_prologue_epilogue(func: &mut ir::Function, isa: &dyn TargetIsa) -> CodegenResult<()> { if isa.triple().pointer_width().unwrap() != PointerWidth::U64 { panic!("TODO: windows-fastcall: x86-32 not implemented yet"); } @@ -374,7 +374,7 @@ fn fastcall_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> Codeg } /// Insert a System V-compatible prologue and epilogue. -fn system_v_prologue_epilogue(func: &mut ir::Function, isa: &TargetIsa) -> CodegenResult<()> { +fn system_v_prologue_epilogue(func: &mut ir::Function, isa: &dyn TargetIsa) -> CodegenResult<()> { // The original 32-bit x86 ELF ABI had a 4-byte aligned stack pointer, but // newer versions use a 16-byte aligned stack pointer. let stack_align = 16; @@ -435,7 +435,7 @@ fn insert_common_prologue( stack_size: i64, reg_type: ir::types::Type, csrs: &RegisterSet, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { if stack_size > 0 { // Check if there is a special stack limit parameter. If so insert stack check. diff --git a/cranelift/codegen/src/isa/x86/enc_tables.rs b/cranelift/codegen/src/isa/x86/enc_tables.rs index dd7bf02c86..474ef3c544 100644 --- a/cranelift/codegen/src/isa/x86/enc_tables.rs +++ b/cranelift/codegen/src/isa/x86/enc_tables.rs @@ -115,7 +115,7 @@ fn expand_sdivrem( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - isa: &isa::TargetIsa, + isa: &dyn isa::TargetIsa, ) { let (x, y, is_srem) = match func.dfg[inst] { ir::InstructionData::Binary { @@ -225,7 +225,7 @@ fn expand_udivrem( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - isa: &isa::TargetIsa, + isa: &dyn isa::TargetIsa, ) { let (x, y, is_urem) = match func.dfg[inst] { ir::InstructionData::Binary { @@ -278,7 +278,7 @@ fn expand_minmax( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { let (x, y, x86_opc, bitwise_opc) = match func.dfg[inst] { ir::InstructionData::Binary { @@ -370,7 +370,7 @@ fn expand_fcvt_from_uint( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { let x; match func.dfg[inst] { @@ -441,7 +441,7 @@ fn expand_fcvt_to_sint( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { use crate::ir::immediates::{Ieee32, Ieee64}; @@ -536,7 +536,7 @@ fn expand_fcvt_to_sint_sat( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { use crate::ir::immediates::{Ieee32, Ieee64}; @@ -655,7 +655,7 @@ fn expand_fcvt_to_uint( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { use crate::ir::immediates::{Ieee32, Ieee64}; @@ -736,7 +736,7 @@ fn expand_fcvt_to_uint_sat( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &isa::TargetIsa, + _isa: &dyn isa::TargetIsa, ) { use crate::ir::immediates::{Ieee32, Ieee64}; diff --git a/cranelift/codegen/src/isa/x86/mod.rs b/cranelift/codegen/src/isa/x86/mod.rs index acefe0e786..c71e97410a 100644 --- a/cranelift/codegen/src/isa/x86/mod.rs +++ b/cranelift/codegen/src/isa/x86/mod.rs @@ -42,7 +42,7 @@ fn isa_constructor( triple: Triple, shared_flags: shared_settings::Flags, builder: shared_settings::Builder, -) -> Box { +) -> Box { let level1 = match triple.pointer_width().unwrap() { PointerWidth::U16 => unimplemented!("x86-16"), PointerWidth::U32 => &enc_tables::LEVEL1_I32[..], @@ -123,7 +123,7 @@ impl TargetIsa for Isa { func: &ir::Function, inst: ir::Inst, divert: &mut regalloc::RegDiversions, - sink: &mut CodeSink, + sink: &mut dyn CodeSink, ) { binemit::emit_inst(func, inst, divert, sink) } diff --git a/cranelift/codegen/src/legalizer/boundary.rs b/cranelift/codegen/src/legalizer/boundary.rs index c4bbcc9db6..8912743dd5 100644 --- a/cranelift/codegen/src/legalizer/boundary.rs +++ b/cranelift/codegen/src/legalizer/boundary.rs @@ -35,7 +35,7 @@ use std::vec::Vec; /// This changes all signatures to be ABI-compliant with full `ArgumentLoc` annotations. It doesn't /// change the entry block arguments, calls, or return instructions, so this can leave the function /// in a state with type discrepancies. -pub fn legalize_signatures(func: &mut Function, isa: &TargetIsa) { +pub fn legalize_signatures(func: &mut Function, isa: &dyn TargetIsa) { legalize_signature(&mut func.signature, true, isa); for sig_data in func.dfg.signatures.values_mut() { legalize_signature(sig_data, false, isa); @@ -49,14 +49,14 @@ pub fn legalize_signatures(func: &mut Function, isa: &TargetIsa) { /// Legalize the libcall signature, which we may generate on the fly after /// `legalize_signatures` has been called. -pub fn legalize_libcall_signature(signature: &mut Signature, isa: &TargetIsa) { +pub fn legalize_libcall_signature(signature: &mut Signature, isa: &dyn TargetIsa) { legalize_signature(signature, false, isa); } /// Legalize the given signature. /// /// `current` is true if this is the signature for the current function. -fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) { +fn legalize_signature(signature: &mut Signature, current: bool, isa: &dyn TargetIsa) { isa.legalize_signature(signature, current); } diff --git a/cranelift/codegen/src/legalizer/call.rs b/cranelift/codegen/src/legalizer/call.rs index 6122937f3c..4321dbb90b 100644 --- a/cranelift/codegen/src/legalizer/call.rs +++ b/cranelift/codegen/src/legalizer/call.rs @@ -14,7 +14,7 @@ pub fn expand_call( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { // Unpack the instruction. let (func_ref, old_args) = match func.dfg[inst] { diff --git a/cranelift/codegen/src/legalizer/globalvalue.rs b/cranelift/codegen/src/legalizer/globalvalue.rs index 344a8b8d0f..97ef58c2bb 100644 --- a/cranelift/codegen/src/legalizer/globalvalue.rs +++ b/cranelift/codegen/src/legalizer/globalvalue.rs @@ -13,7 +13,7 @@ pub fn expand_global_value( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { // Unpack the instruction. let gv = match func.dfg[inst] { @@ -90,7 +90,7 @@ fn load_addr( offset: ir::immediates::Offset32, global_type: ir::Type, readonly: bool, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { // We need to load a pointer from the `base` global value, so insert a new `global_value` // instruction. This depends on the iterative legalization loop. Note that the IR verifier @@ -123,7 +123,7 @@ fn load_addr( } /// Expand a `global_value` instruction for a symbolic name global. -fn symbol(inst: ir::Inst, func: &mut ir::Function, gv: ir::GlobalValue, isa: &TargetIsa) { +fn symbol(inst: ir::Inst, func: &mut ir::Function, gv: ir::GlobalValue, isa: &dyn TargetIsa) { let ptr_ty = isa.pointer_type(); func.dfg.replace(inst).symbol_value(ptr_ty, gv); } diff --git a/cranelift/codegen/src/legalizer/heap.rs b/cranelift/codegen/src/legalizer/heap.rs index 19217a8af9..33f37155ee 100644 --- a/cranelift/codegen/src/legalizer/heap.rs +++ b/cranelift/codegen/src/legalizer/heap.rs @@ -14,7 +14,7 @@ pub fn expand_heap_addr( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { // Unpack the instruction. let (heap, offset, access_size) = match func.dfg[inst] { diff --git a/cranelift/codegen/src/legalizer/libcall.rs b/cranelift/codegen/src/legalizer/libcall.rs index c4cbac30ee..01ff630f01 100644 --- a/cranelift/codegen/src/legalizer/libcall.rs +++ b/cranelift/codegen/src/legalizer/libcall.rs @@ -7,7 +7,7 @@ use crate::legalizer::boundary::legalize_libcall_signature; use std::vec::Vec; /// Try to expand `inst` as a library call, returning true is successful. -pub fn expand_as_libcall(inst: ir::Inst, func: &mut ir::Function, isa: &TargetIsa) -> bool { +pub fn expand_as_libcall(inst: ir::Inst, func: &mut ir::Function, isa: &dyn TargetIsa) -> bool { // Does the opcode/ctrl_type combo even have a well-known runtime library name. let libcall = match ir::LibCall::for_inst(func.dfg[inst].opcode(), func.dfg.ctrl_typevar(inst)) { diff --git a/cranelift/codegen/src/legalizer/mod.rs b/cranelift/codegen/src/legalizer/mod.rs index 2e1db93d42..0a59f0d1b5 100644 --- a/cranelift/codegen/src/legalizer/mod.rs +++ b/cranelift/codegen/src/legalizer/mod.rs @@ -41,7 +41,7 @@ fn legalize_inst( inst: ir::Inst, pos: &mut FuncCursor, cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> bool { let opcode = pos.func.dfg[inst].opcode(); @@ -83,7 +83,7 @@ fn legalize_inst( /// - Transform any instructions that don't have a legal representation in `isa`. /// - Fill out `func.encodings`. /// -pub fn legalize_function(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa: &TargetIsa) { +pub fn legalize_function(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa: &dyn TargetIsa) { let _tt = timing::legalize(); debug_assert!(cfg.is_valid()); @@ -129,7 +129,7 @@ fn expand_cond_trap( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { // Parse the instruction. let trapz; @@ -179,7 +179,7 @@ fn expand_br_table( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { if isa.flags().jump_tables_enabled() { expand_br_table_jt(inst, func, cfg, isa); @@ -193,7 +193,7 @@ fn expand_br_table_jt( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { use crate::ir::condcodes::IntCC; @@ -239,7 +239,7 @@ fn expand_br_table_conds( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { use crate::ir::condcodes::IntCC; @@ -280,7 +280,7 @@ fn expand_select( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { let (ctrl, tval, fval) = match func.dfg[inst] { ir::InstructionData::Ternary { @@ -315,7 +315,7 @@ fn expand_br_icmp( inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { let (cond, a, b, destination, ebb_args) = match func.dfg[inst] { ir::InstructionData::BranchIcmp { @@ -350,7 +350,7 @@ fn expand_fconst( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { let ty = func.dfg.value_type(func.dfg.first_result(inst)); debug_assert!(!ty.is_vector(), "Only scalar fconst supported: {}", ty); @@ -378,7 +378,7 @@ fn expand_stack_load( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { let ty = func.dfg.value_type(func.dfg.first_result(inst)); let addr_ty = isa.pointer_type(); @@ -410,7 +410,7 @@ fn expand_stack_store( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { let addr_ty = isa.pointer_type(); diff --git a/cranelift/codegen/src/legalizer/table.rs b/cranelift/codegen/src/legalizer/table.rs index 14da52612f..0c4385e96b 100644 --- a/cranelift/codegen/src/legalizer/table.rs +++ b/cranelift/codegen/src/legalizer/table.rs @@ -15,7 +15,7 @@ pub fn expand_table_addr( inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph, - _isa: &TargetIsa, + _isa: &dyn TargetIsa, ) { // Unpack the instruction. let (table, index, element_offset) = match func.dfg[inst] { diff --git a/cranelift/codegen/src/licm.rs b/cranelift/codegen/src/licm.rs index 14c4630dc7..2af4ef3244 100644 --- a/cranelift/codegen/src/licm.rs +++ b/cranelift/codegen/src/licm.rs @@ -17,7 +17,7 @@ use std::vec::Vec; /// loop-invariant instructions out of them. /// Changes the CFG and domtree in-place during the operation. pub fn do_licm( - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, cfg: &mut ControlFlowGraph, domtree: &mut DominatorTree, @@ -64,7 +64,7 @@ pub fn do_licm( // Insert a pre-header before the header, modifying the function layout and CFG to reflect it. // A jump instruction to the header is placed at the end of the pre-header. fn create_pre_header( - isa: &TargetIsa, + isa: &dyn TargetIsa, header: Ebb, func: &mut Function, cfg: &mut ControlFlowGraph, diff --git a/cranelift/codegen/src/postopt.rs b/cranelift/codegen/src/postopt.rs index a82a3e59d3..ef027f6f25 100644 --- a/cranelift/codegen/src/postopt.rs +++ b/cranelift/codegen/src/postopt.rs @@ -45,7 +45,7 @@ fn optimize_cpu_flags( pos: &mut EncCursor, inst: Inst, last_flags_clobber: Option, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) { // Look for compare and branch patterns. // This code could be considerably simplified with non-lexical lifetimes. @@ -179,7 +179,7 @@ struct MemOpInfo { offset: Offset32, } -fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa) { +fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &dyn TargetIsa) { // Look for simple loads and stores we can optimize. let info = match pos.func.dfg[inst] { InstructionData::Load { @@ -357,7 +357,7 @@ fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa) // // The main post-opt pass. -pub fn do_postopt(func: &mut Function, isa: &TargetIsa) { +pub fn do_postopt(func: &mut Function, isa: &dyn TargetIsa) { let _tt = timing::postopt(); let mut pos = EncCursor::new(func, isa); while let Some(_ebb) = pos.next_ebb() { diff --git a/cranelift/codegen/src/print_errors.rs b/cranelift/codegen/src/print_errors.rs index 2d09845c92..a18b5d6955 100644 --- a/cranelift/codegen/src/print_errors.rs +++ b/cranelift/codegen/src/print_errors.rs @@ -17,8 +17,8 @@ use std::vec::Vec; /// Pretty-print a verifier error. pub fn pretty_verifier_error<'a>( func: &ir::Function, - isa: Option<&TargetIsa>, - func_w: Option>, + isa: Option<&dyn TargetIsa>, + func_w: Option>, errors: VerifierErrors, ) -> String { let mut errors = errors.0; @@ -44,14 +44,14 @@ pub fn pretty_verifier_error<'a>( w } -struct PrettyVerifierError<'a>(Box, &'a mut Vec); +struct PrettyVerifierError<'a>(Box, &'a mut Vec); impl<'a> FuncWriter for PrettyVerifierError<'a> { fn write_ebb_header( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, ebb: Ebb, indent: usize, ) -> fmt::Result { @@ -60,10 +60,10 @@ impl<'a> FuncWriter for PrettyVerifierError<'a> { fn write_instruction( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, inst: Inst, indent: usize, ) -> fmt::Result { @@ -72,10 +72,10 @@ impl<'a> FuncWriter for PrettyVerifierError<'a> { fn write_entity_definition( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, entity: AnyEntity, - value: &fmt::Display, + value: &dyn fmt::Display, ) -> fmt::Result { pretty_preamble_error(w, func, entity, value, &mut *self.0, self.1) } @@ -83,12 +83,12 @@ impl<'a> FuncWriter for PrettyVerifierError<'a> { /// Pretty-print a function verifier error for a given EBB. fn pretty_ebb_header_error( - w: &mut Write, + w: &mut dyn Write, func: &Function, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, cur_ebb: Ebb, indent: usize, - func_w: &mut FuncWriter, + func_w: &mut dyn FuncWriter, errors: &mut Vec, ) -> fmt::Result { let mut s = String::new(); @@ -121,13 +121,13 @@ fn pretty_ebb_header_error( /// Pretty-print a function verifier error for a given instruction. fn pretty_instruction_error( - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, cur_inst: Inst, indent: usize, - func_w: &mut FuncWriter, + func_w: &mut dyn FuncWriter, errors: &mut Vec, ) -> fmt::Result { let mut s = String::new(); @@ -159,11 +159,11 @@ fn pretty_instruction_error( } fn pretty_preamble_error( - w: &mut Write, + w: &mut dyn Write, func: &Function, entity: AnyEntity, - value: &fmt::Display, - func_w: &mut FuncWriter, + value: &dyn fmt::Display, + func_w: &mut dyn FuncWriter, errors: &mut Vec, ) -> fmt::Result { let mut s = String::new(); @@ -195,7 +195,7 @@ fn pretty_preamble_error( /// Prints: /// ; ^~~~~~ -fn print_arrow(w: &mut Write, entity: &str) -> fmt::Result { +fn print_arrow(w: &mut dyn Write, entity: &str) -> fmt::Result { write!(w, ";")?; let indent = entity.len() - entity.trim_start().len(); @@ -212,13 +212,13 @@ fn print_arrow(w: &mut Write, entity: &str) -> fmt::Result { /// Prints: /// ; error: [ERROR BODY] -fn print_error(w: &mut Write, err: VerifierError) -> fmt::Result { +fn print_error(w: &mut dyn Write, err: VerifierError) -> fmt::Result { writeln!(w, "; error: {}", err.to_string())?; Ok(()) } /// Pretty-print a Cranelift error. -pub fn pretty_error(func: &ir::Function, isa: Option<&TargetIsa>, err: CodegenError) -> String { +pub fn pretty_error(func: &ir::Function, isa: Option<&dyn TargetIsa>, err: CodegenError) -> String { if let CodegenError::Verifier(e) = err { pretty_verifier_error(func, isa, None, e) } else { diff --git a/cranelift/codegen/src/regalloc/affinity.rs b/cranelift/codegen/src/regalloc/affinity.rs index bbd29f8f2e..7eea98ab8a 100644 --- a/cranelift/codegen/src/regalloc/affinity.rs +++ b/cranelift/codegen/src/regalloc/affinity.rs @@ -48,7 +48,7 @@ impl Affinity { } /// Create an affinity that matches an ABI argument for `isa`. - pub fn abi(arg: &AbiParam, isa: &TargetIsa) -> Self { + pub fn abi(arg: &AbiParam, isa: &dyn TargetIsa) -> Self { match arg.location { ArgumentLoc::Unassigned => Affinity::Unassigned, ArgumentLoc::Reg(_) => Affinity::Reg(isa.regclass_for_abi_type(arg.value_type).into()), diff --git a/cranelift/codegen/src/regalloc/coalescing.rs b/cranelift/codegen/src/regalloc/coalescing.rs index 401b795eea..4ba19ebbf4 100644 --- a/cranelift/codegen/src/regalloc/coalescing.rs +++ b/cranelift/codegen/src/regalloc/coalescing.rs @@ -66,7 +66,7 @@ pub struct Coalescing { /// One-shot context created once per invocation. struct Context<'a> { - isa: &'a TargetIsa, + isa: &'a dyn TargetIsa, encinfo: EncInfo, func: &'a mut Function, @@ -108,7 +108,7 @@ impl Coalescing { /// Convert `func` to Conventional SSA form and build virtual registers in the process. pub fn conventional_ssa( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, cfg: &ControlFlowGraph, domtree: &DominatorTree, diff --git a/cranelift/codegen/src/regalloc/coloring.rs b/cranelift/codegen/src/regalloc/coloring.rs index 12ef018329..4e584b5a64 100644 --- a/cranelift/codegen/src/regalloc/coloring.rs +++ b/cranelift/codegen/src/regalloc/coloring.rs @@ -118,7 +118,7 @@ impl Coloring { /// Run the coloring algorithm over `func`. pub fn run( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, domtree: &DominatorTree, liveness: &mut Liveness, diff --git a/cranelift/codegen/src/regalloc/context.rs b/cranelift/codegen/src/regalloc/context.rs index a12a09dee1..cb4b4245f4 100644 --- a/cranelift/codegen/src/regalloc/context.rs +++ b/cranelift/codegen/src/regalloc/context.rs @@ -75,7 +75,7 @@ impl Context { /// location that is consistent with instruction encoding constraints. pub fn run( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, cfg: &ControlFlowGraph, domtree: &mut DominatorTree, diff --git a/cranelift/codegen/src/regalloc/liveness.rs b/cranelift/codegen/src/regalloc/liveness.rs index 0befe50bf3..7b31aedd54 100644 --- a/cranelift/codegen/src/regalloc/liveness.rs +++ b/cranelift/codegen/src/regalloc/liveness.rs @@ -195,7 +195,7 @@ type LiveRangeSet = SparseMap; fn get_or_create<'a>( lrset: &'a mut LiveRangeSet, value: Value, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &Function, encinfo: &EncInfo, ) -> &'a mut LiveRange { @@ -389,7 +389,7 @@ impl Liveness { /// Compute the live ranges of all SSA values used in `func`. /// This clears out any existing analysis stored in this data structure. - pub fn compute(&mut self, isa: &TargetIsa, func: &mut Function, cfg: &ControlFlowGraph) { + pub fn compute(&mut self, isa: &dyn TargetIsa, func: &mut Function, cfg: &ControlFlowGraph) { let _tt = timing::ra_liveness(); self.ranges.clear(); diff --git a/cranelift/codegen/src/regalloc/pressure.rs b/cranelift/codegen/src/regalloc/pressure.rs index 2db3ec3d03..3b15a1c6e2 100644 --- a/cranelift/codegen/src/regalloc/pressure.rs +++ b/cranelift/codegen/src/regalloc/pressure.rs @@ -281,7 +281,7 @@ mod tests { use target_lexicon::triple; // Make an arm32 `TargetIsa`, if possible. - fn arm32() -> Option> { + fn arm32() -> Option> { use crate::isa; use crate::settings; @@ -294,7 +294,7 @@ mod tests { } // Get a register class by name. - fn rc_by_name(isa: &TargetIsa, name: &str) -> RegClass { + fn rc_by_name(isa: &dyn TargetIsa, name: &str) -> RegClass { isa.register_info() .classes .iter() diff --git a/cranelift/codegen/src/regalloc/reload.rs b/cranelift/codegen/src/regalloc/reload.rs index 11c1a5513d..fb6b61ec6f 100644 --- a/cranelift/codegen/src/regalloc/reload.rs +++ b/cranelift/codegen/src/regalloc/reload.rs @@ -65,7 +65,7 @@ impl Reload { /// Run the reload algorithm over `func`. pub fn run( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, domtree: &DominatorTree, liveness: &mut Liveness, @@ -466,7 +466,7 @@ fn handle_abi_args( abi_types: &[AbiParam], var_args: &[Value], offset: usize, - isa: &TargetIsa, + isa: &dyn TargetIsa, liveness: &Liveness, ) { debug_assert_eq!(abi_types.len(), var_args.len()); diff --git a/cranelift/codegen/src/regalloc/solver.rs b/cranelift/codegen/src/regalloc/solver.rs index 96ccdd2841..0d6a816dcb 100644 --- a/cranelift/codegen/src/regalloc/solver.rs +++ b/cranelift/codegen/src/regalloc/solver.rs @@ -406,7 +406,7 @@ impl fmt::Display for Move { impl fmt::Debug for Move { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let as_display: &fmt::Display = self; + let as_display: &dyn fmt::Display = self; as_display.fmt(f) } } @@ -1139,7 +1139,7 @@ mod tests { use target_lexicon::triple; // Make an arm32 `TargetIsa`, if possible. - fn arm32() -> Option> { + fn arm32() -> Option> { use crate::isa; use crate::settings; diff --git a/cranelift/codegen/src/regalloc/spilling.rs b/cranelift/codegen/src/regalloc/spilling.rs index 9065566003..f45dd41c94 100644 --- a/cranelift/codegen/src/regalloc/spilling.rs +++ b/cranelift/codegen/src/regalloc/spilling.rs @@ -91,7 +91,7 @@ impl Spilling { /// Run the spilling algorithm over `func`. pub fn run( &mut self, - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &mut Function, domtree: &DominatorTree, liveness: &mut Liveness, diff --git a/cranelift/codegen/src/settings.rs b/cranelift/codegen/src/settings.rs index 6da73076e4..748484b10c 100644 --- a/cranelift/codegen/src/settings.rs +++ b/cranelift/codegen/src/settings.rs @@ -346,7 +346,7 @@ pub struct FlagsOrIsa<'a> { pub flags: &'a Flags, /// The ISA may not be present. - pub isa: Option<&'a TargetIsa>, + pub isa: Option<&'a dyn TargetIsa>, } impl<'a> From<&'a Flags> for FlagsOrIsa<'a> { @@ -355,8 +355,8 @@ impl<'a> From<&'a Flags> for FlagsOrIsa<'a> { } } -impl<'a> From<&'a TargetIsa> for FlagsOrIsa<'a> { - fn from(isa: &'a TargetIsa) -> FlagsOrIsa { +impl<'a> From<&'a dyn TargetIsa> for FlagsOrIsa<'a> { + fn from(isa: &'a dyn TargetIsa) -> FlagsOrIsa { FlagsOrIsa { flags: isa.flags(), isa: Some(isa), diff --git a/cranelift/codegen/src/value_label.rs b/cranelift/codegen/src/value_label.rs index d70d6258fa..8dab92b892 100644 --- a/cranelift/codegen/src/value_label.rs +++ b/cranelift/codegen/src/value_label.rs @@ -81,7 +81,7 @@ where pub fn build_value_labels_ranges( func: &Function, regalloc: &Context, - isa: &TargetIsa, + isa: &dyn TargetIsa, ) -> ValueLabelsRanges where T: From + Deref + Ord + Copy, diff --git a/cranelift/codegen/src/verifier/flags.rs b/cranelift/codegen/src/verifier/flags.rs index 9be8d48280..43a235def5 100644 --- a/cranelift/codegen/src/verifier/flags.rs +++ b/cranelift/codegen/src/verifier/flags.rs @@ -24,7 +24,7 @@ use crate::verifier::{VerifierErrors, VerifierStepResult}; pub fn verify_flags( func: &ir::Function, cfg: &ControlFlowGraph, - isa: Option<&isa::TargetIsa>, + isa: Option<&dyn isa::TargetIsa>, errors: &mut VerifierErrors, ) -> VerifierStepResult<()> { let _tt = timing::verify_flags(); diff --git a/cranelift/codegen/src/verifier/liveness.rs b/cranelift/codegen/src/verifier/liveness.rs index 9556ae3703..c396a46803 100644 --- a/cranelift/codegen/src/verifier/liveness.rs +++ b/cranelift/codegen/src/verifier/liveness.rs @@ -23,7 +23,7 @@ use core::cmp::Ordering; /// We don't verify that live ranges are minimal. This would require recomputing live ranges for /// all values. pub fn verify_liveness( - isa: &TargetIsa, + isa: &dyn TargetIsa, func: &Function, cfg: &ControlFlowGraph, liveness: &Liveness, @@ -42,7 +42,7 @@ pub fn verify_liveness( } struct LivenessVerifier<'a> { - isa: &'a TargetIsa, + isa: &'a dyn TargetIsa, func: &'a Function, cfg: &'a ControlFlowGraph, liveness: &'a Liveness, diff --git a/cranelift/codegen/src/verifier/locations.rs b/cranelift/codegen/src/verifier/locations.rs index 26e5edfaf1..bcf006e7f5 100644 --- a/cranelift/codegen/src/verifier/locations.rs +++ b/cranelift/codegen/src/verifier/locations.rs @@ -19,7 +19,7 @@ use crate::verifier::{VerifierErrors, VerifierStepResult}; /// If a liveness analysis is provided, it is used to verify that there are no active register /// diversions across control flow edges. pub fn verify_locations( - isa: &isa::TargetIsa, + isa: &dyn isa::TargetIsa, func: &ir::Function, liveness: Option<&Liveness>, errors: &mut VerifierErrors, @@ -37,7 +37,7 @@ pub fn verify_locations( } struct LocationVerifier<'a> { - isa: &'a isa::TargetIsa, + isa: &'a dyn isa::TargetIsa, func: &'a ir::Function, reginfo: isa::RegInfo, encinfo: isa::EncInfo, diff --git a/cranelift/codegen/src/verifier/mod.rs b/cranelift/codegen/src/verifier/mod.rs index 38a52f0934..fc1a38ed99 100644 --- a/cranelift/codegen/src/verifier/mod.rs +++ b/cranelift/codegen/src/verifier/mod.rs @@ -266,7 +266,7 @@ struct Verifier<'a> { func: &'a Function, expected_cfg: ControlFlowGraph, expected_domtree: DominatorTree, - isa: Option<&'a TargetIsa>, + isa: Option<&'a dyn TargetIsa>, } impl<'a> Verifier<'a> { diff --git a/cranelift/codegen/src/write.rs b/cranelift/codegen/src/write.rs index f1810524d8..cf44fa8aca 100644 --- a/cranelift/codegen/src/write.rs +++ b/cranelift/codegen/src/write.rs @@ -22,9 +22,9 @@ pub trait FuncWriter { /// Write the extended basic block header for the current function. fn write_ebb_header( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, ebb: Ebb, indent: usize, ) -> fmt::Result; @@ -32,10 +32,10 @@ pub trait FuncWriter { /// Write the given `inst` to `w`. fn write_instruction( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, inst: Inst, indent: usize, ) -> fmt::Result; @@ -43,7 +43,7 @@ pub trait FuncWriter { /// Write the preamble to `w`. By default, this uses `write_entity_definition`. fn write_preamble( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, regs: Option<&RegInfo>, ) -> Result { @@ -53,7 +53,7 @@ pub trait FuncWriter { /// Default impl of `write_preamble` fn super_preamble( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, regs: Option<&RegInfo>, ) -> Result { @@ -108,10 +108,10 @@ pub trait FuncWriter { /// Write an entity definition defined in the preamble to `w`. fn write_entity_definition( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, entity: AnyEntity, - value: &fmt::Display, + value: &dyn fmt::Display, ) -> fmt::Result { self.super_entity_definition(w, func, entity, value) } @@ -120,10 +120,10 @@ pub trait FuncWriter { #[allow(unused_variables)] fn super_entity_definition( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, entity: AnyEntity, - value: &fmt::Display, + value: &dyn fmt::Display, ) -> fmt::Result { writeln!(w, " {} = {}", entity, value) } @@ -135,10 +135,10 @@ pub struct PlainWriter; impl FuncWriter for PlainWriter { fn write_instruction( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, inst: Inst, indent: usize, ) -> fmt::Result { @@ -147,9 +147,9 @@ impl FuncWriter for PlainWriter { fn write_ebb_header( &mut self, - w: &mut Write, + w: &mut dyn Write, func: &Function, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, ebb: Ebb, indent: usize, ) -> fmt::Result { @@ -160,7 +160,7 @@ impl FuncWriter for PlainWriter { /// Write `func` to `w` as equivalent text. /// Use `isa` to emit ISA-dependent annotations. pub fn write_function( - w: &mut Write, + w: &mut dyn Write, func: &Function, annotations: &DisplayFunctionAnnotations, ) -> fmt::Result { @@ -184,7 +184,7 @@ fn alias_map(func: &Function) -> SecondaryMap> { /// pretty_function_error is passed as 'closure' to add error decoration. pub fn decorate_function( func_w: &mut FW, - w: &mut Write, + w: &mut dyn Write, func: &Function, annotations: &DisplayFunctionAnnotations, ) -> fmt::Result { @@ -210,7 +210,7 @@ pub fn decorate_function( // // Function spec. -fn write_spec(w: &mut Write, func: &Function, regs: Option<&RegInfo>) -> fmt::Result { +fn write_spec(w: &mut dyn Write, func: &Function, regs: Option<&RegInfo>) -> fmt::Result { write!(w, "{}{}", func.name, func.signature.display(regs)) } @@ -218,7 +218,12 @@ fn write_spec(w: &mut Write, func: &Function, regs: Option<&RegInfo>) -> fmt::Re // // Basic blocks -fn write_arg(w: &mut Write, func: &Function, regs: Option<&RegInfo>, arg: Value) -> fmt::Result { +fn write_arg( + w: &mut dyn Write, + func: &Function, + regs: Option<&RegInfo>, + arg: Value, +) -> fmt::Result { write!(w, "{}: {}", arg, func.dfg.value_type(arg))?; let loc = func.locations[arg]; if loc.is_assigned() { @@ -235,9 +240,9 @@ fn write_arg(w: &mut Write, func: &Function, regs: Option<&RegInfo>, arg: Value) /// ebb10(v4: f64, v5: b1): /// pub fn write_ebb_header( - w: &mut Write, + w: &mut dyn Write, func: &Function, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, ebb: Ebb, indent: usize, ) -> fmt::Result { @@ -263,7 +268,7 @@ pub fn write_ebb_header( writeln!(w, "):") } -fn write_valueloc(w: &mut Write, loc: &ValueLoc, regs: &RegInfo) -> fmt::Result { +fn write_valueloc(w: &mut dyn Write, loc: &ValueLoc, regs: &RegInfo) -> fmt::Result { match loc { ValueLoc::Reg(r) => write!(w, "{}", regs.display_regunit(*r)), ValueLoc::Stack(ss) => write!(w, "{}", ss), @@ -272,7 +277,7 @@ fn write_valueloc(w: &mut Write, loc: &ValueLoc, regs: &RegInfo) -> fmt::Result } fn write_value_range_markers( - w: &mut Write, + w: &mut dyn Write, val_ranges: &ValueLabelsRanges, regs: &RegInfo, offset: u32, @@ -306,7 +311,7 @@ fn write_value_range_markers( fn decorate_ebb( func_w: &mut FW, - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, annotations: &DisplayFunctionAnnotations, @@ -385,7 +390,7 @@ fn type_suffix(func: &Function, inst: Inst) -> Option { /// Write out any aliases to the given target, including indirect aliases fn write_value_aliases( - w: &mut Write, + w: &mut dyn Write, aliases: &SecondaryMap>, target: Value, indent: usize, @@ -402,10 +407,10 @@ fn write_value_aliases( } fn write_instruction( - w: &mut Write, + w: &mut dyn Write, func: &Function, aliases: &SecondaryMap>, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, inst: Inst, indent: usize, ) -> fmt::Result { @@ -472,9 +477,9 @@ fn write_instruction( /// Write the operands of `inst` to `w` with a prepended space. pub fn write_operands( - w: &mut Write, + w: &mut dyn Write, dfg: &DataFlowGraph, - isa: Option<&TargetIsa>, + isa: Option<&dyn TargetIsa>, inst: Inst, ) -> fmt::Result { let pool = &dfg.value_lists; @@ -687,7 +692,7 @@ pub fn write_operands( } /// Write EBB args using optional parantheses. -fn write_ebb_args(w: &mut Write, args: &[Value]) -> fmt::Result { +fn write_ebb_args(w: &mut dyn Write, args: &[Value]) -> fmt::Result { if args.is_empty() { Ok(()) } else { diff --git a/cranelift/entity/src/lib.rs b/cranelift/entity/src/lib.rs index 8d5579000b..57287d6c79 100644 --- a/cranelift/entity/src/lib.rs +++ b/cranelift/entity/src/lib.rs @@ -126,7 +126,7 @@ macro_rules! entity_impl { impl $crate::__core::fmt::Debug for $entity { fn fmt(&self, f: &mut $crate::__core::fmt::Formatter) -> $crate::__core::fmt::Result { - (self as &$crate::__core::fmt::Display).fmt(f) + (self as &dyn $crate::__core::fmt::Display).fmt(f) } } }; diff --git a/cranelift/faerie/src/backend.rs b/cranelift/faerie/src/backend.rs index 29f3c0480d..57dc21376a 100644 --- a/cranelift/faerie/src/backend.rs +++ b/cranelift/faerie/src/backend.rs @@ -27,10 +27,10 @@ pub enum FaerieTrapCollection { /// A builder for `FaerieBackend`. pub struct FaerieBuilder { - isa: Box, + isa: Box, name: String, collect_traps: FaerieTrapCollection, - libcall_names: Box String>, + libcall_names: Box String>, } impl FaerieBuilder { @@ -48,10 +48,10 @@ impl FaerieBuilder { /// floating point instructions, and for stack probes. If you don't know what to use for this /// argument, use `cranelift_module::default_libcall_names()`. pub fn new( - isa: Box, + isa: Box, name: String, collect_traps: FaerieTrapCollection, - libcall_names: Box String>, + libcall_names: Box String>, ) -> ModuleResult { if !isa.flags().is_pic() { return Err(ModuleError::Backend( @@ -71,10 +71,10 @@ impl FaerieBuilder { /// /// See the `FaerieBuilder` for a convenient way to construct `FaerieBackend` instances. pub struct FaerieBackend { - isa: Box, + isa: Box, artifact: faerie::Artifact, trap_manifest: Option, - libcall_names: Box String>, + libcall_names: Box String>, } pub struct FaerieCompiledFunction { @@ -117,7 +117,7 @@ impl Backend for FaerieBackend { } } - fn isa(&self) -> &TargetIsa { + fn isa(&self) -> &dyn TargetIsa { &*self.isa } @@ -361,7 +361,7 @@ struct FaerieRelocSink<'a> { artifact: &'a mut faerie::Artifact, name: &'a str, namespace: &'a ModuleNamespace<'a, FaerieBackend>, - libcall_names: &'a Fn(ir::LibCall) -> String, + libcall_names: &'a dyn Fn(ir::LibCall) -> String, } impl<'a> RelocSink for FaerieRelocSink<'a> { diff --git a/cranelift/filetests/src/lib.rs b/cranelift/filetests/src/lib.rs index 6284e945fa..fbd069bcb5 100644 --- a/cranelift/filetests/src/lib.rs +++ b/cranelift/filetests/src/lib.rs @@ -110,7 +110,7 @@ pub fn run_passes( /// /// This function knows how to create all of the possible `test ` commands that can appear in /// a `.clif` test file. -fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult> { +fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult> { match parsed.command { "binemit" => test_binemit::subtest(parsed), "cat" => test_cat::subtest(parsed), diff --git a/cranelift/filetests/src/runone.rs b/cranelift/filetests/src/runone.rs index 323442d4b5..3a69c37c4e 100644 --- a/cranelift/filetests/src/runone.rs +++ b/cranelift/filetests/src/runone.rs @@ -102,10 +102,10 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test // Given a slice of tests, generate a vector of (test, flags, isa) tuples. fn test_tuples<'a>( - tests: &'a [Box], + tests: &'a [Box], isa_spec: &'a IsaSpec, no_isa_flags: &'a Flags, -) -> SubtestResult)>> { +) -> SubtestResult)>> { let mut out = Vec::new(); for test in tests { if test.needs_isa() { @@ -131,7 +131,7 @@ fn test_tuples<'a>( } fn run_one_test<'a>( - tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>), + tuple: (&'a dyn SubTest, &'a Flags, Option<&'a dyn TargetIsa>), func: Cow, context: &mut Context<'a>, ) -> SubtestResult<()> { diff --git a/cranelift/filetests/src/subtest.rs b/cranelift/filetests/src/subtest.rs index 4400561cc8..0264169e4c 100644 --- a/cranelift/filetests/src/subtest.rs +++ b/cranelift/filetests/src/subtest.rs @@ -25,7 +25,7 @@ pub struct Context<'a> { /// Target ISA to test against. Only guaranteed to be present for sub-tests whose `needs_isa` /// method returned `true`. For other sub-tests, this is set if the test file has a unique ISA. - pub isa: Option<&'a TargetIsa>, + pub isa: Option<&'a dyn TargetIsa>, } impl<'a> Context<'a> { diff --git a/cranelift/filetests/src/test_binemit.rs b/cranelift/filetests/src/test_binemit.rs index a80b3aefe6..0b1e838795 100644 --- a/cranelift/filetests/src/test_binemit.rs +++ b/cranelift/filetests/src/test_binemit.rs @@ -18,7 +18,7 @@ use std::fmt::Write; struct TestBinEmit; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "binemit"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_cat.rs b/cranelift/filetests/src/test_cat.rs index 88ebadf11e..756b5e5700 100644 --- a/cranelift/filetests/src/test_cat.rs +++ b/cranelift/filetests/src/test_cat.rs @@ -13,7 +13,7 @@ use std::borrow::Cow; /// The result is verified by filecheck. struct TestCat; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "cat"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_compile.rs b/cranelift/filetests/src/test_compile.rs index fee681d609..e9150a73ee 100644 --- a/cranelift/filetests/src/test_compile.rs +++ b/cranelift/filetests/src/test_compile.rs @@ -13,7 +13,7 @@ use std::borrow::Cow; struct TestCompile; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "compile"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_dce.rs b/cranelift/filetests/src/test_dce.rs index 2b07654f64..b7b72d2a77 100644 --- a/cranelift/filetests/src/test_dce.rs +++ b/cranelift/filetests/src/test_dce.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; struct TestDCE; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "dce"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_domtree.rs b/cranelift/filetests/src/test_domtree.rs index e8aeca9bfa..05c7dc31e5 100644 --- a/cranelift/filetests/src/test_domtree.rs +++ b/cranelift/filetests/src/test_domtree.rs @@ -25,7 +25,7 @@ use std::fmt::{self, Write}; struct TestDomtree; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "domtree"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_legalizer.rs b/cranelift/filetests/src/test_legalizer.rs index cb9ab8858c..ec182f4092 100644 --- a/cranelift/filetests/src/test_legalizer.rs +++ b/cranelift/filetests/src/test_legalizer.rs @@ -12,7 +12,7 @@ use std::borrow::Cow; struct TestLegalizer; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "legalizer"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_licm.rs b/cranelift/filetests/src/test_licm.rs index 32360cadc7..31385f8081 100644 --- a/cranelift/filetests/src/test_licm.rs +++ b/cranelift/filetests/src/test_licm.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; struct TestLICM; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "licm"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_postopt.rs b/cranelift/filetests/src/test_postopt.rs index e7919b13ca..5d5486e912 100644 --- a/cranelift/filetests/src/test_postopt.rs +++ b/cranelift/filetests/src/test_postopt.rs @@ -11,7 +11,7 @@ use std::borrow::Cow; struct TestPostopt; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "postopt"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_preopt.rs b/cranelift/filetests/src/test_preopt.rs index 2da3005df6..7e0e23475a 100644 --- a/cranelift/filetests/src/test_preopt.rs +++ b/cranelift/filetests/src/test_preopt.rs @@ -15,7 +15,7 @@ use std::borrow::Cow; struct TestPreopt; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "preopt"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_print_cfg.rs b/cranelift/filetests/src/test_print_cfg.rs index 7053234dc3..4483c23939 100644 --- a/cranelift/filetests/src/test_print_cfg.rs +++ b/cranelift/filetests/src/test_print_cfg.rs @@ -13,7 +13,7 @@ use cranelift_reader::TestCommand; /// Object implementing the `test print-cfg` sub-test. struct TestPrintCfg; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "print-cfg"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_regalloc.rs b/cranelift/filetests/src/test_regalloc.rs index a813b43e2f..5a316c022f 100644 --- a/cranelift/filetests/src/test_regalloc.rs +++ b/cranelift/filetests/src/test_regalloc.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; struct TestRegalloc; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "regalloc"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_shrink.rs b/cranelift/filetests/src/test_shrink.rs index 2cbd2b614f..d32da3c384 100644 --- a/cranelift/filetests/src/test_shrink.rs +++ b/cranelift/filetests/src/test_shrink.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; struct TestShrink; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "shrink"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_simple_gvn.rs b/cranelift/filetests/src/test_simple_gvn.rs index 3752129a92..831a632951 100644 --- a/cranelift/filetests/src/test_simple_gvn.rs +++ b/cranelift/filetests/src/test_simple_gvn.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; struct TestSimpleGVN; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "simple-gvn"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_simple_preopt.rs b/cranelift/filetests/src/test_simple_preopt.rs index 4d2e7a7414..286a86ba23 100644 --- a/cranelift/filetests/src/test_simple_preopt.rs +++ b/cranelift/filetests/src/test_simple_preopt.rs @@ -11,7 +11,7 @@ use std::borrow::Cow; struct TestSimplePreopt; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "simple_preopt"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/filetests/src/test_verifier.rs b/cranelift/filetests/src/test_verifier.rs index 7e057248fb..e8d3ffb3ef 100644 --- a/cranelift/filetests/src/test_verifier.rs +++ b/cranelift/filetests/src/test_verifier.rs @@ -19,7 +19,7 @@ use std::fmt::Write; struct TestVerifier; -pub fn subtest(parsed: &TestCommand) -> SubtestResult> { +pub fn subtest(parsed: &TestCommand) -> SubtestResult> { assert_eq!(parsed.command, "verifier"); if !parsed.options.is_empty() { Err(format!("No options allowed on {}", parsed)) diff --git a/cranelift/frontend/src/frontend.rs b/cranelift/frontend/src/frontend.rs index 407d03fec4..82a3a09f1a 100644 --- a/cranelift/frontend/src/frontend.rs +++ b/cranelift/frontend/src/frontend.rs @@ -571,7 +571,7 @@ impl<'a> FunctionBuilder<'a> { /// Useful for debug purposes. Use it with `None` for standard printing. // Clippy thinks the lifetime that follows is needless, but rustc needs it #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_lifetimes))] - pub fn display<'b, I: Into>>(&'b self, isa: I) -> DisplayFunction { + pub fn display<'b, I: Into>>(&'b self, isa: I) -> DisplayFunction { self.func.display(isa) } } diff --git a/cranelift/module/src/backend.rs b/cranelift/module/src/backend.rs index fa23d24f01..316c0a3e2b 100644 --- a/cranelift/module/src/backend.rs +++ b/cranelift/module/src/backend.rs @@ -53,7 +53,7 @@ where fn new(_: Self::Builder) -> Self; /// Return the `TargetIsa` to compile for. - fn isa(&self) -> &TargetIsa; + fn isa(&self) -> &dyn TargetIsa; /// Declare a function. fn declare_function(&mut self, name: &str, linkage: Linkage); @@ -135,7 +135,7 @@ where /// Default names for `ir::LibCall`s. A function by this name is imported into the object as /// part of the translation of a `ir::ExternalName::LibCall` variant. -pub fn default_libcall_names() -> Box String> { +pub fn default_libcall_names() -> Box String> { Box::new(move |libcall| match libcall { ir::LibCall::Probestack => "__cranelift_probestack".to_owned(), ir::LibCall::CeilF32 => "ceilf".to_owned(), diff --git a/cranelift/module/src/module.rs b/cranelift/module/src/module.rs index 5d8f3c5f60..33a13b7f9a 100644 --- a/cranelift/module/src/module.rs +++ b/cranelift/module/src/module.rs @@ -690,7 +690,7 @@ where } /// Return the target isa - pub fn isa(&self) -> &isa::TargetIsa { + pub fn isa(&self) -> &dyn isa::TargetIsa { self.backend.isa() } diff --git a/cranelift/preopt/src/lib.rs b/cranelift/preopt/src/lib.rs index 310d1ba614..e8cf7be321 100644 --- a/cranelift/preopt/src/lib.rs +++ b/cranelift/preopt/src/lib.rs @@ -37,7 +37,7 @@ use cranelift_codegen::{isa::TargetIsa, settings::FlagsOrIsa, CodegenResult, Con /// Since this can be resource intensive (and code-size inflating), /// it is separated from `Context::compile` to allow DCE to remove it /// if it's not used. -pub fn optimize(ctx: &mut Context, isa: &TargetIsa) -> CodegenResult<()> { +pub fn optimize(ctx: &mut Context, isa: &dyn TargetIsa) -> CodegenResult<()> { ctx.verify_if(isa)?; fold_constants(ctx, isa)?; diff --git a/cranelift/reader/src/isaspec.rs b/cranelift/reader/src/isaspec.rs index 6aefce354a..140eb8324b 100644 --- a/cranelift/reader/src/isaspec.rs +++ b/cranelift/reader/src/isaspec.rs @@ -19,12 +19,12 @@ pub enum IsaSpec { /// The parsed file does contain `isa` commands. /// Each `isa` command is used to configure a `TargetIsa` trait object. - Some(Vec>), + Some(Vec>), } impl IsaSpec { /// If the `IsaSpec` contains exactly 1 `TargetIsa` we return a reference to it - pub fn unique_isa(&self) -> Option<&TargetIsa> { + pub fn unique_isa(&self) -> Option<&dyn TargetIsa> { if let IsaSpec::Some(ref isa_vec) = *self { if isa_vec.len() == 1 { return Some(&*isa_vec[0]); @@ -35,7 +35,11 @@ impl IsaSpec { } /// Parse an iterator of command line options and apply them to `config`. -pub fn parse_options<'a, I>(iter: I, config: &mut Configurable, loc: Location) -> ParseResult<()> +pub fn parse_options<'a, I>( + iter: I, + config: &mut dyn Configurable, + loc: Location, +) -> ParseResult<()> where I: Iterator, { diff --git a/cranelift/reader/src/parser.rs b/cranelift/reader/src/parser.rs index 42dfd55f01..037ed2acce 100644 --- a/cranelift/reader/src/parser.rs +++ b/cranelift/reader/src/parser.rs @@ -113,11 +113,11 @@ struct Context<'a> { /// information. This is only `Some` if exactly one set of `isa` directives were found in the /// prologue (it is valid to have directives for multiple different targets, but in that case /// we couldn't know which target the provided encodings are intended for) - unique_isa: Option<&'a TargetIsa>, + unique_isa: Option<&'a dyn TargetIsa>, } impl<'a> Context<'a> { - fn new(f: Function, unique_isa: Option<&'a TargetIsa>) -> Self { + fn new(f: Function, unique_isa: Option<&'a dyn TargetIsa>) -> Self { Self { function: f, map: SourceMap::new(), @@ -720,7 +720,7 @@ impl<'a> Parser<'a> { } // Match and consume a register unit either by number `%15` or by name `%rax`. - fn match_regunit(&mut self, isa: Option<&TargetIsa>) -> ParseResult { + fn match_regunit(&mut self, isa: Option<&dyn TargetIsa>) -> ParseResult { if let Some(Token::Name(name)) = self.token() { self.consume(); match isa { @@ -891,7 +891,7 @@ impl<'a> Parser<'a> { /// This is the top-level parse function matching the whole contents of a file. pub fn parse_function_list( &mut self, - unique_isa: Option<&TargetIsa>, + unique_isa: Option<&dyn TargetIsa>, ) -> ParseResult)>> { let mut list = Vec::new(); while self.token().is_some() { @@ -911,7 +911,7 @@ impl<'a> Parser<'a> { // fn parse_function( &mut self, - unique_isa: Option<&TargetIsa>, + unique_isa: Option<&dyn TargetIsa>, ) -> ParseResult<(Function, Details<'a>)> { // Begin gathering comments. // Make sure we don't include any comments before the `function` keyword. @@ -999,7 +999,7 @@ impl<'a> Parser<'a> { // // signature ::= * "(" [paramlist] ")" ["->" retlist] [callconv] // - fn parse_signature(&mut self, unique_isa: Option<&TargetIsa>) -> ParseResult { + fn parse_signature(&mut self, unique_isa: Option<&dyn TargetIsa>) -> ParseResult { // Calling convention defaults to `fast`, but can be changed. let mut sig = Signature::new(CallConv::Fast); @@ -1033,7 +1033,7 @@ impl<'a> Parser<'a> { // fn parse_abi_param_list( &mut self, - unique_isa: Option<&TargetIsa>, + unique_isa: Option<&dyn TargetIsa>, ) -> ParseResult> { let mut list = Vec::new(); @@ -1050,7 +1050,7 @@ impl<'a> Parser<'a> { } // Parse a single argument type with flags. - fn parse_abi_param(&mut self, unique_isa: Option<&TargetIsa>) -> ParseResult { + fn parse_abi_param(&mut self, unique_isa: Option<&dyn TargetIsa>) -> ParseResult { // abi-param ::= * type { flag } [ argumentloc ] let mut arg = AbiParam::new(self.match_type("expected parameter type")?); @@ -1079,7 +1079,7 @@ impl<'a> Parser<'a> { // Parse an argument location specifier; either a register or a byte offset into the stack. fn parse_argument_location( &mut self, - unique_isa: Option<&TargetIsa>, + unique_isa: Option<&dyn TargetIsa>, ) -> ParseResult { // argumentloc ::= '[' regname | uimm32 ']' if self.optional(Token::LBracket) { @@ -1426,7 +1426,7 @@ impl<'a> Parser<'a> { // fn parse_signature_decl( &mut self, - unique_isa: Option<&TargetIsa>, + unique_isa: Option<&dyn TargetIsa>, ) -> ParseResult<(SigRef, Signature)> { let sig = self.match_sig("expected signature number: sig«n»")?; self.match_token(Token::Equal, "expected '=' in signature decl")?; diff --git a/cranelift/simplejit/src/backend.rs b/cranelift/simplejit/src/backend.rs index 3786e3e964..c182ada674 100644 --- a/cranelift/simplejit/src/backend.rs +++ b/cranelift/simplejit/src/backend.rs @@ -23,9 +23,9 @@ const READONLY_DATA_ALIGNMENT: u8 = 0x1; /// A builder for `SimpleJITBackend`. pub struct SimpleJITBuilder { - isa: Box, + isa: Box, symbols: HashMap, - libcall_names: Box String>, + libcall_names: Box String>, } impl SimpleJITBuilder { @@ -35,7 +35,7 @@ impl SimpleJITBuilder { /// enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain /// floating point instructions, and for stack probes. If you don't know what to use for this /// argument, use `cranelift_module::default_libcall_names()`. - pub fn new(libcall_names: Box String>) -> Self { + pub fn new(libcall_names: Box String>) -> Self { let flag_builder = settings::builder(); let isa_builder = cranelift_native::builder().unwrap_or_else(|msg| { panic!("host machine is not supported: {}", msg); @@ -56,7 +56,10 @@ impl SimpleJITBuilder { /// enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain /// floating point instructions, and for stack probes. If you don't know what to use for this /// argument, use `cranelift_module::default_libcall_names()`. - pub fn with_isa(isa: Box, libcall_names: Box String>) -> Self { + pub fn with_isa( + isa: Box, + libcall_names: Box String>, + ) -> Self { debug_assert!(!isa.flags().is_pic(), "SimpleJIT requires non-PIC code"); let symbols = HashMap::new(); Self { @@ -108,9 +111,9 @@ impl SimpleJITBuilder { /// /// See the `SimpleJITBuilder` for a convenient way to construct `SimpleJITBackend` instances. pub struct SimpleJITBackend { - isa: Box, + isa: Box, symbols: HashMap, - libcall_names: Box String>, + libcall_names: Box String>, code_memory: Memory, readonly_memory: Memory, writable_memory: Memory, @@ -205,7 +208,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { } } - fn isa(&self) -> &TargetIsa { + fn isa(&self) -> &dyn TargetIsa { &*self.isa } diff --git a/cranelift/src/disasm.rs b/cranelift/src/disasm.rs index 65fb33ec06..d7ba0dca6b 100644 --- a/cranelift/src/disasm.rs +++ b/cranelift/src/disasm.rs @@ -85,7 +85,7 @@ cfg_if! { use capstone::prelude::*; use target_lexicon::Architecture; - fn get_disassembler(isa: &TargetIsa) -> Result { + fn get_disassembler(isa: &dyn TargetIsa) -> Result { let cs = match isa.triple().architecture { Architecture::Riscv32 | Architecture::Riscv64 => { return Err(String::from("No disassembler for RiscV")) @@ -117,7 +117,7 @@ cfg_if! { cs.map_err(|err| err.to_string()) } - pub fn print_disassembly(isa: &TargetIsa, mem: &[u8]) -> Result<(), String> { + pub fn print_disassembly(isa: &dyn TargetIsa, mem: &[u8]) -> Result<(), String> { let mut cs = get_disassembler(isa)?; println!("\nDisassembly of {} bytes:", mem.len()); @@ -156,7 +156,7 @@ cfg_if! { Ok(()) } } else { - pub fn print_disassembly(_: &TargetIsa, _: &[u8]) -> Result<(), String> { + pub fn print_disassembly(_: &dyn TargetIsa, _: &[u8]) -> Result<(), String> { println!("\nNo disassembly available."); Ok(()) } @@ -164,7 +164,7 @@ cfg_if! { } pub fn print_all( - isa: &TargetIsa, + isa: &dyn TargetIsa, mem: &[u8], code_size: u32, rodata_size: u32, diff --git a/cranelift/src/utils.rs b/cranelift/src/utils.rs index a05c0ac3b0..908b310007 100644 --- a/cranelift/src/utils.rs +++ b/cranelift/src/utils.rs @@ -42,7 +42,7 @@ pub fn read_to_end>(path: P) -> io::Result> { /// Like `FlagsOrIsa`, but holds ownership. pub enum OwnedFlagsOrIsa { Flags(settings::Flags), - Isa(Box), + Isa(Box), } impl OwnedFlagsOrIsa { diff --git a/cranelift/wasm/src/module_translator.rs b/cranelift/wasm/src/module_translator.rs index 1cf0f4cd2d..72f257acea 100644 --- a/cranelift/wasm/src/module_translator.rs +++ b/cranelift/wasm/src/module_translator.rs @@ -13,7 +13,7 @@ use wasmparser::{ModuleReader, SectionCode}; /// [`Function`](../codegen/ir/function/struct.Function.html). pub fn translate_module<'data>( data: &'data [u8], - environ: &mut ModuleEnvironment<'data>, + environ: &mut dyn ModuleEnvironment<'data>, ) -> WasmResult<()> { let _tt = timing::wasm_translate_module(); let mut reader = ModuleReader::new(data)?; diff --git a/cranelift/wasm/src/sections_translator.rs b/cranelift/wasm/src/sections_translator.rs index 929114984a..e3dacc1b38 100644 --- a/cranelift/wasm/src/sections_translator.rs +++ b/cranelift/wasm/src/sections_translator.rs @@ -27,7 +27,7 @@ use wasmparser::{ /// Parses the Type section of the wasm module. pub fn parse_type_section( types: TypeSectionReader, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_signatures(types.get_count()); @@ -60,7 +60,7 @@ pub fn parse_type_section( /// Parses the Import section of the wasm module. pub fn parse_import_section<'data>( imports: ImportSectionReader<'data>, - environ: &mut ModuleEnvironment<'data>, + environ: &mut dyn ModuleEnvironment<'data>, ) -> WasmResult<()> { environ.reserve_imports(imports.get_count()); @@ -122,7 +122,7 @@ pub fn parse_import_section<'data>( /// Parses the Function section of the wasm module. pub fn parse_function_section( functions: FunctionSectionReader, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_func_types(functions.get_count()); @@ -137,7 +137,7 @@ pub fn parse_function_section( /// Parses the Table section of the wasm module. pub fn parse_table_section( tables: TableSectionReader, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_tables(tables.get_count()); @@ -159,7 +159,7 @@ pub fn parse_table_section( /// Parses the Memory section of the wasm module. pub fn parse_memory_section( memories: MemorySectionReader, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_memories(memories.get_count()); @@ -178,7 +178,7 @@ pub fn parse_memory_section( /// Parses the Global section of the wasm module. pub fn parse_global_section( globals: GlobalSectionReader, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_globals(globals.get_count()); @@ -215,7 +215,7 @@ pub fn parse_global_section( /// Parses the Export section of the wasm module. pub fn parse_export_section<'data>( exports: ExportSectionReader<'data>, - environ: &mut ModuleEnvironment<'data>, + environ: &mut dyn ModuleEnvironment<'data>, ) -> WasmResult<()> { environ.reserve_exports(exports.get_count()); @@ -243,7 +243,7 @@ pub fn parse_export_section<'data>( } /// Parses the Start section of the wasm module. -pub fn parse_start_section(index: u32, environ: &mut ModuleEnvironment) -> WasmResult<()> { +pub fn parse_start_section(index: u32, environ: &mut dyn ModuleEnvironment) -> WasmResult<()> { environ.declare_start_func(FuncIndex::from_u32(index)); Ok(()) } @@ -251,7 +251,7 @@ pub fn parse_start_section(index: u32, environ: &mut ModuleEnvironment) -> WasmR /// Parses the Element section of the wasm module. pub fn parse_element_section<'data>( elements: ElementSectionReader<'data>, - environ: &mut ModuleEnvironment, + environ: &mut dyn ModuleEnvironment, ) -> WasmResult<()> { environ.reserve_table_elements(elements.get_count()); @@ -292,7 +292,7 @@ pub fn parse_element_section<'data>( /// Parses the Code section of the wasm module. pub fn parse_code_section<'data>( code: CodeSectionReader<'data>, - environ: &mut ModuleEnvironment<'data>, + environ: &mut dyn ModuleEnvironment<'data>, ) -> WasmResult<()> { for body in code { let mut reader = body?.get_binary_reader(); @@ -306,7 +306,7 @@ pub fn parse_code_section<'data>( /// Parses the Data section of the wasm module. pub fn parse_data_section<'data>( data: DataSectionReader<'data>, - environ: &mut ModuleEnvironment<'data>, + environ: &mut dyn ModuleEnvironment<'data>, ) -> WasmResult<()> { environ.reserve_data_initializers(data.get_count());