Remove sink arguments from compile_and_emit
The data can be accessed after the fact using context.mach_compile_result
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
use crate::disasm::{print_all, PrintRelocs, PrintStackMaps, PrintTraps};
|
||||
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;
|
||||
@@ -79,9 +80,36 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) -
|
||||
|
||||
// Compile and encode the result to machine code.
|
||||
context
|
||||
.compile_and_emit(isa, &mut mem, &mut relocs, &mut traps, &mut stack_maps)
|
||||
.compile_and_emit(isa, &mut mem)
|
||||
.map_err(|err| anyhow::anyhow!("{}", pretty_error(&context.func, err)))?;
|
||||
let code_info = context.mach_compile_result.as_ref().unwrap().code_info();
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user