Remove all Sink traits

This commit is contained in:
bjorn3
2022-01-11 19:03:10 +01:00
parent b803514d55
commit f0e821b9e0
13 changed files with 188 additions and 504 deletions

View File

@@ -1,13 +1,12 @@
//! CLI tool to read Cranelift IR files and compile them into native code.
use crate::disasm::{print_all, PrintRelocs, PrintStackMaps, PrintTraps};
use crate::disasm::print_all;
use crate::utils::{parse_sets_and_triple, read_to_string};
use anyhow::{Context as _, Result};
use cranelift_codegen::binemit::{RelocSink, StackMapSink, TrapSink};
use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::settings::FlagsOrIsa;
use cranelift_codegen::timing;
use cranelift_codegen::Context;
use cranelift_codegen::{timing, MachReloc, MachStackMap, MachTrap};
use cranelift_reader::{parse_test, ParseOptions};
use std::path::Path;
use std::path::PathBuf;
@@ -69,10 +68,6 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
};
for (func, _) in test_file.functions {
let mut relocs = PrintRelocs::new(options.print);
let mut traps = PrintTraps::new(options.print);
let mut stack_maps = PrintStackMaps::new(options.print);
if let Some(isa) = isa {
let mut context = Context::new();
context.func = func;
@@ -84,32 +79,6 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
.map_err(|err| anyhow::anyhow!("{}", pretty_error(&context.func, err)))?;
let result = context.mach_compile_result.as_ref().unwrap();
let code_info = result.code_info();
for &MachReloc {
offset,
srcloc,
kind,
ref name,
addend,
} in result.buffer.relocs()
{
relocs.reloc_external(offset, srcloc, kind, name, addend);
}
for &MachTrap {
offset,
srcloc,
code,
} in result.buffer.traps()
{
traps.trap(offset, srcloc, code);
}
for &MachStackMap {
offset_end,
ref stack_map,
..
} in result.buffer.stack_maps()
{
stack_maps.add_stack_map(offset_end, stack_map.clone());
}
if options.print {
println!("{}", context.func.display());
@@ -120,9 +89,10 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
isa,
&mem,
code_info.total_size,
&relocs,
&traps,
&stack_maps,
options.print,
result.buffer.relocs(),
result.buffer.traps(),
result.buffer.stack_maps(),
)?;
}
}