2 #if defined(__i386__) || defined(__386__)
8 #include "main/execmem.h"
15 static unsigned char *cptr( void (*label
)() )
17 return (unsigned char *)(unsigned long)label
;
22 static void do_realloc( struct x86_function
*p
)
26 p
->store
= _mesa_exec_malloc(p
->size
);
30 unsigned used
= p
->csr
- p
->store
;
31 unsigned char *tmp
= p
->store
;
33 p
->store
= _mesa_exec_malloc(p
->size
);
34 memcpy(p
->store
, tmp
, used
);
35 p
->csr
= p
->store
+ used
;
40 /* Emit bytes to the instruction stream:
42 static unsigned char *reserve( struct x86_function
*p
, int bytes
)
44 if (p
->csr
+ bytes
- p
->store
> p
->size
)
48 unsigned char *csr
= p
->csr
;
56 static void emit_1b( struct x86_function
*p
, char b0
)
58 char *csr
= (char *)reserve(p
, 1);
62 static void emit_1i( struct x86_function
*p
, int i0
)
64 int *icsr
= (int *)reserve(p
, sizeof(i0
));
68 static void emit_1ub( struct x86_function
*p
, unsigned char b0
)
70 unsigned char *csr
= reserve(p
, 1);
74 static void emit_2ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
)
76 unsigned char *csr
= reserve(p
, 2);
81 static void emit_3ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
, unsigned char b2
)
83 unsigned char *csr
= reserve(p
, 3);
90 /* Build a modRM byte + possible displacement. No treatment of SIB
91 * indexing. BZZT - no way to encode an absolute address.
93 static void emit_modrm( struct x86_function
*p
,
95 struct x86_reg regmem
)
97 unsigned char val
= 0;
99 assert(reg
.mod
== mod_REG
);
101 val
|= regmem
.mod
<< 6; /* mod field */
102 val
|= reg
.idx
<< 3; /* reg field */
103 val
|= regmem
.idx
; /* r/m field */
107 /* Oh-oh we've stumbled into the SIB thing.
109 if (regmem
.file
== file_REG32
&&
110 regmem
.idx
== reg_SP
) {
111 emit_1ub(p
, 0x24); /* simplistic! */
114 switch (regmem
.mod
) {
119 emit_1b(p
, regmem
.disp
);
122 emit_1i(p
, regmem
.disp
);
131 static void emit_modrm_noreg( struct x86_function
*p
,
133 struct x86_reg regmem
)
135 struct x86_reg dummy
= x86_make_reg(file_REG32
, op
);
136 emit_modrm(p
, dummy
, regmem
);
139 /* Many x86 instructions have two opcodes to cope with the situations
140 * where the destination is a register or memory reference
141 * respectively. This function selects the correct opcode based on
142 * the arguments presented.
144 static void emit_op_modrm( struct x86_function
*p
,
145 unsigned char op_dst_is_reg
,
146 unsigned char op_dst_is_mem
,
152 emit_1ub(p
, op_dst_is_reg
);
153 emit_modrm(p
, dst
, src
);
158 assert(src
.mod
== mod_REG
);
159 emit_1ub(p
, op_dst_is_mem
);
160 emit_modrm(p
, src
, dst
);
174 /* Create and manipulate registers and regmem values:
176 struct x86_reg
x86_make_reg( enum x86_reg_file file
,
177 enum x86_reg_name idx
)
189 struct x86_reg
x86_make_disp( struct x86_reg reg
,
192 assert(reg
.file
== file_REG32
);
194 if (reg
.mod
== mod_REG
)
200 reg
.mod
= mod_INDIRECT
;
201 else if (reg
.disp
<= 127 && reg
.disp
>= -128)
204 reg
.mod
= mod_DISP32
;
209 struct x86_reg
x86_deref( struct x86_reg reg
)
211 return x86_make_disp(reg
, 0);
214 struct x86_reg
x86_get_base_reg( struct x86_reg reg
)
216 return x86_make_reg( reg
.file
, reg
.idx
);
219 unsigned char *x86_get_label( struct x86_function
*p
)
226 /***********************************************************************
231 void x86_jcc( struct x86_function
*p
,
233 unsigned char *label
)
235 int offset
= label
- (x86_get_label(p
) + 2);
237 if (offset
<= 127 && offset
>= -128) {
238 emit_1ub(p
, 0x70 + cc
);
239 emit_1b(p
, (char) offset
);
242 offset
= label
- (x86_get_label(p
) + 6);
243 emit_2ub(p
, 0x0f, 0x80 + cc
);
248 /* Always use a 32bit offset for forward jumps:
250 unsigned char *x86_jcc_forward( struct x86_function
*p
,
253 emit_2ub(p
, 0x0f, 0x80 + cc
);
255 return x86_get_label(p
);
258 unsigned char *x86_jmp_forward( struct x86_function
*p
)
262 return x86_get_label(p
);
265 unsigned char *x86_call_forward( struct x86_function
*p
)
269 return x86_get_label(p
);
272 /* Fixup offset from forward jump:
274 void x86_fixup_fwd_jump( struct x86_function
*p
,
275 unsigned char *fixup
)
277 *(int *)(fixup
- 4) = x86_get_label(p
) - fixup
;
280 void x86_jmp( struct x86_function
*p
, unsigned char *label
)
283 emit_1i(p
, label
- x86_get_label(p
) - 4);
287 /* This doesn't work once we start reallocating & copying the
288 * generated code on buffer fills, because the call is relative to the
291 void x86_call( struct x86_function
*p
, void (*label
)())
294 emit_1i(p
, cptr(label
) - x86_get_label(p
) - 4);
297 void x86_call( struct x86_function
*p
, struct x86_reg reg
)
300 emit_modrm_noreg(p
, 2, reg
);
306 * Temporary. As I need immediate operands, and dont want to mess with the codegen,
307 * I load the immediate into general purpose register and use it.
309 void x86_mov_reg_imm( struct x86_function
*p
, struct x86_reg dst
, int imm
)
311 assert(dst
.mod
== mod_REG
);
312 emit_1ub(p
, 0xb8 + dst
.idx
);
316 void x86_push( struct x86_function
*p
,
319 assert(reg
.mod
== mod_REG
);
320 emit_1ub(p
, 0x50 + reg
.idx
);
321 p
->stack_offset
+= 4;
324 void x86_pop( struct x86_function
*p
,
327 assert(reg
.mod
== mod_REG
);
328 emit_1ub(p
, 0x58 + reg
.idx
);
329 p
->stack_offset
-= 4;
332 void x86_inc( struct x86_function
*p
,
335 assert(reg
.mod
== mod_REG
);
336 emit_1ub(p
, 0x40 + reg
.idx
);
339 void x86_dec( struct x86_function
*p
,
342 assert(reg
.mod
== mod_REG
);
343 emit_1ub(p
, 0x48 + reg
.idx
);
346 void x86_ret( struct x86_function
*p
)
351 void x86_sahf( struct x86_function
*p
)
356 void x86_mov( struct x86_function
*p
,
360 emit_op_modrm( p
, 0x8b, 0x89, dst
, src
);
363 void x86_xor( struct x86_function
*p
,
367 emit_op_modrm( p
, 0x33, 0x31, dst
, src
);
370 void x86_cmp( struct x86_function
*p
,
374 emit_op_modrm( p
, 0x3b, 0x39, dst
, src
);
377 void x86_lea( struct x86_function
*p
,
382 emit_modrm( p
, dst
, src
);
385 void x86_test( struct x86_function
*p
,
390 emit_modrm( p
, dst
, src
);
393 void x86_add( struct x86_function
*p
,
397 emit_op_modrm(p
, 0x03, 0x01, dst
, src
);
400 void x86_mul( struct x86_function
*p
,
403 assert (src
.file
== file_REG32
&& src
.mod
== mod_REG
);
404 emit_op_modrm(p
, 0xf7, 0, x86_make_reg (file_REG32
, reg_SP
), src
);
407 void x86_sub( struct x86_function
*p
,
411 emit_op_modrm(p
, 0x2b, 0x29, dst
, src
);
414 void x86_or( struct x86_function
*p
,
418 emit_op_modrm( p
, 0x0b, 0x09, dst
, src
);
421 void x86_and( struct x86_function
*p
,
425 emit_op_modrm( p
, 0x23, 0x21, dst
, src
);
430 /***********************************************************************
435 void sse_movss( struct x86_function
*p
,
439 emit_2ub(p
, 0xF3, X86_TWOB
);
440 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
443 void sse_movaps( struct x86_function
*p
,
447 emit_1ub(p
, X86_TWOB
);
448 emit_op_modrm( p
, 0x28, 0x29, dst
, src
);
451 void sse_movups( struct x86_function
*p
,
455 emit_1ub(p
, X86_TWOB
);
456 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
459 void sse_movhps( struct x86_function
*p
,
463 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
464 emit_1ub(p
, X86_TWOB
);
465 emit_op_modrm( p
, 0x16, 0x17, dst
, src
); /* cf movlhps */
468 void sse_movlps( struct x86_function
*p
,
472 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
473 emit_1ub(p
, X86_TWOB
);
474 emit_op_modrm( p
, 0x12, 0x13, dst
, src
); /* cf movhlps */
477 void sse_maxps( struct x86_function
*p
,
481 emit_2ub(p
, X86_TWOB
, 0x5F);
482 emit_modrm( p
, dst
, src
);
485 void sse_maxss( struct x86_function
*p
,
489 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5F);
490 emit_modrm( p
, dst
, src
);
493 void sse_divss( struct x86_function
*p
,
497 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5E);
498 emit_modrm( p
, dst
, src
);
501 void sse_minps( struct x86_function
*p
,
505 emit_2ub(p
, X86_TWOB
, 0x5D);
506 emit_modrm( p
, dst
, src
);
509 void sse_subps( struct x86_function
*p
,
513 emit_2ub(p
, X86_TWOB
, 0x5C);
514 emit_modrm( p
, dst
, src
);
517 void sse_mulps( struct x86_function
*p
,
521 emit_2ub(p
, X86_TWOB
, 0x59);
522 emit_modrm( p
, dst
, src
);
525 void sse_mulss( struct x86_function
*p
,
529 emit_3ub(p
, 0xF3, X86_TWOB
, 0x59);
530 emit_modrm( p
, dst
, src
);
533 void sse_addps( struct x86_function
*p
,
537 emit_2ub(p
, X86_TWOB
, 0x58);
538 emit_modrm( p
, dst
, src
);
541 void sse_addss( struct x86_function
*p
,
545 emit_3ub(p
, 0xF3, X86_TWOB
, 0x58);
546 emit_modrm( p
, dst
, src
);
549 void sse_andnps( struct x86_function
*p
,
553 emit_2ub(p
, X86_TWOB
, 0x55);
554 emit_modrm( p
, dst
, src
);
557 void sse_andps( struct x86_function
*p
,
561 emit_2ub(p
, X86_TWOB
, 0x54);
562 emit_modrm( p
, dst
, src
);
565 void sse_rsqrtps( struct x86_function
*p
,
569 emit_2ub(p
, X86_TWOB
, 0x52);
570 emit_modrm( p
, dst
, src
);
573 void sse_rsqrtss( struct x86_function
*p
,
577 emit_3ub(p
, 0xF3, X86_TWOB
, 0x52);
578 emit_modrm( p
, dst
, src
);
582 void sse_movhlps( struct x86_function
*p
,
586 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
587 emit_2ub(p
, X86_TWOB
, 0x12);
588 emit_modrm( p
, dst
, src
);
591 void sse_movlhps( struct x86_function
*p
,
595 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
596 emit_2ub(p
, X86_TWOB
, 0x16);
597 emit_modrm( p
, dst
, src
);
600 void sse_orps( struct x86_function
*p
,
604 emit_2ub(p
, X86_TWOB
, 0x56);
605 emit_modrm( p
, dst
, src
);
608 void sse_xorps( struct x86_function
*p
,
612 emit_2ub(p
, X86_TWOB
, 0x57);
613 emit_modrm( p
, dst
, src
);
616 void sse_cvtps2pi( struct x86_function
*p
,
620 assert(dst
.file
== file_MMX
&&
621 (src
.file
== file_XMM
|| src
.mod
!= mod_REG
));
625 emit_2ub(p
, X86_TWOB
, 0x2d);
626 emit_modrm( p
, dst
, src
);
630 /* Shufps can also be used to implement a reduced swizzle when dest ==
633 void sse_shufps( struct x86_function
*p
,
638 emit_2ub(p
, X86_TWOB
, 0xC6);
639 emit_modrm(p
, dest
, arg0
);
643 void sse_cmpps( struct x86_function
*p
,
648 emit_2ub(p
, X86_TWOB
, 0xC2);
649 emit_modrm(p
, dest
, arg0
);
653 void sse_pmovmskb( struct x86_function
*p
,
657 emit_3ub(p
, 0x66, X86_TWOB
, 0xD7);
658 emit_modrm(p
, dest
, src
);
661 /***********************************************************************
666 * Perform a reduced swizzle:
668 void sse2_pshufd( struct x86_function
*p
,
673 emit_3ub(p
, 0x66, X86_TWOB
, 0x70);
674 emit_modrm(p
, dest
, arg0
);
678 void sse2_cvttps2dq( struct x86_function
*p
,
682 emit_3ub( p
, 0xF3, X86_TWOB
, 0x5B );
683 emit_modrm( p
, dst
, src
);
686 void sse2_cvtps2dq( struct x86_function
*p
,
690 emit_3ub(p
, 0x66, X86_TWOB
, 0x5B);
691 emit_modrm( p
, dst
, src
);
694 void sse2_packssdw( struct x86_function
*p
,
698 emit_3ub(p
, 0x66, X86_TWOB
, 0x6B);
699 emit_modrm( p
, dst
, src
);
702 void sse2_packsswb( struct x86_function
*p
,
706 emit_3ub(p
, 0x66, X86_TWOB
, 0x63);
707 emit_modrm( p
, dst
, src
);
710 void sse2_packuswb( struct x86_function
*p
,
714 emit_3ub(p
, 0x66, X86_TWOB
, 0x67);
715 emit_modrm( p
, dst
, src
);
718 void sse2_rcpps( struct x86_function
*p
,
722 emit_2ub(p
, X86_TWOB
, 0x53);
723 emit_modrm( p
, dst
, src
);
726 void sse2_rcpss( struct x86_function
*p
,
730 emit_3ub(p
, 0xF3, X86_TWOB
, 0x53);
731 emit_modrm( p
, dst
, src
);
734 void sse2_movd( struct x86_function
*p
,
738 emit_2ub(p
, 0x66, X86_TWOB
);
739 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
745 /***********************************************************************
748 void x87_fist( struct x86_function
*p
, struct x86_reg dst
)
751 emit_modrm_noreg(p
, 2, dst
);
754 void x87_fistp( struct x86_function
*p
, struct x86_reg dst
)
757 emit_modrm_noreg(p
, 3, dst
);
760 void x87_fild( struct x86_function
*p
, struct x86_reg arg
)
763 emit_modrm_noreg(p
, 0, arg
);
766 void x87_fldz( struct x86_function
*p
)
768 emit_2ub(p
, 0xd9, 0xee);
772 void x87_fldcw( struct x86_function
*p
, struct x86_reg arg
)
774 assert(arg
.file
== file_REG32
);
775 assert(arg
.mod
!= mod_REG
);
777 emit_modrm_noreg(p
, 5, arg
);
780 void x87_fld1( struct x86_function
*p
)
782 emit_2ub(p
, 0xd9, 0xe8);
785 void x87_fldl2e( struct x86_function
*p
)
787 emit_2ub(p
, 0xd9, 0xea);
790 void x87_fldln2( struct x86_function
*p
)
792 emit_2ub(p
, 0xd9, 0xed);
795 void x87_fwait( struct x86_function
*p
)
800 void x87_fnclex( struct x86_function
*p
)
802 emit_2ub(p
, 0xdb, 0xe2);
805 void x87_fclex( struct x86_function
*p
)
812 static void x87_arith_op( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
,
813 unsigned char dst0ub0
,
814 unsigned char dst0ub1
,
815 unsigned char arg0ub0
,
816 unsigned char arg0ub1
,
817 unsigned char argmem_noreg
)
819 assert(dst
.file
== file_x87
);
821 if (arg
.file
== file_x87
) {
823 emit_2ub(p
, dst0ub0
, dst0ub1
+arg
.idx
);
824 else if (arg
.idx
== 0)
825 emit_2ub(p
, arg0ub0
, arg0ub1
+arg
.idx
);
829 else if (dst
.idx
== 0) {
830 assert(arg
.file
== file_REG32
);
832 emit_modrm_noreg(p
, argmem_noreg
, arg
);
838 void x87_fmul( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
840 x87_arith_op(p
, dst
, arg
,
846 void x87_fsub( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
848 x87_arith_op(p
, dst
, arg
,
854 void x87_fsubr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
856 x87_arith_op(p
, dst
, arg
,
862 void x87_fadd( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
864 x87_arith_op(p
, dst
, arg
,
870 void x87_fdiv( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
872 x87_arith_op(p
, dst
, arg
,
878 void x87_fdivr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
880 x87_arith_op(p
, dst
, arg
,
886 void x87_fmulp( struct x86_function
*p
, struct x86_reg dst
)
888 assert(dst
.file
== file_x87
);
889 assert(dst
.idx
>= 1);
890 emit_2ub(p
, 0xde, 0xc8+dst
.idx
);
893 void x87_fsubp( struct x86_function
*p
, struct x86_reg dst
)
895 assert(dst
.file
== file_x87
);
896 assert(dst
.idx
>= 1);
897 emit_2ub(p
, 0xde, 0xe8+dst
.idx
);
900 void x87_fsubrp( struct x86_function
*p
, struct x86_reg dst
)
902 assert(dst
.file
== file_x87
);
903 assert(dst
.idx
>= 1);
904 emit_2ub(p
, 0xde, 0xe0+dst
.idx
);
907 void x87_faddp( struct x86_function
*p
, struct x86_reg dst
)
909 assert(dst
.file
== file_x87
);
910 assert(dst
.idx
>= 1);
911 emit_2ub(p
, 0xde, 0xc0+dst
.idx
);
914 void x87_fdivp( struct x86_function
*p
, struct x86_reg dst
)
916 assert(dst
.file
== file_x87
);
917 assert(dst
.idx
>= 1);
918 emit_2ub(p
, 0xde, 0xf8+dst
.idx
);
921 void x87_fdivrp( struct x86_function
*p
, struct x86_reg dst
)
923 assert(dst
.file
== file_x87
);
924 assert(dst
.idx
>= 1);
925 emit_2ub(p
, 0xde, 0xf0+dst
.idx
);
928 void x87_fucom( struct x86_function
*p
, struct x86_reg arg
)
930 assert(arg
.file
== file_x87
);
931 emit_2ub(p
, 0xdd, 0xe0+arg
.idx
);
934 void x87_fucomp( struct x86_function
*p
, struct x86_reg arg
)
936 assert(arg
.file
== file_x87
);
937 emit_2ub(p
, 0xdd, 0xe8+arg
.idx
);
940 void x87_fucompp( struct x86_function
*p
)
942 emit_2ub(p
, 0xda, 0xe9);
945 void x87_fxch( struct x86_function
*p
, struct x86_reg arg
)
947 assert(arg
.file
== file_x87
);
948 emit_2ub(p
, 0xd9, 0xc8+arg
.idx
);
951 void x87_fabs( struct x86_function
*p
)
953 emit_2ub(p
, 0xd9, 0xe1);
956 void x87_fchs( struct x86_function
*p
)
958 emit_2ub(p
, 0xd9, 0xe0);
961 void x87_fcos( struct x86_function
*p
)
963 emit_2ub(p
, 0xd9, 0xff);
967 void x87_fprndint( struct x86_function
*p
)
969 emit_2ub(p
, 0xd9, 0xfc);
972 void x87_fscale( struct x86_function
*p
)
974 emit_2ub(p
, 0xd9, 0xfd);
977 void x87_fsin( struct x86_function
*p
)
979 emit_2ub(p
, 0xd9, 0xfe);
982 void x87_fsincos( struct x86_function
*p
)
984 emit_2ub(p
, 0xd9, 0xfb);
987 void x87_fsqrt( struct x86_function
*p
)
989 emit_2ub(p
, 0xd9, 0xfa);
992 void x87_fxtract( struct x86_function
*p
)
994 emit_2ub(p
, 0xd9, 0xf4);
999 * Restrictions: -1.0 <= st0 <= 1.0
1001 void x87_f2xm1( struct x86_function
*p
)
1003 emit_2ub(p
, 0xd9, 0xf0);
1006 /* st1 = st1 * log2(st0);
1009 void x87_fyl2x( struct x86_function
*p
)
1011 emit_2ub(p
, 0xd9, 0xf1);
1014 /* st1 = st1 * log2(st0 + 1.0);
1017 * A fast operation, with restrictions: -.29 < st0 < .29
1019 void x87_fyl2xp1( struct x86_function
*p
)
1021 emit_2ub(p
, 0xd9, 0xf9);
1025 void x87_fld( struct x86_function
*p
, struct x86_reg arg
)
1027 if (arg
.file
== file_x87
)
1028 emit_2ub(p
, 0xd9, 0xc0 + arg
.idx
);
1031 emit_modrm_noreg(p
, 0, arg
);
1035 void x87_fst( struct x86_function
*p
, struct x86_reg dst
)
1037 if (dst
.file
== file_x87
)
1038 emit_2ub(p
, 0xdd, 0xd0 + dst
.idx
);
1041 emit_modrm_noreg(p
, 2, dst
);
1045 void x87_fstp( struct x86_function
*p
, struct x86_reg dst
)
1047 if (dst
.file
== file_x87
)
1048 emit_2ub(p
, 0xdd, 0xd8 + dst
.idx
);
1051 emit_modrm_noreg(p
, 3, dst
);
1055 void x87_fcom( struct x86_function
*p
, struct x86_reg dst
)
1057 if (dst
.file
== file_x87
)
1058 emit_2ub(p
, 0xd8, 0xd0 + dst
.idx
);
1061 emit_modrm_noreg(p
, 2, dst
);
1065 void x87_fcomp( struct x86_function
*p
, struct x86_reg dst
)
1067 if (dst
.file
== file_x87
)
1068 emit_2ub(p
, 0xd8, 0xd8 + dst
.idx
);
1071 emit_modrm_noreg(p
, 3, dst
);
1076 void x87_fnstsw( struct x86_function
*p
, struct x86_reg dst
)
1078 assert(dst
.file
== file_REG32
);
1080 if (dst
.idx
== reg_AX
&&
1082 emit_2ub(p
, 0xdf, 0xe0);
1085 emit_modrm_noreg(p
, 7, dst
);
1092 /***********************************************************************
1096 void mmx_emms( struct x86_function
*p
)
1098 assert(p
->need_emms
);
1099 emit_2ub(p
, 0x0f, 0x77);
1103 void mmx_packssdw( struct x86_function
*p
,
1105 struct x86_reg src
)
1107 assert(dst
.file
== file_MMX
&&
1108 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1112 emit_2ub(p
, X86_TWOB
, 0x6b);
1113 emit_modrm( p
, dst
, src
);
1116 void mmx_packuswb( struct x86_function
*p
,
1118 struct x86_reg src
)
1120 assert(dst
.file
== file_MMX
&&
1121 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1125 emit_2ub(p
, X86_TWOB
, 0x67);
1126 emit_modrm( p
, dst
, src
);
1129 void mmx_movd( struct x86_function
*p
,
1131 struct x86_reg src
)
1134 emit_1ub(p
, X86_TWOB
);
1135 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
1138 void mmx_movq( struct x86_function
*p
,
1140 struct x86_reg src
)
1143 emit_1ub(p
, X86_TWOB
);
1144 emit_op_modrm( p
, 0x6f, 0x7f, dst
, src
);
1148 /***********************************************************************
1153 /* Retreive a reference to one of the function arguments, taking into
1154 * account any push/pop activity:
1156 struct x86_reg
x86_fn_arg( struct x86_function
*p
,
1159 return x86_make_disp(x86_make_reg(file_REG32
, reg_SP
),
1160 p
->stack_offset
+ arg
* 4); /* ??? */
1164 void x86_init_func( struct x86_function
*p
)
1171 int x86_init_func_size( struct x86_function
*p
, unsigned code_size
)
1173 p
->size
= code_size
;
1174 p
->store
= _mesa_exec_malloc(code_size
);
1176 return p
->store
!= NULL
;
1179 void x86_release_func( struct x86_function
*p
)
1181 _mesa_exec_free(p
->store
);
1188 void (*x86_get_func( struct x86_function
*p
))(void)
1190 if (DISASSEM
&& p
->store
)
1191 printf("disassemble %p %p\n", p
->store
, p
->csr
);
1192 return (void (*)(void)) (unsigned long) p
->store
;
1197 void x86sse_dummy( void )
1203 #else /* USE_X86_ASM */
1205 int x86sse_c_dummy_var
; /* silence warning */
1207 #endif /* USE_X86_ASM */