WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit 5370306e authored by qinsoon's avatar qinsoon
Browse files

fix implementation of truncating to i32

parent 4bd070a0
......@@ -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