cdrom: remove cdrWrite3 reschedule
[pcsx_rearmed.git] / libpcsxcore / ix86_64 / ix86-64.h
1 /*
2  * ix86 definitions v0.6.2
3  *  Authors: linuzappz <linuzappz@pcsx.net>
4  *           alexey silinov
5  *           goldfinger
6  *           shadow < shadow@pcsx2.net >
7  */
8
9 #ifndef __IX86_H__
10 #define __IX86_H__
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #include "../psxcommon.h"       // Basic types header
17 #include <assert.h>
18 #include <stdbool.h>
19
20 #if defined(__MINGW32__)
21 #define PCSX2_ALIGNED16(x) __declspec(align(16)) x
22 #else
23 #define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
24 #endif
25
26
27 #ifdef __x86_64__
28 #define XMMREGS 16
29 #define X86REGS 16
30 #else
31 #define XMMREGS 8
32 #define X86REGS 8
33 #endif
34
35 #define MMXREGS 8
36
37 #define SIB 4
38 #define DISP32 5
39
40 // general types
41 typedef int x86IntRegType;
42 #define EAX 0
43 #define EBX 3
44 #define ECX 1
45 #define EDX 2
46 #define ESI 6
47 #define EDI 7
48 #define EBP 5
49 #define ESP 4
50
51 #ifdef __x86_64__
52 #define RAX 0
53 #define RBX 3
54 #define RCX 1
55 #define RDX 2
56 #define RSI 6
57 #define RDI 7
58 #define RBP 5
59 #define RSP 4
60 #define R8  8 
61 #define R9  9 
62 #define R10 10
63 #define R11 11
64 #define R12 12
65 #define R13 13
66 #define R14 14
67 #define R15 15
68
69 #define X86_TEMP RAX // don't allocate anything
70
71 #ifdef _MSC_VER
72 extern x86IntRegType g_x86savedregs[8];
73 extern x86IntRegType g_x86tempregs[6];
74 #else
75 extern x86IntRegType g_x86savedregs[6];
76 extern x86IntRegType g_x86tempregs[8];
77 #endif
78
79 extern x86IntRegType g_x86allregs[14]; // all registers that can be used by the recs
80 extern x86IntRegType g_x868bitregs[11];
81 extern x86IntRegType g_x86non8bitregs[3];
82
83 #ifdef _MSC_VER
84 #define X86ARG1 RCX
85 #define X86ARG2 RDX
86 #define X86ARG3 R8
87 #define X86ARG4 R9
88 #else
89 #define X86ARG1 RDI
90 #define X86ARG2 RSI
91 #define X86ARG3 RDX
92 #define X86ARG4 RCX
93 #endif
94
95 #else
96
97 #define X86ARG1 EAX
98 #define X86ARG2 ECX
99 #define X86ARG3 EDX
100 #define X86ARG4 EBX
101
102 #endif // __x86_64__
103
104 #define MM0 0
105 #define MM1 1
106 #define MM2 2
107 #define MM3 3
108 #define MM4 4
109 #define MM5 5
110 #define MM6 6
111 #define MM7 7
112
113 typedef int x86MMXRegType;
114
115 #define XMM0 0 
116 #define XMM1 1 
117 #define XMM2 2 
118 #define XMM3 3 
119 #define XMM4 4 
120 #define XMM5 5 
121 #define XMM6 6 
122 #define XMM7 7 
123 #define XMM8 8 
124 #define XMM9 9 
125 #define XMM10 10 
126 #define XMM11 11 
127 #define XMM12 12 
128 #define XMM13 13 
129 #define XMM14 14 
130 #define XMM15 15
131
132 typedef int x86SSERegType;
133
134 typedef enum
135 {
136         XMMT_INT = 0, // integer (sse2 only)
137         XMMT_FPS = 1, // floating point
138         //XMMT_FPD = 3, // double
139 } XMMSSEType;
140
141 extern XMMSSEType g_xmmtypes[XMMREGS];
142
143 void cpudetectInit( void );//this is all that needs to be called and will fill up the below structs
144
145 //cpu capabilities structure
146 typedef struct {
147    u32 hasFloatingPointUnit;
148    u32 hasVirtual8086ModeEnhancements;
149    u32 hasDebuggingExtensions;
150    u32 hasPageSizeExtensions;
151    u32 hasTimeStampCounter;
152    u32 hasModelSpecificRegisters;
153    u32 hasPhysicalAddressExtension;
154    u32 hasCOMPXCHG8BInstruction;
155    u32 hasAdvancedProgrammableInterruptController;
156    u32 hasSEPFastSystemCall;
157    u32 hasMemoryTypeRangeRegisters;
158    u32 hasPTEGlobalFlag;
159    u32 hasMachineCheckArchitecture;
160    u32 hasConditionalMoveAndCompareInstructions;
161    u32 hasFGPageAttributeTable;
162    u32 has36bitPageSizeExtension;
163    u32 hasProcessorSerialNumber;
164    u32 hasCFLUSHInstruction;
165    u32 hasDebugStore;
166    u32 hasACPIThermalMonitorAndClockControl;
167    u32 hasMultimediaExtensions;
168    u32 hasFastStreamingSIMDExtensionsSaveRestore;
169    u32 hasStreamingSIMDExtensions;
170    u32 hasStreamingSIMD2Extensions;
171    u32 hasSelfSnoop;
172    u32 hasHyperThreading;
173    u32 hasThermalMonitor;
174    u32 hasIntel64BitArchitecture;
175    u32 hasStreamingSIMD3Extensions;
176    //that is only for AMDs
177    u32 hasMultimediaExtensionsExt;
178    u32 hasAMD64BitArchitecture;
179    u32 has3DNOWInstructionExtensionsExt;
180    u32 has3DNOWInstructionExtensions;
181 } CAPABILITIES;
182
183 extern CAPABILITIES cpucaps;
184
185 typedef struct {
186    
187    u32 x86Family;          // Processor Family
188    u32 x86Model;           // Processor Model
189    u32 x86PType;           // Processor Type
190    u32 x86StepID;          // Stepping ID
191    u32 x86Flags;           // Feature Flags
192    u32 x86EFlags;          // Extended Feature Flags
193    //all the above returns hex values
194    s8  x86ID[16];          // Vendor ID  //the vendor creator (in %s)
195    s8  x86Type[20];   //cpu type in char format //the cpu type (in %s)
196    s8  x86Fam[50];    // family in char format //the original cpu name string (in %s)
197    u32 cpuspeed;      // speed of cpu //this will give cpu speed (in %d)
198 } CPUINFO;
199
200 extern CPUINFO cpuinfo;
201
202 extern s8  *x86Ptr;
203 extern u8  *j8Ptr[32];
204 extern u32 *j32Ptr[32];
205
206
207 #ifdef __x86_64__
208 #define X86_64ASSERT() assert(0)
209 #define MEMADDR_(addr, oplen)   (sptr)((uptr)(addr) - ((uptr)x86Ptr + ((u64)(oplen))))
210 #define SPTR32(addr)            ((addr) < 0x80000000L && (addr) >= -0x80000000L)
211 #define UPTR32(addr)            ((addr) < 0x100000000L)
212 #define MEMADDR(addr, oplen)    ({ sptr _a = MEMADDR_(addr, oplen); assert(SPTR32(_a)); _a; })
213 #else
214 #define X86_64ASSERT()
215 #define SPTR32(a) 1
216 #define UPTR32(a) 1
217 #define MEMADDR(addr, oplen)    (addr)
218 #endif
219
220 #ifdef __x86_64__
221 #define Rex( w, r, x, b ) write8( 0x40 | ((w) << 3) | ((r) << 2) | ((x) << 1) | (b) )
222 #else
223 #define Rex(w,r,x,b) assert(0)
224 #endif
225 #define RexRXB(w, reg, index, base) if(w || (reg) >= 8 || (index) >= 8 || (base) >= 8 ) \
226         Rex(w, (reg)>=8, (index)>=8, (base)>=8)
227 #define RexR(w, reg) RexRXB(w, reg, 0, 0)
228 #define RexB(w, base) RexRXB(w, 0, 0, base)
229 #define RexRB(w, reg, base) RexRXB(w, reg, 0, base)
230
231 void x86SetPtr( char *ptr );
232 void x86Shutdown( void );
233
234 void x86SetJ8( u8 *j8 );
235 void x86SetJ8A( u8 *j8 );
236 void x86SetJ16( u16 *j16 );
237 void x86SetJ16A( u16 *j16 );
238 void x86SetJ32( u32 *j32 );
239 void x86SetJ32A( u32 *j32 );
240
241 void x86Align( int bytes );
242 u64 GetCPUTick( void );
243
244 // General Helper functions
245 #define ModRM(mod, rm, reg) write8( ( mod << 6 ) | ( (rm & 7) << 3 ) | ( reg & 7 ) )
246 #define SibSB(ss, rm, index) write8( ( ss << 6 ) | ( rm << 3 ) | ( index ) )
247 void SET8R( int cc, int to );
248 u8* J8Rel( int cc, int to );
249 u32* J32Rel( int cc, u32 to );
250 void CMOV32RtoR( int cc, int to, int from );
251 void CMOV32MtoR( int cc, int to, uptr from );
252
253 void MEMADDR_OP(bool w, unsigned opl, u64 op, bool isreg, int reg, uptr p, sptr off);
254
255 #define VAROP1(op) 1, op
256 #define VAROP2(op1, op2) 2, (op1) | ((op2) << 8)
257
258 //******************
259 // IX86 intructions 
260 //******************
261
262 //
263 // * scale values:
264 // *  0 - *1
265 // *  1 - *2
266 // *  2 - *4
267 // *  3 - *8
268 // 
269
270 void STC( void );
271 void CLC( void );
272
273 ////////////////////////////////////
274 // mov instructions               //
275 ////////////////////////////////////
276
277 // mov r64 to r64 
278 void MOV64RtoR( x86IntRegType to, x86IntRegType from );
279 // mov r64 to m64 
280 void MOV64RtoM( uptr to, x86IntRegType from );
281 // mov m64 to r64 
282 void MOV64MtoR( x86IntRegType to, uptr from );
283 // mov sign ext imm32 to m64 
284 void MOV64I32toM( uptr to, u32 from );
285 // mov sign ext imm32 to r64
286 void MOV64I32toR( x86IntRegType to, s32 from);
287 // mov imm64 to r64
288 void MOV64ItoR( x86IntRegType to, u64 from);
289 // mov imm64 to [r64+off]
290 void MOV64ItoRmOffset( x86IntRegType to, u32 from, int offset);
291 // mov [r64+offset] to r64
292 void MOV64RmOffsettoR( x86IntRegType to, x86IntRegType from, int offset );
293 // mov [r64][r64*scale] to r64
294 void MOV64RmStoR( x86IntRegType to, x86IntRegType from, x86IntRegType from2, int scale);
295 // mov r64 to [r64+offset]
296 void MOV64RtoRmOffset( x86IntRegType to, x86IntRegType from, int offset );
297 // mov r64 to [r64][r64*scale]
298 void MOV64RtoRmS( x86IntRegType to, x86IntRegType from, x86IntRegType from2, int scale);
299
300 // mov r32 to r32 
301 void MOV32RtoR( x86IntRegType to, x86IntRegType from );
302 // mov r32 to m32 
303 void MOV32RtoM( uptr to, x86IntRegType from );
304 // mov m32 to r32 
305 void MOV32MtoR( x86IntRegType to, uptr from );
306 // mov [r32] to r32 
307 void MOV32RmtoR( x86IntRegType to, x86IntRegType from );
308 void MOV32RmtoROffset( x86IntRegType to, x86IntRegType from, int offset );
309 // mov [r32][r32<<scale] to r32 
310 void MOV32RmStoR( x86IntRegType to, x86IntRegType from, x86IntRegType from2, int scale );
311 // mov [imm32(from2) + r32(from1)<<scale] to r32 
312 void MOV32RmSOffsettoR( x86IntRegType to, x86IntRegType from1, int from2, int scale );
313 // mov r32 to [r32] 
314 void MOV32RtoRm( x86IntRegType to, x86IntRegType from );
315 // mov r32 to [r32][r32*scale]
316 void MOV32RtoRmS( x86IntRegType to, x86IntRegType from, x86IntRegType from2, int scale );
317 // mov imm32 to r32 
318 void MOV32ItoR( x86IntRegType to, u32 from );
319 // mov imm32 to m32 
320 void MOV32ItoM( uptr to, u32 from );
321 // mov imm32 to [r32+off]
322 void MOV32ItoRmOffset( x86IntRegType to, u32 from, int offset);
323 // mov r32 to [r32+off]
324 void MOV32RtoRmOffset( x86IntRegType to, x86IntRegType from, int offset);
325
326 // mov r16 to m16 
327 void MOV16RtoM( uptr to, x86IntRegType from );
328 // mov m16 to r16 
329 void MOV16MtoR( x86IntRegType to, uptr from );
330 // mov [r32] to r16
331 void MOV16RmtoR( x86IntRegType to, x86IntRegType from ) ;
332 void MOV16RmtoROffset( x86IntRegType to, x86IntRegType from, int offset );
333 // mov [imm32(from2) + r32(from1)<<scale] to r16 
334 void MOV16RmSOffsettoR( x86IntRegType to, x86IntRegType from1, u32 from2, int scale );
335 // mov r16 to [r32]
336 void MOV16RtoRm(x86IntRegType to, x86IntRegType from);
337 // mov imm16 to m16 
338 void MOV16ItoM( uptr to, u16 from );
339 /* mov r16 to [r32][r32*scale] */
340 void MOV16RtoRmS( x86IntRegType to, x86IntRegType from, x86IntRegType from2, int scale);
341 // mov imm16 to r16
342 void MOV16ItoR( x86IntRegType to, u16 from );
343 // mov imm16 to [r16+off]
344 void MOV16ItoRmOffset( x86IntRegType to, u16 from, u32 offset);
345 // mov r16 to [r16+off]
346 void MOV16RtoRmOffset( x86IntRegType to, x86IntRegType from, int offset);
347
348 // mov r8 to m8 
349 void MOV8RtoM( uptr to, x86IntRegType from );
350 // mov m8 to r8 
351 void MOV8MtoR( x86IntRegType to, uptr from );
352 // mov [r32] to r8
353 void MOV8RmtoR(x86IntRegType to, x86IntRegType from);
354 void MOV8RmtoROffset(x86IntRegType to, x86IntRegType from, int offset);
355 // mov r8 to [r32]
356 void MOV8RtoRm(x86IntRegType to, x86IntRegType from);
357 // mov imm8 to m8 
358 void MOV8ItoM( uptr to, u8 from );
359 // mov imm8 to r8
360 void MOV8ItoR( x86IntRegType to, u8 from );
361 // mov imm8 to [r8+off]
362 void MOV8ItoRmOffset( x86IntRegType to, u8 from, int offset);
363 // mov r8 to [r8+off]
364 void MOV8RtoRmOffset( x86IntRegType to, x86IntRegType from, int offset);
365
366 // movsx r8 to r32 
367 void MOVSX32R8toR( x86IntRegType to, x86IntRegType from );
368 void MOVSX32Rm8toR( x86IntRegType to, x86IntRegType from );
369 void MOVSX32Rm8toROffset( x86IntRegType to, x86IntRegType from, int offset );
370 // movsx m8 to r32 
371 void MOVSX32M8toR( x86IntRegType to, uptr from );
372 // movsx r16 to r32 
373 void MOVSX32R16toR( x86IntRegType to, x86IntRegType from );
374 void MOVSX32Rm16toR( x86IntRegType to, x86IntRegType from );
375 void MOVSX32Rm16toROffset( x86IntRegType to, x86IntRegType from, int offset );
376 // movsx m16 to r32 
377 void MOVSX32M16toR( x86IntRegType to, uptr from );
378
379 // movzx r8 to r32 
380 void MOVZX32R8toR( x86IntRegType to, x86IntRegType from );
381 void MOVZX32Rm8toR( x86IntRegType to, x86IntRegType from );
382 void MOVZX32Rm8toROffset( x86IntRegType to, x86IntRegType from, int offset );
383 // movzx m8 to r32 
384 void MOVZX32M8toR( x86IntRegType to, uptr from );
385 // movzx r16 to r32 
386 void MOVZX32R16toR( x86IntRegType to, x86IntRegType from );
387 void MOVZX32Rm16toR( x86IntRegType to, x86IntRegType from );
388 void MOVZX32Rm16toROffset( x86IntRegType to, x86IntRegType from, int offset );
389 // movzx m16 to r32 
390 void MOVZX32M16toR( x86IntRegType to, uptr from );
391
392 #ifdef __x86_64__
393 void MOVZX64R8toR( x86IntRegType to, x86IntRegType from );
394 void MOVZX64Rm8toR( x86IntRegType to, x86IntRegType from );
395 void MOVZX64Rm8toROffset( x86IntRegType to, x86IntRegType from, int offset );
396 // movzx m8 to r64
397 void MOVZX64M8toR( x86IntRegType to, uptr from );
398 // movzx r16 to r64 
399 void MOVZX64R16toR( x86IntRegType to, x86IntRegType from );
400 void MOVZX64Rm16toR( x86IntRegType to, x86IntRegType from );
401 void MOVZX64Rm16toROffset( x86IntRegType to, x86IntRegType from, int offset );
402 // movzx m16 to r64
403 void MOVZX64M16toR( x86IntRegType to, uptr from );
404 #endif
405
406 // cmovbe r32 to r32 
407 void CMOVBE32RtoR( x86IntRegType to, x86IntRegType from );
408 // cmovbe m32 to r32
409 void CMOVBE32MtoR( x86IntRegType to, uptr from );
410 // cmovb r32 to r32 
411 void CMOVB32RtoR( x86IntRegType to, x86IntRegType from );
412 // cmovb m32 to r32
413 void CMOVB32MtoR( x86IntRegType to, uptr from );
414 // cmovae r32 to r32 
415 void CMOVAE32RtoR( x86IntRegType to, x86IntRegType from );
416 // cmovae m32 to r32
417 void CMOVAE32MtoR( x86IntRegType to, uptr from );
418 // cmova r32 to r32 
419 void CMOVA32RtoR( x86IntRegType to, x86IntRegType from );
420 // cmova m32 to r32
421 void CMOVA32MtoR( x86IntRegType to, uptr from );
422
423 // cmovo r32 to r32 
424 void CMOVO32RtoR( x86IntRegType to, x86IntRegType from );
425 // cmovo m32 to r32
426 void CMOVO32MtoR( x86IntRegType to, uptr from );
427 // cmovp r32 to r32 
428 void CMOVP32RtoR( x86IntRegType to, x86IntRegType from );
429 // cmovp m32 to r32
430 void CMOVP32MtoR( x86IntRegType to, uptr from );
431 // cmovs r32 to r32 
432 void CMOVS32RtoR( x86IntRegType to, x86IntRegType from );
433 // cmovs m32 to r32
434 void CMOVS32MtoR( x86IntRegType to, uptr from );
435 // cmovno r32 to r32 
436 void CMOVNO32RtoR( x86IntRegType to, x86IntRegType from );
437 // cmovno m32 to r32
438 void CMOVNO32MtoR( x86IntRegType to, uptr from );
439 // cmovnp r32 to r32 
440 void CMOVNP32RtoR( x86IntRegType to, x86IntRegType from );
441 // cmovnp m32 to r32
442 void CMOVNP32MtoR( x86IntRegType to, uptr from );
443 // cmovns r32 to r32 
444 void CMOVNS32RtoR( x86IntRegType to, x86IntRegType from );
445 // cmovns m32 to r32
446 void CMOVNS32MtoR( x86IntRegType to, uptr from );
447
448 // cmovne r32 to r32 
449 void CMOVNE32RtoR( x86IntRegType to, x86IntRegType from );
450 // cmovne m32 to r32
451 void CMOVNE32MtoR( x86IntRegType to, uptr from );
452 // cmove r32 to r32
453 void CMOVE32RtoR( x86IntRegType to, x86IntRegType from );
454 // cmove m32 to r32
455 void CMOVE32MtoR( x86IntRegType to, uptr from );
456 // cmovg r32 to r32
457 void CMOVG32RtoR( x86IntRegType to, x86IntRegType from );
458 // cmovg m32 to r32
459 void CMOVG32MtoR( x86IntRegType to, uptr from );
460 // cmovge r32 to r32
461 void CMOVGE32RtoR( x86IntRegType to, x86IntRegType from );
462 // cmovge m32 to r32
463 void CMOVGE32MtoR( x86IntRegType to, uptr from );
464 // cmovl r32 to r32
465 void CMOVL32RtoR( x86IntRegType to, x86IntRegType from );
466 // cmovl m32 to r32
467 void CMOVL32MtoR( x86IntRegType to, uptr from );
468 // cmovle r32 to r32
469 void CMOVLE32RtoR( x86IntRegType to, x86IntRegType from );
470 // cmovle m32 to r32
471 void CMOVLE32MtoR( x86IntRegType to, uptr from );
472
473 ////////////////////////////////////
474 // arithmetic instructions        //
475 ////////////////////////////////////
476
477 // add imm32 to r64 
478 void ADD64ItoR( x86IntRegType to, u32 from );
479 // add m64 to r64 
480 void ADD64MtoR( x86IntRegType to, uptr from );
481
482 // add imm32 to r32 
483 void ADD32ItoR( x86IntRegType to, u32 from );
484 // add imm32 to m32 
485 void ADD32ItoM( uptr to, u32 from );
486 // add imm32 to [r32+off]
487 void ADD32ItoRmOffset( x86IntRegType to, u32 from, int offset);
488 // add r32 to r32 
489 void ADD32RtoR( x86IntRegType to, x86IntRegType from );
490 // add r32 to m32 
491 void ADD32RtoM( uptr to, x86IntRegType from );
492 // add m32 to r32 
493 void ADD32MtoR( x86IntRegType to, uptr from );
494
495 // add r16 to r16 
496 void ADD16RtoR( x86IntRegType to , x86IntRegType from );
497 // add imm16 to r16 
498 void ADD16ItoR( x86IntRegType to, u16 from );
499 // add imm16 to m16 
500 void ADD16ItoM( uptr to, u16 from );
501 // add r16 to m16 
502 void ADD16RtoM( uptr to, x86IntRegType from );
503 // add m16 to r16 
504 void ADD16MtoR( x86IntRegType to, uptr from );
505
506 // add m8 to r8
507 void ADD8MtoR( x86IntRegType to, uptr from );
508
509 // adc imm32 to r32 
510 void ADC32ItoR( x86IntRegType to, u32 from );
511 // adc imm32 to m32 
512 void ADC32ItoM( uptr to, u32 from );
513 // adc r32 to r32 
514 void ADC32RtoR( x86IntRegType to, x86IntRegType from );
515 // adc m32 to r32 
516 void ADC32MtoR( x86IntRegType to, uptr from );
517 // adc r32 to m32 
518 void ADC32RtoM( uptr to, x86IntRegType from );
519
520 // inc r32 
521 void INC32R( x86IntRegType to );
522 // inc m32 
523 void INC32M( uptr to );
524 // inc r16 
525 void INC16R( x86IntRegType to );
526 // inc m16 
527 void INC16M( uptr to );
528
529 // sub m64 to r64 
530 void SUB64MtoR( x86IntRegType to, uptr from );
531 void SUB64ItoR( x86IntRegType to, u32 from );
532
533 // sub imm32 to r32 
534 void SUB32ItoR( x86IntRegType to, u32 from );
535 // sub imm32 to m32
536 void SUB32ItoM( uptr to, u32 from ) ;
537 // sub r32 to r32 
538 void SUB32RtoR( x86IntRegType to, x86IntRegType from );
539 // sub m32 to r32 
540 void SUB32MtoR( x86IntRegType to, uptr from ) ;
541 // sub r32 to m32 
542 void SUB32RtoM( uptr to, x86IntRegType from );
543 // sub r16 to r16 
544 void SUB16RtoR( x86IntRegType to, u16 from );
545 // sub imm16 to r16 
546 void SUB16ItoR( x86IntRegType to, u16 from );
547 // sub imm16 to m16
548 void SUB16ItoM( uptr to, u16 from ) ;
549 // sub m16 to r16 
550 void SUB16MtoR( x86IntRegType to, uptr from );
551
552 // sbb r64 to r64 
553 void SBB64RtoR( x86IntRegType to, x86IntRegType from );
554
555 // sbb imm32 to r32 
556 void SBB32ItoR( x86IntRegType to, u32 from );
557 // sbb imm32 to m32 
558 void SBB32ItoM( uptr to, u32 from );
559 // sbb r32 to r32 
560 void SBB32RtoR( x86IntRegType to, x86IntRegType from );
561 // sbb m32 to r32 
562 void SBB32MtoR( x86IntRegType to, uptr from );
563 // sbb r32 to m32 
564 void SBB32RtoM( uptr to, x86IntRegType from );
565
566 // dec r32 
567 void DEC32R( x86IntRegType to );
568 // dec m32 
569 void DEC32M( uptr to );
570 // dec r16 
571 void DEC16R( x86IntRegType to );
572 // dec m16 
573 void DEC16M( uptr to );
574
575 // mul eax by r32 to edx:eax 
576 void MUL32R( x86IntRegType from );
577 // mul eax by m32 to edx:eax 
578 void MUL32M( uptr from );
579
580 // imul eax by r32 to edx:eax 
581 void IMUL32R( x86IntRegType from );
582 // imul eax by m32 to edx:eax 
583 void IMUL32M( uptr from );
584 // imul r32 by r32 to r32 
585 void IMUL32RtoR( x86IntRegType to, x86IntRegType from );
586
587 // div eax by r32 to edx:eax 
588 void DIV32R( x86IntRegType from );
589 // div eax by m32 to edx:eax 
590 void DIV32M( uptr from );
591
592 // idiv eax by r32 to edx:eax 
593 void IDIV32R( x86IntRegType from );
594 // idiv eax by m32 to edx:eax 
595 void IDIV32M( uptr from );
596
597 ////////////////////////////////////
598 // shifting instructions          //
599 ////////////////////////////////////
600
601 // shl imm8 to r64 
602 void SHL64ItoR( x86IntRegType to, u8 from );
603 // shl cl to r64
604 void SHL64CLtoR( x86IntRegType to );
605 // shr imm8 to r64 
606 void SHR64ItoR( x86IntRegType to, u8 from );
607 // shr cl to r64
608 void SHR64CLtoR( x86IntRegType to );
609 // sar imm8 to r64 
610 void SAR64ItoR( x86IntRegType to, u8 from );
611 // sar cl to r64
612 void SAR64CLtoR( x86IntRegType to );
613
614 // shl imm8 to r32 
615 void SHL32ItoR( x86IntRegType to, u8 from );
616 /* shl imm8 to m32 */
617 void SHL32ItoM( uptr to, u8 from );
618 // shl cl to r32 
619 void SHL32CLtoR( x86IntRegType to );
620
621 // shl imm8 to r16
622 void SHL16ItoR( x86IntRegType to, u8 from );
623 // shl imm8 to r8
624 void SHL8ItoR( x86IntRegType to, u8 from );
625
626 // shr imm8 to r32 
627 void SHR32ItoR( x86IntRegType to, u8 from );
628 /* shr imm8 to m32 */
629 void SHR32ItoM( uptr to, u8 from );
630 // shr cl to r32 
631 void SHR32CLtoR( x86IntRegType to );
632
633 // shr imm8 to r8
634 void SHR8ItoR( x86IntRegType to, u8 from );
635
636 // sar imm8 to r32 
637 void SAR32ItoR( x86IntRegType to, u8 from );
638 // sar imm8 to m32 
639 void SAR32ItoM( uptr to, u8 from );
640 // sar cl to r32 
641 void SAR32CLtoR( x86IntRegType to );
642
643 // sar imm8 to r16
644 void SAR16ItoR( x86IntRegType to, u8 from );
645
646 // ror imm8 to r32 (rotate right)
647 void ROR32ItoR( x86IntRegType to,u8 from );
648
649 void RCR32ItoR( x86IntRegType to,u8 from );
650 // shld imm8 to r32
651 void SHLD32ItoR( x86IntRegType to, x86IntRegType from, u8 shift );
652 // shrd imm8 to r32
653 void SHRD32ItoR( x86IntRegType to, x86IntRegType from, u8 shift );
654
655 // sal imm8 to r32 
656 #define SAL32ItoR SHL32ItoR
657 // sal cl to r32 
658 #define SAL32CLtoR SHL32CLtoR
659
660 // logical instructions
661
662 // or imm32 to r64 
663 void OR64ItoR( x86IntRegType to, u32 from );
664 // or m64 to r64 
665 void OR64MtoR( x86IntRegType to, uptr from );
666 // or r64 to r64
667 void OR64RtoR( x86IntRegType to, x86IntRegType from );
668 // or r32 to m64
669 void OR64RtoM( uptr to, x86IntRegType from );
670
671 // or imm32 to r32 
672 void OR32ItoR( x86IntRegType to, u32 from );
673 // or imm32 to m32 
674 void OR32ItoM( uptr to, u32 from );
675 // or r32 to r32 
676 void OR32RtoR( x86IntRegType to, x86IntRegType from );
677 // or r32 to m32 
678 void OR32RtoM( uptr to, x86IntRegType from );
679 // or m32 to r32 
680 void OR32MtoR( x86IntRegType to, uptr from );
681 // or r16 to r16
682 void OR16RtoR( x86IntRegType to, x86IntRegType from );
683 // or imm16 to r16
684 void OR16ItoR( x86IntRegType to, u16 from );
685 // or imm16 to m16
686 void OR16ItoM( uptr to, u16 from );
687 // or m16 to r16 
688 void OR16MtoR( x86IntRegType to, uptr from );
689 // or r16 to m16 
690 void OR16RtoM( uptr to, x86IntRegType from );
691
692 // or r8 to r8
693 void OR8RtoR( x86IntRegType to, x86IntRegType from );
694 // or r8 to m8
695 void OR8RtoM( uptr to, x86IntRegType from );
696 // or imm8 to m8
697 void OR8ItoM( uptr to, u8 from );
698 // or m8 to r8
699 void OR8MtoR( x86IntRegType to, uptr from );
700
701 // xor imm32 to r64 
702 void XOR64ItoR( x86IntRegType to, u32 from );
703 // xor r64 to r64 
704 void XOR64RtoR( x86IntRegType to, x86IntRegType from );
705 // xor m64 to r64
706 void XOR64MtoR( x86IntRegType to, uptr from );
707 // xor r64 to r64
708 void XOR64RtoR( x86IntRegType to, x86IntRegType from );
709 // xor r64 to m64
710 void XOR64RtoM( uptr to, x86IntRegType from );
711 // xor imm32 to r32 
712 void XOR32ItoR( x86IntRegType to, u32 from );
713 // xor imm32 to m32 
714 void XOR32ItoM( uptr to, u32 from );
715 // xor r32 to r32 
716 void XOR32RtoR( x86IntRegType to, x86IntRegType from );
717 // xor r16 to r16 
718 void XOR16RtoR( x86IntRegType to, x86IntRegType from );
719 // xor r32 to m32 
720 void XOR32RtoM( uptr to, x86IntRegType from );
721 // xor m32 to r32 
722 void XOR32MtoR( x86IntRegType to, uptr from );
723 // xor r16 to m16
724 void XOR16RtoM( uptr to, x86IntRegType from );
725 // xor imm16 to r16
726 void XOR16ItoR( x86IntRegType to, u16 from );
727
728 // and imm32 to r64 
729 void AND64I32toR( x86IntRegType to, u32 from );
730 // and m64 to r64
731 void AND64MtoR( x86IntRegType to, uptr from );
732 // and r64 to m64
733 void AND64RtoM( uptr to, x86IntRegType from );
734 // and r64 to r64
735 void AND64RtoR( x86IntRegType to, x86IntRegType from );
736 // and imm32 to m64
737 void AND64I32toM( uptr to, u32 from );
738
739 // and imm32 to r32 
740 void AND32ItoR( x86IntRegType to, u32 from );
741 // and sign ext imm8 to r32 
742 void AND32I8toR( x86IntRegType to, u8 from );
743 // and imm32 to m32 
744 void AND32ItoM( uptr to, u32 from );
745 // and sign ext imm8 to m32 
746 void AND32I8toM( uptr to, u8 from );
747 // and r32 to r32 
748 void AND32RtoR( x86IntRegType to, x86IntRegType from );
749 // and r32 to m32 
750 void AND32RtoM( uptr to, x86IntRegType from );
751 // and m32 to r32 
752 void AND32MtoR( x86IntRegType to, uptr from );
753 // and r16 to r16
754 void AND16RtoR( x86IntRegType to, x86IntRegType from );
755 // and imm16 to r16 
756 void AND16ItoR( x86IntRegType to, u16 from );
757 // and imm16 to m16
758 void AND16ItoM( uptr to, u16 from );
759 // and r16 to m16
760 void AND16RtoM( uptr to, x86IntRegType from );
761 // and m16 to r16 
762 void AND16MtoR( x86IntRegType to, uptr from );
763 // and imm8 to r8 
764 void AND8ItoR( x86IntRegType to, u8 from );
765 // and imm8 to m32
766 void AND8ItoM( uptr to, u8 from );
767 // and r8 to m8
768 void AND8RtoM( uptr to, x86IntRegType from );
769 // and m8 to r8 
770 void AND8MtoR( x86IntRegType to, uptr from );
771 // and r8 to r8
772 void AND8RtoR( x86IntRegType to, x86IntRegType from );
773
774 // not r64 
775 void NOT64R( x86IntRegType from );
776 // not r32 
777 void NOT32R( x86IntRegType from );
778 // not m32 
779 void NOT32M( uptr from );
780 // neg r64 
781 void NEG64R( x86IntRegType from );
782 // neg r32 
783 void NEG32R( x86IntRegType from );
784 // neg m32 
785 void NEG32M( uptr from );
786 // neg r16 
787 void NEG16R( x86IntRegType from );
788
789 ////////////////////////////////////
790 // jump instructions              //
791 ////////////////////////////////////
792
793 // jmp rel8 
794 u8*  JMP8( u8 to );
795
796 // jmp rel32 
797 u32* JMP32( uptr to );
798 // jmp r32 (r64 if __x86_64__)
799 void JMPR( x86IntRegType to );
800 // jmp m32 
801 void JMP32M( uptr to );
802
803 // jp rel8 
804 u8*  JP8( u8 to );
805 // jnp rel8 
806 u8*  JNP8( u8 to );
807 // je rel8 
808 u8*  JE8( u8 to );
809 // jz rel8 
810 u8*  JZ8( u8 to );
811 // jg rel8 
812 u8*  JG8( u8 to );
813 // jge rel8 
814 u8*  JGE8( u8 to );
815 // js rel8 
816 u8*  JS8( u8 to );
817 // jns rel8 
818 u8*  JNS8( u8 to );
819 // jl rel8 
820 u8*  JL8( u8 to );
821 // ja rel8 
822 u8*  JA8( u8 to );
823 // jae rel8 
824 u8*  JAE8( u8 to );
825 // jb rel8 
826 u8*  JB8( u8 to );
827 // jbe rel8 
828 u8*  JBE8( u8 to );
829 // jle rel8 
830 u8*  JLE8( u8 to );
831 // jne rel8 
832 u8*  JNE8( u8 to );
833 // jnz rel8 
834 u8*  JNZ8( u8 to );
835 // jng rel8 
836 u8*  JNG8( u8 to );
837 // jnge rel8 
838 u8*  JNGE8( u8 to );
839 // jnl rel8 
840 u8*  JNL8( u8 to );
841 // jnle rel8 
842 u8*  JNLE8( u8 to );
843 // jo rel8 
844 u8*  JO8( u8 to );
845 // jno rel8 
846 u8*  JNO8( u8 to );
847
848 // jb rel8 
849 u16*  JB16( u16 to );
850
851 // jb rel32 
852 u32* JB32( u32 to );
853 // je rel32 
854 u32* JE32( u32 to );
855 // jz rel32 
856 u32* JZ32( u32 to );
857 // jg rel32 
858 u32* JG32( u32 to );
859 // jge rel32 
860 u32* JGE32( u32 to );
861 // jl rel32 
862 u32* JL32( u32 to );
863 // jle rel32 
864 u32* JLE32( u32 to );
865 // jae rel32 
866 u32* JAE32( u32 to );
867 // jne rel32 
868 u32* JNE32( u32 to );
869 // jnz rel32 
870 u32* JNZ32( u32 to );
871 // jng rel32 
872 u32* JNG32( u32 to );
873 // jnge rel32 
874 u32* JNGE32( u32 to );
875 // jnl rel32 
876 u32* JNL32( u32 to );
877 // jnle rel32 
878 u32* JNLE32( u32 to );
879 // jo rel32 
880 u32* JO32( u32 to );
881 // jno rel32 
882 u32* JNO32( u32 to );
883 // js rel32
884 u32*  JS32( u32 to );
885
886 // call func 
887 void CALLFunc( uptr func);
888 // call rel32 
889 void CALL32( s32 to );
890 // call r32 
891 void CALL32R( x86IntRegType to );
892 // call m32 
893 void CALL64R( x86IntRegType to );
894
895
896 ////////////////////////////////////
897 // misc instructions              //
898 ////////////////////////////////////
899
900 // cmp imm32 to r64 
901 void CMP64I32toR( x86IntRegType to, u32 from );
902 // cmp m64 to r64 
903 void CMP64MtoR( x86IntRegType to, uptr from );
904 // cmp r64 to r64 
905 void CMP64RtoR( x86IntRegType to, x86IntRegType from );
906
907 // cmp imm32 to r32 
908 void CMP32ItoR( x86IntRegType to, u32 from );
909 // cmp imm32 to m32 
910 void CMP32ItoM( uptr to, u32 from );
911 // cmp r32 to r32 
912 void CMP32RtoR( x86IntRegType to, x86IntRegType from );
913 // cmp m32 to r32 
914 void CMP32MtoR( x86IntRegType to, uptr from );
915 // cmp imm32 to [r32]
916 void CMP32I8toRm( x86IntRegType to, u8 from);
917 // cmp imm32 to [r32+off]
918 void CMP32I8toRmOffset8( x86IntRegType to, u8 from, u8 off);
919 // cmp imm8 to [r32]
920 void CMP32I8toM( uptr to, u8 from);
921
922 // cmp imm16 to r16 
923 void CMP16ItoR( x86IntRegType to, u16 from );
924 // cmp imm16 to m16 
925 void CMP16ItoM( uptr to, u16 from );
926 // cmp r16 to r16 
927 void CMP16RtoR( x86IntRegType to, x86IntRegType from );
928 // cmp m16 to r16 
929 void CMP16MtoR( x86IntRegType to, uptr from );
930
931 // cmp imm8 to r8
932 void CMP8ItoR( x86IntRegType to, u8 from );
933 // cmp m8 to r8
934 void CMP8MtoR( x86IntRegType to, uptr from );
935
936 // test r64 to r64
937 void TEST64RtoR( x86IntRegType to, x86IntRegType from );
938 // test imm32 to r32 
939 void TEST32ItoR( x86IntRegType to, u32 from );
940 // test imm32 to m32 
941 void TEST32ItoM( uptr to, u32 from );
942 // test r32 to r32 
943 void TEST32RtoR( x86IntRegType to, x86IntRegType from );
944 // test imm32 to [r32]
945 void TEST32ItoRm( x86IntRegType to, u32 from );
946 // test imm16 to r16
947 void TEST16ItoR( x86IntRegType to, u16 from );
948 // test r16 to r16
949 void TEST16RtoR( x86IntRegType to, x86IntRegType from );
950 // test imm8 to r8
951 void TEST8ItoR( x86IntRegType to, u8 from );
952 // test imm8 to r8
953 void TEST8ItoM( uptr to, u8 from );
954
955 // sets r8 
956 void SETS8R( x86IntRegType to );
957 // setl r8 
958 void SETL8R( x86IntRegType to );
959 // setge r8 
960 void SETGE8R( x86IntRegType to );
961 // setge r8 
962 void SETG8R( x86IntRegType to );
963 // seta r8 
964 void SETA8R( x86IntRegType to );
965 // setae r8 
966 void SETAE8R( x86IntRegType to );
967 // setb r8 
968 void SETB8R( x86IntRegType to );
969 // setnz r8 
970 void SETNZ8R( x86IntRegType to );
971 // setz r8 
972 void SETZ8R( x86IntRegType to );
973 // sete r8 
974 void SETE8R( x86IntRegType to );
975
976 // push imm32
977 void PUSH32I( u32 from );
978
979 #ifdef __x86_64__
980 void PUSHI( u32 from );
981 // push r64
982 void PUSH64R( x86IntRegType from );
983 // push m64 
984 void PUSH64M( uptr from );
985 // pop r32 
986 void POP64R( x86IntRegType from );
987 #else
988 // push r32 
989 void PUSH32R( x86IntRegType from );
990 // push m32 
991 void PUSH32M( u32 from );
992 // push imm32 
993 void PUSH32I( u32 from );
994 // pop r32 
995 void POP32R( x86IntRegType from );
996 // pushad 
997 void PUSHA32( void );
998 // popad 
999 void POPA32( void );
1000 #endif
1001
1002 void PUSHR(x86IntRegType from);
1003 void POPR(x86IntRegType from);
1004
1005 // pushfd 
1006 void PUSHFD( void );
1007 // popfd 
1008 void POPFD( void );
1009 // ret 
1010 void RET( void );
1011 // ret (2-byte code used for misprediction)
1012 void RET2( void );
1013
1014 void CBW();
1015 void CWDE();
1016 // cwd 
1017 void CWD( void );
1018 // cdq 
1019 void CDQ( void );
1020 // cdqe
1021 void CDQE( void );
1022
1023 void LAHF();
1024 void SAHF();
1025
1026 void BT32ItoR( x86IntRegType to, x86IntRegType from );
1027 void BSRRtoR(x86IntRegType to, x86IntRegType from);
1028 void BSWAP32R( x86IntRegType to );
1029
1030 // to = from + offset
1031 void LEA16RtoR(x86IntRegType to, x86IntRegType from, u16 offset);
1032 void LEA32RtoR(x86IntRegType to, x86IntRegType from, u32 offset);
1033
1034 // to = from0 + from1
1035 void LEA16RRtoR(x86IntRegType to, x86IntRegType from0, x86IntRegType from1);
1036 void LEA32RRtoR(x86IntRegType to, x86IntRegType from0, x86IntRegType from1);
1037
1038 // to = from << scale (max is 3)
1039 void LEA16RStoR(x86IntRegType to, x86IntRegType from, u32 scale);
1040 void LEA32RStoR(x86IntRegType to, x86IntRegType from, u32 scale);
1041
1042 //******************
1043 // FPU instructions 
1044 //******************
1045
1046 // fild m32 to fpu reg stack 
1047 void FILD32( uptr from );
1048 // fistp m32 from fpu reg stack 
1049 void FISTP32( uptr from );
1050 // fld m32 to fpu reg stack 
1051 void FLD32( uptr from );
1052 // fld st(i)
1053 void FLD(int st);
1054 // fld1 (push +1.0f on the stack)
1055 void FLD1();
1056 // fld1 (push log_2 e on the stack)
1057 void FLDL2E();
1058 // fst m32 from fpu reg stack 
1059 void FST32( uptr to );
1060 // fstp m32 from fpu reg stack 
1061 void FSTP32( uptr to );
1062 // fstp st(i)
1063 void FSTP(int st);
1064
1065 // fldcw fpu control word from m16 
1066 void FLDCW( uptr from );
1067 // fstcw fpu control word to m16 
1068 void FNSTCW( uptr to );
1069 void FXAM();
1070 void FDECSTP();
1071 // frndint
1072 void FRNDINT();
1073 void FXCH(int st);
1074 void F2XM1();
1075 void FSCALE();
1076
1077 // fadd ST(src) to fpu reg stack ST(0) 
1078 void FADD32Rto0( x86IntRegType src );
1079 // fadd ST(0) to fpu reg stack ST(src) 
1080 void FADD320toR( x86IntRegType src );
1081 // fsub ST(src) to fpu reg stack ST(0) 
1082 void FSUB32Rto0( x86IntRegType src );
1083 // fsub ST(0) to fpu reg stack ST(src) 
1084 void FSUB320toR( x86IntRegType src );
1085 // fsubp -> subtract ST(0) from ST(1), store in ST(1) and POP stack 
1086 void FSUBP( void );
1087 // fmul ST(src) to fpu reg stack ST(0) 
1088 void FMUL32Rto0( x86IntRegType src );
1089 // fmul ST(0) to fpu reg stack ST(src) 
1090 void FMUL320toR( x86IntRegType src );
1091 // fdiv ST(src) to fpu reg stack ST(0) 
1092 void FDIV32Rto0( x86IntRegType src );
1093 // fdiv ST(0) to fpu reg stack ST(src) 
1094 void FDIV320toR( x86IntRegType src );
1095 // fdiv ST(0) to fpu reg stack ST(src), pop stack, store in ST(src)
1096 void FDIV320toRP( x86IntRegType src );
1097
1098 // fadd m32 to fpu reg stack 
1099 void FADD32( uptr from );
1100 // fsub m32 to fpu reg stack 
1101 void FSUB32( uptr from );
1102 // fmul m32 to fpu reg stack 
1103 void FMUL32( uptr from );
1104 // fdiv m32 to fpu reg stack 
1105 void FDIV32( uptr from );
1106 // fcomi st, st( i) 
1107 void FCOMI( x86IntRegType src );
1108 // fcomip st, st( i) 
1109 void FCOMIP( x86IntRegType src );
1110 // fucomi st, st( i) 
1111 void FUCOMI( x86IntRegType src );
1112 // fucomip st, st( i) 
1113 void FUCOMIP( x86IntRegType src );
1114 // fcom m32 to fpu reg stack 
1115 void FCOM32( uptr from );
1116 // fabs fpu reg stack 
1117 void FABS( void );
1118 // fsqrt fpu reg stack 
1119 void FSQRT( void );
1120 // ftan fpu reg stack 
1121 void FPATAN( void );
1122 // fsin fpu reg stack 
1123 void FSIN( void );
1124 // fchs fpu reg stack 
1125 void FCHS( void );
1126
1127 // fcmovb fpu reg to fpu reg stack 
1128 void FCMOVB32( x86IntRegType from );
1129 // fcmove fpu reg to fpu reg stack 
1130 void FCMOVE32( x86IntRegType from );
1131 // fcmovbe fpu reg to fpu reg stack 
1132 void FCMOVBE32( x86IntRegType from );
1133 // fcmovu fpu reg to fpu reg stack 
1134 void FCMOVU32( x86IntRegType from );
1135 // fcmovnb fpu reg to fpu reg stack 
1136 void FCMOVNB32( x86IntRegType from );
1137 // fcmovne fpu reg to fpu reg stack 
1138 void FCMOVNE32( x86IntRegType from );
1139 // fcmovnbe fpu reg to fpu reg stack 
1140 void FCMOVNBE32( x86IntRegType from );
1141 // fcmovnu fpu reg to fpu reg stack 
1142 void FCMOVNU32( x86IntRegType from );
1143 void FCOMP32( uptr from );
1144 void FNSTSWtoAX( void );
1145
1146 // probably a little extreme here, but x86-64 should NOT use MMX
1147 #ifdef __x86_64__
1148
1149 #define MMXONLY(code)
1150
1151 #else
1152
1153 #define MMXONLY(code) code
1154
1155 //******************
1156 // MMX instructions 
1157 //******************
1158
1159 // r64 = mm
1160
1161 // movq m64 to r64 
1162 void MOVQMtoR( x86MMXRegType to, uptr from );
1163 // movq r64 to m64 
1164 void MOVQRtoM( uptr to, x86MMXRegType from );
1165
1166 // pand r64 to r64 
1167 void PANDRtoR( x86MMXRegType to, x86MMXRegType from );
1168 void PANDNRtoR( x86MMXRegType to, x86MMXRegType from );
1169 // pand m64 to r64 ;
1170 void PANDMtoR( x86MMXRegType to, uptr from );
1171 // pandn r64 to r64 
1172 void PANDNRtoR( x86MMXRegType to, x86MMXRegType from );
1173 // pandn r64 to r64 
1174 void PANDNMtoR( x86MMXRegType to, uptr from );
1175 // por r64 to r64 
1176 void PORRtoR( x86MMXRegType to, x86MMXRegType from );
1177 // por m64 to r64 
1178 void PORMtoR( x86MMXRegType to, uptr from );
1179 // pxor r64 to r64 
1180 void PXORRtoR( x86MMXRegType to, x86MMXRegType from );
1181 // pxor m64 to r64 
1182 void PXORMtoR( x86MMXRegType to, uptr from );
1183
1184 // psllq r64 to r64 
1185 void PSLLQRtoR( x86MMXRegType to, x86MMXRegType from );
1186 // psllq m64 to r64 
1187 void PSLLQMtoR( x86MMXRegType to, uptr from );
1188 // psllq imm8 to r64 
1189 void PSLLQItoR( x86MMXRegType to, u8 from );
1190 // psrlq r64 to r64 
1191 void PSRLQRtoR( x86MMXRegType to, x86MMXRegType from );
1192 // psrlq m64 to r64 
1193 void PSRLQMtoR( x86MMXRegType to, uptr from );
1194 // psrlq imm8 to r64 
1195 void PSRLQItoR( x86MMXRegType to, u8 from );
1196
1197 // paddusb r64 to r64 
1198 void PADDUSBRtoR( x86MMXRegType to, x86MMXRegType from );
1199 // paddusb m64 to r64 
1200 void PADDUSBMtoR( x86MMXRegType to, uptr from );
1201 // paddusw r64 to r64 
1202 void PADDUSWRtoR( x86MMXRegType to, x86MMXRegType from );
1203 // paddusw m64 to r64 
1204 void PADDUSWMtoR( x86MMXRegType to, uptr from );
1205
1206 // paddb r64 to r64 
1207 void PADDBRtoR( x86MMXRegType to, x86MMXRegType from );
1208 // paddb m64 to r64 
1209 void PADDBMtoR( x86MMXRegType to, uptr from );
1210 // paddw r64 to r64 
1211 void PADDWRtoR( x86MMXRegType to, x86MMXRegType from );
1212 // paddw m64 to r64 
1213 void PADDWMtoR( x86MMXRegType to, uptr from );
1214 // paddd r64 to r64 
1215 void PADDDRtoR( x86MMXRegType to, x86MMXRegType from );
1216 // paddd m64 to r64 
1217 void PADDDMtoR( x86MMXRegType to, uptr from );
1218 void PADDSBRtoR( x86MMXRegType to, x86MMXRegType from );
1219 void PADDSWRtoR( x86MMXRegType to, x86MMXRegType from );
1220
1221 // paddq m64 to r64 (sse2 only?)
1222 void PADDQMtoR( x86MMXRegType to, uptr from );
1223 // paddq r64 to r64 (sse2 only?)
1224 void PADDQRtoR( x86MMXRegType to, x86MMXRegType from );
1225
1226 void PSUBSBRtoR( x86MMXRegType to, x86MMXRegType from ); 
1227 void PSUBSWRtoR( x86MMXRegType to, x86MMXRegType from );
1228
1229 void PSUBBRtoR( x86MMXRegType to, x86MMXRegType from );
1230 void PSUBWRtoR( x86MMXRegType to, x86MMXRegType from );
1231 void PSUBDRtoR( x86MMXRegType to, x86MMXRegType from );
1232 void PSUBDMtoR( x86MMXRegType to, uptr from );
1233
1234 // psubq m64 to r64 (sse2 only?)
1235 void PSUBQMtoR( x86MMXRegType to, uptr from );
1236 // psubq r64 to r64 (sse2 only?)
1237 void PSUBQRtoR( x86MMXRegType to, x86MMXRegType from );
1238
1239 // pmuludq m64 to r64 (sse2 only?)
1240 void PMULUDQMtoR( x86MMXRegType to, uptr from );
1241 // pmuludq r64 to r64 (sse2 only?)
1242 void PMULUDQRtoR( x86MMXRegType to, x86MMXRegType from );
1243
1244 void PCMPEQBRtoR( x86MMXRegType to, x86MMXRegType from );
1245 void PCMPEQWRtoR( x86MMXRegType to, x86MMXRegType from );
1246 void PCMPEQDRtoR( x86MMXRegType to, x86MMXRegType from );
1247 void PCMPEQDMtoR( x86MMXRegType to, uptr from );
1248 void PCMPGTBRtoR( x86MMXRegType to, x86MMXRegType from );
1249 void PCMPGTWRtoR( x86MMXRegType to, x86MMXRegType from );
1250 void PCMPGTDRtoR( x86MMXRegType to, x86MMXRegType from );
1251 void PCMPGTDMtoR( x86MMXRegType to, uptr from );
1252 void PSRLWItoR( x86MMXRegType to, u8 from );
1253 void PSRLDItoR( x86MMXRegType to, u8 from );
1254 void PSRLDRtoR( x86MMXRegType to, x86MMXRegType from );
1255 void PSLLWItoR( x86MMXRegType to, u8 from );
1256 void PSLLDItoR( x86MMXRegType to, u8 from );
1257 void PSLLDRtoR( x86MMXRegType to, x86MMXRegType from );
1258 void PSRAWItoR( x86MMXRegType to, u8 from );
1259 void PSRADItoR( x86MMXRegType to, u8 from );
1260 void PSRADRtoR( x86MMXRegType to, x86MMXRegType from );
1261 void PUNPCKLDQRtoR( x86MMXRegType to, x86MMXRegType from );
1262 void PUNPCKLDQMtoR( x86MMXRegType to, uptr from );
1263 void PUNPCKHDQRtoR( x86MMXRegType to, x86MMXRegType from );
1264 void PUNPCKHDQMtoR( x86MMXRegType to, uptr from );
1265 void MOVQ64ItoR( x86MMXRegType reg, u64 i ); //Prototype.Todo add all consts to end of block.not after jr $+8
1266 void MOVQRtoR( x86MMXRegType to, x86MMXRegType from );
1267 void MOVQRmtoROffset( x86MMXRegType to, x86IntRegType from, u32 offset );
1268 void MOVQRtoRmOffset( x86IntRegType  to, x86MMXRegType from, u32 offset );
1269 void MOVDMtoMMX( x86MMXRegType to, uptr from );
1270 void MOVDMMXtoM( uptr to, x86MMXRegType from );
1271 void MOVD32RtoMMX( x86MMXRegType to, x86IntRegType from );
1272 void MOVD32RmtoMMX( x86MMXRegType to, x86IntRegType from );
1273 void MOVD32RmOffsettoMMX( x86MMXRegType to, x86IntRegType from, u32 offset );
1274 void MOVD32MMXtoR( x86IntRegType to, x86MMXRegType from );
1275 void MOVD32MMXtoRm( x86IntRegType to, x86MMXRegType from );
1276 void MOVD32MMXtoRmOffset( x86IntRegType to, x86MMXRegType from, u32 offset );
1277 void PINSRWRtoMMX( x86MMXRegType to, x86SSERegType from, u8 imm8 );
1278 void PSHUFWRtoR(x86MMXRegType to, x86MMXRegType from, u8 imm8);
1279 void PSHUFWMtoR(x86MMXRegType to, uptr from, u8 imm8);
1280 void MASKMOVQRtoR(x86MMXRegType to, x86MMXRegType from);
1281
1282 // emms 
1283 void EMMS( void );
1284
1285 //**********************************************************************************/
1286 //PACKSSWB,PACKSSDW: Pack Saturate Signed Word 64bits
1287 //**********************************************************************************
1288 void PACKSSWBMMXtoMMX(x86MMXRegType to, x86MMXRegType from);
1289 void PACKSSDWMMXtoMMX(x86MMXRegType to, x86MMXRegType from);
1290
1291 void PMOVMSKBMMXtoR(x86IntRegType to, x86MMXRegType from);
1292
1293 void SSE2_MOVDQ2Q_XMM_to_MM( x86MMXRegType to, x86SSERegType from);
1294 void SSE2_MOVQ2DQ_MM_to_XMM( x86SSERegType to, x86MMXRegType from);
1295
1296 #endif // !__x86_64__
1297
1298 //*********************
1299 // SSE   instructions *
1300 //*********************
1301 void SSE_MOVAPS_M128_to_XMM( x86SSERegType to, uptr from );
1302 void SSE_MOVAPS_XMM_to_M128( uptr to, x86SSERegType from );
1303 void SSE_MOVAPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1304
1305 void SSE_MOVUPS_M128_to_XMM( x86SSERegType to, uptr from );
1306 void SSE_MOVUPS_XMM_to_M128( uptr to, x86SSERegType from );
1307
1308 void SSE_MOVSS_M32_to_XMM( x86SSERegType to, uptr from );
1309 void SSE_MOVSS_XMM_to_M32( u32 to, x86SSERegType from );
1310 void SSE_MOVSS_XMM_to_Rm( x86IntRegType to, x86SSERegType from );
1311 void SSE_MOVSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1312 void SSE_MOVSS_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1313 void SSE_MOVSS_XMM_to_RmOffset( x86IntRegType to, x86SSERegType from, int offset );
1314
1315 void SSE2_MOVSD_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1316
1317 void SSE2_MOVQ_M64_to_XMM( x86SSERegType to, uptr from );
1318 void SSE2_MOVQ_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1319 void SSE2_MOVQ_XMM_to_M64( u32 to, x86SSERegType from );
1320
1321 void SSE_MASKMOVDQU_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1322
1323 void SSE_MOVLPS_M64_to_XMM( x86SSERegType to, uptr from );
1324 void SSE_MOVLPS_XMM_to_M64( u32 to, x86SSERegType from );
1325 void SSE_MOVLPS_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1326 void SSE_MOVLPS_XMM_to_RmOffset( x86IntRegType to, x86SSERegType from, int offset );
1327
1328 void SSE_MOVHPS_M64_to_XMM( x86SSERegType to, uptr from );
1329 void SSE_MOVHPS_XMM_to_M64( u32 to, x86SSERegType from );       
1330 void SSE_MOVHPS_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1331 void SSE_MOVHPS_XMM_to_RmOffset( x86IntRegType to, x86SSERegType from, int offset );
1332
1333 void SSE_MOVLHPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1334 void SSE_MOVHLPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1335 void SSE_MOVLPSRmtoR( x86SSERegType to, x86IntRegType from );
1336 void SSE_MOVLPSRmtoROffset( x86SSERegType to, x86IntRegType from, int offset );
1337 void SSE_MOVLPSRtoRm( x86SSERegType to, x86IntRegType from );
1338 void SSE_MOVLPSRtoRmOffset( x86SSERegType to, x86IntRegType from, int offset );
1339
1340 void SSE_MOVAPSRmStoR( x86SSERegType to, x86IntRegType from, x86IntRegType from2, int scale );
1341 void SSE_MOVAPSRtoRmS( x86SSERegType to, x86IntRegType from, x86IntRegType from2, int scale );
1342 void SSE_MOVAPSRtoRmOffset( x86IntRegType to, x86SSERegType from, int offset );
1343 void SSE_MOVAPSRmtoROffset( x86SSERegType to, x86IntRegType from, int offset );
1344 void SSE_MOVUPSRmStoR( x86SSERegType to, x86IntRegType from, x86IntRegType from2, int scale );
1345 void SSE_MOVUPSRtoRmS( x86SSERegType to, x86IntRegType from, x86IntRegType from2, int scale );
1346 void SSE_MOVUPSRtoRm( x86IntRegType to, x86IntRegType from );
1347 void SSE_MOVUPSRmtoR( x86IntRegType to, x86IntRegType from );
1348
1349 void SSE_MOVUPSRmtoROffset( x86SSERegType to, x86IntRegType from, int offset );
1350 void SSE_MOVUPSRtoRmOffset( x86SSERegType to, x86IntRegType from, int offset );
1351
1352 void SSE2_MOVDQARtoRmOffset( x86IntRegType to, x86SSERegType from, int offset );
1353 void SSE2_MOVDQARmtoROffset( x86SSERegType to, x86IntRegType from, int offset );
1354
1355 void SSE_RCPPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1356 void SSE_RCPPS_M128_to_XMM( x86SSERegType to, uptr from );
1357 void SSE_RCPSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1358 void SSE_RCPSS_M32_to_XMM( x86SSERegType to, uptr from );
1359
1360 void SSE_ORPS_M128_to_XMM( x86SSERegType to, uptr from );
1361 void SSE_ORPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1362 void SSE_XORPS_M128_to_XMM( x86SSERegType to, uptr from );
1363 void SSE_XORPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1364 void SSE_ANDPS_M128_to_XMM( x86SSERegType to, uptr from );
1365 void SSE_ANDPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1366 void SSE_ANDNPS_M128_to_XMM( x86SSERegType to, uptr from );
1367 void SSE_ANDNPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1368 void SSE_ADDPS_M128_to_XMM( x86SSERegType to, uptr from );
1369 void SSE_ADDPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1370 void SSE_ADDSS_M32_to_XMM( x86SSERegType to, uptr from );
1371 void SSE_ADDSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1372 void SSE_SUBPS_M128_to_XMM( x86SSERegType to, uptr from );
1373 void SSE_SUBPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1374 void SSE_SUBSS_M32_to_XMM( x86SSERegType to, uptr from );
1375 void SSE_SUBSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1376 void SSE_MULPS_M128_to_XMM( x86SSERegType to, uptr from );
1377 void SSE_MULPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1378 void SSE_MULSS_M32_to_XMM( x86SSERegType to, uptr from );
1379 void SSE_MULSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1380 void SSE_CMPEQSS_M32_to_XMM( x86SSERegType to, uptr from );
1381 void SSE_CMPEQSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1382 void SSE_CMPLTSS_M32_to_XMM( x86SSERegType to, uptr from );
1383 void SSE_CMPLTSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1384 void SSE_CMPLESS_M32_to_XMM( x86SSERegType to, uptr from );
1385 void SSE_CMPLESS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1386 void SSE_CMPUNORDSS_M32_to_XMM( x86SSERegType to, uptr from );
1387 void SSE_CMPUNORDSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1388 void SSE_CMPNESS_M32_to_XMM( x86SSERegType to, uptr from );
1389 void SSE_CMPNESS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1390 void SSE_CMPNLTSS_M32_to_XMM( x86SSERegType to, uptr from );
1391 void SSE_CMPNLTSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1392 void SSE_CMPNLESS_M32_to_XMM( x86SSERegType to, uptr from );
1393 void SSE_CMPNLESS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1394 void SSE_CMPORDSS_M32_to_XMM( x86SSERegType to, uptr from );
1395 void SSE_CMPORDSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1396
1397 void SSE_UCOMISS_M32_to_XMM( x86SSERegType to, uptr from );
1398 void SSE_UCOMISS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1399
1400 #ifndef __x86_64__
1401 void SSE_PMAXSW_MM_to_MM( x86MMXRegType to, x86MMXRegType from );
1402 void SSE_PMINSW_MM_to_MM( x86MMXRegType to, x86MMXRegType from );
1403 void SSE_CVTPI2PS_MM_to_XMM( x86SSERegType to, x86MMXRegType from );
1404 void SSE_CVTPS2PI_M64_to_MM( x86MMXRegType to, uptr from );
1405 void SSE_CVTPS2PI_XMM_to_MM( x86MMXRegType to, x86SSERegType from );
1406 #endif
1407 void SSE_CVTPI2PS_M64_to_XMM( x86SSERegType to, uptr from );
1408 void SSE_CVTTSS2SI_M32_to_R32(x86IntRegType to, uptr from);
1409 void SSE_CVTTSS2SI_XMM_to_R32(x86IntRegType to, x86SSERegType from);
1410 void SSE_CVTSI2SS_M32_to_XMM(x86SSERegType to, uptr from);
1411 void SSE_CVTSI2SS_R_to_XMM(x86SSERegType to, x86IntRegType from);
1412
1413 void SSE2_CVTDQ2PS_M128_to_XMM( x86SSERegType to, uptr from );
1414 void SSE2_CVTDQ2PS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1415 void SSE2_CVTPS2DQ_M128_to_XMM( x86SSERegType to, uptr from );
1416 void SSE2_CVTPS2DQ_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1417 void SSE2_CVTTPS2DQ_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1418
1419 void SSE_MAXPS_M128_to_XMM( x86SSERegType to, uptr from );
1420 void SSE_MAXPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1421 void SSE_MAXSS_M32_to_XMM( x86SSERegType to, uptr from );
1422 void SSE_MAXSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1423 void SSE_MINPS_M128_to_XMM( x86SSERegType to, uptr from );
1424 void SSE_MINPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1425 void SSE_MINSS_M32_to_XMM( x86SSERegType to, uptr from );
1426 void SSE_MINSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1427 void SSE_RSQRTPS_M128_to_XMM( x86SSERegType to, uptr from );
1428 void SSE_RSQRTPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1429 void SSE_RSQRTSS_M32_to_XMM( x86SSERegType to, uptr from );
1430 void SSE_RSQRTSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1431 void SSE_SQRTPS_M128_to_XMM( x86SSERegType to, uptr from );
1432 void SSE_SQRTPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1433 void SSE_SQRTSS_M32_to_XMM( x86SSERegType to, uptr from );
1434 void SSE_SQRTSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1435 void SSE_UNPCKLPS_M128_to_XMM( x86SSERegType to, uptr from );
1436 void SSE_UNPCKLPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1437 void SSE_UNPCKHPS_M128_to_XMM( x86SSERegType to, uptr from );
1438 void SSE_UNPCKHPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1439 void SSE_SHUFPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from, u8 imm8 );
1440 void SSE_SHUFPS_M128_to_XMM( x86SSERegType to, uptr from, u8 imm8 );
1441 void SSE_SHUFPS_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset, u8 imm8 );
1442 void SSE_CMPEQPS_M128_to_XMM( x86SSERegType to, uptr from );
1443 void SSE_CMPEQPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1444 void SSE_CMPLTPS_M128_to_XMM( x86SSERegType to, uptr from );
1445 void SSE_CMPLTPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1446 void SSE_CMPLEPS_M128_to_XMM( x86SSERegType to, uptr from );
1447 void SSE_CMPLEPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1448 void SSE_CMPUNORDPS_M128_to_XMM( x86SSERegType to, uptr from );
1449 void SSE_CMPUNORDPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1450 void SSE_CMPNEPS_M128_to_XMM( x86SSERegType to, uptr from );
1451 void SSE_CMPNEPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1452 void SSE_CMPNLTPS_M128_to_XMM( x86SSERegType to, uptr from );
1453 void SSE_CMPNLTPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1454 void SSE_CMPNLEPS_M128_to_XMM( x86SSERegType to, uptr from );
1455 void SSE_CMPNLEPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1456 void SSE_CMPORDPS_M128_to_XMM( x86SSERegType to, uptr from );
1457 void SSE_CMPORDPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1458 void SSE_DIVPS_M128_to_XMM( x86SSERegType to, uptr from );
1459 void SSE_DIVPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1460 void SSE_DIVSS_M32_to_XMM( x86SSERegType to, uptr from );
1461 void SSE_DIVSS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1462 // VectorPath
1463 void SSE2_PSHUFD_XMM_to_XMM( x86SSERegType to, x86SSERegType from, u8 imm8 );
1464 void SSE2_PSHUFD_M128_to_XMM( x86SSERegType to, uptr from, u8 imm8 );
1465
1466 void SSE2_PSHUFLW_XMM_to_XMM( x86SSERegType to, x86SSERegType from, u8 imm8 );
1467 void SSE2_PSHUFLW_M128_to_XMM( x86SSERegType to, uptr from, u8 imm8 );
1468 void SSE2_PSHUFHW_XMM_to_XMM( x86SSERegType to, x86SSERegType from, u8 imm8 );
1469 void SSE2_PSHUFHW_M128_to_XMM( x86SSERegType to, uptr from, u8 imm8 );
1470
1471 void SSE_STMXCSR( uptr from );
1472 void SSE_LDMXCSR( uptr from );
1473
1474
1475 //*********************
1476 //  SSE 2 Instructions*
1477 //*********************
1478 void SSE2_MOVDQA_M128_to_XMM(x86SSERegType to, uptr from); 
1479 void SSE2_MOVDQA_XMM_to_M128( uptr to, x86SSERegType from); 
1480 void SSE2_MOVDQA_XMM_to_XMM( x86SSERegType to, x86SSERegType from); 
1481
1482 void SSE2_MOVDQU_M128_to_XMM(x86SSERegType to, uptr from); 
1483 void SSE2_MOVDQU_XMM_to_M128( uptr to, x86SSERegType from); 
1484 void SSE2_MOVDQU_XMM_to_XMM( x86SSERegType to, x86SSERegType from); 
1485
1486 void SSE2_PSRLW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1487 void SSE2_PSRLW_M128_to_XMM(x86SSERegType to, uptr from);
1488 void SSE2_PSRLW_I8_to_XMM(x86SSERegType to, u8 imm8);
1489 void SSE2_PSRLD_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1490 void SSE2_PSRLD_M128_to_XMM(x86SSERegType to, uptr from);
1491 void SSE2_PSRLD_I8_to_XMM(x86SSERegType to, u8 imm8);
1492 void SSE2_PSRLQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1493 void SSE2_PSRLQ_M128_to_XMM(x86SSERegType to, uptr from);
1494 void SSE2_PSRLQ_I8_to_XMM(x86SSERegType to, u8 imm8);
1495 void SSE2_PSRLDQ_I8_to_XMM(x86SSERegType to, u8 imm8);
1496 void SSE2_PSRAW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1497 void SSE2_PSRAW_M128_to_XMM(x86SSERegType to, uptr from);
1498 void SSE2_PSRAW_I8_to_XMM(x86SSERegType to, u8 imm8);
1499 void SSE2_PSRAD_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1500 void SSE2_PSRAD_M128_to_XMM(x86SSERegType to, uptr from);
1501 void SSE2_PSRAD_I8_to_XMM(x86SSERegType to, u8 imm8);
1502 void SSE2_PSLLW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1503 void SSE2_PSLLW_M128_to_XMM(x86SSERegType to, uptr from);
1504 void SSE2_PSLLW_I8_to_XMM(x86SSERegType to, u8 imm8);
1505 void SSE2_PSLLD_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1506 void SSE2_PSLLD_M128_to_XMM(x86SSERegType to, uptr from);
1507 void SSE2_PSLLD_I8_to_XMM(x86SSERegType to, u8 imm8);
1508 void SSE2_PSLLQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1509 void SSE2_PSLLQ_M128_to_XMM(x86SSERegType to, uptr from);
1510 void SSE2_PSLLQ_I8_to_XMM(x86SSERegType to, u8 imm8);
1511 void SSE2_PSLLDQ_I8_to_XMM(x86SSERegType to, u8 imm8);
1512 void SSE2_PMAXSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1513 void SSE2_PMAXSW_M128_to_XMM( x86SSERegType to, uptr from );
1514 void SSE2_PMAXUB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1515 void SSE2_PMAXUB_M128_to_XMM( x86SSERegType to, uptr from );
1516 void SSE2_PMINSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1517 void SSE2_PMINSW_M128_to_XMM( x86SSERegType to, uptr from );
1518 void SSE2_PMINUB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1519 void SSE2_PMINUB_M128_to_XMM( x86SSERegType to, uptr from );
1520 void SSE2_PADDSB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1521 void SSE2_PADDSB_M128_to_XMM( x86SSERegType to, uptr from );
1522 void SSE2_PADDSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1523 void SSE2_PADDSW_M128_to_XMM( x86SSERegType to, uptr from );
1524 void SSE2_PSUBSB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1525 void SSE2_PSUBSB_M128_to_XMM( x86SSERegType to, uptr from );
1526 void SSE2_PSUBSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1527 void SSE2_PSUBSW_M128_to_XMM( x86SSERegType to, uptr from );
1528 void SSE2_PSUBUSB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1529 void SSE2_PSUBUSB_M128_to_XMM( x86SSERegType to, uptr from );
1530 void SSE2_PSUBUSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1531 void SSE2_PSUBUSW_M128_to_XMM( x86SSERegType to, uptr from );
1532 void SSE2_PAND_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1533 void SSE2_PAND_M128_to_XMM( x86SSERegType to, uptr from );
1534 void SSE2_PANDN_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1535 void SSE2_PANDN_M128_to_XMM( x86SSERegType to, uptr from );
1536 void SSE2_PXOR_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1537 void SSE2_PXOR_M128_to_XMM( x86SSERegType to, uptr from );
1538 void SSE2_PADDW_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1539 void SSE2_PADDW_M128_to_XMM(x86SSERegType to, uptr from );
1540 void SSE2_PADDUSB_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1541 void SSE2_PADDUSB_M128_to_XMM( x86SSERegType to, uptr from );
1542 void SSE2_PADDUSW_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1543 void SSE2_PADDUSW_M128_to_XMM( x86SSERegType to, uptr from );
1544 void SSE2_PADDB_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1545 void SSE2_PADDB_M128_to_XMM(x86SSERegType to, uptr from );
1546 void SSE2_PADDD_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1547 void SSE2_PADDD_M128_to_XMM(x86SSERegType to, uptr from );
1548 void SSE2_PADDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1549 void SSE2_PADDQ_M128_to_XMM(x86SSERegType to, uptr from );
1550
1551 //**********************************************************************************/
1552 //PACKSSWB,PACKSSDW: Pack Saturate Signed Word
1553 //**********************************************************************************
1554 void SSE2_PACKSSWB_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1555 void SSE2_PACKSSWB_M128_to_XMM(x86SSERegType to, uptr from);
1556 void SSE2_PACKSSDW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1557 void SSE2_PACKSSDW_M128_to_XMM(x86SSERegType to, uptr from);
1558
1559 void SSE2_PACKUSWB_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1560 void SSE2_PACKUSWB_M128_to_XMM(x86SSERegType to, uptr from);
1561
1562 //**********************************************************************************/
1563 //PUNPCKHWD: Unpack 16bit high
1564 //**********************************************************************************
1565 void SSE2_PUNPCKLBW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1566 void SSE2_PUNPCKLBW_M128_to_XMM(x86SSERegType to, uptr from);
1567 void SSE2_PUNPCKHBW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1568 void SSE2_PUNPCKHBW_M128_to_XMM(x86SSERegType to, uptr from);
1569
1570 void SSE2_PUNPCKLWD_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1571 void SSE2_PUNPCKLWD_M128_to_XMM(x86SSERegType to, uptr from);
1572 void SSE2_PUNPCKHWD_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1573 void SSE2_PUNPCKHWD_M128_to_XMM(x86SSERegType to, uptr from);
1574
1575 void SSE2_PUNPCKLDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1576 void SSE2_PUNPCKLDQ_M128_to_XMM(x86SSERegType to, uptr from);
1577 void SSE2_PUNPCKHDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1578 void SSE2_PUNPCKHDQ_M128_to_XMM(x86SSERegType to, uptr from);
1579
1580 void SSE2_PUNPCKLQDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1581 void SSE2_PUNPCKLQDQ_M128_to_XMM(x86SSERegType to, uptr from);
1582
1583 void SSE2_PUNPCKHQDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1584 void SSE2_PUNPCKHQDQ_M128_to_XMM(x86SSERegType to, uptr from);
1585
1586 // mult by half words
1587 void SSE2_PMULLW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1588 void SSE2_PMULLW_M128_to_XMM(x86SSERegType to, uptr from);
1589 void SSE2_PMULHW_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1590 void SSE2_PMULHW_M128_to_XMM(x86SSERegType to, uptr from);
1591
1592 void SSE2_PMULUDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1593 void SSE2_PMULUDQ_M128_to_XMM(x86SSERegType to, uptr from);
1594
1595
1596 //**********************************************************************************/
1597 //PMOVMSKB: Create 16bit mask from signs of 8bit integers
1598 //**********************************************************************************
1599 void SSE2_PMOVMSKB_XMM_to_R32(x86IntRegType to, x86SSERegType from);
1600
1601 void SSE_MOVMSKPS_XMM_to_R32(x86IntRegType to, x86SSERegType from);
1602 void SSE2_MOVMSKPD_XMM_to_R32(x86IntRegType to, x86SSERegType from);
1603
1604 //**********************************************************************************/
1605 //PEXTRW,PINSRW: Packed Extract/Insert Word                                        *
1606 //**********************************************************************************
1607 void SSE_PEXTRW_XMM_to_R32(x86IntRegType to, x86SSERegType from, u8 imm8 );
1608 void SSE_PINSRW_R32_to_XMM(x86SSERegType from, x86IntRegType to, u8 imm8 );
1609
1610
1611 //**********************************************************************************/
1612 //PSUBx: Subtract Packed Integers                                                  *
1613 //**********************************************************************************
1614 void SSE2_PSUBB_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1615 void SSE2_PSUBB_M128_to_XMM(x86SSERegType to, uptr from );
1616 void SSE2_PSUBW_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1617 void SSE2_PSUBW_M128_to_XMM(x86SSERegType to, uptr from );
1618 void SSE2_PSUBD_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1619 void SSE2_PSUBD_M128_to_XMM(x86SSERegType to, uptr from );
1620 void SSE2_PSUBQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1621 void SSE2_PSUBQ_M128_to_XMM(x86SSERegType to, uptr from );
1622 ///////////////////////////////////////////////////////////////////////////////////////
1623 //**********************************************************************************/
1624 //PCMPxx: Compare Packed Integers                                                  *
1625 //**********************************************************************************
1626 void SSE2_PCMPGTB_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1627 void SSE2_PCMPGTB_M128_to_XMM(x86SSERegType to, uptr from );
1628 void SSE2_PCMPGTW_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1629 void SSE2_PCMPGTW_M128_to_XMM(x86SSERegType to, uptr from );
1630 void SSE2_PCMPGTD_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1631 void SSE2_PCMPGTD_M128_to_XMM(x86SSERegType to, uptr from );
1632 void SSE2_PCMPEQB_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1633 void SSE2_PCMPEQB_M128_to_XMM(x86SSERegType to, uptr from );
1634 void SSE2_PCMPEQW_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1635 void SSE2_PCMPEQW_M128_to_XMM(x86SSERegType to, uptr from );
1636 void SSE2_PCMPEQD_XMM_to_XMM(x86SSERegType to, x86SSERegType from );
1637 void SSE2_PCMPEQD_M128_to_XMM(x86SSERegType to, uptr from );
1638 //**********************************************************************************/
1639 //MOVD: Move Dword(32bit) to /from XMM reg                                         *
1640 //**********************************************************************************
1641 void SSE2_MOVD_M32_to_XMM( x86SSERegType to, uptr from );
1642 void SSE2_MOVD_R_to_XMM( x86SSERegType to, x86IntRegType from );
1643 void SSE2_MOVD_Rm_to_XMM( x86SSERegType to, x86IntRegType from );
1644 void SSE2_MOVD_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1645 void SSE2_MOVD_XMM_to_M32( u32 to, x86SSERegType from );
1646 void SSE2_MOVD_XMM_to_R( x86IntRegType to, x86SSERegType from );
1647 void SSE2_MOVD_XMM_to_Rm( x86IntRegType to, x86SSERegType from );
1648 void SSE2_MOVD_XMM_to_RmOffset( x86IntRegType to, x86SSERegType from, int offset );
1649
1650 #ifdef __x86_64__
1651 void SSE2_MOVQ_XMM_to_R( x86IntRegType to, x86SSERegType from );
1652 void SSE2_MOVQ_R_to_XMM( x86SSERegType to, x86IntRegType from );
1653 #endif
1654
1655 //**********************************************************************************/
1656 //POR : SSE Bitwise OR                                                             *
1657 //**********************************************************************************
1658 void SSE2_POR_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1659 void SSE2_POR_M128_to_XMM( x86SSERegType to, uptr from );
1660
1661 void SSE3_HADDPS_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1662 void SSE3_HADDPS_M128_to_XMM(x86SSERegType to, uptr from);
1663
1664 void SSE3_MOVSLDUP_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1665 void SSE3_MOVSLDUP_M128_to_XMM(x86SSERegType to, uptr from);
1666 void SSE3_MOVSHDUP_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1667 void SSE3_MOVSHDUP_M128_to_XMM(x86SSERegType to, uptr from);
1668 //*********************
1669 // SSE-X - uses both SSE,SSE2 code and tries to keep consistensies between the data
1670 // Uses g_xmmtypes to infer the correct type.
1671 //*********************
1672 void SSEX_MOVDQA_M128_to_XMM( x86SSERegType to, uptr from );
1673 void SSEX_MOVDQA_XMM_to_M128( uptr to, x86SSERegType from );
1674 void SSEX_MOVDQA_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1675
1676 void SSEX_MOVDQARmtoROffset( x86SSERegType to, x86IntRegType from, int offset );
1677 void SSEX_MOVDQARtoRmOffset( x86IntRegType to, x86SSERegType from, int offset );
1678
1679 void SSEX_MOVDQU_M128_to_XMM( x86SSERegType to, uptr from );
1680 void SSEX_MOVDQU_XMM_to_M128( uptr to, x86SSERegType from );
1681 void SSEX_MOVDQU_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1682
1683 void SSEX_MOVD_M32_to_XMM( x86SSERegType to, uptr from );
1684 void SSEX_MOVD_XMM_to_M32( u32 to, x86SSERegType from );
1685 void SSEX_MOVD_XMM_to_Rm( x86IntRegType to, x86SSERegType from );
1686 void SSEX_MOVD_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1687 void SSEX_MOVD_XMM_to_RmOffset( x86IntRegType to, x86SSERegType from, int offset );
1688
1689 void SSEX_POR_M128_to_XMM( x86SSERegType to, uptr from );
1690 void SSEX_POR_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1691 void SSEX_PXOR_M128_to_XMM( x86SSERegType to, uptr from );
1692 void SSEX_PXOR_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1693 void SSEX_PAND_M128_to_XMM( x86SSERegType to, uptr from );
1694 void SSEX_PAND_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1695 void SSEX_PANDN_M128_to_XMM( x86SSERegType to, uptr from );
1696 void SSEX_PANDN_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1697
1698 void SSEX_PUNPCKLDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1699 void SSEX_PUNPCKLDQ_M128_to_XMM(x86SSERegType to, uptr from);
1700 void SSEX_PUNPCKHDQ_XMM_to_XMM(x86SSERegType to, x86SSERegType from);
1701 void SSEX_PUNPCKHDQ_M128_to_XMM(x86SSERegType to, uptr from);
1702
1703 void SSEX_MOVHLPS_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1704
1705 //*********************
1706 // 3DNOW instructions * 
1707 //*********************
1708 void FEMMS( void );
1709 void PFCMPEQMtoR( x86IntRegType to, uptr from );
1710 void PFCMPGTMtoR( x86IntRegType to, uptr from );
1711 void PFCMPGEMtoR( x86IntRegType to, uptr from );
1712 void PFADDMtoR( x86IntRegType to, uptr from );
1713 void PFADDRtoR( x86IntRegType to, x86IntRegType from );
1714 void PFSUBMtoR( x86IntRegType to, uptr from );
1715 void PFSUBRtoR( x86IntRegType to, x86IntRegType from );
1716 void PFMULMtoR( x86IntRegType to, uptr from );
1717 void PFMULRtoR( x86IntRegType to, x86IntRegType from );
1718 void PFRCPMtoR( x86IntRegType to, uptr from );
1719 void PFRCPRtoR( x86IntRegType to, x86IntRegType from );
1720 void PFRCPIT1RtoR( x86IntRegType to, x86IntRegType from );
1721 void PFRCPIT2RtoR( x86IntRegType to, x86IntRegType from );
1722 void PFRSQRTRtoR( x86IntRegType to, x86IntRegType from );
1723 void PFRSQIT1RtoR( x86IntRegType to, x86IntRegType from );
1724 void PF2IDMtoR( x86IntRegType to, uptr from );
1725 void PF2IDRtoR( x86IntRegType to, x86IntRegType from );
1726 void PI2FDMtoR( x86IntRegType to, uptr from );
1727 void PI2FDRtoR( x86IntRegType to, x86IntRegType from );
1728 void PFMAXMtoR( x86IntRegType to, uptr from );
1729 void PFMAXRtoR( x86IntRegType to, x86IntRegType from );
1730 void PFMINMtoR( x86IntRegType to, uptr from );
1731 void PFMINRtoR( x86IntRegType to, x86IntRegType from );
1732
1733 void SSE2EMU_MOVSD_XMM_to_XMM( x86SSERegType to, x86SSERegType from);
1734 void SSE2EMU_MOVQ_M64_to_XMM( x86SSERegType to, uptr from);
1735 void SSE2EMU_MOVQ_XMM_to_XMM( x86SSERegType to, x86SSERegType from);
1736 void SSE2EMU_MOVD_RmOffset_to_XMM( x86SSERegType to, x86IntRegType from, int offset );
1737 void SSE2EMU_MOVD_XMM_to_RmOffset(x86IntRegType to, x86SSERegType from, int offset );
1738
1739 #ifndef __x86_64__
1740 void SSE2EMU_MOVDQ2Q_XMM_to_MM( x86MMXRegType to, x86SSERegType from);
1741 void SSE2EMU_MOVQ2DQ_MM_to_XMM( x86SSERegType to, x86MMXRegType from);
1742 #endif
1743
1744 /* SSE2 emulated functions for SSE CPU's by kekko*/
1745
1746 void SSE2EMU_PSHUFD_XMM_to_XMM( x86SSERegType to, x86SSERegType from, u8 imm8 );
1747 void SSE2EMU_MOVD_XMM_to_R( x86IntRegType to, x86SSERegType from );
1748 void SSE2EMU_CVTPS2DQ_XMM_to_XMM( x86SSERegType to, x86SSERegType from );
1749 void SSE2EMU_CVTDQ2PS_M128_to_XMM( x86SSERegType to, uptr from );
1750 void SSE2EMU_MOVD_XMM_to_M32( uptr to, x86SSERegType from );
1751 void SSE2EMU_MOVD_R_to_XMM( x86SSERegType to, x86IntRegType from );
1752
1753 ////////////////////////////////////////////////////
1754 #ifdef _DEBUG
1755 #define WRITECHECK() CheckX86Ptr()
1756 #else
1757 #define WRITECHECK()
1758 #endif
1759
1760 #define writeVAL(val) ({ \
1761                 WRITECHECK(); \
1762                 *(typeof(val)*)x86Ptr = (val); \
1763                 x86Ptr += sizeof(val); \
1764                 (void)0; \
1765         })
1766
1767 #define write8(val )  writeVAL((u8)(val))
1768 #define write16(val ) writeVAL((u16)(val))
1769 #define write32( val ) writeVAL((u32)(val))
1770 #define write64( val ) writeVAL((u64)(val))
1771
1772 #ifdef __cplusplus
1773 }
1774 #endif
1775
1776 #endif // __IX86_H__