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