X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fx86%2Frtasm%2Fx86sse.c;h=0d3242f1ae5765c04c4a6eb75e9302ff581c3dc1;hb=8e3696137f2cb7b4f5a3824f26186ecbb06f9282;hp=5aedf5b04beb16be24275f357c05908f2cf74983;hpb=5aaeb13a768f0c7d3706f6c170901b118ae1aa2d;p=mesa.git diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index 5aedf5b04be..0d3242f1ae5 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1,16 +1,22 @@ #ifdef USE_X86_ASM #if defined(__i386__) || defined(__386__) -#include "main/imports.h" +#include +#include +#include + +#include "main/execmem.h" #include "x86sse.h" #define DISASSEM 0 #define X86_TWOB 0x0f +#if 0 static unsigned char *cptr( void (*label)() ) { return (unsigned char *)(unsigned long)label; } +#endif static void do_realloc( struct x86_function *p ) @@ -84,18 +90,18 @@ static void emit_3ub( struct x86_function *p, unsigned char b0, unsigned char b1 /* Build a modRM byte + possible displacement. No treatment of SIB * indexing. BZZT - no way to encode an absolute address. */ -static void emit_modrm( struct x86_function *p, - struct x86_reg reg, +static void emit_modrm( struct x86_function *p, + struct x86_reg reg, struct x86_reg regmem ) { unsigned char val = 0; - + assert(reg.mod == mod_REG); - + val |= regmem.mod << 6; /* mod field */ val |= reg.idx << 3; /* reg field */ val |= regmem.idx; /* r/m field */ - + emit_1ub(p, val); /* Oh-oh we've stumbled into the SIB thing. @@ -136,11 +142,11 @@ static void emit_modrm_noreg( struct x86_function *p, * the arguments presented. */ static void emit_op_modrm( struct x86_function *p, - unsigned char op_dst_is_reg, + unsigned char op_dst_is_reg, unsigned char op_dst_is_mem, struct x86_reg dst, struct x86_reg src ) -{ +{ switch (dst.mod) { case mod_REG: emit_1ub(p, op_dst_is_reg); @@ -227,7 +233,7 @@ void x86_jcc( struct x86_function *p, unsigned char *label ) { int offset = label - (x86_get_label(p) + 2); - + if (offset <= 127 && offset >= -128) { emit_1ub(p, 0x70 + cc); emit_1b(p, (char) offset); @@ -611,7 +617,7 @@ void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) { - assert(dst.file == file_MMX && + assert(dst.file == file_MMX && (src.file == file_XMM || src.mod != mod_REG)); p->need_emms = 1; @@ -627,21 +633,21 @@ void sse_cvtps2pi( struct x86_function *p, void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf) + unsigned char shuf) { emit_2ub(p, X86_TWOB, 0xC6); emit_modrm(p, dest, arg0); - emit_1ub(p, shuf); + emit_1ub(p, shuf); } void sse_cmpps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char cc) + unsigned char cc) { emit_2ub(p, X86_TWOB, 0xC2); emit_modrm(p, dest, arg0); - emit_1ub(p, cc); + emit_1ub(p, cc); } void sse_pmovmskb( struct x86_function *p, @@ -662,11 +668,11 @@ void sse_pmovmskb( struct x86_function *p, void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, - unsigned char shuf) + unsigned char shuf) { emit_3ub(p, 0x66, X86_TWOB, 0x70); emit_modrm(p, dest, arg0); - emit_1ub(p, shuf); + emit_1ub(p, shuf); } void sse2_cvttps2dq( struct x86_function *p, @@ -813,9 +819,9 @@ static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86 assert(dst.file == file_x87); if (arg.file == file_x87) { - if (dst.idx == 0) + if (dst.idx == 0) emit_2ub(p, dst0ub0, dst0ub1+arg.idx); - else if (arg.idx == 0) + else if (arg.idx == 0) emit_2ub(p, arg0ub0, arg0ub1+arg.idx); else assert(0); @@ -831,7 +837,7 @@ static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86 void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xc8, 0xdc, 0xc8, 4); @@ -839,7 +845,7 @@ void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xe0, 0xdc, 0xe8, 4); @@ -847,7 +853,7 @@ void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xe8, 0xdc, 0xe0, 5); @@ -855,7 +861,7 @@ void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xc0, 0xdc, 0xc0, 0); @@ -863,7 +869,7 @@ void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xf0, 0xdc, 0xf8, 6); @@ -871,7 +877,7 @@ void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg ) { - x87_arith_op(p, dst, arg, + x87_arith_op(p, dst, arg, 0xd8, 0xf8, 0xdc, 0xf0, 7); @@ -1008,7 +1014,7 @@ void x87_fyl2x( struct x86_function *p ) /* st1 = st1 * log2(st0 + 1.0); * pop_stack; * - * A fast operation, with restrictions: -.29 < st0 < .29 + * A fast operation, with restrictions: -.29 < st0 < .29 */ void x87_fyl2xp1( struct x86_function *p ) { @@ -1018,7 +1024,7 @@ void x87_fyl2xp1( struct x86_function *p ) void x87_fld( struct x86_function *p, struct x86_reg arg ) { - if (arg.file == file_x87) + if (arg.file == file_x87) emit_2ub(p, 0xd9, 0xc0 + arg.idx); else { emit_1ub(p, 0xd9); @@ -1028,7 +1034,7 @@ void x87_fld( struct x86_function *p, struct x86_reg arg ) void x87_fst( struct x86_function *p, struct x86_reg dst ) { - if (dst.file == file_x87) + if (dst.file == file_x87) emit_2ub(p, 0xdd, 0xd0 + dst.idx); else { emit_1ub(p, 0xd9); @@ -1038,7 +1044,7 @@ void x87_fst( struct x86_function *p, struct x86_reg dst ) void x87_fstp( struct x86_function *p, struct x86_reg dst ) { - if (dst.file == file_x87) + if (dst.file == file_x87) emit_2ub(p, 0xdd, 0xd8 + dst.idx); else { emit_1ub(p, 0xd9); @@ -1048,7 +1054,7 @@ void x87_fstp( struct x86_function *p, struct x86_reg dst ) void x87_fcom( struct x86_function *p, struct x86_reg dst ) { - if (dst.file == file_x87) + if (dst.file == file_x87) emit_2ub(p, 0xd8, 0xd0 + dst.idx); else { emit_1ub(p, 0xd8); @@ -1058,7 +1064,7 @@ void x87_fcom( struct x86_function *p, struct x86_reg dst ) void x87_fcomp( struct x86_function *p, struct x86_reg dst ) { - if (dst.file == file_x87) + if (dst.file == file_x87) emit_2ub(p, 0xd8, 0xd8 + dst.idx); else { emit_1ub(p, 0xd8); @@ -1072,7 +1078,7 @@ 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) + dst.mod == mod_REG) emit_2ub(p, 0xdf, 0xe0); else { emit_1ub(p, 0xdd); @@ -1098,7 +1104,7 @@ void mmx_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) { - assert(dst.file == file_MMX && + assert(dst.file == file_MMX && (src.file == file_MMX || src.mod != mod_REG)); p->need_emms = 1; @@ -1111,7 +1117,7 @@ void mmx_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src ) { - assert(dst.file == file_MMX && + assert(dst.file == file_MMX && (src.file == file_MMX || src.mod != mod_REG)); p->need_emms = 1; @@ -1150,7 +1156,7 @@ void mmx_movq( struct x86_function *p, struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg ) { - return x86_make_disp(x86_make_reg(file_REG32, reg_SP), + return x86_make_disp(x86_make_reg(file_REG32, reg_SP), p->stack_offset + arg * 4); /* ??? */ } @@ -1182,7 +1188,7 @@ void x86_release_func( struct x86_function *p ) void (*x86_get_func( struct x86_function *p ))(void) { if (DISASSEM && p->store) - _mesa_printf("disassemble %p %p\n", p->store, p->csr); + printf("disassemble %p %p\n", p->store, p->csr); return (void (*)(void)) (unsigned long) p->store; }