Skip to content

Commit

Permalink
more sse stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMerrill committed Oct 20, 2019
1 parent 1c7b53d commit 251965c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions emu/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
READMODRM; VXOR(xmm_modrm_val, xmm_modrm_reg,128);
break;

case 0x6e: TRACEI("movd modrm, xmm");
READMODRM; VZLOAD(modrm_val, xmm_modrm_reg,32);
break;

case 0x73: TRACEI("psrlq xmm imm");
READIMM8; VIMM_SHIFTR(xmm_modrm_reg, imm,64);
break;

case 0x7e: TRACEI("movd xmm, modrm");
READMODRM; VSTORE(xmm_modrm_reg, xmm_modrm_val,32);
break;

case 0x80: TRACEI("jo rel\t");
READIMM; J_REL(O, imm); break;
case 0x81: TRACEI("jno rel\t");
Expand Down
5 changes: 5 additions & 0 deletions emu/sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void vec_store128(struct cpu_state *UNUSED(cpu), union xmm_reg *dst, const union
*dst = *src;
}

void vec_imm_shiftr64(struct cpu_state *UNUSED(cpu), const uint64_t amount, union xmm_reg *src) {
src->qw[0] >>= (uint8_t) amount;
src->qw[1] >>= (uint8_t) amount;
}

void vec_xor128(struct cpu_state *UNUSED(cpu), union xmm_reg *src, union xmm_reg *dst) {
dst->qw[0] ^= src->qw[0];
dst->qw[1] ^= src->qw[1];
Expand Down
6 changes: 6 additions & 0 deletions emu/sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ void vec_compare32(struct cpu_state *UNUSED(cpu), float *f2, float *f1);
* - If v(...) is being used, the first argument is source.
* - If v_write(...) is being used, the first argument is being written to.
* Because the first argument is the operand that might be memory.
*
* jit/gen method | arg order
* ----------------|------------
* v() | const a, b
* v_write() | a, const b
*/

void vec_load32(struct cpu_state *UNUSED(cpu), const union xmm_reg *src, union xmm_reg *dst);
Expand All @@ -32,6 +37,7 @@ void vec_store32(struct cpu_state *UNUSED(cpu), union xmm_reg *src, const union
void vec_store64(struct cpu_state *UNUSED(cpu), union xmm_reg *src, const union xmm_reg *dst);
void vec_store128(struct cpu_state *UNUSED(cpu), union xmm_reg *src, const union xmm_reg *dst);

void vec_imm_shiftr64(struct cpu_state *UNUSED(cpu), const uint64 amount, union xmm_reg *src);
void vec_xor128(struct cpu_state *cpu, union xmm_reg *src, union xmm_reg *dst);

#endif
3 changes: 2 additions & 1 deletion jit/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static inline bool gen_vec(enum arg rm, enum arg reg, void (*helper)(), gadget_t
#define v_write(op, src, dst,z) _v(arg_##dst, arg_##src, vec_##op##z, vec_helper_store##z##_gadgets, z)

#define VLOAD(src, dst,z) v(load, src, dst,z)
#define VZLOAD(src, dst,z) v_write(zload, dst, src,z)
#define VZLOAD(src, dst,z) v(zload, src, dst, z)
#define VLOAD_PADNOTMEM(src, dst, z) do { \
if (arg_##src == arg_xmm_modrm_val && modrm.type != modrm_mem) { \
VZLOAD(src, dst, z); \
Expand All @@ -494,6 +494,7 @@ static inline bool gen_vec(enum arg rm, enum arg reg, void (*helper)(), gadget_t
} while (0)
#define VSTORE(src, dst,z) v_write(store, src, dst,z)
#define VCOMPARE(src, dst,z) v(compare, src, dst,z)
#define VIMM_SHIFTR(src, amount,z) v(imm_shiftr, amount, src,z)
#define VXOR(src, dst,z) v(xor, src, dst,z)

#define DECODER_RET int
Expand Down

0 comments on commit 251965c

Please sign in to comment.