forked from AbleOS/holey-bytes
adding regalloc option
This commit is contained in:
parent
981c17ff19
commit
454b0ffd1c
|
@ -39,6 +39,7 @@ pub struct Options {
|
||||||
pub fmt: bool,
|
pub fmt: bool,
|
||||||
pub fmt_stdout: bool,
|
pub fmt_stdout: bool,
|
||||||
pub dump_asm: bool,
|
pub dump_asm: bool,
|
||||||
|
pub in_house_regalloc: bool,
|
||||||
pub extra_threads: usize,
|
pub extra_threads: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ impl Options {
|
||||||
fmt: args.contains(&"--fmt"),
|
fmt: args.contains(&"--fmt"),
|
||||||
fmt_stdout: args.contains(&"--fmt-stdout"),
|
fmt_stdout: args.contains(&"--fmt-stdout"),
|
||||||
dump_asm: args.contains(&"--dump-asm"),
|
dump_asm: args.contains(&"--dump-asm"),
|
||||||
|
in_house_regalloc: args.contains(&"--in-house-regalloc"),
|
||||||
extra_threads: args
|
extra_threads: args
|
||||||
.iter()
|
.iter()
|
||||||
.position(|&a| a == "--threads")
|
.position(|&a| a == "--threads")
|
||||||
|
@ -92,6 +94,8 @@ pub fn run_compiler(root_file: &str, options: Options, out: &mut Vec<u8>) -> std
|
||||||
write!(out, "{}", &parsed.ast[0])?;
|
write!(out, "{}", &parsed.ast[0])?;
|
||||||
} else {
|
} else {
|
||||||
let mut backend = HbvmBackend::default();
|
let mut backend = HbvmBackend::default();
|
||||||
|
backend.use_in_house_regalloc = options.in_house_regalloc;
|
||||||
|
|
||||||
let mut ctx = crate::son::CodegenCtx::default();
|
let mut ctx = crate::son::CodegenCtx::default();
|
||||||
*ctx.parser.errors.get_mut() = parsed.errors;
|
*ctx.parser.errors.get_mut() = parsed.errors;
|
||||||
let mut codegen = son::Codegen::new(&mut backend, &parsed.ast, &mut ctx);
|
let mut codegen = son::Codegen::new(&mut backend, &parsed.ast, &mut ctx);
|
||||||
|
|
|
@ -49,6 +49,8 @@ struct Assembler {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct HbvmBackend {
|
pub struct HbvmBackend {
|
||||||
|
pub use_in_house_regalloc: bool,
|
||||||
|
|
||||||
funcs: EntVec<ty::Func, FuncDt>,
|
funcs: EntVec<ty::Func, FuncDt>,
|
||||||
globals: EntVec<ty::Global, GlobalDt>,
|
globals: EntVec<ty::Global, GlobalDt>,
|
||||||
asm: Assembler,
|
asm: Assembler,
|
||||||
|
@ -258,8 +260,11 @@ impl Backend for HbvmBackend {
|
||||||
nodes[MEM].outputs = mems;
|
nodes[MEM].outputs = mems;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (saved, tail) = self.emit_body_code(nodes, sig, tys, files);
|
let (saved, tail) = if self.use_in_house_regalloc {
|
||||||
//let (saved, tail) = self.emit_body_code_my(nodes, sig, tys, files);
|
self.emit_body_code_my(nodes, sig, tys, files)
|
||||||
|
} else {
|
||||||
|
self.emit_body_code(nodes, sig, tys, files)
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(last_ret) = self.ret_relocs.last()
|
if let Some(last_ret) = self.ret_relocs.last()
|
||||||
&& last_ret.offset as usize == self.code.len() - 5
|
&& last_ret.offset as usize == self.code.len() - 5
|
||||||
|
|
Loading…
Reference in a new issue