odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

x86instdb_p.h (17265B)


      1 // This file is part of AsmJit project <https://asmjit.com>
      2 //
      3 // See <asmjit/core.h> or LICENSE.md for license and copyright information
      4 // SPDX-License-Identifier: Zlib
      5 
      6 #ifndef ASMJIT_X86_X86INSTDB_P_H_INCLUDED
      7 #define ASMJIT_X86_X86INSTDB_P_H_INCLUDED
      8 
      9 #include "../core/instdb_p.h"
     10 #include "../x86/x86instdb.h"
     11 
     12 ASMJIT_BEGIN_SUB_NAMESPACE(x86)
     13 
     14 //! \cond INTERNAL
     15 //! \addtogroup asmjit_x86
     16 //! \{
     17 
     18 namespace InstDB {
     19 
     20 //! Instruction encoding (X86|X86_64).
     21 //!
     22 //! This is a specific identifier that is used by AsmJit to describe the way each instruction is encoded. Some
     23 //! encodings are special only for a single instruction as X86 instruction set contains a lot of legacy encodings,
     24 //! and some encodings describe a group of instructions that share some commons, like MMX, SSE, AVX, AVX512
     25 //! instructions, etc...
     26 enum EncodingId : uint32_t {
     27   kEncodingNone = 0,                     //!< Never used.
     28   kEncodingX86Op,                        //!< X86 [OP].
     29   kEncodingX86Op_Mod11RM,                //!< X86 [OP] (opcode with ModRM byte where MOD must be 11b).
     30   kEncodingX86Op_Mod11RM_I8,             //!< X86 [OP] (opcode with ModRM byte + 8-bit immediate).
     31   kEncodingX86Op_xAddr,                  //!< X86 [OP] (implicit address in the first register operand).
     32   kEncodingX86Op_xAX,                    //!< X86 [OP] (implicit or explicit '?AX' form).
     33   kEncodingX86Op_xDX_xAX,                //!< X86 [OP] (implicit or explicit '?DX, ?AX' form).
     34   kEncodingX86Op_MemZAX,                 //!< X86 [OP] (implicit or explicit '[EAX|RAX]' form).
     35   kEncodingX86I_xAX,                     //!< X86 [I] (implicit or explicit '?AX' form).
     36   kEncodingX86M,                         //!< X86 [M] (handles 2|4|8-bytes size).
     37   kEncodingX86M_NoMemSize,               //!< X86 [M] (handles 2|4|8-bytes size, but doesn't consider memory size).
     38   kEncodingX86M_NoSize,                  //!< X86 [M] (doesn't handle any size).
     39   kEncodingX86M_GPB,                     //!< X86 [M] (handles single-byte size).
     40   kEncodingX86M_GPB_MulDiv,              //!< X86 [M] (like GPB, handles implicit|explicit MUL|DIV|IDIV).
     41   kEncodingX86M_Only,                    //!< X86 [M] (restricted to memory operand of any size).
     42   kEncodingX86M_Only_EDX_EAX,            //!< X86 [M] (memory operand only, followed by implicit `EDX` and `EAX`).
     43   kEncodingX86M_Nop,                     //!< X86 [M] (special case of NOP instruction).
     44   kEncodingX86R_Native,                  //!< X86 [R] (register must be either 32-bit or 64-bit depending on arch).
     45   kEncodingX86R_FromM,                   //!< X86 [R] - which specifies memory address.
     46   kEncodingX86R32_EDX_EAX,               //!< X86 [R32] followed by implicit `EDX` and `EAX`.
     47   kEncodingX86Rm,                        //!< X86 [RM] (doesn't handle single-byte size).
     48   kEncodingX86Rm_Raw66H,                 //!< X86 [RM] (used by LZCNT, POPCNT, and TZCNT).
     49   kEncodingX86Rm_NoSize,                 //!< X86 [RM] (doesn't add REX.W prefix if 64-bit reg is used).
     50   kEncodingX86Mr,                        //!< X86 [MR] (doesn't handle single-byte size).
     51   kEncodingX86Mr_NoSize,                 //!< X86 [MR] (doesn't handle any size).
     52   kEncodingX86Arith,                     //!< X86 adc, add, and, cmp, or, sbb, sub, xor.
     53   kEncodingX86Bswap,                     //!< X86 bswap.
     54   kEncodingX86Bt,                        //!< X86 bt, btc, btr, bts.
     55   kEncodingX86Call,                      //!< X86 call.
     56   kEncodingX86Cmpxchg,                   //!< X86 [MR] cmpxchg.
     57   kEncodingX86Cmpxchg8b_16b,             //!< X86 [MR] cmpxchg8b, cmpxchg16b.
     58   kEncodingX86Crc,                       //!< X86 crc32.
     59   kEncodingX86Enter,                     //!< X86 enter.
     60   kEncodingX86Imul,                      //!< X86 imul.
     61   kEncodingX86In,                        //!< X86 in.
     62   kEncodingX86Ins,                       //!< X86 ins[b|q|d].
     63   kEncodingX86IncDec,                    //!< X86 inc, dec.
     64   kEncodingX86Int,                       //!< X86 int (interrupt).
     65   kEncodingX86Jcc,                       //!< X86 jcc.
     66   kEncodingX86JecxzLoop,                 //!< X86 jcxz, jecxz, jrcxz, loop, loope, loopne.
     67   kEncodingX86Jmp,                       //!< X86 jmp.
     68   kEncodingX86JmpRel,                    //!< X86 xbegin.
     69   kEncodingX86LcallLjmp,                 //!< X86 lcall/ljmp.
     70   kEncodingX86Lea,                       //!< X86 lea.
     71   kEncodingX86Mov,                       //!< X86 mov (all possible cases).
     72   kEncodingX86Movabs,                    //!< X86 movabs.
     73   kEncodingX86MovsxMovzx,                //!< X86 movsx, movzx.
     74   kEncodingX86MovntiMovdiri,             //!< X86 movnti/movdiri.
     75   kEncodingX86EnqcmdMovdir64b,           //!< X86 enqcmd/enqcmds/movdir64b.
     76   kEncodingX86Out,                       //!< X86 out.
     77   kEncodingX86Outs,                      //!< X86 out[b|w|d].
     78   kEncodingX86Push,                      //!< X86 push.
     79   kEncodingX86Pushw,                     //!< X86 pushw.
     80   kEncodingX86Pop,                       //!< X86 pop.
     81   kEncodingX86Ret,                       //!< X86 ret.
     82   kEncodingX86Rot,                       //!< X86 rcl, rcr, rol, ror, sal, sar, shl, shr.
     83   kEncodingX86Set,                       //!< X86 setcc.
     84   kEncodingX86ShldShrd,                  //!< X86 shld, shrd.
     85   kEncodingX86StrRm,                     //!< X86 lods.
     86   kEncodingX86StrMr,                     //!< X86 scas, stos.
     87   kEncodingX86StrMm,                     //!< X86 cmps, movs.
     88   kEncodingX86Test,                      //!< X86 test.
     89   kEncodingX86Xadd,                      //!< X86 xadd.
     90   kEncodingX86Xchg,                      //!< X86 xchg.
     91   kEncodingX86Fence,                     //!< X86 lfence, mfence, sfence.
     92   kEncodingX86Bndmov,                    //!< X86 [RM|MR] (used by BNDMOV).
     93   kEncodingFpuOp,                        //!< FPU [OP].
     94   kEncodingFpuArith,                     //!< FPU fadd, fdiv, fdivr, fmul, fsub, fsubr.
     95   kEncodingFpuCom,                       //!< FPU fcom, fcomp.
     96   kEncodingFpuFldFst,                    //!< FPU fld, fst, fstp.
     97   kEncodingFpuM,                         //!< FPU fiadd, ficom, ficomp, fidiv, fidivr, fild, fimul, fist, fistp, fisttp, fisub, fisubr.
     98   kEncodingFpuR,                         //!< FPU fcmov, fcomi, fcomip, ffree, fucom, fucomi, fucomip, fucomp, fxch.
     99   kEncodingFpuRDef,                      //!< FPU faddp, fdivp, fdivrp, fmulp, fsubp, fsubrp.
    100   kEncodingFpuStsw,                      //!< FPU fnstsw, Fstsw.
    101   kEncodingExtRm,                        //!< EXT [RM].
    102   kEncodingExtRm_XMM0,                   //!< EXT [RM<XMM0>].
    103   kEncodingExtRm_ZDI,                    //!< EXT [RM<ZDI>].
    104   kEncodingExtRm_P,                      //!< EXT [RM] (propagates 66H if the instruction uses XMM register).
    105   kEncodingExtRm_Wx,                     //!< EXT [RM] (propagates REX.W if GPQ is used or the second operand is GPQ/QWORD_PTR).
    106   kEncodingExtRm_Wx_GpqOnly,             //!< EXT [RM] (propagates REX.W if the first operand is GPQ register).
    107   kEncodingExtRmRi,                      //!< EXT [RM|RI].
    108   kEncodingExtRmRi_P,                    //!< EXT [RM|RI] (propagates 66H if the instruction uses XMM register).
    109   kEncodingExtRmi,                       //!< EXT [RMI].
    110   kEncodingExtRmi_P,                     //!< EXT [RMI] (propagates 66H if the instruction uses XMM register).
    111   kEncodingExtPextrw,                    //!< EXT pextrw.
    112   kEncodingExtExtract,                   //!< EXT pextrb, pextrd, pextrq, extractps.
    113   kEncodingExtMov,                       //!< EXT mov?? - #1:[MM|XMM, MM|XMM|Mem] #2:[MM|XMM|Mem, MM|XMM].
    114   kEncodingExtMovbe,                     //!< EXT movbe.
    115   kEncodingExtMovd,                      //!< EXT movd.
    116   kEncodingExtMovq,                      //!< EXT movq.
    117   kEncodingExtExtrq,                     //!< EXT extrq (SSE4A).
    118   kEncodingExtInsertq,                   //!< EXT insrq (SSE4A).
    119   kEncodingExt3dNow,                     //!< EXT [RMI] (3DNOW specific).
    120   kEncodingVexOp,                        //!< VEX [OP].
    121   kEncodingVexOpMod,                     //!< VEX [OP] with MODR/M.
    122   kEncodingVexKmov,                      //!< VEX [RM|MR] (used by kmov[b|w|d|q]).
    123   kEncodingVexR_Wx,                      //!< VEX|EVEX [R] (propagatex VEX.W if GPQ used).
    124   kEncodingVexM,                         //!< VEX|EVEX [M].
    125   kEncodingVexMr_Lx,                     //!< VEX|EVEX [MR] (propagates VEX|EVEX.L if YMM used).
    126   kEncodingVexMr_VM,                     //!< VEX|EVEX [MR] (VSIB support).
    127   kEncodingVexMri,                       //!< VEX|EVEX [MRI].
    128   kEncodingVexMri_Lx,                    //!< VEX|EVEX [MRI] (propagates VEX|EVEX.L if YMM used).
    129   kEncodingVexMri_Vpextrw,               //!< VEX|EVEX [MRI] (special case required by VPEXTRW instruction).
    130   kEncodingVexMvr_Wx,                    //!< VEX|EVEX [MVR] (propagates VEX|EVEX.W if GPQ used).
    131   kEncodingVexRm,                        //!< VEX|EVEX [RM].
    132   kEncodingVexRm_ZDI,                    //!< VEX|EVEX [RM<ZDI>].
    133   kEncodingVexRm_Wx,                     //!< VEX|EVEX [RM] (propagates VEX|EVEX.W if GPQ used).
    134   kEncodingVexRm_Lx,                     //!< VEX|EVEX [RM] (propagates VEX|EVEX.L if YMM used).
    135   kEncodingVexRm_Lx_Narrow,              //!< VEX|EVEX [RM] (the destination vector size is narrowed).
    136   kEncodingVexRm_Lx_Bcst,                //!< VEX|EVEX [RM] (can handle broadcast r32/r64).
    137   kEncodingVexRm_VM,                     //!< VEX|EVEX [RM] (propagates VEX|EVEX.L, VSIB support).
    138   kEncodingVexRmi,                       //!< VEX|EVEX [RMI].
    139   kEncodingVexRmi_Wx,                    //!< VEX|EVEX [RMI] (propagates VEX|EVEX.W if GPQ used).
    140   kEncodingVexRmi_Lx,                    //!< VEX|EVEX [RMI] (propagates VEX|EVEX.L if YMM used).
    141   kEncodingVexRvm,                       //!< VEX|EVEX [RVM].
    142   kEncodingVexRvm_Wx,                    //!< VEX|EVEX [RVM] (propagates VEX|EVEX.W if GPQ used).
    143   kEncodingVexRvm_ZDX_Wx,                //!< VEX|EVEX [RVM<ZDX>] (propagates VEX|EVEX.W if GPQ used).
    144   kEncodingVexRvm_Lx,                    //!< VEX|EVEX [RVM] (propagates VEX|EVEX.L if YMM used).
    145   kEncodingVexRvm_Lx_KEvex,              //!< VEX|EVEX [RVM] (forces EVEX prefix if K register is used on destination).
    146   kEncodingVexRvm_Lx_2xK,                //!< VEX|EVEX [RVM] (vp2intersectd/vp2intersectq).
    147   kEncodingVexRvmr,                      //!< VEX|EVEX [RVMR].
    148   kEncodingVexRvmr_Lx,                   //!< VEX|EVEX [RVMR] (propagates VEX|EVEX.L if YMM used).
    149   kEncodingVexRvmi,                      //!< VEX|EVEX [RVMI].
    150   kEncodingVexRvmi_KEvex,                //!< VEX|EVEX [RVMI] (forces EVEX prefix if K register is used on destination).
    151   kEncodingVexRvmi_Lx,                   //!< VEX|EVEX [RVMI] (propagates VEX|EVEX.L if YMM used).
    152   kEncodingVexRvmi_Lx_KEvex,             //!< VEX|EVEX [RVMI] (forces EVEX prefix if K register is used on destination).
    153   kEncodingVexRmv,                       //!< VEX|EVEX [RMV].
    154   kEncodingVexRmv_Wx,                    //!< VEX|EVEX [RMV] (propagates VEX|EVEX.W if GPQ used).
    155   kEncodingVexRmv_VM,                    //!< VEX|EVEX [RMV] (propagates VEX|EVEX.L, VSIB support).
    156   kEncodingVexRmvRm_VM,                  //!< VEX|EVEX [RMV|RM] (propagates VEX|EVEX.L, VSIB support).
    157   kEncodingVexRmvi,                      //!< VEX|EVEX [RMVI].
    158   kEncodingVexRmMr,                      //!< VEX|EVEX [RM|MR].
    159   kEncodingVexRmMr_Lx,                   //!< VEX|EVEX [RM|MR] (propagates VEX|EVEX.L if YMM used).
    160   kEncodingVexRvmRmv,                    //!< VEX|EVEX [RVM|RMV].
    161   kEncodingVexRvmRmi,                    //!< VEX|EVEX [RVM|RMI].
    162   kEncodingVexRvmRmi_Lx,                 //!< VEX|EVEX [RVM|RMI] (propagates VEX|EVEX.L if YMM used).
    163   kEncodingVexRvmRmvRmi,                 //!< VEX|EVEX [RVM|RMV|RMI].
    164   kEncodingVexRvmMr,                     //!< VEX|EVEX [RVM|MR].
    165   kEncodingVexRvmMvr,                    //!< VEX|EVEX [RVM|MVR].
    166   kEncodingVexRvmMvr_Lx,                 //!< VEX|EVEX [RVM|MVR] (propagates VEX|EVEX.L if YMM used).
    167   kEncodingVexRvmVmi,                    //!< VEX|EVEX [RVM|VMI].
    168   kEncodingVexRvmVmi_Lx,                 //!< VEX|EVEX [RVM|VMI] (propagates VEX|EVEX.L if YMM used).
    169   kEncodingVexRvmVmi_Lx_MEvex,           //!< VEX|EVEX [RVM|VMI] (propagates EVEX if the second operand is memory).
    170   kEncodingVexVm,                        //!< VEX|EVEX [VM].
    171   kEncodingVexVm_Wx,                     //!< VEX|EVEX [VM] (propagates VEX|EVEX.W if GPQ used).
    172   kEncodingVexVmi,                       //!< VEX|EVEX [VMI].
    173   kEncodingVexVmi_Lx,                    //!< VEX|EVEX [VMI] (propagates VEX|EVEX.L if YMM used).
    174   kEncodingVexVmi4_Wx,                   //!< VEX|EVEX [VMI] (propagates VEX|EVEX.W if GPQ used, DWORD Immediate).
    175   kEncodingVexVmi_Lx_MEvex,              //!< VEX|EVEX [VMI] (force EVEX prefix when the second operand is memory)
    176   kEncodingVexRvrmRvmr,                  //!< VEX|EVEX [RVRM|RVMR].
    177   kEncodingVexRvrmRvmr_Lx,               //!< VEX|EVEX [RVRM|RVMR] (propagates VEX|EVEX.L if YMM used).
    178   kEncodingVexRvrmiRvmri_Lx,             //!< VEX|EVEX [RVRMI|RVMRI] (propagates VEX|EVEX.L if YMM used).
    179   kEncodingVexMovdMovq,                  //!< VEX|EVEX vmovd, vmovq.
    180   kEncodingVexMovssMovsd,                //!< VEX|EVEX vmovss, vmovsd.
    181   kEncodingFma4,                         //!< FMA4 [R, R, R/M, R/M].
    182   kEncodingFma4_Lx,                      //!< FMA4 [R, R, R/M, R/M] (propagates AVX.L if YMM used).
    183   kEncodingAmxCfg,                       //!< AMX ldtilecfg/sttilecfg.
    184   kEncodingAmxR,                         //!< AMX [R] - tilezero.
    185   kEncodingAmxRm,                        //!< AMX tileloadd/tileloaddt1.
    186   kEncodingAmxMr,                        //!< AMX tilestored.
    187   kEncodingAmxRmv,                       //!< AMX instructions that use TMM registers.
    188   kEncodingCount                         //!< Count of instruction encodings.
    189 };
    190 
    191 //! Additional information table, provides CPU extensions required to execute an instruction and RW flags.
    192 struct AdditionalInfo {
    193   //! Index to `inst_flags_table`.
    194   uint8_t _inst_flags_index;
    195   //! Index to `rw_flags_info_table`.
    196   uint8_t _rw_flags_index;
    197   //! Features vector.
    198   uint8_t _features[6];
    199 
    200   inline const uint8_t* features_begin() const noexcept { return _features; }
    201   inline const uint8_t* features_end() const noexcept { return _features + ASMJIT_ARRAY_SIZE(_features); }
    202 };
    203 
    204 struct RWInfo {
    205   enum Category : uint8_t {
    206     kCategoryGeneric = 0,
    207     kCategoryGenericEx,
    208     kCategoryMov,
    209     kCategoryMovabs,
    210     kCategoryImul,
    211     kCategoryMovh64,
    212     kCategoryPunpcklxx,
    213     kCategoryVmaskmov,
    214     kCategoryVmovddup,
    215     kCategoryVmovmskpd,
    216     kCategoryVmovmskps,
    217     kCategoryVmov1_2,
    218     kCategoryVmov1_4,
    219     kCategoryVmov1_8,
    220     kCategoryVmov2_1,
    221     kCategoryVmov4_1,
    222     kCategoryVmov8_1
    223   };
    224 
    225   uint8_t category;
    226   uint8_t rm_info;
    227   uint8_t op_info_index[6];
    228 };
    229 
    230 struct RWInfoOp {
    231   uint64_t r_byte_mask;
    232   uint64_t w_byte_mask;
    233   uint8_t phys_id;
    234   uint8_t consecutive_lead_count;
    235   uint8_t reserved[2];
    236   OpRWFlags flags;
    237 };
    238 
    239 //! R/M information.
    240 //!
    241 //! This data is used to replace register operand by a memory operand reliably.
    242 struct RWInfoRm {
    243   enum Category : uint8_t {
    244     kCategoryNone = 0,
    245     kCategoryFixed,
    246     kCategoryConsistent,
    247     kCategoryHalf,
    248     kCategoryQuarter,
    249     kCategoryEighth
    250   };
    251 
    252   enum Flags : uint8_t {
    253     kFlagAmbiguous = 0x01,
    254     //! Special semantics for PEXTRW - memory operand can only be used with SSE4.1 instruction and it's forbidden in MMX.
    255     kFlagPextrw = 0x02,
    256     //! Special semantics for MOVSS and MOVSD - doesn't zero extend the destination if the operation is a reg to reg move.
    257     kFlagMovssMovsd = 0x04,
    258     //! Special semantics for AVX shift instructions that do not provide reg/mem in AVX/AVX2 mode (AVX-512 is required).
    259     kFlagFeatureIfRMI = 0x08
    260   };
    261 
    262   uint8_t category;
    263   uint8_t rm_ops_mask;
    264   uint8_t fixed_size;
    265   uint8_t flags;
    266   uint8_t rm_feature;
    267 };
    268 
    269 struct RWFlagsInfoTable {
    270   //! CPU/FPU flags read.
    271   uint32_t read_flags;
    272   //! CPU/FPU flags written or undefined.
    273   uint32_t write_flags;
    274 };
    275 
    276 extern const uint8_t rw_info_index_a_table[Inst::_kIdCount];
    277 extern const uint8_t rw_info_index_b_table[Inst::_kIdCount];
    278 extern const RWInfo rw_info_a_table[];
    279 extern const RWInfo rw_info_b_table[];
    280 extern const RWInfoOp rw_info_op_table[];
    281 extern const RWInfoRm rw_info_rm_table[];
    282 extern const RWFlagsInfoTable rw_flags_info_table[];
    283 extern const InstRWFlags inst_flags_table[];
    284 
    285 extern const uint32_t main_opcode_table[];
    286 extern const uint32_t alt_opcode_table[];
    287 
    288 #ifndef ASMJIT_NO_TEXT
    289 
    290 extern const InstNameIndex _inst_name_index;
    291 extern const char _inst_name_string_table[];
    292 extern const uint32_t _inst_name_index_table[];
    293 
    294 extern const char alias_name_string_table[];
    295 extern const uint32_t alias_name_index_table[];
    296 extern const uint32_t alias_index_to_inst_id_table[];
    297 
    298 // ${NameDataInfo:Begin}
    299 // ------------------- Automatically generated, do not edit -------------------
    300 static constexpr uint32_t kAliasTableSize = 44;
    301 // ----------------------------------------------------------------------------
    302 // ${NameDataInfo:End}
    303 
    304 #endif // !ASMJIT_NO_TEXT
    305 
    306 extern const AdditionalInfo additional_info_table[];
    307 
    308 } // {InstDB}
    309 
    310 //! \}
    311 //! \endcond
    312 
    313 ASMJIT_END_SUB_NAMESPACE
    314 
    315 #endif // ASMJIT_X86_X86INSTDB_P_H_INCLUDED