sse: Implement 0F52/rcpps (#57)

This commit is contained in:
Fabian 2018-08-28 12:27:25 -05:00
parent 5dd26ead30
commit 9e902eb1dc
2 changed files with 38 additions and 4 deletions

View file

@ -511,8 +511,7 @@ const encodings = [
// mmx, sse
// - Skipped are not implemented
// - Missing are sse3+, and floating point
// - skipped or missing are sse3+
{ sse: 1, opcode: 0x0F10, e: 1 },
{ sse: 1, opcode: 0xF30F10, e: 1 },
@ -567,7 +566,10 @@ const encodings = [
{ sse: 1, opcode: 0x660F51, e: 1 },
{ sse: 1, opcode: 0xF20F51, e: 1 },
{ sse: 1, opcode: 0xF30F51, e: 1 },
{ sse: 1, opcode: 0x0F52, skip: 1 },
// approximation of 1/sqrt(x). Skipped because our approximation doesn't match intel's
{ sse: 1, opcode: 0x0F52, e: 1, skip: 1, },
{ sse: 1, opcode: 0xF30F52, e: 1, skip: 1, },
// reciprocal: approximation of 1/x. Skipped because our approximation doesn't match intel's
{ sse: 1, opcode: 0x0F53, e: 1, skip: 1, },

View file

@ -5830,8 +5830,40 @@ pub unsafe fn instr_F30F51_reg(mut r1: i32, mut r2: i32) -> () {
pub unsafe fn instr_F30F51_mem(mut addr: i32, mut r: i32) -> () {
instr_F30F51(return_on_pagefault!(fpu_load_m32(addr)) as f32, r);
}
#[no_mangle]
pub unsafe fn instr_0F52() -> () { unimplemented_sse(); }
pub unsafe fn instr_0F52(mut source: reg128, mut r: i32) -> () {
c_comment!(("rcpps xmm1, xmm2/m128"));
let mut result: reg128 = reg128 {
f32_0: [
1i32 as f32 / source.f32_0[0usize].sqrt(),
1i32 as f32 / source.f32_0[1usize].sqrt(),
1i32 as f32 / source.f32_0[2usize].sqrt(),
1i32 as f32 / source.f32_0[3usize].sqrt(),
],
};
write_xmm_reg128(r, result);
}
#[no_mangle]
pub unsafe fn instr_0F52_reg(mut r1: i32, mut r2: i32) -> () { instr_0F52(read_xmm128s(r1), r2); }
#[no_mangle]
pub unsafe fn instr_0F52_mem(mut addr: i32, mut r: i32) -> () {
instr_0F52(return_on_pagefault!(safe_read128s(addr)), r);
}
#[no_mangle]
pub unsafe fn instr_F30F52(mut source: f32, mut r: i32) -> () {
c_comment!(("rsqrtss xmm1, xmm2/m32"));
write_xmm_f32(r, 1i32 as f32 / source.sqrt());
}
#[no_mangle]
pub unsafe fn instr_F30F52_reg(mut r1: i32, mut r2: i32) -> () {
instr_F30F52(read_xmm_f32(r1), r2);
}
#[no_mangle]
pub unsafe fn instr_F30F52_mem(mut addr: i32, mut r: i32) -> () {
instr_F30F52(return_on_pagefault!(fpu_load_m32(addr)) as f32, r);
}
#[no_mangle]
pub unsafe fn instr_0F53(mut source: reg128, mut r: i32) -> () {
c_comment!(("rcpps xmm, xmm/m128"));