ddb2ec37380196e7064509a5fb2e053c7a70f894
2 #if defined(__i386__) || defined(__386__)
6 #include "main/imports.h"
7 #include "main/execmem.h"
14 static unsigned char *cptr( void (*label
)() )
16 return (unsigned char *)(unsigned long)label
;
21 static void do_realloc( struct x86_function
*p
)
25 p
->store
= _mesa_exec_malloc(p
->size
);
29 unsigned used
= p
->csr
- p
->store
;
30 unsigned char *tmp
= p
->store
;
32 p
->store
= _mesa_exec_malloc(p
->size
);
33 memcpy(p
->store
, tmp
, used
);
34 p
->csr
= p
->store
+ used
;
39 /* Emit bytes to the instruction stream:
41 static unsigned char *reserve( struct x86_function
*p
, int bytes
)
43 if (p
->csr
+ bytes
- p
->store
> p
->size
)
47 unsigned char *csr
= p
->csr
;
55 static void emit_1b( struct x86_function
*p
, char b0
)
57 char *csr
= (char *)reserve(p
, 1);
61 static void emit_1i( struct x86_function
*p
, int i0
)
63 int *icsr
= (int *)reserve(p
, sizeof(i0
));
67 static void emit_1ub( struct x86_function
*p
, unsigned char b0
)
69 unsigned char *csr
= reserve(p
, 1);
73 static void emit_2ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
)
75 unsigned char *csr
= reserve(p
, 2);
80 static void emit_3ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
, unsigned char b2
)
82 unsigned char *csr
= reserve(p
, 3);
89 /* Build a modRM byte + possible displacement. No treatment of SIB
90 * indexing. BZZT - no way to encode an absolute address.
92 static void emit_modrm( struct x86_function
*p
,
94 struct x86_reg regmem
)
96 unsigned char val
= 0;
98 assert(reg
.mod
== mod_REG
);
100 val
|= regmem
.mod
<< 6; /* mod field */
101 val
|= reg
.idx
<< 3; /* reg field */
102 val
|= regmem
.idx
; /* r/m field */
106 /* Oh-oh we've stumbled into the SIB thing.
108 if (regmem
.file
== file_REG32
&&
109 regmem
.idx
== reg_SP
) {
110 emit_1ub(p
, 0x24); /* simplistic! */
113 switch (regmem
.mod
) {
118 emit_1b(p
, regmem
.disp
);
121 emit_1i(p
, regmem
.disp
);
130 static void emit_modrm_noreg( struct x86_function
*p
,
132 struct x86_reg regmem
)
134 struct x86_reg dummy
= x86_make_reg(file_REG32
, op
);
135 emit_modrm(p
, dummy
, regmem
);
138 /* Many x86 instructions have two opcodes to cope with the situations
139 * where the destination is a register or memory reference
140 * respectively. This function selects the correct opcode based on
141 * the arguments presented.
143 static void emit_op_modrm( struct x86_function
*p
,
144 unsigned char op_dst_is_reg
,
145 unsigned char op_dst_is_mem
,
151 emit_1ub(p
, op_dst_is_reg
);
152 emit_modrm(p
, dst
, src
);
157 assert(src
.mod
== mod_REG
);
158 emit_1ub(p
, op_dst_is_mem
);
159 emit_modrm(p
, src
, dst
);
173 /* Create and manipulate registers and regmem values:
175 struct x86_reg
x86_make_reg( enum x86_reg_file file
,
176 enum x86_reg_name idx
)
188 struct x86_reg
x86_make_disp( struct x86_reg reg
,
191 assert(reg
.file
== file_REG32
);
193 if (reg
.mod
== mod_REG
)
199 reg
.mod
= mod_INDIRECT
;
200 else if (reg
.disp
<= 127 && reg
.disp
>= -128)
203 reg
.mod
= mod_DISP32
;
208 struct x86_reg
x86_deref( struct x86_reg reg
)
210 return x86_make_disp(reg
, 0);
213 struct x86_reg
x86_get_base_reg( struct x86_reg reg
)
215 return x86_make_reg( reg
.file
, reg
.idx
);
218 unsigned char *x86_get_label( struct x86_function
*p
)
225 /***********************************************************************
230 void x86_jcc( struct x86_function
*p
,
232 unsigned char *label
)
234 int offset
= label
- (x86_get_label(p
) + 2);
236 if (offset
<= 127 && offset
>= -128) {
237 emit_1ub(p
, 0x70 + cc
);
238 emit_1b(p
, (char) offset
);
241 offset
= label
- (x86_get_label(p
) + 6);
242 emit_2ub(p
, 0x0f, 0x80 + cc
);
247 /* Always use a 32bit offset for forward jumps:
249 unsigned char *x86_jcc_forward( struct x86_function
*p
,
252 emit_2ub(p
, 0x0f, 0x80 + cc
);
254 return x86_get_label(p
);
257 unsigned char *x86_jmp_forward( struct x86_function
*p
)
261 return x86_get_label(p
);
264 unsigned char *x86_call_forward( struct x86_function
*p
)
268 return x86_get_label(p
);
271 /* Fixup offset from forward jump:
273 void x86_fixup_fwd_jump( struct x86_function
*p
,
274 unsigned char *fixup
)
276 *(int *)(fixup
- 4) = x86_get_label(p
) - fixup
;
279 void x86_jmp( struct x86_function
*p
, unsigned char *label
)
282 emit_1i(p
, label
- x86_get_label(p
) - 4);
286 /* This doesn't work once we start reallocating & copying the
287 * generated code on buffer fills, because the call is relative to the
290 void x86_call( struct x86_function
*p
, void (*label
)())
293 emit_1i(p
, cptr(label
) - x86_get_label(p
) - 4);
296 void x86_call( struct x86_function
*p
, struct x86_reg reg
)
299 emit_modrm_noreg(p
, 2, reg
);
305 * Temporary. As I need immediate operands, and dont want to mess with the codegen,
306 * I load the immediate into general purpose register and use it.
308 void x86_mov_reg_imm( struct x86_function
*p
, struct x86_reg dst
, int imm
)
310 assert(dst
.mod
== mod_REG
);
311 emit_1ub(p
, 0xb8 + dst
.idx
);
315 void x86_push( struct x86_function
*p
,
318 assert(reg
.mod
== mod_REG
);
319 emit_1ub(p
, 0x50 + reg
.idx
);
320 p
->stack_offset
+= 4;
323 void x86_pop( struct x86_function
*p
,
326 assert(reg
.mod
== mod_REG
);
327 emit_1ub(p
, 0x58 + reg
.idx
);
328 p
->stack_offset
-= 4;
331 void x86_inc( struct x86_function
*p
,
334 assert(reg
.mod
== mod_REG
);
335 emit_1ub(p
, 0x40 + reg
.idx
);
338 void x86_dec( struct x86_function
*p
,
341 assert(reg
.mod
== mod_REG
);
342 emit_1ub(p
, 0x48 + reg
.idx
);
345 void x86_ret( struct x86_function
*p
)
350 void x86_sahf( struct x86_function
*p
)
355 void x86_mov( struct x86_function
*p
,
359 emit_op_modrm( p
, 0x8b, 0x89, dst
, src
);
362 void x86_xor( struct x86_function
*p
,
366 emit_op_modrm( p
, 0x33, 0x31, dst
, src
);
369 void x86_cmp( struct x86_function
*p
,
373 emit_op_modrm( p
, 0x3b, 0x39, dst
, src
);
376 void x86_lea( struct x86_function
*p
,
381 emit_modrm( p
, dst
, src
);
384 void x86_test( struct x86_function
*p
,
389 emit_modrm( p
, dst
, src
);
392 void x86_add( struct x86_function
*p
,
396 emit_op_modrm(p
, 0x03, 0x01, dst
, src
);
399 void x86_mul( struct x86_function
*p
,
402 assert (src
.file
== file_REG32
&& src
.mod
== mod_REG
);
403 emit_op_modrm(p
, 0xf7, 0, x86_make_reg (file_REG32
, reg_SP
), src
);
406 void x86_sub( struct x86_function
*p
,
410 emit_op_modrm(p
, 0x2b, 0x29, dst
, src
);
413 void x86_or( struct x86_function
*p
,
417 emit_op_modrm( p
, 0x0b, 0x09, dst
, src
);
420 void x86_and( struct x86_function
*p
,
424 emit_op_modrm( p
, 0x23, 0x21, dst
, src
);
429 /***********************************************************************
434 void sse_movss( struct x86_function
*p
,
438 emit_2ub(p
, 0xF3, X86_TWOB
);
439 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
442 void sse_movaps( struct x86_function
*p
,
446 emit_1ub(p
, X86_TWOB
);
447 emit_op_modrm( p
, 0x28, 0x29, dst
, src
);
450 void sse_movups( struct x86_function
*p
,
454 emit_1ub(p
, X86_TWOB
);
455 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
458 void sse_movhps( struct x86_function
*p
,
462 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
463 emit_1ub(p
, X86_TWOB
);
464 emit_op_modrm( p
, 0x16, 0x17, dst
, src
); /* cf movlhps */
467 void sse_movlps( struct x86_function
*p
,
471 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
472 emit_1ub(p
, X86_TWOB
);
473 emit_op_modrm( p
, 0x12, 0x13, dst
, src
); /* cf movhlps */
476 void sse_maxps( struct x86_function
*p
,
480 emit_2ub(p
, X86_TWOB
, 0x5F);
481 emit_modrm( p
, dst
, src
);
484 void sse_maxss( struct x86_function
*p
,
488 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5F);
489 emit_modrm( p
, dst
, src
);
492 void sse_divss( struct x86_function
*p
,
496 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5E);
497 emit_modrm( p
, dst
, src
);
500 void sse_minps( struct x86_function
*p
,
504 emit_2ub(p
, X86_TWOB
, 0x5D);
505 emit_modrm( p
, dst
, src
);
508 void sse_subps( struct x86_function
*p
,
512 emit_2ub(p
, X86_TWOB
, 0x5C);
513 emit_modrm( p
, dst
, src
);
516 void sse_mulps( struct x86_function
*p
,
520 emit_2ub(p
, X86_TWOB
, 0x59);
521 emit_modrm( p
, dst
, src
);
524 void sse_mulss( struct x86_function
*p
,
528 emit_3ub(p
, 0xF3, X86_TWOB
, 0x59);
529 emit_modrm( p
, dst
, src
);
532 void sse_addps( struct x86_function
*p
,
536 emit_2ub(p
, X86_TWOB
, 0x58);
537 emit_modrm( p
, dst
, src
);
540 void sse_addss( struct x86_function
*p
,
544 emit_3ub(p
, 0xF3, X86_TWOB
, 0x58);
545 emit_modrm( p
, dst
, src
);
548 void sse_andnps( struct x86_function
*p
,
552 emit_2ub(p
, X86_TWOB
, 0x55);
553 emit_modrm( p
, dst
, src
);
556 void sse_andps( struct x86_function
*p
,
560 emit_2ub(p
, X86_TWOB
, 0x54);
561 emit_modrm( p
, dst
, src
);
564 void sse_rsqrtps( struct x86_function
*p
,
568 emit_2ub(p
, X86_TWOB
, 0x52);
569 emit_modrm( p
, dst
, src
);
572 void sse_rsqrtss( struct x86_function
*p
,
576 emit_3ub(p
, 0xF3, X86_TWOB
, 0x52);
577 emit_modrm( p
, dst
, src
);
581 void sse_movhlps( struct x86_function
*p
,
585 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
586 emit_2ub(p
, X86_TWOB
, 0x12);
587 emit_modrm( p
, dst
, src
);
590 void sse_movlhps( struct x86_function
*p
,
594 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
595 emit_2ub(p
, X86_TWOB
, 0x16);
596 emit_modrm( p
, dst
, src
);
599 void sse_orps( struct x86_function
*p
,
603 emit_2ub(p
, X86_TWOB
, 0x56);
604 emit_modrm( p
, dst
, src
);
607 void sse_xorps( struct x86_function
*p
,
611 emit_2ub(p
, X86_TWOB
, 0x57);
612 emit_modrm( p
, dst
, src
);
615 void sse_cvtps2pi( struct x86_function
*p
,
619 assert(dst
.file
== file_MMX
&&
620 (src
.file
== file_XMM
|| src
.mod
!= mod_REG
));
624 emit_2ub(p
, X86_TWOB
, 0x2d);
625 emit_modrm( p
, dst
, src
);
629 /* Shufps can also be used to implement a reduced swizzle when dest ==
632 void sse_shufps( struct x86_function
*p
,
637 emit_2ub(p
, X86_TWOB
, 0xC6);
638 emit_modrm(p
, dest
, arg0
);
642 void sse_cmpps( struct x86_function
*p
,
647 emit_2ub(p
, X86_TWOB
, 0xC2);
648 emit_modrm(p
, dest
, arg0
);
652 void sse_pmovmskb( struct x86_function
*p
,
656 emit_3ub(p
, 0x66, X86_TWOB
, 0xD7);
657 emit_modrm(p
, dest
, src
);
660 /***********************************************************************
665 * Perform a reduced swizzle:
667 void sse2_pshufd( struct x86_function
*p
,
672 emit_3ub(p
, 0x66, X86_TWOB
, 0x70);
673 emit_modrm(p
, dest
, arg0
);
677 void sse2_cvttps2dq( struct x86_function
*p
,
681 emit_3ub( p
, 0xF3, X86_TWOB
, 0x5B );
682 emit_modrm( p
, dst
, src
);
685 void sse2_cvtps2dq( struct x86_function
*p
,
689 emit_3ub(p
, 0x66, X86_TWOB
, 0x5B);
690 emit_modrm( p
, dst
, src
);
693 void sse2_packssdw( struct x86_function
*p
,
697 emit_3ub(p
, 0x66, X86_TWOB
, 0x6B);
698 emit_modrm( p
, dst
, src
);
701 void sse2_packsswb( struct x86_function
*p
,
705 emit_3ub(p
, 0x66, X86_TWOB
, 0x63);
706 emit_modrm( p
, dst
, src
);
709 void sse2_packuswb( struct x86_function
*p
,
713 emit_3ub(p
, 0x66, X86_TWOB
, 0x67);
714 emit_modrm( p
, dst
, src
);
717 void sse2_rcpps( struct x86_function
*p
,
721 emit_2ub(p
, X86_TWOB
, 0x53);
722 emit_modrm( p
, dst
, src
);
725 void sse2_rcpss( struct x86_function
*p
,
729 emit_3ub(p
, 0xF3, X86_TWOB
, 0x53);
730 emit_modrm( p
, dst
, src
);
733 void sse2_movd( struct x86_function
*p
,
737 emit_2ub(p
, 0x66, X86_TWOB
);
738 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
744 /***********************************************************************
747 void x87_fist( struct x86_function
*p
, struct x86_reg dst
)
750 emit_modrm_noreg(p
, 2, dst
);
753 void x87_fistp( struct x86_function
*p
, struct x86_reg dst
)
756 emit_modrm_noreg(p
, 3, dst
);
759 void x87_fild( struct x86_function
*p
, struct x86_reg arg
)
762 emit_modrm_noreg(p
, 0, arg
);
765 void x87_fldz( struct x86_function
*p
)
767 emit_2ub(p
, 0xd9, 0xee);
771 void x87_fldcw( struct x86_function
*p
, struct x86_reg arg
)
773 assert(arg
.file
== file_REG32
);
774 assert(arg
.mod
!= mod_REG
);
776 emit_modrm_noreg(p
, 5, arg
);
779 void x87_fld1( struct x86_function
*p
)
781 emit_2ub(p
, 0xd9, 0xe8);
784 void x87_fldl2e( struct x86_function
*p
)
786 emit_2ub(p
, 0xd9, 0xea);
789 void x87_fldln2( struct x86_function
*p
)
791 emit_2ub(p
, 0xd9, 0xed);
794 void x87_fwait( struct x86_function
*p
)
799 void x87_fnclex( struct x86_function
*p
)
801 emit_2ub(p
, 0xdb, 0xe2);
804 void x87_fclex( struct x86_function
*p
)
811 static void x87_arith_op( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
,
812 unsigned char dst0ub0
,
813 unsigned char dst0ub1
,
814 unsigned char arg0ub0
,
815 unsigned char arg0ub1
,
816 unsigned char argmem_noreg
)
818 assert(dst
.file
== file_x87
);
820 if (arg
.file
== file_x87
) {
822 emit_2ub(p
, dst0ub0
, dst0ub1
+arg
.idx
);
823 else if (arg
.idx
== 0)
824 emit_2ub(p
, arg0ub0
, arg0ub1
+arg
.idx
);
828 else if (dst
.idx
== 0) {
829 assert(arg
.file
== file_REG32
);
831 emit_modrm_noreg(p
, argmem_noreg
, arg
);
837 void x87_fmul( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
839 x87_arith_op(p
, dst
, arg
,
845 void x87_fsub( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
847 x87_arith_op(p
, dst
, arg
,
853 void x87_fsubr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
855 x87_arith_op(p
, dst
, arg
,
861 void x87_fadd( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
863 x87_arith_op(p
, dst
, arg
,
869 void x87_fdiv( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
871 x87_arith_op(p
, dst
, arg
,
877 void x87_fdivr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
879 x87_arith_op(p
, dst
, arg
,
885 void x87_fmulp( struct x86_function
*p
, struct x86_reg dst
)
887 assert(dst
.file
== file_x87
);
888 assert(dst
.idx
>= 1);
889 emit_2ub(p
, 0xde, 0xc8+dst
.idx
);
892 void x87_fsubp( struct x86_function
*p
, struct x86_reg dst
)
894 assert(dst
.file
== file_x87
);
895 assert(dst
.idx
>= 1);
896 emit_2ub(p
, 0xde, 0xe8+dst
.idx
);
899 void x87_fsubrp( struct x86_function
*p
, struct x86_reg dst
)
901 assert(dst
.file
== file_x87
);
902 assert(dst
.idx
>= 1);
903 emit_2ub(p
, 0xde, 0xe0+dst
.idx
);
906 void x87_faddp( struct x86_function
*p
, struct x86_reg dst
)
908 assert(dst
.file
== file_x87
);
909 assert(dst
.idx
>= 1);
910 emit_2ub(p
, 0xde, 0xc0+dst
.idx
);
913 void x87_fdivp( struct x86_function
*p
, struct x86_reg dst
)
915 assert(dst
.file
== file_x87
);
916 assert(dst
.idx
>= 1);
917 emit_2ub(p
, 0xde, 0xf8+dst
.idx
);
920 void x87_fdivrp( struct x86_function
*p
, struct x86_reg dst
)
922 assert(dst
.file
== file_x87
);
923 assert(dst
.idx
>= 1);
924 emit_2ub(p
, 0xde, 0xf0+dst
.idx
);
927 void x87_fucom( struct x86_function
*p
, struct x86_reg arg
)
929 assert(arg
.file
== file_x87
);
930 emit_2ub(p
, 0xdd, 0xe0+arg
.idx
);
933 void x87_fucomp( struct x86_function
*p
, struct x86_reg arg
)
935 assert(arg
.file
== file_x87
);
936 emit_2ub(p
, 0xdd, 0xe8+arg
.idx
);
939 void x87_fucompp( struct x86_function
*p
)
941 emit_2ub(p
, 0xda, 0xe9);
944 void x87_fxch( struct x86_function
*p
, struct x86_reg arg
)
946 assert(arg
.file
== file_x87
);
947 emit_2ub(p
, 0xd9, 0xc8+arg
.idx
);
950 void x87_fabs( struct x86_function
*p
)
952 emit_2ub(p
, 0xd9, 0xe1);
955 void x87_fchs( struct x86_function
*p
)
957 emit_2ub(p
, 0xd9, 0xe0);
960 void x87_fcos( struct x86_function
*p
)
962 emit_2ub(p
, 0xd9, 0xff);
966 void x87_fprndint( struct x86_function
*p
)
968 emit_2ub(p
, 0xd9, 0xfc);
971 void x87_fscale( struct x86_function
*p
)
973 emit_2ub(p
, 0xd9, 0xfd);
976 void x87_fsin( struct x86_function
*p
)
978 emit_2ub(p
, 0xd9, 0xfe);
981 void x87_fsincos( struct x86_function
*p
)
983 emit_2ub(p
, 0xd9, 0xfb);
986 void x87_fsqrt( struct x86_function
*p
)
988 emit_2ub(p
, 0xd9, 0xfa);
991 void x87_fxtract( struct x86_function
*p
)
993 emit_2ub(p
, 0xd9, 0xf4);
998 * Restrictions: -1.0 <= st0 <= 1.0
1000 void x87_f2xm1( struct x86_function
*p
)
1002 emit_2ub(p
, 0xd9, 0xf0);
1005 /* st1 = st1 * log2(st0);
1008 void x87_fyl2x( struct x86_function
*p
)
1010 emit_2ub(p
, 0xd9, 0xf1);
1013 /* st1 = st1 * log2(st0 + 1.0);
1016 * A fast operation, with restrictions: -.29 < st0 < .29
1018 void x87_fyl2xp1( struct x86_function
*p
)
1020 emit_2ub(p
, 0xd9, 0xf9);
1024 void x87_fld( struct x86_function
*p
, struct x86_reg arg
)
1026 if (arg
.file
== file_x87
)
1027 emit_2ub(p
, 0xd9, 0xc0 + arg
.idx
);
1030 emit_modrm_noreg(p
, 0, arg
);
1034 void x87_fst( struct x86_function
*p
, struct x86_reg dst
)
1036 if (dst
.file
== file_x87
)
1037 emit_2ub(p
, 0xdd, 0xd0 + dst
.idx
);
1040 emit_modrm_noreg(p
, 2, dst
);
1044 void x87_fstp( struct x86_function
*p
, struct x86_reg dst
)
1046 if (dst
.file
== file_x87
)
1047 emit_2ub(p
, 0xdd, 0xd8 + dst
.idx
);
1050 emit_modrm_noreg(p
, 3, dst
);
1054 void x87_fcom( struct x86_function
*p
, struct x86_reg dst
)
1056 if (dst
.file
== file_x87
)
1057 emit_2ub(p
, 0xd8, 0xd0 + dst
.idx
);
1060 emit_modrm_noreg(p
, 2, dst
);
1064 void x87_fcomp( struct x86_function
*p
, struct x86_reg dst
)
1066 if (dst
.file
== file_x87
)
1067 emit_2ub(p
, 0xd8, 0xd8 + dst
.idx
);
1070 emit_modrm_noreg(p
, 3, dst
);
1075 void x87_fnstsw( struct x86_function
*p
, struct x86_reg dst
)
1077 assert(dst
.file
== file_REG32
);
1079 if (dst
.idx
== reg_AX
&&
1081 emit_2ub(p
, 0xdf, 0xe0);
1084 emit_modrm_noreg(p
, 7, dst
);
1091 /***********************************************************************
1095 void mmx_emms( struct x86_function
*p
)
1097 assert(p
->need_emms
);
1098 emit_2ub(p
, 0x0f, 0x77);
1102 void mmx_packssdw( struct x86_function
*p
,
1104 struct x86_reg src
)
1106 assert(dst
.file
== file_MMX
&&
1107 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1111 emit_2ub(p
, X86_TWOB
, 0x6b);
1112 emit_modrm( p
, dst
, src
);
1115 void mmx_packuswb( struct x86_function
*p
,
1117 struct x86_reg src
)
1119 assert(dst
.file
== file_MMX
&&
1120 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1124 emit_2ub(p
, X86_TWOB
, 0x67);
1125 emit_modrm( p
, dst
, src
);
1128 void mmx_movd( struct x86_function
*p
,
1130 struct x86_reg src
)
1133 emit_1ub(p
, X86_TWOB
);
1134 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
1137 void mmx_movq( struct x86_function
*p
,
1139 struct x86_reg src
)
1142 emit_1ub(p
, X86_TWOB
);
1143 emit_op_modrm( p
, 0x6f, 0x7f, dst
, src
);
1147 /***********************************************************************
1152 /* Retreive a reference to one of the function arguments, taking into
1153 * account any push/pop activity:
1155 struct x86_reg
x86_fn_arg( struct x86_function
*p
,
1158 return x86_make_disp(x86_make_reg(file_REG32
, reg_SP
),
1159 p
->stack_offset
+ arg
* 4); /* ??? */
1163 void x86_init_func( struct x86_function
*p
)
1170 int x86_init_func_size( struct x86_function
*p
, unsigned code_size
)
1172 p
->size
= code_size
;
1173 p
->store
= _mesa_exec_malloc(code_size
);
1175 return p
->store
!= NULL
;
1178 void x86_release_func( struct x86_function
*p
)
1180 _mesa_exec_free(p
->store
);
1187 void (*x86_get_func( struct x86_function
*p
))(void)
1189 if (DISASSEM
&& p
->store
)
1190 printf("disassemble %p %p\n", p
->store
, p
->csr
);
1191 return (void (*)(void)) (unsigned long) p
->store
;
1196 void x86sse_dummy( void )
1202 #else /* USE_X86_ASM */
1204 int x86sse_c_dummy_var
; /* silence warning */
1206 #endif /* USE_X86_ASM */