772471c7230a7308348ebd9f157f71b2b4e83394
1 #if defined(__i386__) || defined(__386__)
9 static unsigned char *cptr( void (*label
)() )
11 return (unsigned char *)(unsigned long)label
;
15 static void do_realloc( struct x86_function
*p
)
19 p
->store
= _mesa_exec_malloc(p
->size
);
23 unsigned used
= p
->csr
- p
->store
;
24 unsigned char *tmp
= p
->store
;
26 p
->store
= _mesa_exec_malloc(p
->size
);
27 memcpy(p
->store
, tmp
, used
);
28 p
->csr
= p
->store
+ used
;
33 /* Emit bytes to the instruction stream:
35 static unsigned char *reserve( struct x86_function
*p
, int bytes
)
37 if (p
->csr
+ bytes
- p
->store
> p
->size
)
41 unsigned char *csr
= p
->csr
;
49 static void emit_1b( struct x86_function
*p
, char b0
)
51 char *csr
= (char *)reserve(p
, 1);
55 static void emit_1i( struct x86_function
*p
, int i0
)
57 int *icsr
= (int *)reserve(p
, sizeof(i0
));
61 static void emit_1ub( struct x86_function
*p
, unsigned char b0
)
63 unsigned char *csr
= reserve(p
, 1);
67 static void emit_2ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
)
69 unsigned char *csr
= reserve(p
, 2);
74 static void emit_3ub( struct x86_function
*p
, unsigned char b0
, unsigned char b1
, unsigned char b2
)
76 unsigned char *csr
= reserve(p
, 3);
83 /* Build a modRM byte + possible displacement. No treatment of SIB
84 * indexing. BZZT - no way to encode an absolute address.
86 static void emit_modrm( struct x86_function
*p
,
88 struct x86_reg regmem
)
90 unsigned char val
= 0;
92 assert(reg
.mod
== mod_REG
);
94 val
|= regmem
.mod
<< 6; /* mod field */
95 val
|= reg
.idx
<< 3; /* reg field */
96 val
|= regmem
.idx
; /* r/m field */
100 /* Oh-oh we've stumbled into the SIB thing.
102 if (regmem
.file
== file_REG32
&&
103 regmem
.idx
== reg_SP
) {
104 emit_1ub(p
, 0x24); /* simplistic! */
107 switch (regmem
.mod
) {
112 emit_1b(p
, regmem
.disp
);
115 emit_1i(p
, regmem
.disp
);
124 static void emit_modrm_noreg( struct x86_function
*p
,
126 struct x86_reg regmem
)
128 struct x86_reg dummy
= x86_make_reg(file_REG32
, op
);
129 emit_modrm(p
, dummy
, regmem
);
132 /* Many x86 instructions have two opcodes to cope with the situations
133 * where the destination is a register or memory reference
134 * respectively. This function selects the correct opcode based on
135 * the arguments presented.
137 static void emit_op_modrm( struct x86_function
*p
,
138 unsigned char op_dst_is_reg
,
139 unsigned char op_dst_is_mem
,
145 emit_1ub(p
, op_dst_is_reg
);
146 emit_modrm(p
, dst
, src
);
151 assert(src
.mod
== mod_REG
);
152 emit_1ub(p
, op_dst_is_mem
);
153 emit_modrm(p
, src
, dst
);
167 /* Create and manipulate registers and regmem values:
169 struct x86_reg
x86_make_reg( enum x86_reg_file file
,
170 enum x86_reg_name idx
)
182 struct x86_reg
x86_make_disp( struct x86_reg reg
,
185 assert(reg
.file
== file_REG32
);
187 if (reg
.mod
== mod_REG
)
193 reg
.mod
= mod_INDIRECT
;
194 else if (reg
.disp
<= 127 && reg
.disp
>= -128)
197 reg
.mod
= mod_DISP32
;
202 struct x86_reg
x86_deref( struct x86_reg reg
)
204 return x86_make_disp(reg
, 0);
207 struct x86_reg
x86_get_base_reg( struct x86_reg reg
)
209 return x86_make_reg( reg
.file
, reg
.idx
);
212 unsigned char *x86_get_label( struct x86_function
*p
)
219 /***********************************************************************
224 void x86_jcc( struct x86_function
*p
,
226 unsigned char *label
)
228 int offset
= label
- (x86_get_label(p
) + 2);
230 if (offset
<= 127 && offset
>= -128) {
231 emit_1ub(p
, 0x70 + cc
);
232 emit_1b(p
, (char) offset
);
235 offset
= label
- (x86_get_label(p
) + 6);
236 emit_2ub(p
, 0x0f, 0x80 + cc
);
241 /* Always use a 32bit offset for forward jumps:
243 unsigned char *x86_jcc_forward( struct x86_function
*p
,
246 emit_2ub(p
, 0x0f, 0x80 + cc
);
248 return x86_get_label(p
);
251 unsigned char *x86_jmp_forward( struct x86_function
*p
)
255 return x86_get_label(p
);
258 unsigned char *x86_call_forward( struct x86_function
*p
)
262 return x86_get_label(p
);
265 /* Fixup offset from forward jump:
267 void x86_fixup_fwd_jump( struct x86_function
*p
,
268 unsigned char *fixup
)
270 *(int *)(fixup
- 4) = x86_get_label(p
) - fixup
;
273 void x86_jmp( struct x86_function
*p
, unsigned char *label
)
276 emit_1i(p
, label
- x86_get_label(p
) - 4);
280 /* This doesn't work once we start reallocating & copying the
281 * generated code on buffer fills, because the call is relative to the
284 void x86_call( struct x86_function
*p
, void (*label
)())
287 emit_1i(p
, cptr(label
) - x86_get_label(p
) - 4);
290 void x86_call( struct x86_function
*p
, struct x86_reg reg
)
293 emit_modrm(p
, reg
, reg
);
299 * Temporary. As I need immediate operands, and dont want to mess with the codegen,
300 * I load the immediate into general purpose register and use it.
302 void x86_mov_reg_imm( struct x86_function
*p
, struct x86_reg dst
, int imm
)
304 assert(dst
.mod
== mod_REG
);
305 emit_1ub(p
, 0xb8 + dst
.idx
);
309 void x86_push( struct x86_function
*p
,
312 assert(reg
.mod
== mod_REG
);
313 emit_1ub(p
, 0x50 + reg
.idx
);
314 p
->stack_offset
+= 4;
317 void x86_pop( struct x86_function
*p
,
320 assert(reg
.mod
== mod_REG
);
321 emit_1ub(p
, 0x58 + reg
.idx
);
322 p
->stack_offset
-= 4;
325 void x86_inc( struct x86_function
*p
,
328 assert(reg
.mod
== mod_REG
);
329 emit_1ub(p
, 0x40 + reg
.idx
);
332 void x86_dec( struct x86_function
*p
,
335 assert(reg
.mod
== mod_REG
);
336 emit_1ub(p
, 0x48 + reg
.idx
);
339 void x86_ret( struct x86_function
*p
)
344 void x86_sahf( struct x86_function
*p
)
349 void x86_mov( struct x86_function
*p
,
353 emit_op_modrm( p
, 0x8b, 0x89, dst
, src
);
356 void x86_xor( struct x86_function
*p
,
360 emit_op_modrm( p
, 0x33, 0x31, dst
, src
);
363 void x86_cmp( struct x86_function
*p
,
367 emit_op_modrm( p
, 0x3b, 0x39, dst
, src
);
370 void x86_lea( struct x86_function
*p
,
375 emit_modrm( p
, dst
, src
);
378 void x86_test( struct x86_function
*p
,
383 emit_modrm( p
, dst
, src
);
386 void x86_add( struct x86_function
*p
,
390 emit_op_modrm(p
, 0x03, 0x01, dst
, src
);
393 void x86_mul( struct x86_function
*p
,
396 assert (src
.file
== file_REG32
&& src
.mod
== mod_REG
);
397 emit_op_modrm(p
, 0xf7, 0, x86_make_reg (file_REG32
, reg_SP
), src
);
400 void x86_sub( struct x86_function
*p
,
404 emit_op_modrm(p
, 0x2b, 0x29, dst
, src
);
407 void x86_or( struct x86_function
*p
,
411 emit_op_modrm( p
, 0x0b, 0x09, dst
, src
);
414 void x86_and( struct x86_function
*p
,
418 emit_op_modrm( p
, 0x23, 0x21, dst
, src
);
423 /***********************************************************************
428 void sse_movss( struct x86_function
*p
,
432 emit_2ub(p
, 0xF3, X86_TWOB
);
433 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
436 void sse_movaps( struct x86_function
*p
,
440 emit_1ub(p
, X86_TWOB
);
441 emit_op_modrm( p
, 0x28, 0x29, dst
, src
);
444 void sse_movups( struct x86_function
*p
,
448 emit_1ub(p
, X86_TWOB
);
449 emit_op_modrm( p
, 0x10, 0x11, dst
, src
);
452 void sse_movhps( struct x86_function
*p
,
456 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
457 emit_1ub(p
, X86_TWOB
);
458 emit_op_modrm( p
, 0x16, 0x17, dst
, src
); /* cf movlhps */
461 void sse_movlps( struct x86_function
*p
,
465 assert(dst
.mod
!= mod_REG
|| src
.mod
!= mod_REG
);
466 emit_1ub(p
, X86_TWOB
);
467 emit_op_modrm( p
, 0x12, 0x13, dst
, src
); /* cf movhlps */
470 void sse_maxps( struct x86_function
*p
,
474 emit_2ub(p
, X86_TWOB
, 0x5F);
475 emit_modrm( p
, dst
, src
);
478 void sse_maxss( struct x86_function
*p
,
482 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5F);
483 emit_modrm( p
, dst
, src
);
486 void sse_divss( struct x86_function
*p
,
490 emit_3ub(p
, 0xF3, X86_TWOB
, 0x5E);
491 emit_modrm( p
, dst
, src
);
494 void sse_minps( struct x86_function
*p
,
498 emit_2ub(p
, X86_TWOB
, 0x5D);
499 emit_modrm( p
, dst
, src
);
502 void sse_subps( struct x86_function
*p
,
506 emit_2ub(p
, X86_TWOB
, 0x5C);
507 emit_modrm( p
, dst
, src
);
510 void sse_mulps( struct x86_function
*p
,
514 emit_2ub(p
, X86_TWOB
, 0x59);
515 emit_modrm( p
, dst
, src
);
518 void sse_mulss( struct x86_function
*p
,
522 emit_3ub(p
, 0xF3, X86_TWOB
, 0x59);
523 emit_modrm( p
, dst
, src
);
526 void sse_addps( struct x86_function
*p
,
530 emit_2ub(p
, X86_TWOB
, 0x58);
531 emit_modrm( p
, dst
, src
);
534 void sse_addss( struct x86_function
*p
,
538 emit_3ub(p
, 0xF3, X86_TWOB
, 0x58);
539 emit_modrm( p
, dst
, src
);
542 void sse_andnps( struct x86_function
*p
,
546 emit_2ub(p
, X86_TWOB
, 0x55);
547 emit_modrm( p
, dst
, src
);
550 void sse_andps( struct x86_function
*p
,
554 emit_2ub(p
, X86_TWOB
, 0x54);
555 emit_modrm( p
, dst
, src
);
558 void sse_rsqrtps( struct x86_function
*p
,
562 emit_2ub(p
, X86_TWOB
, 0x52);
563 emit_modrm( p
, dst
, src
);
566 void sse_rsqrtss( struct x86_function
*p
,
570 emit_3ub(p
, 0xF3, X86_TWOB
, 0x52);
571 emit_modrm( p
, dst
, src
);
575 void sse_movhlps( struct x86_function
*p
,
579 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
580 emit_2ub(p
, X86_TWOB
, 0x12);
581 emit_modrm( p
, dst
, src
);
584 void sse_movlhps( struct x86_function
*p
,
588 assert(dst
.mod
== mod_REG
&& src
.mod
== mod_REG
);
589 emit_2ub(p
, X86_TWOB
, 0x16);
590 emit_modrm( p
, dst
, src
);
593 void sse_orps( struct x86_function
*p
,
597 emit_2ub(p
, X86_TWOB
, 0x56);
598 emit_modrm( p
, dst
, src
);
601 void sse_xorps( struct x86_function
*p
,
605 emit_2ub(p
, X86_TWOB
, 0x57);
606 emit_modrm( p
, dst
, src
);
609 void sse_cvtps2pi( struct x86_function
*p
,
613 assert(dst
.file
== file_MMX
&&
614 (src
.file
== file_XMM
|| src
.mod
!= mod_REG
));
618 emit_2ub(p
, X86_TWOB
, 0x2d);
619 emit_modrm( p
, dst
, src
);
623 /* Shufps can also be used to implement a reduced swizzle when dest ==
626 void sse_shufps( struct x86_function
*p
,
631 emit_2ub(p
, X86_TWOB
, 0xC6);
632 emit_modrm(p
, dest
, arg0
);
636 void sse_cmpps( struct x86_function
*p
,
641 emit_2ub(p
, X86_TWOB
, 0xC2);
642 emit_modrm(p
, dest
, arg0
);
646 void sse_pmovmskb( struct x86_function
*p
,
650 emit_3ub(p
, 0x66, X86_TWOB
, 0xD7);
651 emit_modrm(p
, dest
, src
);
654 /***********************************************************************
659 * Perform a reduced swizzle:
661 void sse2_pshufd( struct x86_function
*p
,
666 emit_3ub(p
, 0x66, X86_TWOB
, 0x70);
667 emit_modrm(p
, dest
, arg0
);
671 void sse2_cvttps2dq( struct x86_function
*p
,
675 emit_3ub( p
, 0xF3, X86_TWOB
, 0x5B );
676 emit_modrm( p
, dst
, src
);
679 void sse2_cvtps2dq( struct x86_function
*p
,
683 emit_3ub(p
, 0x66, X86_TWOB
, 0x5B);
684 emit_modrm( p
, dst
, src
);
687 void sse2_packssdw( struct x86_function
*p
,
691 emit_3ub(p
, 0x66, X86_TWOB
, 0x6B);
692 emit_modrm( p
, dst
, src
);
695 void sse2_packsswb( struct x86_function
*p
,
699 emit_3ub(p
, 0x66, X86_TWOB
, 0x63);
700 emit_modrm( p
, dst
, src
);
703 void sse2_packuswb( struct x86_function
*p
,
707 emit_3ub(p
, 0x66, X86_TWOB
, 0x67);
708 emit_modrm( p
, dst
, src
);
711 void sse2_rcpps( struct x86_function
*p
,
715 emit_2ub(p
, X86_TWOB
, 0x53);
716 emit_modrm( p
, dst
, src
);
719 void sse2_rcpss( struct x86_function
*p
,
723 emit_3ub(p
, 0xF3, X86_TWOB
, 0x53);
724 emit_modrm( p
, dst
, src
);
727 void sse2_movd( struct x86_function
*p
,
731 emit_2ub(p
, 0x66, X86_TWOB
);
732 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
738 /***********************************************************************
741 void x87_fist( struct x86_function
*p
, struct x86_reg dst
)
744 emit_modrm_noreg(p
, 2, dst
);
747 void x87_fistp( struct x86_function
*p
, struct x86_reg dst
)
750 emit_modrm_noreg(p
, 3, dst
);
753 void x87_fild( struct x86_function
*p
, struct x86_reg arg
)
756 emit_modrm_noreg(p
, 0, arg
);
759 void x87_fldz( struct x86_function
*p
)
761 emit_2ub(p
, 0xd9, 0xee);
765 void x87_fldcw( struct x86_function
*p
, struct x86_reg arg
)
767 assert(arg
.file
== file_REG32
);
768 assert(arg
.mod
!= mod_REG
);
770 emit_modrm_noreg(p
, 5, arg
);
773 void x87_fld1( struct x86_function
*p
)
775 emit_2ub(p
, 0xd9, 0xe8);
778 void x87_fldl2e( struct x86_function
*p
)
780 emit_2ub(p
, 0xd9, 0xea);
783 void x87_fldln2( struct x86_function
*p
)
785 emit_2ub(p
, 0xd9, 0xed);
788 void x87_fwait( struct x86_function
*p
)
793 void x87_fnclex( struct x86_function
*p
)
795 emit_2ub(p
, 0xdb, 0xe2);
798 void x87_fclex( struct x86_function
*p
)
805 static void x87_arith_op( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
,
806 unsigned char dst0ub0
,
807 unsigned char dst0ub1
,
808 unsigned char arg0ub0
,
809 unsigned char arg0ub1
,
810 unsigned char argmem_noreg
)
812 assert(dst
.file
== file_x87
);
814 if (arg
.file
== file_x87
) {
816 emit_2ub(p
, dst0ub0
, dst0ub1
+arg
.idx
);
817 else if (arg
.idx
== 0)
818 emit_2ub(p
, arg0ub0
, arg0ub1
+arg
.idx
);
822 else if (dst
.idx
== 0) {
823 assert(arg
.file
== file_REG32
);
825 emit_modrm_noreg(p
, argmem_noreg
, arg
);
831 void x87_fmul( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
833 x87_arith_op(p
, dst
, arg
,
839 void x87_fsub( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
841 x87_arith_op(p
, dst
, arg
,
847 void x87_fsubr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
849 x87_arith_op(p
, dst
, arg
,
855 void x87_fadd( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
857 x87_arith_op(p
, dst
, arg
,
863 void x87_fdiv( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
865 x87_arith_op(p
, dst
, arg
,
871 void x87_fdivr( struct x86_function
*p
, struct x86_reg dst
, struct x86_reg arg
)
873 x87_arith_op(p
, dst
, arg
,
879 void x87_fmulp( struct x86_function
*p
, struct x86_reg dst
)
881 assert(dst
.file
== file_x87
);
882 assert(dst
.idx
>= 1);
883 emit_2ub(p
, 0xde, 0xc8+dst
.idx
);
886 void x87_fsubp( struct x86_function
*p
, struct x86_reg dst
)
888 assert(dst
.file
== file_x87
);
889 assert(dst
.idx
>= 1);
890 emit_2ub(p
, 0xde, 0xe8+dst
.idx
);
893 void x87_fsubrp( struct x86_function
*p
, struct x86_reg dst
)
895 assert(dst
.file
== file_x87
);
896 assert(dst
.idx
>= 1);
897 emit_2ub(p
, 0xde, 0xe0+dst
.idx
);
900 void x87_faddp( struct x86_function
*p
, struct x86_reg dst
)
902 assert(dst
.file
== file_x87
);
903 assert(dst
.idx
>= 1);
904 emit_2ub(p
, 0xde, 0xc0+dst
.idx
);
907 void x87_fdivp( struct x86_function
*p
, struct x86_reg dst
)
909 assert(dst
.file
== file_x87
);
910 assert(dst
.idx
>= 1);
911 emit_2ub(p
, 0xde, 0xf8+dst
.idx
);
914 void x87_fdivrp( struct x86_function
*p
, struct x86_reg dst
)
916 assert(dst
.file
== file_x87
);
917 assert(dst
.idx
>= 1);
918 emit_2ub(p
, 0xde, 0xf0+dst
.idx
);
921 void x87_fucom( struct x86_function
*p
, struct x86_reg arg
)
923 assert(arg
.file
== file_x87
);
924 emit_2ub(p
, 0xdd, 0xe0+arg
.idx
);
927 void x87_fucomp( struct x86_function
*p
, struct x86_reg arg
)
929 assert(arg
.file
== file_x87
);
930 emit_2ub(p
, 0xdd, 0xe8+arg
.idx
);
933 void x87_fucompp( struct x86_function
*p
)
935 emit_2ub(p
, 0xda, 0xe9);
938 void x87_fxch( struct x86_function
*p
, struct x86_reg arg
)
940 assert(arg
.file
== file_x87
);
941 emit_2ub(p
, 0xd9, 0xc8+arg
.idx
);
944 void x87_fabs( struct x86_function
*p
)
946 emit_2ub(p
, 0xd9, 0xe1);
949 void x87_fchs( struct x86_function
*p
)
951 emit_2ub(p
, 0xd9, 0xe0);
954 void x87_fcos( struct x86_function
*p
)
956 emit_2ub(p
, 0xd9, 0xff);
960 void x87_fprndint( struct x86_function
*p
)
962 emit_2ub(p
, 0xd9, 0xfc);
965 void x87_fscale( struct x86_function
*p
)
967 emit_2ub(p
, 0xd9, 0xfd);
970 void x87_fsin( struct x86_function
*p
)
972 emit_2ub(p
, 0xd9, 0xfe);
975 void x87_fsincos( struct x86_function
*p
)
977 emit_2ub(p
, 0xd9, 0xfb);
980 void x87_fsqrt( struct x86_function
*p
)
982 emit_2ub(p
, 0xd9, 0xfa);
985 void x87_fxtract( struct x86_function
*p
)
987 emit_2ub(p
, 0xd9, 0xf4);
992 * Restrictions: -1.0 <= st0 <= 1.0
994 void x87_f2xm1( struct x86_function
*p
)
996 emit_2ub(p
, 0xd9, 0xf0);
999 /* st1 = st1 * log2(st0);
1002 void x87_fyl2x( struct x86_function
*p
)
1004 emit_2ub(p
, 0xd9, 0xf1);
1007 /* st1 = st1 * log2(st0 + 1.0);
1010 * A fast operation, with restrictions: -.29 < st0 < .29
1012 void x87_fyl2xp1( struct x86_function
*p
)
1014 emit_2ub(p
, 0xd9, 0xf9);
1018 void x87_fld( struct x86_function
*p
, struct x86_reg arg
)
1020 if (arg
.file
== file_x87
)
1021 emit_2ub(p
, 0xd9, 0xc0 + arg
.idx
);
1024 emit_modrm_noreg(p
, 0, arg
);
1028 void x87_fst( struct x86_function
*p
, struct x86_reg dst
)
1030 if (dst
.file
== file_x87
)
1031 emit_2ub(p
, 0xdd, 0xd0 + dst
.idx
);
1034 emit_modrm_noreg(p
, 2, dst
);
1038 void x87_fstp( struct x86_function
*p
, struct x86_reg dst
)
1040 if (dst
.file
== file_x87
)
1041 emit_2ub(p
, 0xdd, 0xd8 + dst
.idx
);
1044 emit_modrm_noreg(p
, 3, dst
);
1048 void x87_fcom( struct x86_function
*p
, struct x86_reg dst
)
1050 if (dst
.file
== file_x87
)
1051 emit_2ub(p
, 0xd8, 0xd0 + dst
.idx
);
1054 emit_modrm_noreg(p
, 2, dst
);
1058 void x87_fcomp( struct x86_function
*p
, struct x86_reg dst
)
1060 if (dst
.file
== file_x87
)
1061 emit_2ub(p
, 0xd8, 0xd8 + dst
.idx
);
1064 emit_modrm_noreg(p
, 3, dst
);
1069 void x87_fnstsw( struct x86_function
*p
, struct x86_reg dst
)
1071 assert(dst
.file
== file_REG32
);
1073 if (dst
.idx
== reg_AX
&&
1075 emit_2ub(p
, 0xdf, 0xe0);
1078 emit_modrm_noreg(p
, 7, dst
);
1085 /***********************************************************************
1089 void mmx_emms( struct x86_function
*p
)
1091 assert(p
->need_emms
);
1092 emit_2ub(p
, 0x0f, 0x77);
1096 void mmx_packssdw( struct x86_function
*p
,
1098 struct x86_reg src
)
1100 assert(dst
.file
== file_MMX
&&
1101 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1105 emit_2ub(p
, X86_TWOB
, 0x6b);
1106 emit_modrm( p
, dst
, src
);
1109 void mmx_packuswb( struct x86_function
*p
,
1111 struct x86_reg src
)
1113 assert(dst
.file
== file_MMX
&&
1114 (src
.file
== file_MMX
|| src
.mod
!= mod_REG
));
1118 emit_2ub(p
, X86_TWOB
, 0x67);
1119 emit_modrm( p
, dst
, src
);
1122 void mmx_movd( struct x86_function
*p
,
1124 struct x86_reg src
)
1127 emit_1ub(p
, X86_TWOB
);
1128 emit_op_modrm( p
, 0x6e, 0x7e, dst
, src
);
1131 void mmx_movq( struct x86_function
*p
,
1133 struct x86_reg src
)
1136 emit_1ub(p
, X86_TWOB
);
1137 emit_op_modrm( p
, 0x6f, 0x7f, dst
, src
);
1141 /***********************************************************************
1146 /* Retreive a reference to one of the function arguments, taking into
1147 * account any push/pop activity:
1149 struct x86_reg
x86_fn_arg( struct x86_function
*p
,
1152 return x86_make_disp(x86_make_reg(file_REG32
, reg_SP
),
1153 p
->stack_offset
+ arg
* 4); /* ??? */
1157 void x86_init_func( struct x86_function
*p
)
1164 int x86_init_func_size( struct x86_function
*p
, unsigned code_size
)
1166 p
->size
= code_size
;
1167 p
->store
= _mesa_exec_malloc(code_size
);
1169 return p
->store
!= NULL
;
1172 void x86_release_func( struct x86_function
*p
)
1174 _mesa_exec_free(p
->store
);
1181 void (*x86_get_func( struct x86_function
*p
))(void)
1183 if (DISASSEM
&& p
->store
)
1184 _mesa_printf("disassemble %p %p\n", p
->store
, p
->csr
);
1185 return (void (*)(void)) (unsigned long) p
->store
;
1190 void x86sse_dummy( void )