Commit 83f3055c authored by qinsoon's avatar qinsoon

[wip] need to add more insts at backend for different operand lengths

parent 5eb42af0
...@@ -1075,7 +1075,7 @@ impl CodeGenerator for ASMCodeGen { ...@@ -1075,7 +1075,7 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_symbolic(directive_globl(func_symbol.clone())); self.add_asm_symbolic(directive_globl(func_symbol.clone()));
self.add_asm_symbolic(format!("{}:", func_symbol.clone())); self.add_asm_symbolic(format!("{}:", func_symbol.clone()));
ValueLocation::Relocatable(RegGroup::GPR, func_name) ValueLocation::Relocatable(RegGroup::GPR64, func_name)
} }
fn finish_code(&mut self, func_name: MuName) -> (Box<MachineCode + Sync + Send>, ValueLocation) { fn finish_code(&mut self, func_name: MuName) -> (Box<MachineCode + Sync + Send>, ValueLocation) {
...@@ -1091,7 +1091,7 @@ impl CodeGenerator for ASMCodeGen { ...@@ -1091,7 +1091,7 @@ impl CodeGenerator for ASMCodeGen {
( (
self.cur.take().unwrap(), self.cur.take().unwrap(),
ValueLocation::Relocatable(RegGroup::GPR, func_end) ValueLocation::Relocatable(RegGroup::GPR64, func_end)
) )
} }
...@@ -1141,7 +1141,7 @@ impl CodeGenerator for ASMCodeGen { ...@@ -1141,7 +1141,7 @@ impl CodeGenerator for ASMCodeGen {
self.start_block(block_name.clone()); self.start_block(block_name.clone());
ValueLocation::Relocatable(RegGroup::GPR, mangled_name) ValueLocation::Relocatable(RegGroup::GPR64, mangled_name)
} }
fn end_block(&mut self, block_name: MuName) { fn end_block(&mut self, block_name: MuName) {
...@@ -2123,7 +2123,7 @@ impl CodeGenerator for ASMCodeGen { ...@@ -2123,7 +2123,7 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_symbolic(directive_globl(callsite_symbol.clone())); self.add_asm_symbolic(directive_globl(callsite_symbol.clone()));
self.add_asm_symbolic(format!("{}:", callsite_symbol.clone())); self.add_asm_symbolic(format!("{}:", callsite_symbol.clone()));
ValueLocation::Relocatable(RegGroup::GPR, callsite) ValueLocation::Relocatable(RegGroup::GPR64, callsite)
} }
fn emit_call_near_r64(&mut self, callsite: String, func: &P<Value>) -> ValueLocation { fn emit_call_near_r64(&mut self, callsite: String, func: &P<Value>) -> ValueLocation {
......
This diff is collapsed.
...@@ -170,4 +170,30 @@ pub struct BackendTypeInfo { ...@@ -170,4 +170,30 @@ pub struct BackendTypeInfo {
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub enum RegGroup {GPR, FPR} pub enum RegGroup {GPR8, GPR16, GPR32, GPR64, FPR32, FPR64}
impl RegGroup {
pub fn get(ty: &P<MuType>) -> RegGroup {
match ty.v {
MuType_::Int(len) if len == 8 => RegGroup::GPR8,
MuType_::Int(len) if len == 16 => RegGroup::GPR16,
MuType_::Int(len) if len == 32 => RegGroup::GPR32,
MuType_::Int(len) if len == 64 => RegGroup::GPR64,
MuType_::Ref(_)
| MuType_::IRef(_)
| MuType_::WeakRef(_)
| MuType_::UPtr(_)
| MuType_::ThreadRef
| MuType_::StackRef
| MuType_::Tagref64
| MuType_::FuncRef(_)
| MuType_::UFuncPtr(_) => RegGroup::GPR64,
MuType_::Float => RegGroup::FPR32,
MuType_::Double => RegGroup::FPR64,
_ => unimplemented!()
}
}
}
\ No newline at end of file
...@@ -64,8 +64,12 @@ impl <'a> GraphColoring<'a> { ...@@ -64,8 +64,12 @@ impl <'a> GraphColoring<'a> {
precolored: LinkedHashSet::new(), precolored: LinkedHashSet::new(),
colors: { colors: {
let mut map = HashMap::new(); let mut map = HashMap::new();
map.insert(backend::RegGroup::GPR, LinkedHashSet::new()); map.insert(backend::RegGroup::GPR8, LinkedHashSet::new());
map.insert(backend::RegGroup::FPR, LinkedHashSet::new()); map.insert(backend::RegGroup::GPR16, LinkedHashSet::new());
map.insert(backend::RegGroup::GPR32, LinkedHashSet::new());
map.insert(backend::RegGroup::GPR64, LinkedHashSet::new());
map.insert(backend::RegGroup::FPR32, LinkedHashSet::new());
map.insert(backend::RegGroup::FPR64, LinkedHashSet::new());
map map
}, },
colored_nodes: Vec::new(), colored_nodes: Vec::new(),
......
...@@ -54,18 +54,7 @@ impl InterferenceGraph { ...@@ -54,18 +54,7 @@ impl InterferenceGraph {
self.nodes.insert(reg_id, node.clone()); self.nodes.insert(reg_id, node.clone());
// add node property // add node property
let group = { let group = backend::RegGroup::get(entry.ty());
let ref ty = entry.ty();
if types::is_scalar(ty) {
if types::is_fp(ty) {
backend::RegGroup::FPR
} else {
backend::RegGroup::GPR
}
} else {
unimplemented!()
}
};
let property = NodeProperty { let property = NodeProperty {
color: None, color: None,
group: group, group: group,
......
...@@ -25,7 +25,7 @@ lazy_static! { ...@@ -25,7 +25,7 @@ lazy_static! {
ret_tys: vec![ADDRESS_TYPE.clone()], ret_tys: vec![ADDRESS_TYPE.clone()],
arg_tys: vec![] arg_tys: vec![]
}), }),
aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_get_thread_local")), aot: ValueLocation::Relocatable(RegGroup::GPR64, String::from("muentry_get_thread_local")),
jit: RwLock::new(None), jit: RwLock::new(None),
}; };
...@@ -37,7 +37,7 @@ lazy_static! { ...@@ -37,7 +37,7 @@ lazy_static! {
ret_tys: vec![], ret_tys: vec![],
arg_tys: vec![ADDRESS_TYPE.clone()] arg_tys: vec![ADDRESS_TYPE.clone()]
}), }),
aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_swap_back_to_native_stack")), aot: ValueLocation::Relocatable(RegGroup::GPR64, String::from("muentry_swap_back_to_native_stack")),
jit: RwLock::new(None), jit: RwLock::new(None),
}; };
...@@ -48,7 +48,7 @@ lazy_static! { ...@@ -48,7 +48,7 @@ lazy_static! {
ret_tys: vec![ADDRESS_TYPE.clone()], ret_tys: vec![ADDRESS_TYPE.clone()],
arg_tys: vec![UINT64_TYPE.clone(), UINT64_TYPE.clone()] arg_tys: vec![UINT64_TYPE.clone(), UINT64_TYPE.clone()]
}), }),
aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_slow")), aot: ValueLocation::Relocatable(RegGroup::GPR64, String::from("muentry_alloc_slow")),
jit: RwLock::new(None), jit: RwLock::new(None),
}; };
...@@ -59,7 +59,7 @@ lazy_static! { ...@@ -59,7 +59,7 @@ lazy_static! {
ret_tys: vec![], ret_tys: vec![],
arg_tys: vec![ADDRESS_TYPE.clone()] arg_tys: vec![ADDRESS_TYPE.clone()]
}), }),
aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_throw_exception")), aot: ValueLocation::Relocatable(RegGroup::GPR64, String::from("muentry_throw_exception")),
jit: RwLock::new(None), jit: RwLock::new(None),
}; };
} }
\ No newline at end of file
...@@ -153,9 +153,9 @@ impl ValueLocation { ...@@ -153,9 +153,9 @@ impl ValueLocation {
#[allow(unused_variables)] #[allow(unused_variables)]
pub fn from_constant(c: Constant) -> ValueLocation { pub fn from_constant(c: Constant) -> ValueLocation {
match c { match c {
Constant::Int(int_val) => ValueLocation::Constant(RegGroup::GPR, utils::mem::u64_to_raw(int_val)), Constant::Int(int_val) => ValueLocation::Constant(RegGroup::GPR64, utils::mem::u64_to_raw(int_val)),
Constant::Float(f32_val) => ValueLocation::Constant(RegGroup::FPR, utils::mem::f32_to_raw(f32_val)), Constant::Float(f32_val) => ValueLocation::Constant(RegGroup::FPR32, utils::mem::f32_to_raw(f32_val)),
Constant::Double(f64_val) => ValueLocation::Constant(RegGroup::FPR, utils::mem::f64_to_raw(f64_val)), Constant::Double(f64_val) => ValueLocation::Constant(RegGroup::FPR64, utils::mem::f64_to_raw(f64_val)),
_ => unimplemented!() _ => unimplemented!()
} }
......
...@@ -123,8 +123,12 @@ impl MuStack { ...@@ -123,8 +123,12 @@ impl MuStack {
let (reg_group, word) = val.load_value(); let (reg_group, word) = val.load_value();
match reg_group { match reg_group {
RegGroup::GPR => gpr_used.push(word), RegGroup::GPR8
RegGroup::FPR => fpr_used.push(word), | RegGroup::GPR16
| RegGroup::GPR32
| RegGroup::GPR64 => gpr_used.push(word),
RegGroup::FPR32
| RegGroup::FPR64 => fpr_used.push(word),
} }
} }
......
...@@ -24,13 +24,18 @@ pub fn get_test_clang_path() -> String { ...@@ -24,13 +24,18 @@ pub fn get_test_clang_path() -> String {
pub fn exec (mut cmd: Command) -> Output { pub fn exec (mut cmd: Command) -> Output {
println!("executing: {:?}", cmd); println!("executing: {:?}", cmd);
let output = cmd.output().expect("failed to execute"); let output = match cmd.output() {
Ok(res) => res,
Err(e) => panic!("failed to execute: {}", e)
};
println!("---out---"); println!("---out---");
println!("{}", String::from_utf8_lossy(&output.stdout)); println!("{}", String::from_utf8_lossy(&output.stdout));
println!("---err---"); println!("---err---");
println!("{}", String::from_utf8_lossy(&output.stderr)); println!("{}", String::from_utf8_lossy(&output.stderr));
assert!(output.status.success());
output output
} }
......
...@@ -642,7 +642,7 @@ impl <'a> VM { ...@@ -642,7 +642,7 @@ impl <'a> VM {
if self.is_running() { if self.is_running() {
unimplemented!() unimplemented!()
} else { } else {
ValueLocation::Relocatable(backend::RegGroup::GPR, func.name().unwrap()) ValueLocation::Relocatable(backend::RegGroup::GPR64, func.name().unwrap())
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment