Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HADDPS instruction #837

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gen/x86_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ const encodings = [
{ sse: 1, opcode: 0x660F59, e: 1, custom: 1 },
{ sse: 1, opcode: 0xF20F59, e: 1, custom: 1 },
{ sse: 1, opcode: 0xF30F59, e: 1, custom: 1 },
{ sse: 1, opcode: 0xF20F7C, e: 1, custom: 1 },

{ sse: 1, opcode: 0x0F5A, e: 1, custom: 1 },
{ sse: 1, opcode: 0x660F5A, e: 1, custom: 1 },
Expand Down
18 changes: 18 additions & 0 deletions src/rust/cpu/instructions_0f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,24 @@ pub unsafe fn instr_F30F59_reg(r1: i32, r2: i32) { instr_F30F59(read_xmm_f32(r1)
pub unsafe fn instr_F30F59_mem(addr: i32, r: i32) {
instr_F30F59(return_on_pagefault!(safe_read_f32(addr)), r);
}
#[no_mangle]
pub unsafe fn instr_F20F7C(source: reg128, r: i32) {
// haddps xmm, xmm/mem128
let destination = read_xmm128s(r);
let result = reg128 {
f32: [
destination.f32[0] + destination.f32[1],
destination.f32[2] + destination.f32[3],
source.f32[0] + source.f32[1],
source.f32[2] + source.f32[3],
],
};
write_xmm_reg128(r, result);
}
pub unsafe fn instr_F20F7C_reg(r1: i32, r2: i32) { instr_F20F7C(read_xmm128s(r1), r2); }
pub unsafe fn instr_F20F7C_mem(addr: i32, r: i32) {
instr_F20F7C(return_on_pagefault!(safe_read128s(addr)), r);
}

#[no_mangle]
pub unsafe fn instr_0F5A(source: u64, r: i32) {
Expand Down
6 changes: 6 additions & 0 deletions src/rust/jit_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6128,6 +6128,12 @@ pub fn instr_F30F59_mem_jit(ctx: &mut JitContext, modrm_byte: ModrmByte, r: u32)
pub fn instr_F30F59_reg_jit(ctx: &mut JitContext, r1: u32, r2: u32) {
sse_read_f32_xmm_xmm(ctx, "instr_F30F59", r1, r2);
}
pub fn instr_F20F7C_mem_jit(ctx: &mut JitContext, modrm_byte: ModrmByte, r: u32) {
sse_read128_xmm_mem(ctx, "instr_F20F7C", modrm_byte, r);
}
pub fn instr_F20F7C_reg_jit(ctx: &mut JitContext, r1: u32, r2: u32) {
sse_read128_xmm_xmm(ctx, "instr_F20F7C", r1, r2);
}

pub fn instr_0F5A_mem_jit(ctx: &mut JitContext, modrm_byte: ModrmByte, r: u32) {
sse_read64_xmm_mem(ctx, "instr_0F5A", modrm_byte, r);
Expand Down