Remove unused CodeSink methods
This commit is contained in:
@@ -99,26 +99,10 @@ impl<'a> MemoryCodeSink<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CodeSink for MemoryCodeSink<'a> {
|
impl<'a> CodeSink for MemoryCodeSink<'a> {
|
||||||
fn offset(&self) -> CodeOffset {
|
|
||||||
self.offset as CodeOffset
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put1(&mut self, x: u8) {
|
fn put1(&mut self, x: u8) {
|
||||||
self.write(x);
|
self.write(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn put2(&mut self, x: u16) {
|
|
||||||
self.write(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put4(&mut self, x: u32) {
|
|
||||||
self.write(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put8(&mut self, x: u64) {
|
|
||||||
self.write(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn reloc_external(
|
fn reloc_external(
|
||||||
&mut self,
|
&mut self,
|
||||||
srcloc: SourceLoc,
|
srcloc: SourceLoc,
|
||||||
@@ -126,17 +110,17 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
|||||||
name: &ExternalName,
|
name: &ExternalName,
|
||||||
addend: Addend,
|
addend: Addend,
|
||||||
) {
|
) {
|
||||||
let ofs = self.offset();
|
let ofs = self.offset as CodeOffset;
|
||||||
self.relocs.reloc_external(ofs, srcloc, rel, name, addend);
|
self.relocs.reloc_external(ofs, srcloc, rel, name, addend);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trap(&mut self, code: TrapCode, srcloc: SourceLoc) {
|
fn trap(&mut self, code: TrapCode, srcloc: SourceLoc) {
|
||||||
let ofs = self.offset();
|
let ofs = self.offset as CodeOffset;
|
||||||
self.traps.trap(ofs, srcloc, code);
|
self.traps.trap(ofs, srcloc, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_codegen(&mut self) {
|
fn end_codegen(&mut self) {
|
||||||
self.info.total_size = self.offset();
|
self.info.total_size = self.offset as CodeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) {
|
fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) {
|
||||||
@@ -144,7 +128,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
|
|||||||
opcode.is_call(),
|
opcode.is_call(),
|
||||||
"adding call site info for a non-call instruction."
|
"adding call site info for a non-call instruction."
|
||||||
);
|
);
|
||||||
let ret_addr = self.offset();
|
let ret_addr = self.offset as CodeOffset;
|
||||||
self.relocs.add_call_site(opcode, ret_addr, loc);
|
self.relocs.add_call_site(opcode, ret_addr, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,21 +105,9 @@ pub struct CodeInfo {
|
|||||||
/// A `CodeSink` will receive all of the machine code for a function. It also accepts relocations
|
/// A `CodeSink` will receive all of the machine code for a function. It also accepts relocations
|
||||||
/// which are locations in the code section that need to be fixed up when linking.
|
/// which are locations in the code section that need to be fixed up when linking.
|
||||||
pub trait CodeSink {
|
pub trait CodeSink {
|
||||||
/// Get the current position.
|
|
||||||
fn offset(&self) -> CodeOffset;
|
|
||||||
|
|
||||||
/// Add 1 byte to the code section.
|
/// Add 1 byte to the code section.
|
||||||
fn put1(&mut self, _: u8);
|
fn put1(&mut self, _: u8);
|
||||||
|
|
||||||
/// Add 2 bytes to the code section.
|
|
||||||
fn put2(&mut self, _: u16);
|
|
||||||
|
|
||||||
/// Add 4 bytes to the code section.
|
|
||||||
fn put4(&mut self, _: u32);
|
|
||||||
|
|
||||||
/// Add 8 bytes to the code section.
|
|
||||||
fn put8(&mut self, _: u64);
|
|
||||||
|
|
||||||
/// Add a relocation referencing an external symbol plus the addend at the current offset.
|
/// Add a relocation referencing an external symbol plus the addend at the current offset.
|
||||||
fn reloc_external(&mut self, _: SourceLoc, _: Reloc, _: &ExternalName, _: Addend);
|
fn reloc_external(&mut self, _: SourceLoc, _: Reloc, _: &ExternalName, _: Addend);
|
||||||
|
|
||||||
|
|||||||
@@ -2079,21 +2079,9 @@ mod test {
|
|||||||
relocs: Vec<(CodeOffset, Reloc)>,
|
relocs: Vec<(CodeOffset, Reloc)>,
|
||||||
}
|
}
|
||||||
impl CodeSink for TestCodeSink {
|
impl CodeSink for TestCodeSink {
|
||||||
fn offset(&self) -> CodeOffset {
|
|
||||||
self.offset
|
|
||||||
}
|
|
||||||
fn put1(&mut self, _: u8) {
|
fn put1(&mut self, _: u8) {
|
||||||
self.offset += 1;
|
self.offset += 1;
|
||||||
}
|
}
|
||||||
fn put2(&mut self, _: u16) {
|
|
||||||
self.offset += 2;
|
|
||||||
}
|
|
||||||
fn put4(&mut self, _: u32) {
|
|
||||||
self.offset += 4;
|
|
||||||
}
|
|
||||||
fn put8(&mut self, _: u64) {
|
|
||||||
self.offset += 8;
|
|
||||||
}
|
|
||||||
fn reloc_external(&mut self, _: SourceLoc, r: Reloc, _: &ExternalName, _: Addend) {
|
fn reloc_external(&mut self, _: SourceLoc, r: Reloc, _: &ExternalName, _: Addend) {
|
||||||
self.relocs.push((self.offset, r));
|
self.relocs.push((self.offset, r));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,26 +81,10 @@ struct SizeSink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl binemit::CodeSink for SizeSink {
|
impl binemit::CodeSink for SizeSink {
|
||||||
fn offset(&self) -> binemit::CodeOffset {
|
|
||||||
self.offset
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put1(&mut self, _: u8) {
|
fn put1(&mut self, _: u8) {
|
||||||
self.offset += 1;
|
self.offset += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn put2(&mut self, _: u16) {
|
|
||||||
self.offset += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put4(&mut self, _: u32) {
|
|
||||||
self.offset += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn put8(&mut self, _: u64) {
|
|
||||||
self.offset += 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn reloc_external(
|
fn reloc_external(
|
||||||
&mut self,
|
&mut self,
|
||||||
_srcloc: ir::SourceLoc,
|
_srcloc: ir::SourceLoc,
|
||||||
|
|||||||
Reference in New Issue
Block a user