]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/plr/server/src/asmjit/DefsX86X64.h
update
[l4.git] / l4 / pkg / plr / server / src / asmjit / DefsX86X64.h
1 // AsmJit - Complete JIT Assembler for C++ Language.
2
3 // Copyright (c) 2008-2010, Petr Kobalicek <kobalicek.petr@gmail.com>
4 //
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
12 // conditions:
13 // 
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
16 // 
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 // OTHER DEALINGS IN THE SOFTWARE.
25
26 // [Guard]
27 #ifndef _ASMJIT_DEFSX86X64_H
28 #define _ASMJIT_DEFSX86X64_H
29
30 #if !defined(_ASMJIT_DEFS_H)
31 #warning "AsmJit/DefsX86X64.h can be only included by AsmJit/Defs.h"
32 #endif // _ASMJIT_DEFS_H
33
34 // [Dependencies]
35 #include "Build.h"
36 #include "Util.h"
37
38 #include <stdlib.h>
39 #include <string.h>
40
41 // [Api-Begin]
42 #include "ApiBegin.h"
43
44 namespace AsmJit {
45
46 //! @addtogroup AsmJit_Core
47 //! @{
48
49 // ============================================================================
50 // [AsmJit::REG_NUM]
51 // ============================================================================
52
53 //! @var REG_NUM
54 //! @brief Count of General purpose registers and XMM registers.
55 //!
56 //! Count of general purpose registers and XMM registers depends to current
57 //! bit-mode. If application is compiled for 32-bit platform then this number
58 //! is 8, 64-bit platforms have 8 extra general purpose and xmm registers (16
59 //! total).
60
61 //! @brief Count of registers.
62 enum REG_NUM
63 {
64   //! @var REG_NUM_BASE
65   //!
66   //! Count of general purpose registers and XMM registers depends to current
67   //! bit-mode. If application is compiled for 32-bit platform then this number
68   //! is 8, 64-bit platforms have 8 extra general purpose and xmm registers (16
69   //! total).
70 #if defined(ASMJIT_X86)
71   REG_NUM_BASE = 8,
72 #else
73   REG_NUM_BASE = 16,
74 #endif // ASMJIT
75
76   //! @brief Count of general purpose registers.
77   //!
78   //! 8 in 32-bit mode and 16 in 64-bit mode.
79   REG_NUM_GP = REG_NUM_BASE,
80
81   //! @brief Count of MM registers (always 8).
82   REG_NUM_MM = 8,
83
84   //! @brief Count of FPU stack registers (always 8).
85   REG_NUM_FPU = 8,
86
87   //! @brief Count of XMM registers.
88   //!
89   //! 8 in 32-bit mode and 16 in 64-bit mode.
90   REG_NUM_XMM = REG_NUM_BASE
91 };
92
93 // ============================================================================
94 // [AsmJit::REG_INDEX]
95 // ============================================================================
96
97 //! @brief Valid X86 register indexes.
98 //!
99 //! These codes are real, don't miss with @c REG enum! and don't use these
100 //! values if you are not writing AsmJit code.
101 enum REG_INDEX
102 {
103   //! @brief Mask for register code (index).
104   REG_INDEX_MASK = 0x00FF,
105
106   //! @brief ID for AX/EAX/RAX registers.
107   REG_INDEX_EAX = 0,
108   //! @brief ID for CX/ECX/RCX registers.
109   REG_INDEX_ECX = 1,
110   //! @brief ID for DX/EDX/RDX registers.
111   REG_INDEX_EDX = 2,
112   //! @brief ID for BX/EBX/RBX registers.
113   REG_INDEX_EBX = 3,
114   //! @brief ID for SP/ESP/RSP registers.
115   REG_INDEX_ESP = 4,
116   //! @brief ID for BP/EBP/RBP registers.
117   REG_INDEX_EBP = 5,
118   //! @brief ID for SI/ESI/RSI registers.
119   REG_INDEX_ESI = 6,
120   //! @brief ID for DI/EDI/RDI registers.
121   REG_INDEX_EDI = 7,
122
123 #if defined(ASMJIT_X64)
124   //! @brief ID for AX/EAX/RAX registers.
125   REG_INDEX_RAX = 0,
126   //! @brief ID for CX/ECX/RCX registers.
127   REG_INDEX_RCX = 1,
128   //! @brief ID for DX/EDX/RDX registers.
129   REG_INDEX_RDX = 2,
130   //! @brief ID for BX/EBX/RBX registers.
131   REG_INDEX_RBX = 3,
132   //! @brief ID for SP/ESP/RSP registers.
133   REG_INDEX_RSP = 4,
134   //! @brief ID for BP/EBP/RBP registers.
135   REG_INDEX_RBP = 5,
136   //! @brief ID for SI/ESI/RSI registers.
137   REG_INDEX_RSI = 6,
138   //! @brief ID for DI/EDI/RDI registers.
139   REG_INDEX_RDI = 7,
140
141   //! @brief ID for r8 register (additional register introduced by 64-bit architecture).
142   REG_INDEX_R8 = 8,
143   //! @brief ID for R9 register (additional register introduced by 64-bit architecture).
144   REG_INDEX_R9 = 9,
145   //! @brief ID for R10 register (additional register introduced by 64-bit architecture).
146   REG_INDEX_R10 = 10,
147   //! @brief ID for R11 register (additional register introduced by 64-bit architecture).
148   REG_INDEX_R11 = 11,
149   //! @brief ID for R12 register (additional register introduced by 64-bit architecture).
150   REG_INDEX_R12 = 12,
151   //! @brief ID for R13 register (additional register introduced by 64-bit architecture).
152   REG_INDEX_R13 = 13,
153   //! @brief ID for R14 register (additional register introduced by 64-bit architecture).
154   REG_INDEX_R14 = 14,
155   //! @brief ID for R15 register (additional register introduced by 64-bit architecture).
156   REG_INDEX_R15 = 15,
157 #endif // ASMJIT_X64
158
159   //! @brief ID for mm0 register.
160   REG_INDEX_MM0 = 0,
161   //! @brief ID for mm1 register.
162   REG_INDEX_MM1 = 1,
163   //! @brief ID for mm2 register.
164   REG_INDEX_MM2 = 2,
165   //! @brief ID for mm3 register.
166   REG_INDEX_MM3 = 3,
167   //! @brief ID for mm4 register.
168   REG_INDEX_MM4 = 4,
169   //! @brief ID for mm5 register.
170   REG_INDEX_MM5 = 5,
171   //! @brief ID for mm6 register.
172   REG_INDEX_MM6 = 6,
173   //! @brief ID for mm7 register.
174   REG_INDEX_MM7 = 7,
175
176   //! @brief ID for xmm0 register.
177   REG_INDEX_XMM0 = 0,
178   //! @brief ID for xmm1 register.
179   REG_INDEX_XMM1 = 1,
180   //! @brief ID for xmm2 register.
181   REG_INDEX_XMM2 = 2,
182   //! @brief ID for xmm3 register.
183   REG_INDEX_XMM3 = 3,
184   //! @brief ID for xmm4 register.
185   REG_INDEX_XMM4 = 4,
186   //! @brief ID for xmm5 register.
187   REG_INDEX_XMM5 = 5,
188   //! @brief ID for xmm6 register.
189   REG_INDEX_XMM6 = 6,
190   //! @brief ID for xmm7 register.
191   REG_INDEX_XMM7 = 7
192
193 #if defined(ASMJIT_X64)
194   ,
195
196   //! @brief ID for xmm8 register (additional register introduced by 64-bit architecture).
197   REG_INDEX_XMM8 = 8,
198   //! @brief ID for xmm9 register (additional register introduced by 64-bit architecture).
199   REG_INDEX_XMM9 = 9,
200   //! @brief ID for xmm10 register (additional register introduced by 64-bit architecture).
201   REG_INDEX_XMM10 = 10,
202   //! @brief ID for xmm11 register (additional register introduced by 64-bit architecture).
203   REG_INDEX_XMM11 = 11,
204   //! @brief ID for xmm12 register (additional register introduced by 64-bit architecture).
205   REG_INDEX_XMM12 = 12,
206   //! @brief ID for xmm13 register (additional register introduced by 64-bit architecture).
207   REG_INDEX_XMM13 = 13,
208   //! @brief ID for xmm14 register (additional register introduced by 64-bit architecture).
209   REG_INDEX_XMM14 = 14,
210   //! @brief ID for xmm15 register (additional register introduced by 64-bit architecture).
211   REG_INDEX_XMM15 = 15
212 #endif // ASMJIT_X64
213 };
214
215 // ============================================================================
216 // [AsmJit::REG_TYPE]
217 // ============================================================================
218
219 //! @brief Pseudo (not real X86) register types.
220 enum REG_TYPE
221 {
222   //! @brief Mask for register type.
223   REG_TYPE_MASK = 0xFF00,
224
225   // First byte contains register type (mask 0xFF00), Second byte contains
226   // register index code.
227
228   // --------------------------------------------------------------------------
229   // [GP Register Types]
230   // --------------------------------------------------------------------------
231
232   //! @brief 8-bit general purpose register type (LO).
233   REG_TYPE_GPB_LO = 0x0100,
234   //! @brief 8-bit general purpose register type (HI, only AH, BH, CH, DH).
235   REG_TYPE_GPB_HI = 0x0200,
236   //! @brief 16-bit general purpose register type.
237   REG_TYPE_GPW = 0x1000,
238   //! @brief 32-bit general purpose register type.
239   REG_TYPE_GPD = 0x2000,
240   //! @brief 64-bit general purpose register type.
241   REG_TYPE_GPQ = 0x3000,
242
243   //! @var REG_GPN
244   //! @brief 32-bit or 64-bit general purpose register type.
245
246   // native 32-bit or 64-bit register type (depends to x86 or x64 mode).
247 #if defined(ASMJIT_X86)
248   REG_TYPE_GPN = REG_TYPE_GPD,
249 #else
250   REG_TYPE_GPN = REG_TYPE_GPQ,
251 #endif
252
253   // --------------------------------------------------------------------------
254   // [X87 (FPU) Register Type]
255   // --------------------------------------------------------------------------
256
257   //! @brief X87 (FPU) register type.
258   REG_TYPE_X87 = 0x5000,
259
260   // --------------------------------------------------------------------------
261   // [MM Register Type]
262   // --------------------------------------------------------------------------
263
264   //! @brief 64-bit MM register type.
265   REG_TYPE_MM = 0x6000,
266
267   // --------------------------------------------------------------------------
268   // [XMM Register Type]
269   // --------------------------------------------------------------------------
270
271   //! @brief 128-bit XMM register type.
272   REG_TYPE_XMM = 0x7000
273 };
274
275 // ============================================================================
276 // [AsmJit::REG_CODE]
277 // ============================================================================
278
279 //! @brief Pseudo (not real X86) register codes used for generating opcodes.
280 //!
281 //! From this register code can be generated real x86 register ID, type of
282 //! register and size of register.
283 enum REG_CODE
284 {
285   // --------------------------------------------------------------------------
286   // [8-bit Registers]
287   // --------------------------------------------------------------------------
288
289   REG_AL = REG_TYPE_GPB_LO,
290   REG_CL,
291   REG_DL,
292   REG_BL,
293 #if defined(ASMJIT_X64)
294   REG_SPL,
295   REG_BPL,
296   REG_SIL,
297   REG_DIL,
298 #endif // ASMJIT_X64
299
300 #if defined(ASMJIT_X64)
301   REG_R8B,
302   REG_R9B,
303   REG_R10B,
304   REG_R11B,
305   REG_R12B,
306   REG_R13B,
307   REG_R14B,
308   REG_R15B,
309 #endif // ASMJIT_X64
310
311   REG_AH = REG_TYPE_GPB_HI,
312   REG_CH,
313   REG_DH,
314   REG_BH,
315
316   // --------------------------------------------------------------------------
317   // [16-bit Registers]
318   // --------------------------------------------------------------------------
319
320   REG_AX = REG_TYPE_GPW,
321   REG_CX,
322   REG_DX,
323   REG_BX,
324   REG_SP,
325   REG_BP,
326   REG_SI,
327   REG_DI,
328 #if defined(ASMJIT_X64)
329   REG_R8W,
330   REG_R9W,
331   REG_R10W,
332   REG_R11W,
333   REG_R12W,
334   REG_R13W,
335   REG_R14W,
336   REG_R15W,
337 #endif // ASMJIT_X64
338
339   // --------------------------------------------------------------------------
340   // [32-bit Registers]
341   // --------------------------------------------------------------------------
342
343   REG_EAX = REG_TYPE_GPD,
344   REG_ECX,
345   REG_EDX,
346   REG_EBX,
347   REG_ESP,
348   REG_EBP,
349   REG_ESI,
350   REG_EDI,
351 #if defined(ASMJIT_X64)
352   REG_R8D,
353   REG_R9D,
354   REG_R10D,
355   REG_R11D,
356   REG_R12D,
357   REG_R13D,
358   REG_R14D,
359   REG_R15D,
360 #endif // ASMJIT_X64
361
362   // --------------------------------------------------------------------------
363   // [64-bit Registers]
364   // --------------------------------------------------------------------------
365
366 #if defined(ASMJIT_X64)
367   REG_RAX = REG_TYPE_GPQ,
368   REG_RCX,
369   REG_RDX,
370   REG_RBX,
371   REG_RSP,
372   REG_RBP,
373   REG_RSI,
374   REG_RDI,
375   REG_R8,
376   REG_R9,
377   REG_R10,
378   REG_R11,
379   REG_R12,
380   REG_R13,
381   REG_R14,
382   REG_R15,
383 #endif // ASMJIT_X64
384
385   // --------------------------------------------------------------------------
386   // [MM Registers]
387   // --------------------------------------------------------------------------
388
389   REG_MM0 = REG_TYPE_MM,
390   REG_MM1,
391   REG_MM2,
392   REG_MM3,
393   REG_MM4,
394   REG_MM5,
395   REG_MM6,
396   REG_MM7,
397
398   // --------------------------------------------------------------------------
399   // [XMM Registers]
400   // --------------------------------------------------------------------------
401
402   REG_XMM0 = REG_TYPE_XMM,
403   REG_XMM1,
404   REG_XMM2,
405   REG_XMM3,
406   REG_XMM4,
407   REG_XMM5,
408   REG_XMM6,
409   REG_XMM7,
410 #if defined(ASMJIT_X64)
411   REG_XMM8,
412   REG_XMM9,
413   REG_XMM10,
414   REG_XMM11,
415   REG_XMM12,
416   REG_XMM13,
417   REG_XMM14,
418   REG_XMM15,
419 #endif // ASMJIT_X64
420
421   // --------------------------------------------------------------------------
422   // [Native registers (depends if processor runs in 32-bit or 64-bit mode)]
423   // --------------------------------------------------------------------------
424
425   REG_NAX = REG_TYPE_GPN,
426   REG_NCX,
427   REG_NDX,
428   REG_NBX,
429   REG_NSP,
430   REG_NBP,
431   REG_NSI,
432   REG_NDI
433 };
434
435 // ============================================================================
436 // [AsmJit::SEGMENT_PREFIX]
437 // ============================================================================
438
439 //! @brief Segment override prefixes.
440 enum SEGMENT_PREFIX
441 {
442   // DO NOT MODIFY INDEX CODES - They are used by logger in this order.
443
444   //! @brief No segment override prefix.
445   SEGMENT_NONE = 0,
446   //! @brief Use 'cs' segment override prefix.
447   SEGMENT_CS = 1,
448   //! @brief Use 'ss' segment override prefix.
449   SEGMENT_SS = 2,
450   //! @brief Use 'ds' segment override prefix.
451   SEGMENT_DS = 3,
452   //! @brief Use 'es' segment override prefix.
453   SEGMENT_ES = 4,
454   //! @brief Use 'fs' segment override prefix.
455   SEGMENT_FS = 5,
456   //! @brief Use 'gs' segment override prefix.
457   SEGMENT_GS = 6,
458   //! @brief End of prefix codes
459   _SEGMENT_END
460 };
461
462 // ============================================================================
463 // [AsmJit::PREFETCH_HINT]
464 // ============================================================================
465
466 //! @brief Prefetch hints.
467 enum PREFETCH_HINT
468 {
469   //! @brief Prefetch to L0 cache.
470   PREFETCH_T0  = 1,
471   //! @brief Prefetch to L1 cache.
472   PREFETCH_T1  = 2,
473   //! @brief Prefetch to L2 cache.
474   PREFETCH_T2  = 3,
475   //! @brief Prefetch using NT hint.
476   PREFETCH_NTA = 0
477 };
478
479 // ============================================================================
480 // [AsmJit::CONDITION]
481 // ============================================================================
482
483 //! @brief Condition codes.
484 enum CONDITION
485 {
486   //! @brief No condition code.
487   C_NO_CONDITION  = -1,
488
489   // Condition codes from processor manuals.
490   C_A             = 0x7,
491   C_AE            = 0x3,
492   C_B             = 0x2,
493   C_BE            = 0x6,
494   C_C             = 0x2,
495   C_E             = 0x4,
496   C_G             = 0xF,
497   C_GE            = 0xD,
498   C_L             = 0xC,
499   C_LE            = 0xE,
500   C_NA            = 0x6,
501   C_NAE           = 0x2,
502   C_NB            = 0x3,
503   C_NBE           = 0x7,
504   C_NC            = 0x3,
505   C_NE            = 0x5,
506   C_NG            = 0xE,
507   C_NGE           = 0xC,
508   C_NL            = 0xD,
509   C_NLE           = 0xF,
510   C_NO            = 0x1,
511   C_NP            = 0xB,
512   C_NS            = 0x9,
513   C_NZ            = 0x5,
514   C_O             = 0x0,
515   C_P             = 0xA,
516   C_PE            = 0xA,
517   C_PO            = 0xB,
518   C_S             = 0x8,
519   C_Z             = 0x4,
520
521   // Simplified condition codes
522   C_OVERFLOW      = 0x0,
523   C_NO_OVERFLOW   = 0x1,
524   C_BELOW         = 0x2,
525   C_ABOVE_EQUAL   = 0x3,
526   C_EQUAL         = 0x4,
527   C_NOT_EQUAL     = 0x5,
528   C_BELOW_EQUAL   = 0x6,
529   C_ABOVE         = 0x7,
530   C_SIGN          = 0x8,
531   C_NOT_SIGN      = 0x9,
532   C_PARITY_EVEN   = 0xA,
533   C_PARITY_ODD    = 0xB,
534   C_LESS          = 0xC,
535   C_GREATER_EQUAL = 0xD,
536   C_LESS_EQUAL    = 0xE,
537   C_GREATER       = 0xF,
538
539   // aliases
540   C_ZERO          = 0x4,
541   C_NOT_ZERO      = 0x5,
542   C_NEGATIVE      = 0x8,
543   C_POSITIVE      = 0x9,
544
545   // x87 floating point only
546   C_FP_UNORDERED  = 16,
547   C_FP_NOT_UNORDERED = 17
548 };
549
550 //! @brief  Returns the equivalent of !cc.
551 //!
552 //! Negation of the default no_condition (-1) results in a non-default
553 //! no_condition value (-2). As long as tests for no_condition check
554 //! for condition < 0, this will work as expected.
555 static inline CONDITION negateCondition(CONDITION cc)
556 {
557   return static_cast<CONDITION>(cc ^ 1);
558 }
559
560 //! @brief Corresponds to transposing the operands of a comparison.
561 static inline CONDITION reverseCondition(CONDITION cc)
562 {
563   switch (cc) {
564     case C_BELOW:
565       return C_ABOVE;
566     case C_ABOVE:
567       return C_BELOW;
568     case C_ABOVE_EQUAL:
569       return C_BELOW_EQUAL;
570     case C_BELOW_EQUAL:
571       return C_ABOVE_EQUAL;
572     case C_LESS:
573       return C_GREATER;
574     case C_GREATER:
575       return C_LESS;
576     case C_GREATER_EQUAL:
577       return C_LESS_EQUAL;
578     case C_LESS_EQUAL:
579       return C_GREATER_EQUAL;
580     default:
581       return cc;
582   };
583 }
584
585 struct ASMJIT_API ConditionToInstruction
586 {
587   //! @brief Used to map condition code to jcc instructions.
588   static const uint32_t _jcctable[16];
589   //! @brief Used to map condition code to cmovcc instructions.
590   static const uint32_t _cmovcctable[16];
591   //! @brief Used to map condition code to setcc instructions.
592   static const uint32_t _setcctable[16];
593
594   //! @brief Translate condition code @a cc to jcc instruction code.
595   //! @sa @c INST_CODE, @c INST_J.
596   static inline uint32_t toJCC(CONDITION cc) ASMJIT_NOTHROW
597   {
598     ASMJIT_ASSERT(static_cast<uint32_t>(cc) <= 0xF);
599     return _jcctable[cc];
600   }
601
602   //! @brief Translate condition code @a cc to cmovcc instruction code.
603   //! @sa @c INST_CODE, @c INST_CMOV.
604   static inline uint32_t toCMovCC(CONDITION cc) ASMJIT_NOTHROW
605   {
606     ASMJIT_ASSERT(static_cast<uint32_t>(cc) <= 0xF);
607     return _cmovcctable[cc];
608   }
609
610   //! @brief Translate condition code @a cc to setcc instruction code.
611   //! @sa @c INST_CODE, @c INST_SET.
612   static inline uint32_t toSetCC(CONDITION cc) ASMJIT_NOTHROW
613   {
614     ASMJIT_ASSERT(static_cast<uint32_t>(cc) <= 0xF);
615     return _setcctable[cc];
616   }
617 };
618
619 // ============================================================================
620 // [AsmJit::SCALE]
621 // ============================================================================
622
623 //! @brief Scale, can be used for addressing.
624 //!
625 //! See @c Op and addressing methods like @c byte_ptr(), @c word_ptr(),
626 //! @c dword_ptr(), etc...
627 enum SCALE
628 {
629   //! @brief Scale 1 times (no scale).
630   TIMES_1 = 0,
631   //! @brief Scale 2 times (same as shifting to left by 1).
632   TIMES_2 = 1,
633   //! @brief Scale 4 times (same as shifting to left by 2).
634   TIMES_4 = 2,
635   //! @brief Scale 8 times (same as shifting to left by 3).
636   TIMES_8 = 3
637 };
638
639 // ============================================================================
640 // [AsmJit::HINT]
641 // ============================================================================
642
643 //! @brief Condition hint, see @c AsmJit::Assembler::jz(), @c AsmJit::Compiler::jz()
644 //! and friends.
645 enum HINT
646 {
647   //! @brief No hint.
648   HINT_NONE = 0x00,
649   //! @brief Condition will be taken (likely).
650   HINT_TAKEN = 0x01,
651   //! @brief Condition will be not taken (unlikely).
652   HINT_NOT_TAKEN = 0x02
653 };
654
655 //! @brief Hint byte value is the byte that will be emitted if hint flag
656 //! is specified by @c HINT.
657 enum HINT_BYTE_VALUE
658 {
659   //! @brief Condition will be taken (likely).
660   HINT_BYTE_VALUE_TAKEN = 0x3E,
661   //! @brief Condition will be not taken (unlikely).
662   HINT_BYTE_VALUE_NOT_TAKEN = 0x2E
663 };
664
665 // ============================================================================
666 // [AsmJit::FP_STATUS]
667 // ============================================================================
668
669 //! @brief Floating point status.
670 enum FP_STATUS
671 {
672   FP_C0 = 0x100,
673   FP_C1 = 0x200,
674   FP_C2 = 0x400,
675   FP_C3 = 0x4000,
676   FP_CC_MASK = 0x4500
677 };
678
679 // ============================================================================
680 // [AsmJit::FP_CW]
681 // ============================================================================
682
683 //! @brief Floating point control word.
684 enum FP_CW
685 {
686   FP_CW_INVOPEX_MASK  = 0x001,
687   FP_CW_DENOPEX_MASK  = 0x002,
688   FP_CW_ZERODIV_MASK  = 0x004,
689   FP_CW_OVFEX_MASK    = 0x008,
690   FP_CW_UNDFEX_MASK   = 0x010,
691   FP_CW_PRECEX_MASK   = 0x020,
692   FP_CW_PRECC_MASK    = 0x300,
693   FP_CW_ROUNDC_MASK   = 0xC00,
694
695   // Values for precision control.
696   FP_CW_PREC_SINGLE   = 0x000,
697   FP_CW_PREC_DOUBLE   = 0x200,
698   FP_CW_PREC_EXTENDED = 0x300,
699
700   // Values for rounding control.
701   FP_CW_ROUND_NEAREST = 0x000,
702   FP_CW_ROUND_DOWN    = 0x400,
703   FP_CW_ROUND_UP      = 0x800,
704   FP_CW_ROUND_TOZERO  = 0xC00
705 };
706
707 // ============================================================================
708 // [AsmJit::INST_CODE]
709 // ============================================================================
710
711 //! @brief Instruction codes.
712 //!
713 //! Note that these instruction codes are AsmJit specific. Each instruction is
714 //! unique ID into AsmJit instruction table. Instruction codes are used together
715 //! with AsmJit::Assembler and you can also use instruction codes to serialize
716 //! instructions by @ref AssemblerCore::_emitInstruction() or
717 //! @ref CompilerCore::_emitInstruction()
718 enum INST_CODE
719 {
720   INST_ADC,           // X86/X64
721   INST_ADD,           // X86/X64
722   INST_ADDPD,
723   INST_ADDPS,
724   INST_ADDSD,
725   INST_ADDSS,
726   INST_ADDSUBPD,
727   INST_ADDSUBPS,
728   INST_AMD_PREFETCH,
729   INST_AMD_PREFETCHW,
730   INST_AND,           // X86/X64
731   INST_ANDNPD,
732   INST_ANDNPS,
733   INST_ANDPD,
734   INST_ANDPS,
735   INST_BLENDPD,
736   INST_BLENDPS,
737   INST_BLENDVPD,
738   INST_BLENDVPS,
739   INST_BSF,           // X86/X64
740   INST_BSR,           // X86/X64
741   INST_BSWAP,         // X86/X64 (i486)
742   INST_BT,            // X86/X64
743   INST_BTC,           // X86/X64
744   INST_BTR,           // X86/X64
745   INST_BTS,           // X86/X64
746   INST_CALL,          // X86/X64
747   INST_CBW,           // X86/X64
748   INST_CDQE,          // X64 only
749   INST_CLC,           // X86/X64
750   INST_CLD,           // X86/X64
751   INST_CLFLUSH,
752   INST_CMC,           // X86/X64
753
754   INST_CMOV,          // Begin (cmovcc) (i586)
755   INST_CMOVA = INST_CMOV, //X86/X64 (cmovcc) (i586)
756   INST_CMOVAE,        // X86/X64 (cmovcc) (i586)
757   INST_CMOVB,         // X86/X64 (cmovcc) (i586)
758   INST_CMOVBE,        // X86/X64 (cmovcc) (i586)
759   INST_CMOVC,         // X86/X64 (cmovcc) (i586)
760   INST_CMOVE,         // X86/X64 (cmovcc) (i586)
761   INST_CMOVG,         // X86/X64 (cmovcc) (i586)
762   INST_CMOVGE,        // X86/X64 (cmovcc) (i586)
763   INST_CMOVL,         // X86/X64 (cmovcc) (i586)
764   INST_CMOVLE,        // X86/X64 (cmovcc) (i586)
765   INST_CMOVNA,        // X86/X64 (cmovcc) (i586)
766   INST_CMOVNAE,       // X86/X64 (cmovcc) (i586)
767   INST_CMOVNB,        // X86/X64 (cmovcc) (i586)
768   INST_CMOVNBE,       // X86/X64 (cmovcc) (i586)
769   INST_CMOVNC,        // X86/X64 (cmovcc) (i586)
770   INST_CMOVNE,        // X86/X64 (cmovcc) (i586)
771   INST_CMOVNG,        // X86/X64 (cmovcc) (i586)
772   INST_CMOVNGE,       // X86/X64 (cmovcc) (i586)
773   INST_CMOVNL,        // X86/X64 (cmovcc) (i586)
774   INST_CMOVNLE,       // X86/X64 (cmovcc) (i586)
775   INST_CMOVNO,        // X86/X64 (cmovcc) (i586)
776   INST_CMOVNP,        // X86/X64 (cmovcc) (i586)
777   INST_CMOVNS,        // X86/X64 (cmovcc) (i586)
778   INST_CMOVNZ,        // X86/X64 (cmovcc) (i586)
779   INST_CMOVO,         // X86/X64 (cmovcc) (i586)
780   INST_CMOVP,         // X86/X64 (cmovcc) (i586)
781   INST_CMOVPE,        // X86/X64 (cmovcc) (i586)
782   INST_CMOVPO,        // X86/X64 (cmovcc) (i586)
783   INST_CMOVS,         // X86/X64 (cmovcc) (i586)
784   INST_CMOVZ,         // X86/X64 (cmovcc) (i586)
785
786   INST_CMP,           // X86/X64
787   INST_CMPPD,
788   INST_CMPPS,
789   INST_CMPSD,
790   INST_CMPSS,
791   INST_CMPXCHG,       // X86/X64 (i486)
792   INST_CMPXCHG16B,    // X64 only
793   INST_CMPXCHG8B,     // X86/X64 (i586)
794   INST_COMISD,
795   INST_COMISS,
796   INST_CPUID,         // X86/X64 (i486)
797   INST_CRC32,
798   INST_CVTDQ2PD,
799   INST_CVTDQ2PS,
800   INST_CVTPD2DQ,
801   INST_CVTPD2PI,
802   INST_CVTPD2PS,
803   INST_CVTPI2PD,
804   INST_CVTPI2PS,
805   INST_CVTPS2DQ,
806   INST_CVTPS2PD,
807   INST_CVTPS2PI,
808   INST_CVTSD2SI,
809   INST_CVTSD2SS,
810   INST_CVTSI2SD,
811   INST_CVTSI2SS,
812   INST_CVTSS2SD,
813   INST_CVTSS2SI,
814   INST_CVTTPD2DQ,
815   INST_CVTTPD2PI,
816   INST_CVTTPS2DQ,
817   INST_CVTTPS2PI,
818   INST_CVTTSD2SI,
819   INST_CVTTSS2SI,
820   INST_CWDE,          // X86/X64
821   INST_DAA,           // X86 only
822   INST_DAS,           // X86 only
823   INST_DEC,           // X86/X64
824   INST_DIV,           // X86/X64
825   INST_DIVPD,
826   INST_DIVPS,
827   INST_DIVSD,
828   INST_DIVSS,
829   INST_DPPD,
830   INST_DPPS,
831   INST_EMMS,          // MMX
832   INST_ENTER,         // X86/X64
833   INST_EXTRACTPS,
834   INST_F2XM1,         // X87
835   INST_FABS,          // X87
836   INST_FADD,          // X87
837   INST_FADDP,         // X87
838   INST_FBLD,          // X87
839   INST_FBSTP,         // X87
840   INST_FCHS,          // X87
841   INST_FCLEX,         // X87
842   INST_FCMOVB,        // X87
843   INST_FCMOVBE,       // X87
844   INST_FCMOVE,        // X87
845   INST_FCMOVNB,       // X87
846   INST_FCMOVNBE,      // X87
847   INST_FCMOVNE,       // X87
848   INST_FCMOVNU,       // X87
849   INST_FCMOVU,        // X87
850   INST_FCOM,          // X87
851   INST_FCOMI,         // X87
852   INST_FCOMIP,        // X87
853   INST_FCOMP,         // X87
854   INST_FCOMPP,        // X87
855   INST_FCOS,          // X87
856   INST_FDECSTP,       // X87
857   INST_FDIV,          // X87
858   INST_FDIVP,         // X87
859   INST_FDIVR,         // X87
860   INST_FDIVRP,        // X87
861   INST_FEMMS,         // 3dNow!
862   INST_FFREE,         // X87
863   INST_FIADD,         // X87
864   INST_FICOM,         // X87
865   INST_FICOMP,        // X87
866   INST_FIDIV,         // X87
867   INST_FIDIVR,        // X87
868   INST_FILD,          // X87
869   INST_FIMUL,         // X87
870   INST_FINCSTP,       // X87
871   INST_FINIT,         // X87
872   INST_FIST,          // X87
873   INST_FISTP,         // X87
874   INST_FISTTP,
875   INST_FISUB,         // X87
876   INST_FISUBR,        // X87
877   INST_FLD,           // X87
878   INST_FLD1,          // X87
879   INST_FLDCW,         // X87
880   INST_FLDENV,        // X87
881   INST_FLDL2E,        // X87
882   INST_FLDL2T,        // X87
883   INST_FLDLG2,        // X87
884   INST_FLDLN2,        // X87
885   INST_FLDPI,         // X87
886   INST_FLDZ,          // X87
887   INST_FMUL,          // X87
888   INST_FMULP,         // X87
889   INST_FNCLEX,        // X87
890   INST_FNINIT,        // X87
891   INST_FNOP,          // X87
892   INST_FNSAVE,        // X87
893   INST_FNSTCW,        // X87
894   INST_FNSTENV,       // X87
895   INST_FNSTSW,        // X87
896   INST_FPATAN,        // X87
897   INST_FPREM,         // X87
898   INST_FPREM1,        // X87
899   INST_FPTAN,         // X87
900   INST_FRNDINT,       // X87
901   INST_FRSTOR,        // X87
902   INST_FSAVE,         // X87
903   INST_FSCALE,        // X87
904   INST_FSIN,          // X87
905   INST_FSINCOS,       // X87
906   INST_FSQRT,         // X87
907   INST_FST,           // X87
908   INST_FSTCW,         // X87
909   INST_FSTENV,        // X87
910   INST_FSTP,          // X87
911   INST_FSTSW,         // X87
912   INST_FSUB,          // X87
913   INST_FSUBP,         // X87
914   INST_FSUBR,         // X87
915   INST_FSUBRP,        // X87
916   INST_FTST,          // X87
917   INST_FUCOM,         // X87
918   INST_FUCOMI,        // X87
919   INST_FUCOMIP,       // X87
920   INST_FUCOMP,        // X87
921   INST_FUCOMPP,       // X87
922   INST_FWAIT,         // X87
923   INST_FXAM,          // X87
924   INST_FXCH,          // X87
925   INST_FXRSTOR,       // X87
926   INST_FXSAVE,        // X87
927   INST_FXTRACT,       // X87
928   INST_FYL2X,         // X87
929   INST_FYL2XP1,       // X87
930   INST_HADDPD,
931   INST_HADDPS,
932   INST_HSUBPD,
933   INST_HSUBPS,
934   INST_IDIV,          // X86/X64
935   INST_IMUL,          // X86/X64
936   INST_INC,           // X86/X64
937   INST_INT3,          // X86/X64
938   INST_J,             // Begin (jcc)
939   INST_JA = 
940     INST_J,           // X86/X64 (jcc)
941   INST_JAE,           // X86/X64 (jcc)
942   INST_JB,            // X86/X64 (jcc)
943   INST_JBE,           // X86/X64 (jcc)
944   INST_JC,            // X86/X64 (jcc)
945   INST_JE,            // X86/X64 (jcc)
946   INST_JG,            // X86/X64 (jcc)
947   INST_JGE,           // X86/X64 (jcc)
948   INST_JL,            // X86/X64 (jcc)
949   INST_JLE,           // X86/X64 (jcc)
950   INST_JNA,           // X86/X64 (jcc)
951   INST_JNAE,          // X86/X64 (jcc)
952   INST_JNB,           // X86/X64 (jcc)
953   INST_JNBE,          // X86/X64 (jcc)
954   INST_JNC,           // X86/X64 (jcc)
955   INST_JNE,           // X86/X64 (jcc)
956   INST_JNG,           // X86/X64 (jcc)
957   INST_JNGE,          // X86/X64 (jcc)
958   INST_JNL,           // X86/X64 (jcc)
959   INST_JNLE,          // X86/X64 (jcc)
960   INST_JNO,           // X86/X64 (jcc)
961   INST_JNP,           // X86/X64 (jcc)
962   INST_JNS,           // X86/X64 (jcc)
963   INST_JNZ,           // X86/X64 (jcc)
964   INST_JO,            // X86/X64 (jcc)
965   INST_JP,            // X86/X64 (jcc)
966   INST_JPE,           // X86/X64 (jcc)
967   INST_JPO,           // X86/X64 (jcc)
968   INST_JS,            // X86/X64 (jcc)
969   INST_JZ,            // X86/X64 (jcc)
970   INST_JMP,           // X86/X64 (jmp)
971   INST_LDDQU,
972   INST_LDMXCSR,
973   INST_LAHF,          // X86/X64 (CPUID NEEDED)
974   INST_LEA,           // X86/X64
975   INST_LEAVE,         // X86/X64
976   INST_LFENCE,
977   INST_MASKMOVDQU,
978   INST_MASKMOVQ,      // MMX Extensions
979   INST_MAXPD,
980   INST_MAXPS,
981   INST_MAXSD,
982   INST_MAXSS,
983   INST_MFENCE,
984   INST_MINPD,
985   INST_MINPS,
986   INST_MINSD,
987   INST_MINSS,
988   INST_MONITOR,
989   INST_MOV,           // X86/X64
990   INST_MOVAPD,
991   INST_MOVAPS,
992   INST_MOVBE,
993   INST_MOVD,
994   INST_MOVDDUP,
995   INST_MOVDQ2Q,
996   INST_MOVDQA,
997   INST_MOVDQU,
998   INST_MOVHLPS,
999   INST_MOVHPD,
1000   INST_MOVHPS,
1001   INST_MOVLHPS,
1002   INST_MOVLPD,
1003   INST_MOVLPS,
1004   INST_MOVMSKPD,
1005   INST_MOVMSKPS,
1006   INST_MOVNTDQ,
1007   INST_MOVNTDQA,
1008   INST_MOVNTI,
1009   INST_MOVNTPD,
1010   INST_MOVNTPS,
1011   INST_MOVNTQ,        // MMX Extensions
1012   INST_MOVQ,
1013   INST_MOVQ2DQ,
1014   INST_MOVSD,
1015   INST_MOVSHDUP,
1016   INST_MOVSLDUP,
1017   INST_MOVSS,
1018   INST_MOVSX,         // X86/X64
1019   INST_MOVSXD,        // X86/X64
1020   INST_MOVUPD,
1021   INST_MOVUPS,
1022   INST_MOVZX,         // X86/X64
1023   INST_MOV_PTR,       // X86/X64
1024   INST_MPSADBW,
1025   INST_MUL,           // X86/X64
1026   INST_MULPD,
1027   INST_MULPS,
1028   INST_MULSD,
1029   INST_MULSS,
1030   INST_MWAIT,
1031   INST_NEG,           // X86/X64
1032   INST_NOP,           // X86/X64
1033   INST_NOT,           // X86/X64
1034   INST_OR,            // X86/X64
1035   INST_ORPD,
1036   INST_ORPS,
1037   INST_PABSB,
1038   INST_PABSD,
1039   INST_PABSW,
1040   INST_PACKSSDW,
1041   INST_PACKSSWB,
1042   INST_PACKUSDW,
1043   INST_PACKUSWB,
1044   INST_PADDB,
1045   INST_PADDD,
1046   INST_PADDQ,
1047   INST_PADDSB,
1048   INST_PADDSW,
1049   INST_PADDUSB,
1050   INST_PADDUSW,
1051   INST_PADDW,
1052   INST_PALIGNR,
1053   INST_PAND,
1054   INST_PANDN,
1055   INST_PAUSE,
1056   INST_PAVGB,         // MMX Extensions
1057   INST_PAVGW,         // MMX Extensions
1058   INST_PBLENDVB,
1059   INST_PBLENDW,
1060   INST_PCMPEQB,
1061   INST_PCMPEQD,
1062   INST_PCMPEQQ,
1063   INST_PCMPEQW,
1064   INST_PCMPESTRI,
1065   INST_PCMPESTRM,
1066   INST_PCMPGTB,
1067   INST_PCMPGTD,
1068   INST_PCMPGTQ,
1069   INST_PCMPGTW,
1070   INST_PCMPISTRI,
1071   INST_PCMPISTRM,
1072   INST_PEXTRB,
1073   INST_PEXTRD,
1074   INST_PEXTRQ,
1075   INST_PEXTRW,        // MMX Extensions
1076   INST_PF2ID,         // 3dNow!
1077   INST_PF2IW,         // 3dNow! Extensions
1078   INST_PFACC,         // 3dNow!
1079   INST_PFADD,         // 3dNow!
1080   INST_PFCMPEQ,       // 3dNow!
1081   INST_PFCMPGE,       // 3dNow!
1082   INST_PFCMPGT,       // 3dNow!
1083   INST_PFMAX,         // 3dNow!
1084   INST_PFMIN,         // 3dNow!
1085   INST_PFMUL,         // 3dNow!
1086   INST_PFNACC,        // 3dNow! Extensions
1087   INST_PFPNACC,       // 3dNow! Extensions
1088   INST_PFRCP,         // 3dNow!
1089   INST_PFRCPIT1,      // 3dNow!
1090   INST_PFRCPIT2,      // 3dNow!
1091   INST_PFRSQIT1,      // 3dNow!
1092   INST_PFRSQRT,       // 3dNow!
1093   INST_PFSUB,         // 3dNow!
1094   INST_PFSUBR,        // 3dNow!
1095   INST_PHADDD,
1096   INST_PHADDSW,
1097   INST_PHADDW,
1098   INST_PHMINPOSUW,
1099   INST_PHSUBD,
1100   INST_PHSUBSW,
1101   INST_PHSUBW,
1102   INST_PI2FD,         // 3dNow!
1103   INST_PI2FW,         // 3dNow! Extensions
1104   INST_PINSRB,
1105   INST_PINSRD,
1106   INST_PINSRQ,
1107   INST_PINSRW,        // MMX Extensions
1108   INST_PMADDUBSW,
1109   INST_PMADDWD,
1110   INST_PMAXSB,
1111   INST_PMAXSD,
1112   INST_PMAXSW,        // MMX Extensions
1113   INST_PMAXUB,        // MMX Extensions
1114   INST_PMAXUD,
1115   INST_PMAXUW,
1116   INST_PMINSB,
1117   INST_PMINSD,
1118   INST_PMINSW,        // MMX Extensions
1119   INST_PMINUB,        // MMX Extensions
1120   INST_PMINUD,
1121   INST_PMINUW,
1122   INST_PMOVMSKB,      // MMX Extensions
1123   INST_PMOVSXBD,
1124   INST_PMOVSXBQ,
1125   INST_PMOVSXBW,
1126   INST_PMOVSXDQ,
1127   INST_PMOVSXWD,
1128   INST_PMOVSXWQ,
1129   INST_PMOVZXBD,
1130   INST_PMOVZXBQ,
1131   INST_PMOVZXBW,
1132   INST_PMOVZXDQ,
1133   INST_PMOVZXWD,
1134   INST_PMOVZXWQ,
1135   INST_PMULDQ,
1136   INST_PMULHRSW,
1137   INST_PMULHUW,       // MMX Extensions
1138   INST_PMULHW,
1139   INST_PMULLD,
1140   INST_PMULLW,
1141   INST_PMULUDQ,
1142   INST_POP,           // X86/X64
1143   INST_POPAD,         // X86 only
1144   INST_POPCNT,
1145   INST_POPFD,         // X86 only
1146   INST_POPFQ,         // X64 only
1147   INST_POR,
1148   INST_PREFETCH,      // MMX Extensions
1149   INST_PSADBW,        // MMX Extensions
1150   INST_PSHUFB,
1151   INST_PSHUFD,
1152   INST_PSHUFW,        // MMX Extensions
1153   INST_PSHUFHW,
1154   INST_PSHUFLW,
1155   INST_PSIGNB,
1156   INST_PSIGND,
1157   INST_PSIGNW,
1158   INST_PSLLD,
1159   INST_PSLLDQ,
1160   INST_PSLLQ,
1161   INST_PSLLW,
1162   INST_PSRAD,
1163   INST_PSRAW,
1164   INST_PSRLD,
1165   INST_PSRLDQ,
1166   INST_PSRLQ,
1167   INST_PSRLW,
1168   INST_PSUBB,
1169   INST_PSUBD,
1170   INST_PSUBQ,
1171   INST_PSUBSB,
1172   INST_PSUBSW,
1173   INST_PSUBUSB,
1174   INST_PSUBUSW,
1175   INST_PSUBW,
1176   INST_PSWAPD,        // 3dNow! Extensions
1177   INST_PTEST,
1178   INST_PUNPCKHBW,
1179   INST_PUNPCKHDQ,
1180   INST_PUNPCKHQDQ,
1181   INST_PUNPCKHWD,
1182   INST_PUNPCKLBW,
1183   INST_PUNPCKLDQ,
1184   INST_PUNPCKLQDQ,
1185   INST_PUNPCKLWD,
1186   INST_PUSH,          // X86/X64
1187   INST_PUSHAD,        // X86 only
1188   INST_PUSHFD,        // X86 only
1189   INST_PUSHFQ,        // X64 only
1190   INST_PXOR,
1191   INST_RCL,           // X86/X64
1192   INST_RCPPS,
1193   INST_RCPSS,
1194   INST_RCR,           // X86/X64
1195   INST_RDTSC,         // X86/X64
1196   INST_RDTSCP,        // X86/X64
1197   INST_REP_LODSB,     // X86/X64 (REP)
1198   INST_REP_LODSD,     // X86/X64 (REP)
1199   INST_REP_LODSQ,     // X64 only (REP)
1200   INST_REP_LODSW,     // X86/X64 (REP)
1201   INST_REP_MOVSB,     // X86/X64 (REP)
1202   INST_REP_MOVSD,     // X86/X64 (REP)
1203   INST_REP_MOVSQ,     // X64 only (REP)
1204   INST_REP_MOVSW,     // X86/X64 (REP)
1205   INST_REP_STOSB,     // X86/X64 (REP)
1206   INST_REP_STOSD,     // X86/X64 (REP)
1207   INST_REP_STOSQ,     // X64 only (REP)
1208   INST_REP_STOSW,     // X86/X64 (REP)
1209   INST_REPE_CMPSB,    // X86/X64 (REP)
1210   INST_REPE_CMPSD,    // X86/X64 (REP)
1211   INST_REPE_CMPSQ,    // X64 only (REP)
1212   INST_REPE_CMPSW,    // X86/X64 (REP)
1213   INST_REPE_SCASB,    // X86/X64 (REP)
1214   INST_REPE_SCASD,    // X86/X64 (REP)
1215   INST_REPE_SCASQ,    // X64 only (REP)
1216   INST_REPE_SCASW,    // X86/X64 (REP)
1217   INST_REPNE_CMPSB,   // X86/X64 (REP)
1218   INST_REPNE_CMPSD,   // X86/X64 (REP)
1219   INST_REPNE_CMPSQ,   // X64 only (REP)
1220   INST_REPNE_CMPSW,   // X86/X64 (REP)
1221   INST_REPNE_SCASB,   // X86/X64 (REP)
1222   INST_REPNE_SCASD,   // X86/X64 (REP)
1223   INST_REPNE_SCASQ,   // X64 only (REP)
1224   INST_REPNE_SCASW,   // X86/X64 (REP)
1225   INST_RET,           // X86/X64
1226   INST_ROL,           // X86/X64
1227   INST_ROR,           // X86/X64
1228   INST_ROUNDPD,
1229   INST_ROUNDPS,
1230   INST_ROUNDSD,
1231   INST_ROUNDSS,
1232   INST_RSQRTPS,
1233   INST_RSQRTSS,
1234   INST_SAHF,          // X86/X64 (CPUID NEEDED)
1235   INST_SAL,           // X86/X64
1236   INST_SAR,           // X86/X64
1237   INST_SBB,           // X86/X64
1238   INST_SET,           // Begin (setcc)
1239   INST_SETA=INST_SET, // X86/X64 (setcc)
1240   INST_SETAE,         // X86/X64 (setcc)
1241   INST_SETB,          // X86/X64 (setcc)
1242   INST_SETBE,         // X86/X64 (setcc)
1243   INST_SETC,          // X86/X64 (setcc)
1244   INST_SETE,          // X86/X64 (setcc)
1245   INST_SETG,          // X86/X64 (setcc)
1246   INST_SETGE,         // X86/X64 (setcc)
1247   INST_SETL,          // X86/X64 (setcc)
1248   INST_SETLE,         // X86/X64 (setcc)
1249   INST_SETNA,         // X86/X64 (setcc)
1250   INST_SETNAE,        // X86/X64 (setcc)
1251   INST_SETNB,         // X86/X64 (setcc)
1252   INST_SETNBE,        // X86/X64 (setcc)
1253   INST_SETNC,         // X86/X64 (setcc)
1254   INST_SETNE,         // X86/X64 (setcc)
1255   INST_SETNG,         // X86/X64 (setcc)
1256   INST_SETNGE,        // X86/X64 (setcc)
1257   INST_SETNL,         // X86/X64 (setcc)
1258   INST_SETNLE,        // X86/X64 (setcc)
1259   INST_SETNO,         // X86/X64 (setcc)
1260   INST_SETNP,         // X86/X64 (setcc)
1261   INST_SETNS,         // X86/X64 (setcc)
1262   INST_SETNZ,         // X86/X64 (setcc)
1263   INST_SETO,          // X86/X64 (setcc)
1264   INST_SETP,          // X86/X64 (setcc)
1265   INST_SETPE,         // X86/X64 (setcc)
1266   INST_SETPO,         // X86/X64 (setcc)
1267   INST_SETS,          // X86/X64 (setcc)
1268   INST_SETZ,          // X86/X64 (setcc)
1269   INST_SFENCE,        // MMX Extensions
1270   INST_SHL,           // X86/X64
1271   INST_SHLD,          // X86/X64
1272   INST_SHR,           // X86/X64
1273   INST_SHRD,          // X86/X64
1274   INST_SHUFPD,
1275   INST_SHUFPS,
1276   INST_SQRTPD,
1277   INST_SQRTPS,
1278   INST_SQRTSD,
1279   INST_SQRTSS,
1280   INST_STC,           // X86/X64
1281   INST_STD,           // X86/X64
1282   INST_STMXCSR,
1283   INST_SUB,           // X86/X64
1284   INST_SUBPD,
1285   INST_SUBPS,
1286   INST_SUBSD,
1287   INST_SUBSS,
1288   INST_TEST,          // X86/X64
1289   INST_UCOMISD,
1290   INST_UCOMISS,
1291   INST_UD2,           // X86/X64
1292   INST_UNPCKHPD,
1293   INST_UNPCKHPS,
1294   INST_UNPCKLPD,
1295   INST_UNPCKLPS,
1296   INST_XADD,          // X86/X64 (i486)
1297   INST_XCHG,          // X86/X64 (i386)
1298   INST_XOR,           // X86/X64
1299   INST_XORPD,
1300   INST_XORPS,
1301
1302   _INST_COUNT,
1303
1304   _INST_J_BEGIN = INST_J,
1305   _INST_J_END = INST_JMP
1306 };
1307
1308 // ============================================================================
1309 // [AsmJit::Instruction Name]
1310 // ============================================================================
1311
1312 //! @internal
1313 //! 
1314 //! @brief Instruction names.
1315 ASMJIT_API extern const char instructionName[];
1316
1317 // ============================================================================
1318 // [AsmJit::Instruction Description]
1319 // ============================================================================
1320
1321 struct InstructionDescription
1322 {
1323   // --------------------------------------------------------------------------
1324   // [Instruction Groups]
1325   // --------------------------------------------------------------------------
1326
1327   //! @brief Instruction groups.
1328   //!
1329   //! This should be only used by assembler, because it's @c AsmJit::Assembler
1330   //! specific grouping. Each group represents one 'case' in the Assembler's 
1331   //! main emit method.
1332   enum G
1333   {
1334     // Gloup categories.
1335     G_EMIT,
1336
1337     G_ALU,
1338     G_BSWAP,
1339     G_BT,
1340     G_CALL,
1341     G_CRC32,
1342     G_ENTER,
1343     G_IMUL,
1344     G_INC_DEC,
1345     G_J,
1346     G_JMP,
1347     G_LEA,
1348     G_M,
1349     G_MOV,
1350     G_MOV_PTR,
1351     G_MOVSX_MOVZX,
1352     G_MOVSXD,
1353     G_PUSH, // I_PUSH is implemented before I_POP
1354     G_POP,
1355     G_R_RM,
1356     G_RM_B,
1357     G_RM,
1358     G_RM_R,
1359     G_REP,
1360     G_RET,
1361     G_ROT,
1362     G_SHLD_SHRD,
1363     G_TEST,
1364     G_XCHG,
1365
1366     // Group for x87 FP instructions in format mem or st(i), st(i) (fadd, fsub, fdiv, ...)
1367     G_X87_FPU,
1368     // Group for x87 FP instructions in format st(i), st(i)
1369     G_X87_STI,
1370     // Group for fld/fst/fstp instruction, internally uses I_X87_MEM group.
1371     G_X87_MEM_STI,
1372     // Group for x87 FP instructions that uses Word, DWord, QWord or TWord memory pointer.
1373     G_X87_MEM,
1374     // Group for x87 FSTSW/FNSTSW instructions
1375     G_X87_FSTSW,
1376
1377     // Group for movbe instruction
1378     G_MOVBE,
1379
1380     // Group for MMX/SSE instructions in format (X)MM|Reg|Mem <- (X)MM|Reg|Mem,
1381     // 0x66 prefix must be set manually in opcodes.
1382     // - Primary opcode is used for instructions in (X)MM <- (X)MM/Mem format,
1383     // - Secondary opcode is used for instructions in (X)MM/Mem <- (X)MM format.
1384     G_MMU_MOV,
1385
1386     // Group for movd and movq instructions.
1387     G_MMU_MOVD,
1388     G_MMU_MOVQ,
1389
1390     // Group for pextrd, pextrq and pextrw instructions (it's special instruction
1391     // not similar to others)
1392     G_MMU_PEXTR,
1393
1394     // Group for prefetch instruction
1395     G_MMU_PREFETCH,
1396
1397     // Group for MMX/SSE instructions in format (X)MM|Reg <- (X)MM|Reg|Mem|Imm,
1398     // 0x66 prefix is added for MMX instructions that used by SSE2 registers.
1399     // - Primary opcode is used for instructions in (X)MM|Reg <- (X)MM|Reg|Mem format,
1400     // - Secondary opcode is iused for instructions in (X)MM|Reg <- Imm format.
1401     G_MMU_RMI,
1402     G_MMU_RM_IMM8,
1403
1404     // Group for 3dNow instructions
1405     G_MMU_RM_3DNOW
1406   };
1407
1408   // --------------------------------------------------------------------------
1409   // [Instruction Core Flags]
1410   // --------------------------------------------------------------------------
1411
1412   //! @brief Instruction core flags.
1413   enum F
1414   {
1415     //! @brief No flags.
1416     F_NONE = 0x00,
1417     //! @brief Instruction is jump, conditional jump, call or ret.
1418     F_JUMP = 0x01,
1419     //! @brief Instruction will overwrite first operand - o[0].
1420     F_MOV = 0x02,
1421     //! @brief Instruction is X87 FPU.
1422     F_FPU = 0x04,
1423     //! @brief Instruction can be prepended using LOCK prefix
1424     //! (usable for multithreaded applications).
1425     F_LOCKABLE = 0x08,
1426
1427     //! @brief Instruction is special, this is for @c Compiler.
1428     F_SPECIAL = 0x10,
1429     //! @brief Instruction always performs memory access.
1430     //!
1431     //! This flag is always combined with @c F_SPECIAL and signalizes that
1432     //! there is implicit address which is accessed (usually EDI/RDI or ESI/EDI).
1433     F_SPECIAL_MEM = 0x20
1434   };
1435
1436   // --------------------------------------------------------------------------
1437   // [Instruction Operand Flags]
1438   // --------------------------------------------------------------------------
1439
1440   //! @brief Instruction operand flags.
1441   enum O
1442   {
1443     // X86, MM, XMM
1444     O_GB          = 0x0001,
1445     O_GW          = 0x0002,
1446     O_GD          = 0x0004,
1447     O_GQ          = 0x0008,
1448     O_MM          = 0x0010,
1449     O_XMM         = 0x0020,
1450     O_MEM         = 0x0040,
1451     O_IMM         = 0x0080,
1452
1453
1454     O_GB_MEM      = O_GB    | O_MEM,
1455     O_GW_MEM      = O_GW    | O_MEM,
1456     O_GD_MEM      = O_GD    | O_MEM,
1457     O_GQ_MEM      = O_GQ    | O_MEM,
1458
1459     O_GQDWB       = O_GQ    | O_GD    | O_GW    | O_GB,
1460     O_GQDW        = O_GQ    | O_GD    | O_GW,
1461     O_GQD         = O_GQ    | O_GD,
1462     O_GWB         = O_GW    | O_GB,
1463
1464     O_GQDWB_MEM   = O_GQDWB | O_MEM,
1465     O_GQDW_MEM    = O_GQDW  | O_MEM,
1466     O_GQD_MEM     = O_GQD   | O_MEM,
1467     O_GWB_MEM     = O_GWB   | O_MEM,
1468
1469     O_MM_MEM      = O_MM    | O_MEM,
1470     O_XMM_MEM     = O_XMM   | O_MEM,
1471     O_MM_XMM      = O_MM    | O_XMM,
1472     O_MM_XMM_MEM  = O_MM    | O_XMM   | O_MEM,
1473
1474     // X87
1475     O_FM_2        = O_MEM   | 0x0100,
1476     O_FM_4        = O_MEM   | 0x0200,
1477     O_FM_8        = O_MEM   | 0x0400,
1478     O_FM_10       = O_MEM   | 0x0800,
1479
1480     O_FM_2_4      = O_FM_2  | O_FM_4,
1481     O_FM_2_4_8    = O_FM_2  | O_FM_4  | O_FM_8,
1482     O_FM_4_8      = O_FM_4  | O_FM_8,
1483     O_FM_4_8_10   = O_FM_4  | O_FM_8  | O_FM_10,
1484
1485     // Don't emit REX prefix.
1486     O_NOREX       = 0x2000
1487   };
1488
1489   // --------------------------------------------------------------------------
1490   // [Members]
1491   // --------------------------------------------------------------------------
1492
1493   //! @brief Instruction code.
1494   uint16_t code;
1495   //! @brief Instruction name index in instructionName[] array.
1496   uint16_t nameIndex;
1497   //! @brief Instruction group, used also by @c Compiler.
1498   uint8_t group;
1499   //! @brief Instruction type flags.
1500   uint8_t flags;
1501   //! @brief First and second operand flags (some groups depends to these settings, used also by @c Compiler).
1502   uint16_t oflags[2];
1503   //! @brief If instruction has only memory operand, this is register opcode.
1504   uint16_t opCodeR;
1505   //! @brief Primary and secondary opcodes.
1506   uint32_t opCode[2];
1507
1508   //! @brief Get the instruction name (null terminated string).
1509   inline const char* getName() const { return instructionName + nameIndex; }
1510
1511   //! @brief Get whether the instruction is conditional or standard jump.
1512   inline bool isJump() const { return (flags & F_JUMP) != 0; }
1513   //! @brief Get whether the instruction is MOV type.
1514   inline bool isMov() const { return (flags & F_MOV) != 0; }
1515   //! @brief Get whether the instruction is X87 FPU type.
1516   inline bool isFPU() const { return (flags & F_FPU) != 0; }
1517   //! @brief Get whether the instruction can be prefixed by LOCK prefix.
1518   inline bool isLockable() const { return (flags & F_LOCKABLE) != 0; }
1519
1520   //! @brief Get whether the instruction is special type (this is used by
1521   //! @c Compiler to manage additional variables or functionality).
1522   inline bool isSpecial() const { return (flags & F_SPECIAL) != 0; }
1523   //! @brief Get whether the instruction is special type and it performs
1524   //! memory access.
1525   inline bool isSpecialMem() const { return (flags & F_SPECIAL_MEM) != 0; }
1526 };
1527
1528 ASMJIT_API extern const InstructionDescription instructionDescription[];
1529
1530 // ============================================================================
1531 // [AsmJit::EMIT_OPTIONS]
1532 // ============================================================================
1533
1534 //! @brief Emit options, mainly for internal purposes.
1535 enum EMIT_OPTIONS
1536 {
1537   //! @brief Force REX prefix to be emitted.
1538   //!
1539   //! This option should be used carefully, because there are unencodable
1540   //! combinations. If you want to access ah, bh, ch or dh registers then you
1541   //! can't emit REX prefix and it will cause an illegal instruction error.
1542   EMIT_OPTION_REX_PREFIX = (1 << 0),
1543
1544   //! @brief Tell @c Assembler or @c Compiler to emit and validate lock prefix.
1545   //!
1546   //! If this option is used and instruction doesn't support LOCK prefix then
1547   //! invalid instruction error is generated.
1548   EMIT_OPTION_LOCK_PREFIX = (1 << 1),
1549
1550   //! @brief Emit short/near jump or conditional jump instead of far one, 
1551   //! saving some bytes.
1552   EMIT_OPTION_SHORT_JUMP = (1 << 2)
1553 };
1554
1555 // ============================================================================
1556 // [AsmJit::CALL_CONV]
1557 // ============================================================================
1558
1559 //! @brief Calling convention type.
1560 //!
1561 //! Calling convention is scheme how function arguments are passed into 
1562 //! function and how functions returns values. In assembler programming
1563 //! it's needed to always comply with function calling conventions, because
1564 //! even small inconsistency can cause undefined behavior or crash.
1565 //!
1566 //! List of calling conventions for 32-bit x86 mode:
1567 //! - @c CALL_CONV_CDECL - Calling convention for C runtime.
1568 //! - @c CALL_CONV_STDCALL - Calling convention for WinAPI functions.
1569 //! - @c CALL_CONV_MSTHISCALL - Calling convention for C++ members under 
1570 //!      Windows (produced by MSVC and all MSVC compatible compilers).
1571 //! - @c CALL_CONV_MSFASTCALL - Fastest calling convention that can be used
1572 //!      by MSVC compiler.
1573 //! - @c CALL_CONV_BORNANDFASTCALL - Borland fastcall convention.
1574 //! - @c CALL_CONV_GCCFASTCALL - GCC fastcall convention (2 register arguments).
1575 //! - @c CALL_CONV_GCCREGPARM_1 - GCC regparm(1) convention.
1576 //! - @c CALL_CONV_GCCREGPARM_2 - GCC regparm(2) convention.
1577 //! - @c CALL_CONV_GCCREGPARM_3 - GCC regparm(3) convention.
1578 //!
1579 //! List of calling conventions for 64-bit x86 mode (x64):
1580 //! - @c CALL_CONV_X64W - Windows 64-bit calling convention (WIN64 ABI).
1581 //! - @c CALL_CONV_X64U - Unix 64-bit calling convention (AMD64 ABI).
1582 //!
1583 //! There is also @c CALL_CONV_DEFAULT that is defined to fit best to your 
1584 //! compiler.
1585 //!
1586 //! These types are used together with @c AsmJit::Compiler::newFunction() 
1587 //! method.
1588 enum CALL_CONV
1589 {
1590   //! @brief Calling convention is invalid (can't be used).
1591   CALL_CONV_NONE = 0,
1592
1593   // [X64 Calling Conventions]
1594
1595   //! @brief X64 calling convention for Windows platform (WIN64 ABI).
1596   //!
1597   //! For first four arguments are used these registers:
1598   //! - 1. 32/64-bit integer or floating point argument - rcx/xmm0
1599   //! - 2. 32/64-bit integer or floating point argument - rdx/xmm1
1600   //! - 3. 32/64-bit integer or floating point argument - r8/xmm2
1601   //! - 4. 32/64-bit integer or floating point argument - r9/xmm3
1602   //!
1603   //! Note first four arguments here means arguments at positions from 1 to 4
1604   //! (included). For example if second argument is not passed by register then
1605   //! rdx/xmm1 register is unused.
1606   //!
1607   //! All other arguments are pushed on the stack in right-to-left direction.
1608   //! Stack is aligned by 16 bytes. There is 32-byte shadow space on the stack
1609   //! that can be used to save up to four 64-bit registers (probably designed to
1610   //! be used to save first four arguments passed in registers).
1611   //!
1612   //! Arguments direction:
1613   //! - Right to Left (except for first 4 parameters that's in registers)
1614   //!
1615   //! Stack is cleaned by:
1616   //! - Caller.
1617   //!
1618   //! Return value:
1619   //! - Integer types - RAX register.
1620   //! - Floating points - XMM0 register.
1621   //!
1622   //! Stack is always aligned by 16 bytes.
1623   //!
1624   //! More information about this calling convention can be found on MSDN:
1625   //! http://msdn.microsoft.com/en-us/library/9b372w95.aspx .
1626   CALL_CONV_X64W = 1,
1627
1628   //! @brief X64 calling convention for Unix platforms (AMD64 ABI).
1629   //!
1630   //! First six 32 or 64-bit integer arguments are passed in rdi, rsi, rdx, 
1631   //! rcx, r8, r9 registers. First eight floating point or XMM arguments 
1632   //! are passed in xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 registers.
1633   //! This means that in registers can be transferred up to 14 arguments total.
1634   //!
1635   //! There is also RED ZONE below the stack pointer that can be used for 
1636   //! temporary storage. The red zone is the space from [rsp-128] to [rsp-8].
1637   //! 
1638   //! Arguments direction:
1639   //! - Right to Left (Except for arguments passed in registers).
1640   //!
1641   //! Stack is cleaned by:
1642   //! - Caller.
1643   //!
1644   //! Return value:
1645   //! - Integer types - RAX register.
1646   //! - Floating points - XMM0 register.
1647   //!
1648   //! Stack is always aligned by 16 bytes.
1649   CALL_CONV_X64U = 2,
1650
1651   // [X86 Calling Conventions]
1652
1653   //! @brief Cdecl calling convention (used by C runtime).
1654   //!
1655   //! Compatible across MSVC and GCC.
1656   //!
1657   //! Arguments direction:
1658   //! - Right to Left
1659   //!
1660   //! Stack is cleaned by:
1661   //! - Caller.
1662   CALL_CONV_CDECL = 3,
1663
1664   //! @brief Stdcall calling convention (used by WinAPI).
1665   //!
1666   //! Compatible across MSVC and GCC.
1667   //!
1668   //! Arguments direction:
1669   //! - Right to Left
1670   //!
1671   //! Stack is cleaned by:
1672   //! - Callee.
1673   //!
1674   //! Return value:
1675   //! - Integer types - EAX:EDX registers.
1676   //! - Floating points - st(0) register.
1677   CALL_CONV_STDCALL = 4,
1678
1679   //! @brief MSVC specific calling convention used by MSVC/Intel compilers
1680   //! for struct/class methods.
1681   //!
1682   //! This is MSVC (and Intel) only calling convention used in Windows
1683   //! world for C++ class methods. Implicit 'this' pointer is stored in
1684   //! ECX register instead of storing it on the stack.
1685   //!
1686   //! Arguments direction:
1687   //! - Right to Left (except this pointer in ECX)
1688   //!
1689   //! Stack is cleaned by:
1690   //! - Callee.
1691   //!
1692   //! Return value:
1693   //! - Integer types - EAX:EDX registers.
1694   //! - Floating points - st(0) register.
1695   //!
1696   //! C++ class methods that have variable count of arguments uses different
1697   //! calling convention called cdecl.
1698   //!
1699   //! @note This calling convention is always used by MSVC for class methods,
1700   //! it's implicit and there is no way how to override it.
1701   CALL_CONV_MSTHISCALL = 5,
1702
1703   //! @brief MSVC specific fastcall.
1704   //!
1705   //! Two first parameters (evaluated from left-to-right) are in ECX:EDX 
1706   //! registers, all others on the stack in right-to-left order.
1707   //!
1708   //! Arguments direction:
1709   //! - Right to Left (except to first two integer arguments in ECX:EDX)
1710   //!
1711   //! Stack is cleaned by:
1712   //! - Callee.
1713   //!
1714   //! Return value:
1715   //! - Integer types - EAX:EDX registers.
1716   //! - Floating points - st(0) register.
1717   //!
1718   //! @note This calling convention differs to GCC one in stack cleaning
1719   //! mechanism.
1720   CALL_CONV_MSFASTCALL = 6,
1721
1722   //! @brief Borland specific fastcall with 2 parameters in registers.
1723   //!
1724   //! Two first parameters (evaluated from left-to-right) are in ECX:EDX 
1725   //! registers, all others on the stack in left-to-right order.
1726   //!
1727   //! Arguments direction:
1728   //! - Left to Right (except to first two integer arguments in ECX:EDX)
1729   //!
1730   //! Stack is cleaned by:
1731   //! - Callee.
1732   //!
1733   //! Return value:
1734   //! - Integer types - EAX:EDX registers.
1735   //! - Floating points - st(0) register.
1736   //!
1737   //! @note Arguments on the stack are in left-to-right order that differs
1738   //! to other fastcall conventions used in different compilers.
1739   CALL_CONV_BORLANDFASTCALL = 7,
1740
1741   //! @brief GCC specific fastcall convention.
1742   //!
1743   //! Two first parameters (evaluated from left-to-right) are in ECX:EDX 
1744   //! registers, all others on the stack in right-to-left order.
1745   //!
1746   //! Arguments direction:
1747   //! - Right to Left (except to first two integer arguments in ECX:EDX)
1748   //!
1749   //! Stack is cleaned by:
1750   //! - Callee.
1751   //!
1752   //! Return value:
1753   //! - Integer types - EAX:EDX registers.
1754   //! - Floating points - st(0) register.
1755   //!
1756   //! @note This calling convention should be compatible to
1757   //! @c CALL_CONV_MSFASTCALL.
1758   CALL_CONV_GCCFASTCALL = 8,
1759
1760   //! @brief GCC specific regparm(1) convention.
1761   //!
1762   //! The first parameter (evaluated from left-to-right) is in EAX register,
1763   //! all others on the stack in right-to-left order.
1764   //!
1765   //! Arguments direction:
1766   //! - Right to Left (except to first one integer argument in EAX)
1767   //!
1768   //! Stack is cleaned by:
1769   //! - Caller.
1770   //!
1771   //! Return value:
1772   //! - Integer types - EAX:EDX registers.
1773   //! - Floating points - st(0) register.
1774   CALL_CONV_GCCREGPARM_1 = 9,
1775
1776   //! @brief GCC specific regparm(2) convention.
1777   //!
1778   //! Two first parameters (evaluated from left-to-right) are in EAX:EDX 
1779   //! registers, all others on the stack in right-to-left order.
1780   //!
1781   //! Arguments direction:
1782   //! - Right to Left (except to first two integer arguments in EAX:EDX)
1783   //!
1784   //! Stack is cleaned by:
1785   //! - Caller.
1786   //!
1787   //! Return value:
1788   //! - Integer types - EAX:EDX registers.
1789   //! - Floating points - st(0) register.
1790   CALL_CONV_GCCREGPARM_2 = 10,
1791
1792   //! @brief GCC specific fastcall with 3 parameters in registers.
1793   //!
1794   //! Three first parameters (evaluated from left-to-right) are in 
1795   //! EAX:EDX:ECX registers, all others on the stack in right-to-left order.
1796   //!
1797   //! Arguments direction:
1798   //! - Right to Left (except to first three integer arguments in EAX:EDX:ECX)
1799   //!
1800   //! Stack is cleaned by:
1801   //! - Caller.
1802   //!
1803   //! Return value:
1804   //! - Integer types - EAX:EDX registers.
1805   //! - Floating points - st(0) register.
1806   CALL_CONV_GCCREGPARM_3 = 11,
1807
1808   // [Preferred Calling Convention]
1809
1810   //! @def CALL_CONV_DEFAULT
1811   //! @brief Default calling convention for current platform / operating system.
1812
1813 #if defined(ASMJIT_X86)
1814
1815   CALL_CONV_DEFAULT = CALL_CONV_CDECL,
1816
1817 # if defined(_MSC_VER)
1818   CALL_CONV_COMPAT_FASTCALL = CALL_CONV_MSFASTCALL,
1819 # elif defined(__GNUC__)
1820   CALL_CONV_COMPAT_FASTCALL = CALL_CONV_GCCFASTCALL,
1821 # elif defined(__BORLANDC__)
1822   CALL_CONV_COMPAT_FASTCALL = CALL_CONV_BORLANDFASTCALL,
1823 # else
1824 #  error "AsmJit::CALL_CONV_COMPATIBLE_FASTCALL_2 - Unsupported."
1825 # endif
1826
1827   CALL_CONV_COMPAT_STDCALL = CALL_CONV_STDCALL,
1828   CALL_CONV_COMPAT_CDECL = CALL_CONV_CDECL
1829
1830 #else
1831
1832 # if defined(ASMJIT_WINDOWS)
1833   CALL_CONV_DEFAULT = CALL_CONV_X64W,
1834 # else
1835   CALL_CONV_DEFAULT = CALL_CONV_X64U,
1836 # endif
1837
1838   CALL_CONV_COMPAT_FASTCALL = CALL_CONV_DEFAULT,
1839   CALL_CONV_COMPAT_STDCALL = CALL_CONV_DEFAULT,
1840   CALL_CONV_COMPAT_CDECL = CALL_CONV_DEFAULT
1841
1842 #endif // ASMJIT_X86
1843 };
1844
1845 // ============================================================================
1846 // [AsmJit::VARIABLE_TYPE]
1847 // ============================================================================
1848
1849 //! @brief Variable type.
1850 enum VARIABLE_TYPE
1851 {
1852   // --------------------------------------------------------------------------
1853   // [Platform Dependent]
1854   // --------------------------------------------------------------------------
1855
1856   //! @brief Variable is 32-bit general purpose register.
1857   VARIABLE_TYPE_GPD = 0,
1858   //! @brief Variable is 64-bit general purpose register.
1859   VARIABLE_TYPE_GPQ = 1,
1860
1861   //! @var VARIABLE_TYPE_GPN
1862   //! @brief Variable is system wide general purpose register (32-bit or 64-bit).
1863 #if defined(ASMJIT_X86)
1864   VARIABLE_TYPE_GPN = VARIABLE_TYPE_GPD,
1865 #else
1866   VARIABLE_TYPE_GPN = VARIABLE_TYPE_GPQ,
1867 #endif
1868
1869   //! @brief Variable is X87 (FPU).
1870   VARIABLE_TYPE_X87 = 2,
1871
1872   //! @brief Variable is X87 (FPU) SP-FP number (float).
1873   VARIABLE_TYPE_X87_1F = 3,
1874
1875   //! @brief Variable is X87 (FPU) DP-FP number (double).
1876   VARIABLE_TYPE_X87_1D = 4,
1877
1878   //! @brief Variable is MM register / memory location.
1879   VARIABLE_TYPE_MM = 5,
1880
1881   //! @brief Variable is XMM register / memory location.
1882   VARIABLE_TYPE_XMM = 6,
1883
1884   //! @brief Variable is SSE scalar SP-FP number.
1885   VARIABLE_TYPE_XMM_1F = 7,
1886   //! @brief Variable is SSE packed SP-FP number (4 floats).
1887   VARIABLE_TYPE_XMM_4F = 8,
1888
1889   //! @brief Variable is SSE2 scalar DP-FP number.
1890   VARIABLE_TYPE_XMM_1D = 9,
1891   //! @brief Variable is SSE2 packed DP-FP number (2 doubles).
1892   VARIABLE_TYPE_XMM_2D = 10,
1893
1894   //! @brief Count of variable types.
1895   _VARIABLE_TYPE_COUNT = 11,
1896
1897   // --------------------------------------------------------------------------
1898   // [Platform Independent]
1899   // --------------------------------------------------------------------------
1900
1901   //! @brief Variable is 32-bit integer.
1902   VARIABLE_TYPE_INT32 = VARIABLE_TYPE_GPD,
1903   //! @brief Variable is 64-bit integer.
1904   VARIABLE_TYPE_INT64 = VARIABLE_TYPE_GPQ,
1905   //! @brief Variable is system dependent integer / pointer.
1906   VARIABLE_TYPE_INTPTR = VARIABLE_TYPE_GPN,
1907
1908 #if !defined(ASMJIT_NODOC)
1909 #if defined(ASMJIT_X86)
1910   VARIABLE_TYPE_FLOAT = VARIABLE_TYPE_X87_1F,
1911   VARIABLE_TYPE_DOUBLE = VARIABLE_TYPE_X87_1D
1912 #else
1913   VARIABLE_TYPE_FLOAT = VARIABLE_TYPE_XMM_1F,
1914   VARIABLE_TYPE_DOUBLE = VARIABLE_TYPE_XMM_1D
1915 #endif
1916 #else
1917   //! @brief Variable is SP-FP (x87 or xmm).
1918   VARIABLE_TYPE_FLOAT = XXX,
1919   //! @brief Variable is DP-FP (x87 or xmm).
1920   VARIABLE_TYPE_DOUBLE = XXX
1921 #endif
1922 };
1923
1924 // ============================================================================
1925 // [AsmJit::VARIABLE_HINT]
1926 // ============================================================================
1927
1928 //! @brief Variable hint (used by @ref Compiler).
1929 //!
1930 //! @sa @ref Compiler.
1931 enum VARIABLE_HINT
1932 {
1933   //! @brief Alloc variable.
1934   VARIABLE_HINT_ALLOC = 0,
1935   //! @brief Spill variable.
1936   VARIABLE_HINT_SPILL = 1,
1937   //! @brief Save variable if modified.
1938   VARIABLE_HINT_SAVE = 2,
1939   //! @brief Save variable if modified and mark it as unused.
1940   VARIABLE_HINT_SAVE_AND_UNUSE = 3,
1941   //! @brief Mark variable as unused.
1942   VARIABLE_HINT_UNUSE = 4
1943 };
1944
1945 //! @}
1946
1947 } // AsmJit namespace
1948
1949 // [Api-End]
1950 #include "ApiEnd.h"
1951
1952 // [Guard]
1953 #endif // _ASMJIT_DEFSX86X64_H