Remove all Sink traits
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
use cranelift_codegen::binemit::{Addend, CodeOffset, Reloc};
|
||||
use cranelift_codegen::entity::PrimaryMap;
|
||||
use cranelift_codegen::ir;
|
||||
use cranelift_codegen::ir::{self, SourceLoc};
|
||||
use cranelift_codegen::MachReloc;
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::Box;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
|
||||
use crate::RelocRecord;
|
||||
|
||||
/// This specifies how data is to be initialized.
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum Init {
|
||||
@@ -59,25 +58,24 @@ pub struct DataDescription {
|
||||
|
||||
impl DataDescription {
|
||||
/// An iterator over all relocations of the data object.
|
||||
pub fn all_relocs<'a>(
|
||||
&'a self,
|
||||
pointer_reloc: Reloc,
|
||||
) -> impl Iterator<Item = RelocRecord> + 'a {
|
||||
pub fn all_relocs<'a>(&'a self, pointer_reloc: Reloc) -> impl Iterator<Item = MachReloc> + 'a {
|
||||
let func_relocs = self
|
||||
.function_relocs
|
||||
.iter()
|
||||
.map(move |&(offset, id)| RelocRecord {
|
||||
reloc: pointer_reloc,
|
||||
.map(move |&(offset, id)| MachReloc {
|
||||
kind: pointer_reloc,
|
||||
offset,
|
||||
srcloc: SourceLoc::default(),
|
||||
name: self.function_decls[id].clone(),
|
||||
addend: 0,
|
||||
});
|
||||
let data_relocs = self
|
||||
.data_relocs
|
||||
.iter()
|
||||
.map(move |&(offset, id, addend)| RelocRecord {
|
||||
reloc: pointer_reloc,
|
||||
.map(move |&(offset, id, addend)| MachReloc {
|
||||
kind: pointer_reloc,
|
||||
offset,
|
||||
srcloc: SourceLoc::default(),
|
||||
name: self.data_decls[id].clone(),
|
||||
addend,
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ mod traps;
|
||||
pub use crate::data_context::{DataContext, DataDescription, Init};
|
||||
pub use crate::module::{
|
||||
DataId, FuncId, FuncOrDataId, Linkage, Module, ModuleCompiledFunction, ModuleDeclarations,
|
||||
ModuleError, ModuleResult, RelocRecord,
|
||||
ModuleError, ModuleResult,
|
||||
};
|
||||
pub use crate::traps::TrapSite;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
use super::HashMap;
|
||||
use crate::data_context::DataContext;
|
||||
use cranelift_codegen::binemit;
|
||||
use cranelift_codegen::entity::{entity_impl, PrimaryMap};
|
||||
use cranelift_codegen::{binemit, MachReloc};
|
||||
use cranelift_codegen::{ir, isa, CodegenError, Context};
|
||||
use std::borrow::ToOwned;
|
||||
use std::string::String;
|
||||
@@ -416,19 +416,6 @@ pub struct ModuleCompiledFunction {
|
||||
pub size: binemit::CodeOffset,
|
||||
}
|
||||
|
||||
/// A record of a relocation to perform.
|
||||
#[derive(Clone)]
|
||||
pub struct RelocRecord {
|
||||
/// Where in the generated code this relocation is to be applied.
|
||||
pub offset: binemit::CodeOffset,
|
||||
/// The kind of relocation this represents.
|
||||
pub reloc: binemit::Reloc,
|
||||
/// What symbol we're relocating against.
|
||||
pub name: ir::ExternalName,
|
||||
/// The offset to add to the relocation.
|
||||
pub addend: binemit::Addend,
|
||||
}
|
||||
|
||||
/// A `Module` is a utility for collecting functions and data objects, and linking them together.
|
||||
pub trait Module {
|
||||
/// Return the `TargetIsa` to compile for.
|
||||
@@ -567,7 +554,7 @@ pub trait Module {
|
||||
&mut self,
|
||||
func: FuncId,
|
||||
bytes: &[u8],
|
||||
relocs: &[RelocRecord],
|
||||
relocs: &[MachReloc],
|
||||
) -> ModuleResult<ModuleCompiledFunction>;
|
||||
|
||||
/// Define a data object, producing the data contents from the given `DataContext`.
|
||||
@@ -662,7 +649,7 @@ impl<M: Module> Module for &mut M {
|
||||
&mut self,
|
||||
func: FuncId,
|
||||
bytes: &[u8],
|
||||
relocs: &[RelocRecord],
|
||||
relocs: &[MachReloc],
|
||||
) -> ModuleResult<ModuleCompiledFunction> {
|
||||
(**self).define_function_bytes(func, bytes, relocs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user