2 #if defined(__i386__) || defined(__386__)
6 #include "main/imports.h"
13 static unsigned char *cptr( void (*label
)() )
15 return (unsigned char *)(unsigned long)label
;
20 static void do_realloc( struct x86_function
*p
)
24 p
->store
= _mesa_exec_malloc(p
->size
);
28 unsigned used
= p
->csr
- p
->store
;
29 unsigned char *tmp
= p
->store
;
31 p
->store
= _mesa_exec_malloc(p
->size
);
32 memcpy(p
->store
, tmp
, used
);
33 p
->csr
= p
->store
+ used
;
38 /* Emit bytes to the instruction stream:
40 static unsigned char *reserve( struct x86_function
*p
, int bytes
)
42 if (p
->csr
+ bytes
- p
->store
> p
->size
)
46 unsigned char *csr
= p
->csr
;
54 static void emit_1b( struct x86_function
*p
, char b0
)
56 char *csr
= (char *)reserve(p
, 1);
60 static void emit_1i( struct x86_function
*p
, int i0
)
62 int *icsr
= (int *)reserve(p
, sizeof(i0
));
66 static void emit_1ub( struct x86_function
*p
, unsigned char b0
)
68 unsigned char *csr
= reserve(p
, 1);
72 static void emit_2ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
)
74 unsigned char *csr
= reserve(p
, 2);
79 static void emit_3ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
, unsigned char b2
)
81 unsigned char *csr
= reserve(p
, 3);
88 /* Build a modRM byte + possible displacement. No treatment of SIB
89 * indexing. BZZT - no way to encode an absolute address.
91 static void emit_modrm( struct x86_function
*p
,
93 struct x86_reg regmem
)
95 unsigned char val
= 0;
97 assert(reg
.mod
== mod_REG
);
99 val
|= regmem
.mod
<< 6; /* mod field */
100 val
|= reg
.idx
<< 3; /* reg field */
101 val
|= regmem
.idx
; /* r/m field */
105 /* Oh-oh we've stumbled into the SIB thing.
107 if (regmem
.file
== file_REG32
&&
108 regmem
.idx
== reg_SP
) {
109 emit_1ub(p
, 0x24); /* simplistic! */
112 switch (regmem
.mod
) {
117 emit_1b(p
, regmem
.disp
);
120 emit_1i(p
, regmem
.disp
);
129 static void emit_modrm_noreg( struct x86_function
*p
,
131 struct x86_reg regmem
)
133 struct x86_reg dummy
= x86_make_reg(file_REG32
, op
);
134 emit_modrm(p
, dummy
, regmem
);
137 /* Many x86 instructions have two opcodes to cope with the situations
138 * where the destination is a register or memory reference
139 * respectively. This function selects the correct opcode based on
140 * the arguments presented.
142 static void emit_op_modrm( struct x86_function
*p
,
143 unsigned char op_dst_is_reg
,
144 unsigned char op_dst_is_mem
,
150 emit_1ub(p
, op_dst_is_reg
);
151 emit_modrm(p
, dst
, src
);
156 assert(src
.mod
== mod_REG
);
157 emit_1ub(p
, op_dst_is_mem
);
158 emit_modrm(p
, src
, dst
);
172 /* Create and manipulate registers and regmem values:
174 struct x86_reg
x86_make_reg( enum x86_reg_file file
,
175 enum x86_reg_name idx
)
187 struct x86_reg
x86_make_disp( struct x86_reg reg
,
190 assert(reg
.file
== file_REG32
);
192 if (reg
.mod
== mod_REG
)
198 reg
.mod
= mod_INDIRECT
;
199 else if (reg
.disp
<= 127 && reg
.disp
>= -128)
202 reg
.mod
= mod_DISP32
;
207 struct x86_reg
x86_deref( struct x86_reg reg
)
209 return x86_make_disp(reg
, 0);
212 struct x86_reg
x86_get_base_reg( struct x86_reg reg
)
214 return x86_make_reg( reg
.file
, reg
.idx
);
217 unsigned char *x86_get_label( struct x86_function
*p
)
224 /***********************************************************************
229 void x86_jcc( struct x86_function
*p
,
231 unsigned char *label
)
233 int offset
= label
- (x86_get_label(p
) + 2);
235 if (offset
<= 127 && offset
>= -128) {
236 emit_1ub(p
, 0x70 + cc
);
237 emit_1b(p
, (char) offset
);
240 offset
= label
- (x86_get_label(p
) + 6);
241 emit_2ub(p
, 0x0f, 0x80 + cc
);
246 /* Always use a 32bit offset for forward jumps:
248 unsigned char *x86_jcc_forward( struct x86_function
*p
,
251 emit_2ub(p
, 0x0f, 0x80 + cc
);
253 return x86_get_label(p
);
256 unsigned char *x86_jmp_forward( struct x86_function
*p
)
260 return x86_get_label(p
);
263 unsigned char *x86_call_forward( struct x86_function
*p
)
267 return x86_get_label(p
);
270 /* Fixup offset from forward jump:
272 void x86_fixup_fwd_jump( struct x86_function
*p
,
273 unsigned char *fixup
)
275 *(int *)(fixup
- 4) = x86_get_label(p
) - fixup
;
278 void x86_jmp( struct x86_function
*p
, unsigned char *label
)
281 emit_1i(p
, label
- x86_get_label(p
) - 4);
285 /* This doesn't work once we start reallocating & copying the
286 * generated code on buffer fills, because the call is relative to the
289 void x86_call( struct x86_function
*p
, void (*label
)())
292 emit_1i(p
, cptr(label
) - x86_get_label(p
) - 4);
295 void x86_call( struct x86_function
*p
, struct x86_reg reg
)
298 emit_modrm_noreg(p
, 2, reg
);
304 * Temporary. As I need immediate operands, and dont want to mess with the codegen,
305 * I load the immediate into general purpose register and use it.
307 void x86_mov_reg_imm( struct x86_function
*p
, struct x86_reg dst
, int imm
)
309 assert(dst
.mod
== mod_REG
);
310 emit_1ub(p
, 0xb8 + dst
.idx
);
314 void x86_push( struct x86_function
*p
,
317 assert(reg
.mod
== mod_REG
);
318 emit_1ub(p
, 0x50 + reg
.idx
);
319 p
->stack_offset
+= 4;
322 void x86_pop( struct x86_function
*p
,
325 assert(reg
.mod
== mod_REG
);
326 emit_1ub(p
, 0x58 + reg
.idx
);
327 p
->stack_offset
-= 4;
330 void x86_inc( struct x86_function
*p
,
333 assert(reg
.mod
== mod_REG
);
334 emit_1ub(p
, 0x40 + reg
.idx
);
337 void x86_dec( struct x86_function
*p
,
340 assert(reg
.mod
== mod_REG
);
341 emit_1ub(p
, 0x48 + reg
.idx
);
344 void x86_ret( struct x86_function
*p
)
349 void x86_sahf( struct x86_function
*p
)
354 void x86_mov( struct x86_function
*p
,
358 emit_op_modrm( p
, 0x8b, 0x89, dst
, src
);
361 void x86_xor( struct x86_function
*p
,
365 emit_op_modrm( p
, 0x33, 0x31, dst
, src
);
368 void x86_cmp( struct x86_function
*p
,
372 emit_op_modrm( p
, 0x3b, 0x39, dst
, src
);
375 void x86_lea( struct x86_function
*p
,
380 emit_modrm( p
, dst
, src
);
383 void x86_test( struct x86_function
*p
,
388 emit_modrm( p
, dst
, src
);
391 void x86_add( struct x86_function
*p
,
395 emit_op_modrm(p
, 0x03, 0x01, dst
, src
);
398 void x86_mul( struct x86_function
*p
,
401 assert (src
.file
== file_REG32
&& src
.mod
== mod_REG
);
402 emit_op_modrm(p
, 0xf7, 0, x86_make_reg (file_REG32
, reg_SP
), src
);
405 void x86_sub( struct x86_function
*p
,
409 emit_op_modrm(p
, 0x2b, 0x29, dst
, src
);
412 void x86_or( struct x86_function
*p
,
416 emit_op_modrm( p
, 0x0b, 0x09, dst
, src
);
419 void x86_and( struct x86_function
*p
,
423 emit_op_modrm( p
, 0x23, 0x21, dst
, src
);
428 /***********************************************************************
433 void sse_movss( struct x86_function
*p
,
437 emit_2ub(p
, 0xF3, X86_TWOB
);
438 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
441 void sse_movaps( struct x86_function
*p
,
445 emit_1ub(p
, X86_TWOB
);
446 emit_op_modrm( p
, 0x28, 0x29, dst
, src
);
449 void sse_movups( struct x86_function
*p
,
453 emit_1ub(p
, X86_TWOB
);
454 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
457 void sse_movhps( struct x86_function
*p
,
461 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
462 emit_1ub(p
, X86_TWOB
);
463 emit_op_modrm( p
, 0x16, 0x17, dst
, src
); /* cf movlhps */
466 void sse_movlps( struct x86_function
*p
,
470 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
471 emit_1ub(p
, X86_TWOB
);
472 emit_op_modrm( p
, 0x12, 0x13, dst
, src
); /* cf movhlps */
475 void sse_maxps( struct x86_function
*p
,
479 emit_2ub(p
, X86_TWOB
, 0x5F);
480 emit_modrm( p
, dst
, src
);
483 void sse_maxss( struct x86_function
*p
,
487 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5F);
488 emit_modrm( p
, dst
, src
);
491 void sse_divss( struct x86_function
*p
,
495 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5E);
496 emit_modrm( p
, dst
, src
);
499 void sse_minps( struct x86_function
*p
,
503 emit_2ub(p
, X86_TWOB
, 0x5D);
504 emit_modrm( p
, dst
, src
);
507 void sse_subps( struct x86_function
*p
,
511 emit_2ub(p
, X86_TWOB
, 0x5C);
512 emit_modrm( p
, dst
, src
);
515 void sse_mulps( struct x86_function
*p
,
519 emit_2ub(p
, X86_TWOB
, 0x59);
520 emit_modrm( p
, dst
, src
);
523 void sse_mulss( struct x86_function
*p
,
527 emit_3ub(p
, 0xF3, X86_TWOB
, 0x59);
528 emit_modrm( p
, dst
, src
);
531 void sse_addps( struct x86_function
*p
,
535 emit_2ub(p
, X86_TWOB
, 0x58);
536 emit_modrm( p
, dst
, src
);
539 void sse_addss( struct x86_function
*p
,
543 emit_3ub(p
, 0xF3, X86_TWOB
, 0x58);
544 emit_modrm( p
, dst
, src
);
547 void sse_andnps( struct x86_function
*p
,
551 emit_2ub(p
, X86_TWOB
, 0x55);
552 emit_modrm( p
, dst
, src
);
555 void sse_andps( struct x86_function
*p
,
559 emit_2ub(p
, X86_TWOB
, 0x54);
560 emit_modrm( p
, dst
, src
);
563 void sse_rsqrtps( struct x86_function
*p
,
567 emit_2ub(p
, X86_TWOB
, 0x52);
568 emit_modrm( p
, dst
, src
);
571 void sse_rsqrtss( struct x86_function
*p
,
575 emit_3ub(p
, 0xF3, X86_TWOB
, 0x52);
576 emit_modrm( p
, dst
, src
);
580 void sse_movhlps( struct x86_function
*p
,
584 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
585 emit_2ub(p
, X86_TWOB
, 0x12);
586 emit_modrm( p
, dst
, src
);
589 void sse_movlhps( struct x86_function
*p
,
593 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
594 emit_2ub(p
, X86_TWOB
, 0x16);
595 emit_modrm( p
, dst
, src
);
598 void sse_orps( struct x86_function
*p
,
602 emit_2ub(p
, X86_TWOB
, 0x56);
603 emit_modrm( p
, dst
, src
);
606 void sse_xorps( struct x86_function
*p
,
610 emit_2ub(p
, X86_TWOB
, 0x57);
611 emit_modrm( p
, dst
, src
);
614 void sse_cvtps2pi( struct x86_function
*p
,
618 assert(dst
.file
== file_MMX
&&
619 (src
.file
== file_XMM
|| src
.mod
!= mod_REG
));
623 emit_2ub(p
, X86_TWOB
, 0x2d);
624 emit_modrm( p
, dst
, src
);
628 /* Shufps can also be used to implement a reduced swizzle when dest ==
631 void sse_shufps( struct x86_function
*p
,
636 emit_2ub(p
, X86_TWOB
, 0xC6);
637 emit_modrm(p
, dest
, arg0
);
641 void sse_cmpps( struct x86_function
*p
,
646 emit_2ub(p
, X86_TWOB
, 0xC2);
647 emit_modrm(p
, dest
, arg0
);
651 void sse_pmovmskb( struct x86_function
*p
,
655 emit_3ub(p
, 0x66, X86_TWOB
, 0xD7);
656 emit_modrm(p
, dest
, src
);
659 /***********************************************************************
664 * Perform a reduced swizzle:
666 void sse2_pshufd( struct x86_function
*p
,
671 emit_3ub(p
, 0x66, X86_TWOB
, 0x70);
672 emit_modrm(p
, dest
, arg0
);
676 void sse2_cvttps2dq( struct x86_function
*p
,
680 emit_3ub( p
, 0xF3, X86_TWOB
, 0x5B );
681 emit_modrm( p
, dst
, src
);
684 void sse2_cvtps2dq( struct x86_function
*p
,
688 emit_3ub(p
, 0x66, X86_TWOB
, 0x5B);
689 emit_modrm( p
, dst
, src
);
692 void sse2_packssdw( struct x86_function
*p
,
696 emit_3ub(p
, 0x66, X86_TWOB
, 0x6B);
697 emit_modrm( p
, dst
, src
);
700 void sse2_packsswb( struct x86_function
*p
,
704 emit_3ub(p
, 0x66, X86_TWOB
, 0x63);
705 emit_modrm( p
, dst
, src
);
708 void sse2_packuswb( struct x86_function
*p
,
712 emit_3ub(p
, 0x66, X86_TWOB
, 0x67);
713 emit_modrm( p
, dst
, src
);
716 void sse2_rcpps( struct x86_function
*p
,
720 emit_2ub(p
, X86_TWOB
, 0x53);
721 emit_modrm( p
, dst
, src
);
724 void sse2_rcpss( struct x86_function
*p
,
728 emit_3ub(p
, 0xF3, X86_TWOB
, 0x53);
729 emit_modrm( p
, dst
, src
);
732 void sse2_movd( struct x86_function
*p
,
736 emit_2ub(p
, 0x66, X86_TWOB
);
737 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
743 /***********************************************************************
746 void x87_fist( struct x86_function
*p
, struct x86_reg dst
)
749 emit_modrm_noreg(p
, 2, dst
);
752 void x87_fistp( struct x86_function
*p
, struct x86_reg dst
)
755 emit_modrm_noreg(p
, 3, dst
);
758 void x87_fild( struct x86_function
*p
, struct x86_reg arg
)
761 emit_modrm_noreg(p
, 0, arg
);
764 void x87_fldz( struct x86_function
*p
)
766 emit_2ub(p
, 0xd9, 0xee);
770 void x87_fldcw( struct x86_function
*p
, struct x86_reg arg
)
772 assert(arg
.file
== file_REG32
);
773 assert(arg
.mod
!= mod_REG
);
775 emit_modrm_noreg(p
, 5, arg
);
778 void x87_fld1( struct x86_function
*p
)
780 emit_2ub(p
, 0xd9, 0xe8);
783 void x87_fldl2e( struct x86_function
*p
)
785 emit_2ub(p
, 0xd9, 0xea);
788 void x87_fldln2( struct x86_function
*p
)
790 emit_2ub(p
, 0xd9, 0xed);
793 void x87_fwait( struct x86_function
*p
)
798 void x87_fnclex( struct x86_function
*p
)
800 emit_2ub(p
, 0xdb, 0xe2);
803 void x87_fclex( struct x86_function
*p
)
810 static void x87_arith_op( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
,
811 unsigned char dst0ub0
,
812 unsigned char dst0ub1
,
813 unsigned char arg0ub0
,
814 unsigned char arg0ub1
,
815 unsigned char argmem_noreg
)
817 assert(dst
.file
== file_x87
);
819 if (arg
.file
== file_x87
) {
821 emit_2ub(p
, dst0ub0
, dst0ub1
+arg
.idx
);
822 else if (arg
.idx
== 0)
823 emit_2ub(p
, arg0ub0
, arg0ub1
+arg
.idx
);
827 else if (dst
.idx
== 0) {
828 assert(arg
.file
== file_REG32
);
830 emit_modrm_noreg(p
, argmem_noreg
, arg
);
836 void x87_fmul( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
838 x87_arith_op(p
, dst
, arg
,
844 void x87_fsub( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
846 x87_arith_op(p
, dst
, arg
,
852 void x87_fsubr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
854 x87_arith_op(p
, dst
, arg
,
860 void x87_fadd( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
862 x87_arith_op(p
, dst
, arg
,
868 void x87_fdiv( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
870 x87_arith_op(p
, dst
, arg
,
876 void x87_fdivr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
878 x87_arith_op(p
, dst
, arg
,
884 void x87_fmulp( struct x86_function
*p
, struct x86_reg dst
)
886 assert(dst
.file
== file_x87
);
887 assert(dst
.idx
>= 1);
888 emit_2ub(p
, 0xde, 0xc8+dst
.idx
);
891 void x87_fsubp( struct x86_function
*p
, struct x86_reg dst
)
893 assert(dst
.file
== file_x87
);
894 assert(dst
.idx
>= 1);
895 emit_2ub(p
, 0xde, 0xe8+dst
.idx
);
898 void x87_fsubrp( struct x86_function
*p
, struct x86_reg dst
)
900 assert(dst
.file
== file_x87
);
901 assert(dst
.idx
>= 1);
902 emit_2ub(p
, 0xde, 0xe0+dst
.idx
);
905 void x87_faddp( struct x86_function
*p
, struct x86_reg dst
)
907 assert(dst
.file
== file_x87
);
908 assert(dst
.idx
>= 1);
909 emit_2ub(p
, 0xde, 0xc0+dst
.idx
);
912 void x87_fdivp( struct x86_function
*p
, struct x86_reg dst
)
914 assert(dst
.file
== file_x87
);
915 assert(dst
.idx
>= 1);
916 emit_2ub(p
, 0xde, 0xf8+dst
.idx
);
919 void x87_fdivrp( struct x86_function
*p
, struct x86_reg dst
)
921 assert(dst
.file
== file_x87
);
922 assert(dst
.idx
>= 1);
923 emit_2ub(p
, 0xde, 0xf0+dst
.idx
);
926 void x87_fucom( struct x86_function
*p
, struct x86_reg arg
)
928 assert(arg
.file
== file_x87
);
929 emit_2ub(p
, 0xdd, 0xe0+arg
.idx
);
932 void x87_fucomp( struct x86_function
*p
, struct x86_reg arg
)
934 assert(arg
.file
== file_x87
);
935 emit_2ub(p
, 0xdd, 0xe8+arg
.idx
);
938 void x87_fucompp( struct x86_function
*p
)
940 emit_2ub(p
, 0xda, 0xe9);
943 void x87_fxch( struct x86_function
*p
, struct x86_reg arg
)
945 assert(arg
.file
== file_x87
);
946 emit_2ub(p
, 0xd9, 0xc8+arg
.idx
);
949 void x87_fabs( struct x86_function
*p
)
951 emit_2ub(p
, 0xd9, 0xe1);
954 void x87_fchs( struct x86_function
*p
)
956 emit_2ub(p
, 0xd9, 0xe0);
959 void x87_fcos( struct x86_function
*p
)
961 emit_2ub(p
, 0xd9, 0xff);
965 void x87_fprndint( struct x86_function
*p
)
967 emit_2ub(p
, 0xd9, 0xfc);
970 void x87_fscale( struct x86_function
*p
)
972 emit_2ub(p
, 0xd9, 0xfd);
975 void x87_fsin( struct x86_function
*p
)
977 emit_2ub(p
, 0xd9, 0xfe);
980 void x87_fsincos( struct x86_function
*p
)
982 emit_2ub(p
, 0xd9, 0xfb);
985 void x87_fsqrt( struct x86_function
*p
)
987 emit_2ub(p
, 0xd9, 0xfa);
990 void x87_fxtract( struct x86_function
*p
)
992 emit_2ub(p
, 0xd9, 0xf4);
997 * Restrictions: -1.0 <= st0 <= 1.0
999 void x87_f2xm1( struct x86_function
*p
)
1001 emit_2ub(p
, 0xd9, 0xf0);
1004 /* st1 = st1 * log2(st0);
1007 void x87_fyl2x( struct x86_function
*p
)
1009 emit_2ub(p
, 0xd9, 0xf1);
1012 /* st1 = st1 * log2(st0 + 1.0);
1015 * A fast operation, with restrictions: -.29 < st0 < .29
1017 void x87_fyl2xp1( struct x86_function
*p
)
1019 emit_2ub(p
, 0xd9, 0xf9);
1023 void x87_fld( struct x86_function
*p
, struct x86_reg arg
)
1025 if (arg
.file
== file_x87
)
1026 emit_2ub(p
, 0xd9, 0xc0 + arg
.idx
);
1029 emit_modrm_noreg(p
, 0, arg
);
1033 void x87_fst( struct x86_function
*p
, struct x86_reg dst
)
1035 if (dst
.file
== file_x87
)
1036 emit_2ub(p
, 0xdd, 0xd0 + dst
.idx
);
1039 emit_modrm_noreg(p
, 2, dst
);
1043 void x87_fstp( struct x86_function
*p
, struct x86_reg dst
)
1045 if (dst
.file
== file_x87
)
1046 emit_2ub(p
, 0xdd, 0xd8 + dst
.idx
);
1049 emit_modrm_noreg(p
, 3, dst
);
1053 void x87_fcom( struct x86_function
*p
, struct x86_reg dst
)
1055 if (dst
.file
== file_x87
)
1056 emit_2ub(p
, 0xd8, 0xd0 + dst
.idx
);
1059 emit_modrm_noreg(p
, 2, dst
);
1063 void x87_fcomp( struct x86_function
*p
, struct x86_reg dst
)
1065 if (dst
.file
== file_x87
)
1066 emit_2ub(p
, 0xd8, 0xd8 + dst
.idx
);
1069 emit_modrm_noreg(p
, 3, dst
);
1074 void x87_fnstsw( struct x86_function
*p
, struct x86_reg dst
)
1076 assert(dst
.file
== file_REG32
);
1078 if (dst
.idx
== reg_AX
&&
1080 emit_2ub(p
, 0xdf, 0xe0);
1083 emit_modrm_noreg(p
, 7, dst
);
1090 /***********************************************************************
1094 void mmx_emms( struct x86_function
*p
)
1096 assert(p
->need_emms
);
1097 emit_2ub(p
, 0x0f, 0x77);
1101 void mmx_packssdw( struct x86_function
*p
,
1103 struct x86_reg src
)
1105 assert(dst
.file
== file_MMX
&&
1106 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1110 emit_2ub(p
, X86_TWOB
, 0x6b);
1111 emit_modrm( p
, dst
, src
);
1114 void mmx_packuswb( struct x86_function
*p
,
1116 struct x86_reg src
)
1118 assert(dst
.file
== file_MMX
&&
1119 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1123 emit_2ub(p
, X86_TWOB
, 0x67);
1124 emit_modrm( p
, dst
, src
);
1127 void mmx_movd( struct x86_function
*p
,
1129 struct x86_reg src
)
1132 emit_1ub(p
, X86_TWOB
);
1133 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
1136 void mmx_movq( struct x86_function
*p
,
1138 struct x86_reg src
)
1141 emit_1ub(p
, X86_TWOB
);
1142 emit_op_modrm( p
, 0x6f, 0x7f, dst
, src
);
1146 /***********************************************************************
1151 /* Retreive a reference to one of the function arguments, taking into
1152 * account any push/pop activity:
1154 struct x86_reg
x86_fn_arg( struct x86_function
*p
,
1157 return x86_make_disp(x86_make_reg(file_REG32
, reg_SP
),
1158 p
->stack_offset
+ arg
* 4); /* ??? */
1162 void x86_init_func( struct x86_function
*p
)
1169 int x86_init_func_size( struct x86_function
*p
, unsigned code_size
)
1171 p
->size
= code_size
;
1172 p
->store
= _mesa_exec_malloc(code_size
);
1174 return p
->store
!= NULL
;
1177 void x86_release_func( struct x86_function
*p
)
1179 _mesa_exec_free(p
->store
);
1186 void (*x86_get_func( struct x86_function
*p
))(void)
1188 if (DISASSEM
&& p
->store
)
1189 printf("disassemble %p %p\n", p
->store
, p
->csr
);
1190 return (void (*)(void)) (unsigned long) p
->store
;
1195 void x86sse_dummy( void )
1201 #else /* USE_X86_ASM */
1203 int x86sse_c_dummy_var
; /* silence warning */
1205 #endif /* USE_X86_ASM */