Commit 349ee0fd authored by qinsoon's avatar qinsoon

fix bugs for last commit

parent eb925382
Pipeline #1230 canceled with stages
in 237 minutes and 55 seconds
......@@ -1083,6 +1083,13 @@ impl Value {
}
}
pub fn extract_func_const(&self) -> Option<MuID> {
match self.v {
Value_::Constant(Constant::FuncRef(id)) => Some(id),
_ => None
}
}
pub fn extract_int_const(&self) -> Option<u64> {
match self.v {
Value_::Constant(Constant::Int(val)) => Some(val),
......
......@@ -6389,7 +6389,7 @@ impl<'a> InstructionSelection {
} else if dest.is_reg() && src.is_mem() {
// mem -> reg
self.backend.emit_mov_r_mem(dest, src);
} else if dest.is_reg() && src.is_const() {
} else if dest.is_reg() && src.is_int_const() {
if src.is_const_zero() {
self.emit_clear_value(dest, f_context, vm);
} else if x86_64::is_valid_x86_imm(src) {
......@@ -6402,6 +6402,10 @@ impl<'a> InstructionSelection {
self.backend.emit_mov_r64_imm64(&tmp, imm64 as i64);
self.backend.emit_mov_r_r(dest, &tmp);
}
} else if dest.is_reg() && src.is_func_const() {
let func_id = src.extract_func_const().unwrap();
let mem = self.get_mem_for_funcref(func_id, vm);
self.backend.emit_mov_r_mem(dest, &mem);
} else if dest.is_mem() && src.is_reg() {
// reg -> mem
self.backend.emit_mov_mem_r(dest, src);
......@@ -6425,7 +6429,13 @@ impl<'a> InstructionSelection {
panic!("unexpected gpr mov between {} -> {}", src, dest);
}
} else if RegGroup::get_from_ty(&src_ty) == RegGroup::GPREX {
if dest.is_reg() && src.is_reg() {
if dest.is_reg() && src.is_int_ex_const() {
let vec = src.extract_int_ex_const();
let (res_l, res_h) = self.split_int128(dest, f_context, vm);
self.backend.emit_mov_r64_imm64(&res_l, vec[0] as i64);
self.backend.emit_mov_r64_imm64(&res_h, vec[1] as i64);
} else if dest.is_reg() && src.is_reg() {
let (op_l, op_h) = self.split_int128(src, f_context, vm);
let (res_l, res_h) = self.split_int128(dest, f_context, vm);
......
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