📄 x86sse.c
字号:
}void sse_xorps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_2ub(p, X86_TWOB, 0x57); emit_modrm( p, dst, src );}void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ assert(dst.file == file_MMX && (src.file == file_XMM || src.mod != mod_REG)); p->need_emms = 1; emit_2ub(p, X86_TWOB, 0x2d); emit_modrm( p, dst, src );}/* Shufps can also be used to implement a reduced swizzle when dest == * arg0. */void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, unsigned char shuf) { emit_2ub(p, X86_TWOB, 0xC6); emit_modrm(p, dest, arg0); emit_1ub(p, shuf); }void sse_cmpps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, unsigned char cc) { emit_2ub(p, X86_TWOB, 0xC2); emit_modrm(p, dest, arg0); emit_1ub(p, cc); }void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src){ emit_3ub(p, 0x66, X86_TWOB, 0xD7); emit_modrm(p, dest, src);}/*********************************************************************** * SSE2 instructions *//** * Perform a reduced swizzle: */void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, unsigned char shuf) { emit_3ub(p, 0x66, X86_TWOB, 0x70); emit_modrm(p, dest, arg0); emit_1ub(p, shuf); }void sse2_cvttps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub( p, 0xF3, X86_TWOB, 0x5B ); emit_modrm( p, dst, src );}void sse2_cvtps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub(p, 0x66, X86_TWOB, 0x5B); emit_modrm( p, dst, src );}void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub(p, 0x66, X86_TWOB, 0x6B); emit_modrm( p, dst, src );}void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub(p, 0x66, X86_TWOB, 0x63); emit_modrm( p, dst, src );}void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub(p, 0x66, X86_TWOB, 0x67); emit_modrm( p, dst, src );}void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_2ub(p, X86_TWOB, 0x53); emit_modrm( p, dst, src );}void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_3ub(p, 0xF3, X86_TWOB, 0x53); emit_modrm( p, dst, src );}void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ emit_2ub(p, 0x66, X86_TWOB); emit_op_modrm( p, 0x6e, 0x7e, dst, src );}/*********************************************************************** * x87 instructions */void x87_fist( struct x86_function *p, struct x86_reg dst ){ emit_1ub(p, 0xdb); emit_modrm_noreg(p, 2, dst);}void x87_fistp( struct x86_function *p, struct x86_reg dst ){ emit_1ub(p, 0xdb); emit_modrm_noreg(p, 3, dst);}void x87_fild( struct x86_function *p, struct x86_reg arg ){ emit_1ub(p, 0xdf); emit_modrm_noreg(p, 0, arg);}void x87_fldz( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xee);}void x87_fldcw( struct x86_function *p, struct x86_reg arg ){ assert(arg.file == file_REG32); assert(arg.mod != mod_REG); emit_1ub(p, 0xd9); emit_modrm_noreg(p, 5, arg);}void x87_fld1( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xe8);}void x87_fldl2e( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xea);}void x87_fldln2( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xed);}void x87_fwait( struct x86_function *p ){ emit_1ub(p, 0x9b);}void x87_fnclex( struct x86_function *p ){ emit_2ub(p, 0xdb, 0xe2);}void x87_fclex( struct x86_function *p ){ x87_fwait(p); x87_fnclex(p);}static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg, unsigned char dst0ub0, unsigned char dst0ub1, unsigned char arg0ub0, unsigned char arg0ub1, unsigned char argmem_noreg){ assert(dst.file == file_x87); if (arg.file == file_x87) { if (dst.idx == 0) emit_2ub(p, dst0ub0, dst0ub1+arg.idx); else if (arg.idx == 0) emit_2ub(p, arg0ub0, arg0ub1+arg.idx); else assert(0); } else if (dst.idx == 0) { assert(arg.file == file_REG32); emit_1ub(p, 0xd8); emit_modrm_noreg(p, argmem_noreg, arg); } else assert(0);}void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xc8, 0xdc, 0xc8, 4);}void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xe0, 0xdc, 0xe8, 4);}void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xe8, 0xdc, 0xe0, 5);}void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xc0, 0xdc, 0xc0, 0);}void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xf0, 0xdc, 0xf8, 6);}void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ){ x87_arith_op(p, dst, arg, 0xd8, 0xf8, 0xdc, 0xf0, 7);}void x87_fmulp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xc8+dst.idx);}void x87_fsubp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xe8+dst.idx);}void x87_fsubrp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xe0+dst.idx);}void x87_faddp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xc0+dst.idx);}void x87_fdivp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xf8+dst.idx);}void x87_fdivrp( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_x87); assert(dst.idx >= 1); emit_2ub(p, 0xde, 0xf0+dst.idx);}void x87_fucom( struct x86_function *p, struct x86_reg arg ){ assert(arg.file == file_x87); emit_2ub(p, 0xdd, 0xe0+arg.idx);}void x87_fucomp( struct x86_function *p, struct x86_reg arg ){ assert(arg.file == file_x87); emit_2ub(p, 0xdd, 0xe8+arg.idx);}void x87_fucompp( struct x86_function *p ){ emit_2ub(p, 0xda, 0xe9);}void x87_fxch( struct x86_function *p, struct x86_reg arg ){ assert(arg.file == file_x87); emit_2ub(p, 0xd9, 0xc8+arg.idx);}void x87_fabs( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xe1);}void x87_fchs( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xe0);}void x87_fcos( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xff);}void x87_fprndint( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xfc);}void x87_fscale( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xfd);}void x87_fsin( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xfe);}void x87_fsincos( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xfb);}void x87_fsqrt( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xfa);}void x87_fxtract( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xf4);}/* st0 = (2^st0)-1 * * Restrictions: -1.0 <= st0 <= 1.0 */void x87_f2xm1( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xf0);}/* st1 = st1 * log2(st0); * pop_stack; */void x87_fyl2x( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xf1);}/* st1 = st1 * log2(st0 + 1.0); * pop_stack; * * A fast operation, with restrictions: -.29 < st0 < .29 */void x87_fyl2xp1( struct x86_function *p ){ emit_2ub(p, 0xd9, 0xf9);}void x87_fld( struct x86_function *p, struct x86_reg arg ){ if (arg.file == file_x87) emit_2ub(p, 0xd9, 0xc0 + arg.idx); else { emit_1ub(p, 0xd9); emit_modrm_noreg(p, 0, arg); }}void x87_fst( struct x86_function *p, struct x86_reg dst ){ if (dst.file == file_x87) emit_2ub(p, 0xdd, 0xd0 + dst.idx); else { emit_1ub(p, 0xd9); emit_modrm_noreg(p, 2, dst); }}void x87_fstp( struct x86_function *p, struct x86_reg dst ){ if (dst.file == file_x87) emit_2ub(p, 0xdd, 0xd8 + dst.idx); else { emit_1ub(p, 0xd9); emit_modrm_noreg(p, 3, dst); }}void x87_fcom( struct x86_function *p, struct x86_reg dst ){ if (dst.file == file_x87) emit_2ub(p, 0xd8, 0xd0 + dst.idx); else { emit_1ub(p, 0xd8); emit_modrm_noreg(p, 2, dst); }}void x87_fcomp( struct x86_function *p, struct x86_reg dst ){ if (dst.file == file_x87) emit_2ub(p, 0xd8, 0xd8 + dst.idx); else { emit_1ub(p, 0xd8); emit_modrm_noreg(p, 3, dst); }}void x87_fnstsw( struct x86_function *p, struct x86_reg dst ){ assert(dst.file == file_REG32); if (dst.idx == reg_AX && dst.mod == mod_REG) emit_2ub(p, 0xdf, 0xe0); else { emit_1ub(p, 0xdd); emit_modrm_noreg(p, 7, dst); }}/*********************************************************************** * MMX instructions */void mmx_emms( struct x86_function *p ){ assert(p->need_emms); emit_2ub(p, 0x0f, 0x77); p->need_emms = 0;}void mmx_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ assert(dst.file == file_MMX && (src.file == file_MMX || src.mod != mod_REG)); p->need_emms = 1; emit_2ub(p, X86_TWOB, 0x6b); emit_modrm( p, dst, src );}void mmx_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ assert(dst.file == file_MMX && (src.file == file_MMX || src.mod != mod_REG)); p->need_emms = 1; emit_2ub(p, X86_TWOB, 0x67); emit_modrm( p, dst, src );}void mmx_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ p->need_emms = 1; emit_1ub(p, X86_TWOB); emit_op_modrm( p, 0x6e, 0x7e, dst, src );}void mmx_movq( struct x86_function *p, struct x86_reg dst, struct x86_reg src ){ p->need_emms = 1; emit_1ub(p, X86_TWOB); emit_op_modrm( p, 0x6f, 0x7f, dst, src );}/*********************************************************************** * Helper functions *//* Retreive a reference to one of the function arguments, taking into * account any push/pop activity: */struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ){ return x86_make_disp(x86_make_reg(file_REG32, reg_SP), p->stack_offset + arg * 4); /* ??? */}void x86_init_func( struct x86_function *p ){ p->size = 0; p->store = NULL; p->csr = p->store;}int x86_init_func_size( struct x86_function *p, unsigned code_size ){ p->size = code_size; p->store = _mesa_exec_malloc(code_size); p->csr = p->store; return p->store != NULL;}void x86_release_func( struct x86_function *p ){ _mesa_exec_free(p->store); p->store = NULL; p->csr = NULL; p->size = 0;}void (*x86_get_func( struct x86_function *p ))(void){ if (DISASSEM && p->store) _mesa_printf("disassemble %p %p\n", p->store, p->csr); return (void (*)(void)) (unsigned long) p->store;}#elsevoid x86sse_dummy( void ){}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -