Remove unused CodeSink methods

This commit is contained in:
bjorn3
2022-01-11 14:45:21 +01:00
parent 88baac4ca6
commit 354c4f7bf8
4 changed files with 4 additions and 60 deletions

View File

@@ -99,26 +99,10 @@ impl<'a> MemoryCodeSink<'a> {
}
impl<'a> CodeSink for MemoryCodeSink<'a> {
fn offset(&self) -> CodeOffset {
self.offset as CodeOffset
}
fn put1(&mut self, x: u8) {
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(
&mut self,
srcloc: SourceLoc,
@@ -126,17 +110,17 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
name: &ExternalName,
addend: Addend,
) {
let ofs = self.offset();
let ofs = self.offset as CodeOffset;
self.relocs.reloc_external(ofs, srcloc, rel, name, addend);
}
fn trap(&mut self, code: TrapCode, srcloc: SourceLoc) {
let ofs = self.offset();
let ofs = self.offset as CodeOffset;
self.traps.trap(ofs, srcloc, code);
}
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) {
@@ -144,7 +128,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
opcode.is_call(),
"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);
}
}

View File

@@ -105,21 +105,9 @@ pub struct CodeInfo {
/// 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.
pub trait CodeSink {
/// Get the current position.
fn offset(&self) -> CodeOffset;
/// Add 1 byte to the code section.
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.
fn reloc_external(&mut self, _: SourceLoc, _: Reloc, _: &ExternalName, _: Addend);

View File

@@ -2079,21 +2079,9 @@ mod test {
relocs: Vec<(CodeOffset, Reloc)>,
}
impl CodeSink for TestCodeSink {
fn offset(&self) -> CodeOffset {
self.offset
}
fn put1(&mut self, _: u8) {
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) {
self.relocs.push((self.offset, r));
}

View File

@@ -81,26 +81,10 @@ struct SizeSink {
}
impl binemit::CodeSink for SizeSink {
fn offset(&self) -> binemit::CodeOffset {
self.offset
}
fn put1(&mut self, _: u8) {
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,
_srcloc: ir::SourceLoc,