00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _RTASM_X86SSE_H_
00025 #define _RTASM_X86SSE_H_
00026
00027 #include "pipe/p_config.h"
00028
00029 #if defined(PIPE_ARCH_X86)
00030
00031
00032
00033
00034
00035 struct x86_reg {
00036 unsigned file:3;
00037 unsigned idx:3;
00038 unsigned mod:2;
00039 int disp:24;
00040 };
00041
00042 struct x86_function {
00043 unsigned size;
00044 unsigned char *store;
00045 unsigned char *csr;
00046
00047 unsigned stack_offset:16;
00048 unsigned need_emms:8;
00049 int x87_stack:8;
00050
00051 unsigned char error_overflow[4];
00052 };
00053
00054 enum x86_reg_file {
00055 file_REG32,
00056 file_MMX,
00057 file_XMM,
00058 file_x87
00059 };
00060
00061
00062
00063 enum x86_reg_mod {
00064 mod_INDIRECT,
00065 mod_DISP8,
00066 mod_DISP32,
00067 mod_REG
00068 };
00069
00070 enum x86_reg_name {
00071 reg_AX,
00072 reg_CX,
00073 reg_DX,
00074 reg_BX,
00075 reg_SP,
00076 reg_BP,
00077 reg_SI,
00078 reg_DI
00079 };
00080
00081
00082 enum x86_cc {
00083 cc_O,
00084 cc_NO,
00085 cc_NAE,
00086 cc_AE,
00087 cc_E,
00088 cc_NE
00089 };
00090
00091 enum sse_cc {
00092 cc_Equal,
00093 cc_LessThan,
00094 cc_LessThanEqual,
00095 cc_Unordered,
00096 cc_NotEqual,
00097 cc_NotLessThan,
00098 cc_NotLessThanEqual,
00099 cc_Ordered
00100 };
00101
00102 #define cc_Z cc_E
00103 #define cc_NZ cc_NE
00104
00105
00106
00107
00108
00109 void x86_init_func( struct x86_function *p );
00110 void x86_init_func_size( struct x86_function *p, unsigned code_size );
00111 void x86_release_func( struct x86_function *p );
00112 void (*x86_get_func( struct x86_function *p ))( void );
00113
00114
00115
00116 void x86_print_reg( struct x86_reg reg );
00117
00118
00119
00120
00121 struct x86_reg x86_make_reg( enum x86_reg_file file,
00122 enum x86_reg_name idx );
00123
00124 struct x86_reg x86_make_disp( struct x86_reg reg,
00125 int disp );
00126
00127 struct x86_reg x86_deref( struct x86_reg reg );
00128
00129 struct x86_reg x86_get_base_reg( struct x86_reg reg );
00130
00131
00132
00133
00134 int x86_get_label( struct x86_function *p );
00135
00136 void x86_jcc( struct x86_function *p,
00137 enum x86_cc cc,
00138 int label );
00139
00140 int x86_jcc_forward( struct x86_function *p,
00141 enum x86_cc cc );
00142
00143 int x86_jmp_forward( struct x86_function *p);
00144
00145 int x86_call_forward( struct x86_function *p);
00146
00147 void x86_fixup_fwd_jump( struct x86_function *p,
00148 int fixup );
00149
00150 void x86_jmp( struct x86_function *p, int label );
00151
00152
00153 void x86_call( struct x86_function *p, struct x86_reg reg);
00154
00155
00156
00157
00158
00159 void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, int imm );
00160 void x86_add_reg_imm8( struct x86_function *p, struct x86_reg dst, ubyte imm );
00161
00162
00163
00164
00165 #define SHUF(_x,_y,_z,_w) (((_x)<<0) | ((_y)<<2) | ((_z)<<4) | ((_w)<<6))
00166 #define SHUF_NOOP RSW(0,1,2,3)
00167 #define GET_SHUF(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
00168
00169 void mmx_emms( struct x86_function *p );
00170 void mmx_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00171 void mmx_movq( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00172 void mmx_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00173 void mmx_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00174
00175 void sse2_cvtps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00176 void sse2_cvttps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00177 void sse2_cvtdq2ps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00178 void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00179 void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00180 void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00181 void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00182 void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0,
00183 unsigned char shuf );
00184 void sse2_rcpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00185 void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00186
00187
00188 void sse_prefetchnta( struct x86_function *p, struct x86_reg ptr);
00189 void sse_prefetch0( struct x86_function *p, struct x86_reg ptr);
00190 void sse_prefetch1( struct x86_function *p, struct x86_reg ptr);
00191
00192 void sse_movntps( struct x86_function *p, struct x86_reg dst, struct x86_reg src);
00193
00194 void sse_addps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00195 void sse_addss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00196 void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00197 void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00198 void sse_andnps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00199 void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00200 void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src,
00201 enum sse_cc cc );
00202 void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00203 void sse_maxss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00204 void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00205 void sse_movaps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00206 void sse_movhlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00207 void sse_movhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00208 void sse_movlhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00209 void sse_movlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00210 void sse_movss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00211 void sse_movups( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00212 void sse_mulps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00213 void sse_mulss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00214 void sse_orps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00215 void sse_xorps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00216 void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00217 void sse_rsqrtps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00218 void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00219 void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0,
00220 unsigned char shuf );
00221 void sse_unpckhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00222 void sse_unpcklps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00223 void sse_pmovmskb( struct x86_function *p, struct x86_reg dest, struct x86_reg src );
00224 void sse2_punpcklbw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00225
00226 void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00227 void x86_and( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00228 void x86_cmp( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00229 void x86_dec( struct x86_function *p, struct x86_reg reg );
00230 void x86_inc( struct x86_function *p, struct x86_reg reg );
00231 void x86_lea( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00232 void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00233 void x86_mul( struct x86_function *p, struct x86_reg src );
00234 void x86_imul( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00235 void x86_or( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00236 void x86_pop( struct x86_function *p, struct x86_reg reg );
00237 void x86_push( struct x86_function *p, struct x86_reg reg );
00238 void x86_push_imm32( struct x86_function *p, int imm );
00239 void x86_ret( struct x86_function *p );
00240 void x86_retw( struct x86_function *p, unsigned short imm );
00241 void x86_sub( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00242 void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00243 void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
00244 void x86_sahf( struct x86_function *p );
00245
00246
00247 void x86_cdecl_caller_push_regs( struct x86_function *p );
00248 void x86_cdecl_caller_pop_regs( struct x86_function *p );
00249
00250 void x87_assert_stack_empty( struct x86_function *p );
00251
00252 void x87_f2xm1( struct x86_function *p );
00253 void x87_fabs( struct x86_function *p );
00254 void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00255 void x87_faddp( struct x86_function *p, struct x86_reg dst );
00256 void x87_fchs( struct x86_function *p );
00257 void x87_fclex( struct x86_function *p );
00258 void x87_fcmovb( struct x86_function *p, struct x86_reg src );
00259 void x87_fcmovbe( struct x86_function *p, struct x86_reg src );
00260 void x87_fcmove( struct x86_function *p, struct x86_reg src );
00261 void x87_fcmovnb( struct x86_function *p, struct x86_reg src );
00262 void x87_fcmovnbe( struct x86_function *p, struct x86_reg src );
00263 void x87_fcmovne( struct x86_function *p, struct x86_reg src );
00264 void x87_fcom( struct x86_function *p, struct x86_reg dst );
00265 void x87_fcomi( struct x86_function *p, struct x86_reg dst );
00266 void x87_fcomip( struct x86_function *p, struct x86_reg dst );
00267 void x87_fcomp( struct x86_function *p, struct x86_reg dst );
00268 void x87_fcos( struct x86_function *p );
00269 void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00270 void x87_fdivp( struct x86_function *p, struct x86_reg dst );
00271 void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00272 void x87_fdivrp( struct x86_function *p, struct x86_reg dst );
00273 void x87_fild( struct x86_function *p, struct x86_reg arg );
00274 void x87_fist( struct x86_function *p, struct x86_reg dst );
00275 void x87_fistp( struct x86_function *p, struct x86_reg dst );
00276 void x87_fld( struct x86_function *p, struct x86_reg arg );
00277 void x87_fld1( struct x86_function *p );
00278 void x87_fldcw( struct x86_function *p, struct x86_reg arg );
00279 void x87_fldl2e( struct x86_function *p );
00280 void x87_fldln2( struct x86_function *p );
00281 void x87_fldz( struct x86_function *p );
00282 void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00283 void x87_fmulp( struct x86_function *p, struct x86_reg dst );
00284 void x87_fnclex( struct x86_function *p );
00285 void x87_fprndint( struct x86_function *p );
00286 void x87_fpop( struct x86_function *p );
00287 void x87_fscale( struct x86_function *p );
00288 void x87_fsin( struct x86_function *p );
00289 void x87_fsincos( struct x86_function *p );
00290 void x87_fsqrt( struct x86_function *p );
00291 void x87_fst( struct x86_function *p, struct x86_reg dst );
00292 void x87_fstp( struct x86_function *p, struct x86_reg dst );
00293 void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00294 void x87_fsubp( struct x86_function *p, struct x86_reg dst );
00295 void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
00296 void x87_fsubrp( struct x86_function *p, struct x86_reg dst );
00297 void x87_ftst( struct x86_function *p );
00298 void x87_fxch( struct x86_function *p, struct x86_reg dst );
00299 void x87_fxtract( struct x86_function *p );
00300 void x87_fyl2x( struct x86_function *p );
00301 void x87_fyl2xp1( struct x86_function *p );
00302 void x87_fwait( struct x86_function *p );
00303 void x87_fnstcw( struct x86_function *p, struct x86_reg dst );
00304 void x87_fnstsw( struct x86_function *p, struct x86_reg dst );
00305 void x87_fucompp( struct x86_function *p );
00306 void x87_fucomp( struct x86_function *p, struct x86_reg arg );
00307 void x87_fucom( struct x86_function *p, struct x86_reg arg );
00308
00309
00310
00311
00312
00313
00314
00315 struct x86_reg x86_fn_arg( struct x86_function *p, unsigned arg );
00316
00317 #endif
00318 #endif