GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit 5370306e authored by qinsoon's avatar qinsoon

fix implementation of truncating to i32

parent 4bd070a0
Pipeline #119 failed with stage
in 30 minutes and 33 seconds
......@@ -640,7 +640,7 @@ impl <'a> InstructionSelection {
// truncate result
if res_tmp.is_int_reg() {
self.emit_truncate_result(&UINT64_TYPE, &res_tmp.ty, &res_tmp);
self.emit_truncate_result(&UINT64_TYPE, &res_tmp.ty, &res_tmp, f_context, vm);
}
}
......@@ -669,7 +669,7 @@ impl <'a> InstructionSelection {
self.backend.emit_mov_r64_r64(&tmp_res, &tmp_op);
// truncate result
self.emit_truncate_result(from_ty, to_ty, &tmp_res);
self.emit_truncate_result(from_ty, to_ty, &tmp_res, f_context, vm);
} else {
panic!("unexpected op (expect ireg): {}", op);
}
......@@ -955,7 +955,7 @@ impl <'a> InstructionSelection {
})
}
fn emit_truncate_result (&mut self, from_ty: &P<MuType>, to_ty: &P<MuType>, op: &P<Value>) {
fn emit_truncate_result (&mut self, from_ty: &P<MuType>, to_ty: &P<MuType>, op: &P<Value>, f_context: &mut FunctionContext, vm: &VM) {
// currently only use 64bits register
// so only keep what is needed in the register (set others to 0)
let from_ty_len = match from_ty.v {
......@@ -972,16 +972,25 @@ impl <'a> InstructionSelection {
} else {
debug_assert!(from_ty_len > to_ty_len);
// ignoring from_ty for now (we use 64bits register for everything)
let mask = match to_ty_len {
8 => 0xFFi32,
16 => 0xFFFFi32,
32 => 0xFFFFFFFFi32,
_ => unimplemented!()
};
if to_ty_len < 32 {
// ignoring from_ty for now (we use 64bits register for everything)
let mask = match to_ty_len {
8 => 0xFFi32,
16 => 0xFFFFi32,
_ => unimplemented!()
};
// and mask, result -> result
self.backend.emit_and_r64_imm32(&op, mask);
} else if to_ty_len == 32 {
let tmp_mask = self.make_temporary(f_context, UINT64_TYPE.clone(), vm);
self.backend.emit_mov_r64_imm64(&tmp_mask, 0xFFFFFFFF as i64);
// and mask, result -> result
self.backend.emit_and_r64_imm32(&op, mask);
self.backend.emit_and_r64_r64(&op, &tmp_mask);
} else {
unimplemented!()
}
}
}
......
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