1 1.1 skrll /* Declarations for Intel 80386 opcode table 2 1.1.1.12 christos Copyright (C) 2007-2026 Free Software Foundation, Inc. 3 1.1 skrll 4 1.1 skrll This file is part of the GNU opcodes library. 5 1.1 skrll 6 1.1 skrll This library is free software; you can redistribute it and/or modify 7 1.1 skrll it under the terms of the GNU General Public License as published by 8 1.1 skrll the Free Software Foundation; either version 3, or (at your option) 9 1.1 skrll any later version. 10 1.1 skrll 11 1.1 skrll It is distributed in the hope that it will be useful, but WITHOUT 12 1.1 skrll ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 1.1 skrll or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 14 1.1 skrll License for more details. 15 1.1 skrll 16 1.1 skrll You should have received a copy of the GNU General Public License 17 1.1 skrll along with GAS; see the file COPYING. If not, write to the Free 18 1.1 skrll Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 19 1.1 skrll 02110-1301, USA. */ 20 1.1 skrll 21 1.1 skrll #include "opcode/i386.h" 22 1.1 skrll #include <limits.h> 23 1.1 skrll #ifndef CHAR_BIT 24 1.1 skrll #define CHAR_BIT 8 25 1.1 skrll #endif 26 1.1 skrll 27 1.1 skrll /* Position of cpu flags bitfiled. */ 28 1.1 skrll 29 1.1.1.10 christos enum i386_cpu 30 1.1.1.2 christos { 31 1.1.1.2 christos /* i186 or better required */ 32 1.1.1.2 christos Cpu186 = 0, 33 1.1.1.2 christos /* i286 or better required */ 34 1.1.1.2 christos Cpu286, 35 1.1.1.2 christos /* i386 or better required */ 36 1.1.1.2 christos Cpu386, 37 1.1.1.2 christos /* i486 or better required */ 38 1.1.1.2 christos Cpu486, 39 1.1.1.2 christos /* i585 or better required */ 40 1.1.1.2 christos Cpu586, 41 1.1.1.2 christos /* i686 or better required */ 42 1.1.1.2 christos Cpu686, 43 1.1.1.8 christos /* CMOV Instruction support required */ 44 1.1.1.8 christos CpuCMOV, 45 1.1.1.8 christos /* FXSR Instruction support required */ 46 1.1.1.8 christos CpuFXSR, 47 1.1.1.2 christos /* CLFLUSH Instruction support required */ 48 1.1.1.2 christos CpuClflush, 49 1.1.1.2 christos /* NOP Instruction support required */ 50 1.1.1.2 christos CpuNop, 51 1.1.1.2 christos /* SYSCALL Instructions support required */ 52 1.1.1.2 christos CpuSYSCALL, 53 1.1.1.2 christos /* Floating point support required */ 54 1.1.1.2 christos Cpu8087, 55 1.1.1.2 christos /* i686 and floating point support required */ 56 1.1.1.2 christos Cpu687, 57 1.1.1.2 christos /* SSE3 and floating point support required */ 58 1.1.1.2 christos CpuFISTTP, 59 1.1.1.2 christos /* MMX support required */ 60 1.1.1.2 christos CpuMMX, 61 1.1.1.2 christos /* SSE support required */ 62 1.1.1.2 christos CpuSSE, 63 1.1.1.2 christos /* SSE2 support required */ 64 1.1.1.2 christos CpuSSE2, 65 1.1.1.2 christos /* SSE3 support required */ 66 1.1.1.2 christos CpuSSE3, 67 1.1.1.2 christos /* VIA PadLock required */ 68 1.1.1.2 christos CpuPadLock, 69 1.1.1.11 christos /* Zhaoxin PadLock RNG2 required */ 70 1.1.1.11 christos CpuPadLockRNG2, 71 1.1.1.11 christos /* Zhaoxin PadLock PHE2 required */ 72 1.1.1.11 christos CpuPadLockPHE2, 73 1.1.1.11 christos /* Zhaoxin PadLock XMODX required */ 74 1.1.1.11 christos CpuPadLockXMODX, 75 1.1.1.11 christos /* Zhaoxin GMI SM2 required */ 76 1.1.1.11 christos CpuGMISM2, 77 1.1.1.11 christos /* Zhaoxin GMI CCS required */ 78 1.1.1.11 christos CpuGMICCS, 79 1.1.1.2 christos /* AMD Secure Virtual Machine Ext-s required */ 80 1.1.1.2 christos CpuSVME, 81 1.1.1.2 christos /* VMX Instructions required */ 82 1.1.1.2 christos CpuVMX, 83 1.1.1.2 christos /* SMX Instructions required */ 84 1.1.1.2 christos CpuSMX, 85 1.1.1.2 christos /* SSSE3 support required */ 86 1.1.1.2 christos CpuSSSE3, 87 1.1.1.2 christos /* SSE4a support required */ 88 1.1.1.2 christos CpuSSE4a, 89 1.1.1.9 christos /* LZCNT support required */ 90 1.1.1.9 christos CpuLZCNT, 91 1.1.1.9 christos /* POPCNT support required */ 92 1.1.1.9 christos CpuPOPCNT, 93 1.1.1.10 christos /* MONITOR support required */ 94 1.1.1.10 christos CpuMONITOR, 95 1.1.1.2 christos /* SSE4.1 support required */ 96 1.1.1.2 christos CpuSSE4_1, 97 1.1.1.2 christos /* SSE4.2 support required */ 98 1.1.1.2 christos CpuSSE4_2, 99 1.1.1.3 christos /* AVX2 support required */ 100 1.1.1.3 christos CpuAVX2, 101 1.1.1.4 christos /* Intel AVX-512 Conflict Detection Instructions support required */ 102 1.1.1.4 christos CpuAVX512CD, 103 1.1.1.4 christos /* Intel AVX-512 Exponential and Reciprocal Instructions support 104 1.1.1.4 christos required */ 105 1.1.1.4 christos CpuAVX512ER, 106 1.1.1.4 christos /* Intel AVX-512 Prefetch Instructions support required */ 107 1.1.1.4 christos CpuAVX512PF, 108 1.1.1.4 christos /* Intel AVX-512 DQ Instructions support required. */ 109 1.1.1.4 christos CpuAVX512DQ, 110 1.1.1.4 christos /* Intel AVX-512 BW Instructions support required. */ 111 1.1.1.4 christos CpuAVX512BW, 112 1.1.1.4 christos /* Intel IAMCU support required */ 113 1.1.1.4 christos CpuIAMCU, 114 1.1.1.2 christos /* Xsave/xrstor New Instructions support required */ 115 1.1.1.2 christos CpuXsave, 116 1.1.1.2 christos /* Xsaveopt New Instructions support required */ 117 1.1.1.2 christos CpuXsaveopt, 118 1.1.1.2 christos /* AES support required */ 119 1.1.1.2 christos CpuAES, 120 1.1.1.10 christos /* PCLMULQDQ support required */ 121 1.1.1.10 christos CpuPCLMULQDQ, 122 1.1.1.2 christos /* FMA support required */ 123 1.1.1.2 christos CpuFMA, 124 1.1.1.2 christos /* FMA4 support required */ 125 1.1.1.2 christos CpuFMA4, 126 1.1.1.2 christos /* XOP support required */ 127 1.1.1.2 christos CpuXOP, 128 1.1.1.2 christos /* LWP support required */ 129 1.1.1.2 christos CpuLWP, 130 1.1.1.3 christos /* BMI support required */ 131 1.1.1.3 christos CpuBMI, 132 1.1.1.3 christos /* TBM support required */ 133 1.1.1.3 christos CpuTBM, 134 1.1.1.2 christos /* MOVBE Instruction support required */ 135 1.1.1.2 christos CpuMovbe, 136 1.1.1.4 christos /* CMPXCHG16B instruction support required. */ 137 1.1.1.4 christos CpuCX16, 138 1.1.1.10 christos /* LAHF/SAHF instruction support required (in 64-bit mode). */ 139 1.1.1.10 christos CpuLAHF_SAHF, 140 1.1.1.2 christos /* EPT Instructions required */ 141 1.1.1.2 christos CpuEPT, 142 1.1.1.2 christos /* RDTSCP Instruction support required */ 143 1.1.1.2 christos CpuRdtscp, 144 1.1.1.2 christos /* FSGSBASE Instructions required */ 145 1.1.1.2 christos CpuFSGSBase, 146 1.1.1.2 christos /* RDRND Instructions required */ 147 1.1.1.2 christos CpuRdRnd, 148 1.1.1.2 christos /* F16C Instructions required */ 149 1.1.1.2 christos CpuF16C, 150 1.1.1.3 christos /* Intel BMI2 support required */ 151 1.1.1.3 christos CpuBMI2, 152 1.1.1.3 christos /* RTM support required */ 153 1.1.1.3 christos CpuRTM, 154 1.1.1.3 christos /* INVPCID Instructions required */ 155 1.1.1.3 christos CpuINVPCID, 156 1.1.1.3 christos /* VMFUNC Instruction required */ 157 1.1.1.3 christos CpuVMFUNC, 158 1.1.1.4 christos /* Intel MPX Instructions required */ 159 1.1.1.4 christos CpuMPX, 160 1.1.1.3 christos /* RDRSEED instruction required. */ 161 1.1.1.3 christos CpuRDSEED, 162 1.1.1.3 christos /* Multi-presisionn add-carry instructions are required. */ 163 1.1.1.3 christos CpuADX, 164 1.1.1.3 christos /* Supports prefetchw and prefetch instructions. */ 165 1.1.1.3 christos CpuPRFCHW, 166 1.1.1.4 christos /* SMAP instructions required. */ 167 1.1.1.4 christos CpuSMAP, 168 1.1.1.4 christos /* SHA instructions required. */ 169 1.1.1.4 christos CpuSHA, 170 1.1.1.10 christos /* SHA512 instructions required. */ 171 1.1.1.10 christos CpuSHA512, 172 1.1.1.10 christos /* SM3 instructions required. */ 173 1.1.1.10 christos CpuSM3, 174 1.1.1.10 christos /* SM4 instructions required. */ 175 1.1.1.10 christos CpuSM4, 176 1.1.1.4 christos /* CLFLUSHOPT instruction required */ 177 1.1.1.4 christos CpuClflushOpt, 178 1.1.1.4 christos /* XSAVES/XRSTORS instruction required */ 179 1.1.1.4 christos CpuXSAVES, 180 1.1.1.4 christos /* XSAVEC instruction required */ 181 1.1.1.4 christos CpuXSAVEC, 182 1.1.1.4 christos /* PREFETCHWT1 instruction required */ 183 1.1.1.4 christos CpuPREFETCHWT1, 184 1.1.1.4 christos /* SE1 instruction required */ 185 1.1.1.4 christos CpuSE1, 186 1.1.1.4 christos /* CLWB instruction required */ 187 1.1.1.4 christos CpuCLWB, 188 1.1.1.4 christos /* Intel AVX-512 IFMA Instructions support required. */ 189 1.1.1.4 christos CpuAVX512IFMA, 190 1.1.1.4 christos /* Intel AVX-512 VBMI Instructions support required. */ 191 1.1.1.4 christos CpuAVX512VBMI, 192 1.1.1.6 christos /* Intel AVX-512 4FMAPS Instructions support required. */ 193 1.1.1.6 christos CpuAVX512_4FMAPS, 194 1.1.1.6 christos /* Intel AVX-512 4VNNIW Instructions support required. */ 195 1.1.1.6 christos CpuAVX512_4VNNIW, 196 1.1.1.6 christos /* Intel AVX-512 VPOPCNTDQ Instructions support required. */ 197 1.1.1.6 christos CpuAVX512_VPOPCNTDQ, 198 1.1.1.6 christos /* Intel AVX-512 VBMI2 Instructions support required. */ 199 1.1.1.6 christos CpuAVX512_VBMI2, 200 1.1.1.6 christos /* Intel AVX-512 VNNI Instructions support required. */ 201 1.1.1.6 christos CpuAVX512_VNNI, 202 1.1.1.6 christos /* Intel AVX-512 BITALG Instructions support required. */ 203 1.1.1.6 christos CpuAVX512_BITALG, 204 1.1.1.8 christos /* Intel AVX-512 BF16 Instructions support required. */ 205 1.1.1.8 christos CpuAVX512_BF16, 206 1.1.1.8 christos /* Intel AVX-512 VP2INTERSECT Instructions support required. */ 207 1.1.1.8 christos CpuAVX512_VP2INTERSECT, 208 1.1.1.12 christos /* AMD AVX-512 BMM Instructions support required. */ 209 1.1.1.12 christos CpuAVX512_BMM, 210 1.1.1.9 christos /* TDX Instructions support required. */ 211 1.1.1.9 christos CpuTDX, 212 1.1.1.9 christos /* Intel AVX VNNI Instructions support required. */ 213 1.1.1.9 christos CpuAVX_VNNI, 214 1.1.1.9 christos /* Intel AVX-512 FP16 Instructions support required. */ 215 1.1.1.9 christos CpuAVX512_FP16, 216 1.1.1.10 christos /* PREFETCHI instruction required */ 217 1.1.1.10 christos CpuPREFETCHI, 218 1.1.1.10 christos /* Intel AVX IFMA Instructions support required. */ 219 1.1.1.10 christos CpuAVX_IFMA, 220 1.1.1.10 christos /* Intel AVX VNNI-INT8 Instructions support required. */ 221 1.1.1.10 christos CpuAVX_VNNI_INT8, 222 1.1.1.10 christos /* Intel AVX VNNI-INT16 Instructions support required. */ 223 1.1.1.10 christos CpuAVX_VNNI_INT16, 224 1.1.1.10 christos /* Intel CMPccXADD instructions support required. */ 225 1.1.1.10 christos CpuCMPCCXADD, 226 1.1.1.10 christos /* Intel WRMSRNS Instructions support required */ 227 1.1.1.10 christos CpuWRMSRNS, 228 1.1.1.10 christos /* Intel MSRLIST Instructions support required. */ 229 1.1.1.10 christos CpuMSRLIST, 230 1.1.1.10 christos /* Intel AVX NE CONVERT Instructions support required. */ 231 1.1.1.10 christos CpuAVX_NE_CONVERT, 232 1.1.1.10 christos /* Intel RAO INT Instructions support required. */ 233 1.1.1.10 christos CpuRAO_INT, 234 1.1.1.10 christos /* fred instruction required */ 235 1.1.1.10 christos CpuFRED, 236 1.1.1.10 christos /* lkgs instruction required */ 237 1.1.1.10 christos CpuLKGS, 238 1.1.1.10 christos /* Intel USER_MSR Instruction support required. */ 239 1.1.1.10 christos CpuUSER_MSR, 240 1.1.1.11 christos /* Intel MSR_IMM Instructions support required. */ 241 1.1.1.11 christos CpuMSR_IMM, 242 1.1.1.11 christos /* Intel MOVRS Instructions support required. */ 243 1.1.1.11 christos CpuMOVRS, 244 1.1.1.4 christos /* mwaitx instruction required */ 245 1.1.1.4 christos CpuMWAITX, 246 1.1.1.4 christos /* Clzero instruction required */ 247 1.1.1.4 christos CpuCLZERO, 248 1.1.1.4 christos /* OSPKE instruction required */ 249 1.1.1.4 christos CpuOSPKE, 250 1.1.1.5 christos /* RDPID instruction required */ 251 1.1.1.5 christos CpuRDPID, 252 1.1.1.6 christos /* PTWRITE instruction required */ 253 1.1.1.6 christos CpuPTWRITE, 254 1.1.1.7 christos /* CET instructions support required */ 255 1.1.1.7 christos CpuIBT, 256 1.1.1.7 christos CpuSHSTK, 257 1.1.1.9 christos /* AMX-INT8 instructions required */ 258 1.1.1.9 christos CpuAMX_INT8, 259 1.1.1.9 christos /* AMX-BF16 instructions required */ 260 1.1.1.9 christos CpuAMX_BF16, 261 1.1.1.10 christos /* AMX-FP16 instructions required */ 262 1.1.1.10 christos CpuAMX_FP16, 263 1.1.1.10 christos /* AMX-COMPLEX instructions required. */ 264 1.1.1.10 christos CpuAMX_COMPLEX, 265 1.1.1.11 christos /* AMX-TF32 Instructions support required. */ 266 1.1.1.11 christos CpuAMX_TF32, 267 1.1.1.11 christos /* AMX-FP8 instructions required */ 268 1.1.1.11 christos CpuAMX_FP8, 269 1.1.1.11 christos /* AMX-MOVRS Instructions support required. */ 270 1.1.1.11 christos CpuAMX_MOVRS, 271 1.1.1.11 christos /* AMX-AVX512 Instructions support required. */ 272 1.1.1.11 christos CpuAMX_AVX512, 273 1.1.1.9 christos /* AMX-TILE instructions required */ 274 1.1.1.9 christos CpuAMX_TILE, 275 1.1.1.6 christos /* GFNI instructions required */ 276 1.1.1.6 christos CpuGFNI, 277 1.1.1.6 christos /* VAES instructions required */ 278 1.1.1.6 christos CpuVAES, 279 1.1.1.6 christos /* VPCLMULQDQ instructions required */ 280 1.1.1.6 christos CpuVPCLMULQDQ, 281 1.1.1.7 christos /* WBNOINVD instructions required */ 282 1.1.1.7 christos CpuWBNOINVD, 283 1.1.1.7 christos /* PCONFIG instructions required */ 284 1.1.1.7 christos CpuPCONFIG, 285 1.1.1.10 christos /* PBNDKB instructions required. */ 286 1.1.1.10 christos CpuPBNDKB, 287 1.1.1.7 christos /* WAITPKG instructions required */ 288 1.1.1.7 christos CpuWAITPKG, 289 1.1.1.9 christos /* UINTR instructions required */ 290 1.1.1.9 christos CpuUINTR, 291 1.1.1.7 christos /* CLDEMOTE instruction required */ 292 1.1.1.7 christos CpuCLDEMOTE, 293 1.1.1.7 christos /* MOVDIRI instruction support required */ 294 1.1.1.7 christos CpuMOVDIRI, 295 1.1.1.7 christos /* MOVDIRR64B instruction required */ 296 1.1.1.7 christos CpuMOVDIR64B, 297 1.1.1.8 christos /* ENQCMD instruction required */ 298 1.1.1.8 christos CpuENQCMD, 299 1.1.1.9 christos /* SERIALIZE instruction required */ 300 1.1.1.9 christos CpuSERIALIZE, 301 1.1.1.8 christos /* RDPRU instruction required */ 302 1.1.1.8 christos CpuRDPRU, 303 1.1.1.8 christos /* MCOMMIT instruction required */ 304 1.1.1.8 christos CpuMCOMMIT, 305 1.1.1.9 christos /* SEV-ES instruction(s) required */ 306 1.1.1.9 christos CpuSEV_ES, 307 1.1.1.9 christos /* TSXLDTRK instruction required */ 308 1.1.1.9 christos CpuTSXLDTRK, 309 1.1.1.9 christos /* KL instruction support required */ 310 1.1.1.9 christos CpuKL, 311 1.1.1.9 christos /* WideKL instruction support required */ 312 1.1.1.9 christos CpuWideKL, 313 1.1.1.9 christos /* HRESET instruction required */ 314 1.1.1.9 christos CpuHRESET, 315 1.1.1.9 christos /* INVLPGB instructions required */ 316 1.1.1.9 christos CpuINVLPGB, 317 1.1.1.9 christos /* TLBSYNC instructions required */ 318 1.1.1.9 christos CpuTLBSYNC, 319 1.1.1.9 christos /* SNP instructions required */ 320 1.1.1.9 christos CpuSNP, 321 1.1.1.10 christos /* RMPQUERY instruction required */ 322 1.1.1.10 christos CpuRMPQUERY, 323 1.1.1.11 christos /* RMPREAD instruction required */ 324 1.1.1.11 christos CpuRMPREAD, 325 1.1.1.12 christos /* Intel APX New Conditional Instructions support required. */ 326 1.1.1.12 christos CpuAPX_NCI, 327 1.1.1.12 christos /* Intel APX Non-Destructive Destination support required. */ 328 1.1.1.12 christos CpuAPX_NDD, 329 1.1.1.12 christos /* Intel APX No-Flags-update support required. */ 330 1.1.1.12 christos CpuAPX_NF, 331 1.1.1.9 christos 332 1.1.1.10 christos /* NOTE: These items, which can be combined with other ISA flags above, need 333 1.1.1.10 christos to remain second to last and in sync with CPU_FLAGS_COMMON. */ 334 1.1.1.9 christos 335 1.1.1.10 christos /* i287 support required */ 336 1.1.1.10 christos Cpu287, 337 1.1.1.10 christos CpuAttrEnums = Cpu287, 338 1.1.1.10 christos /* i387 support required */ 339 1.1.1.10 christos Cpu387, 340 1.1.1.10 christos /* 3dnow! support required */ 341 1.1.1.10 christos Cpu3dnow, 342 1.1.1.10 christos /* 3dnow! Extensions support required */ 343 1.1.1.10 christos Cpu3dnowA, 344 1.1.1.2 christos /* 64bit support required */ 345 1.1.1.2 christos Cpu64, 346 1.1.1.10 christos /* AVX support required */ 347 1.1.1.10 christos CpuAVX, 348 1.1.1.10 christos /* HLE support required */ 349 1.1.1.10 christos CpuHLE, 350 1.1.1.10 christos /* Intel AVX-512 Foundation Instructions support required */ 351 1.1.1.10 christos CpuAVX512F, 352 1.1.1.10 christos /* Intel AVX-512 VL Instructions support required. */ 353 1.1.1.10 christos CpuAVX512VL, 354 1.1.1.10 christos /* Intel APX_F Instructions support required. */ 355 1.1.1.10 christos CpuAPX_F, 356 1.1.1.11 christos /* Intel AVX10.2 Instructions support required. */ 357 1.1.1.11 christos CpuAVX10_2, 358 1.1.1.11 christos /* Intel AMX-TRANSPOSE Instructions support required. */ 359 1.1.1.11 christos CpuAMX_TRANSPOSE, 360 1.1.1.2 christos /* Not supported in the 64bit mode */ 361 1.1.1.2 christos CpuNo64, 362 1.1.1.10 christos 363 1.1.1.10 christos /* NOTE: This item needs to remain last. */ 364 1.1.1.10 christos 365 1.1.1.2 christos /* The last bitfield in i386_cpu_flags. */ 366 1.1.1.2 christos CpuMax = CpuNo64 367 1.1.1.2 christos }; 368 1.1 skrll 369 1.1 skrll #define CpuNumOfUints \ 370 1.1 skrll (CpuMax / sizeof (unsigned int) / CHAR_BIT + 1) 371 1.1 skrll #define CpuNumOfBits \ 372 1.1 skrll (CpuNumOfUints * sizeof (unsigned int) * CHAR_BIT) 373 1.1 skrll 374 1.1.1.10 christos #define CpuIsaBits 8 375 1.1.1.10 christos #define CpuAttrNumOfUints \ 376 1.1.1.10 christos ((CpuIsaBits + CpuMax - CpuAttrEnums) / sizeof (unsigned int) / CHAR_BIT + 1) 377 1.1.1.10 christos #define CpuAttrNumOfBits \ 378 1.1.1.10 christos (CpuAttrNumOfUints * sizeof (unsigned int) * CHAR_BIT) 379 1.1.1.10 christos 380 1.1.1.10 christos /* If you get a compiler error for zero width of an unused field, 381 1.1.1.10 christos comment the respective one out. */ 382 1.1 skrll #define CpuUnused (CpuMax + 1) 383 1.1.1.10 christos #define CpuAttrUnused (CpuIsaBits + CpuMax + 1 - CpuAttrEnums) 384 1.1.1.10 christos 385 1.1.1.10 christos #define CPU_FLAGS_COMMON \ 386 1.1.1.10 christos unsigned int cpu287:1, \ 387 1.1.1.10 christos cpu387:1, \ 388 1.1.1.10 christos cpu3dnow:1, \ 389 1.1.1.10 christos cpu3dnowa:1, \ 390 1.1.1.10 christos cpu64:1, \ 391 1.1.1.10 christos cpuavx:1, \ 392 1.1.1.10 christos cpuhle:1, \ 393 1.1.1.10 christos cpuavx512f:1, \ 394 1.1.1.10 christos cpuavx512vl:1, \ 395 1.1.1.10 christos cpuapx_f:1, \ 396 1.1.1.11 christos cpuavx10_2:1, \ 397 1.1.1.11 christos cpuamx_transpose:1, \ 398 1.1.1.10 christos /* NOTE: This field needs to remain last. */ \ 399 1.1.1.10 christos cpuno64:1 400 1.1.1.10 christos 401 1.1.1.10 christos typedef union i386_cpu_attr 402 1.1.1.10 christos { 403 1.1.1.10 christos struct 404 1.1.1.10 christos { 405 1.1.1.10 christos unsigned int isa:CpuIsaBits; 406 1.1.1.10 christos CPU_FLAGS_COMMON; 407 1.1.1.10 christos #ifdef CpuAttrUnused 408 1.1.1.10 christos unsigned int unused:(CpuAttrNumOfBits - CpuAttrUnused); 409 1.1.1.10 christos #endif 410 1.1.1.10 christos } bitfield; 411 1.1.1.10 christos unsigned int array[CpuAttrNumOfUints]; 412 1.1.1.10 christos } i386_cpu_attr; 413 1.1 skrll 414 1.1 skrll /* We can check if an instruction is available with array instead 415 1.1 skrll of bitfield. */ 416 1.1 skrll typedef union i386_cpu_flags 417 1.1 skrll { 418 1.1 skrll struct 419 1.1 skrll { 420 1.1 skrll unsigned int cpui186:1; 421 1.1 skrll unsigned int cpui286:1; 422 1.1 skrll unsigned int cpui386:1; 423 1.1 skrll unsigned int cpui486:1; 424 1.1 skrll unsigned int cpui586:1; 425 1.1 skrll unsigned int cpui686:1; 426 1.1.1.8 christos unsigned int cpucmov:1; 427 1.1.1.8 christos unsigned int cpufxsr:1; 428 1.1.1.2 christos unsigned int cpuclflush:1; 429 1.1.1.2 christos unsigned int cpunop:1; 430 1.1.1.2 christos unsigned int cpusyscall:1; 431 1.1.1.2 christos unsigned int cpu8087:1; 432 1.1.1.2 christos unsigned int cpu687:1; 433 1.1.1.2 christos unsigned int cpufisttp:1; 434 1.1 skrll unsigned int cpummx:1; 435 1.1 skrll unsigned int cpusse:1; 436 1.1 skrll unsigned int cpusse2:1; 437 1.1 skrll unsigned int cpusse3:1; 438 1.1 skrll unsigned int cpupadlock:1; 439 1.1.1.11 christos unsigned int cpupadlockrng2:1; 440 1.1.1.11 christos unsigned int cpupadlockphe2:1; 441 1.1.1.11 christos unsigned int cpupadlockxmodx:1; 442 1.1.1.11 christos unsigned int cpugmism2:1; 443 1.1.1.11 christos unsigned int cpugmiccs:1; 444 1.1 skrll unsigned int cpusvme:1; 445 1.1 skrll unsigned int cpuvmx:1; 446 1.1 skrll unsigned int cpusmx:1; 447 1.1 skrll unsigned int cpussse3:1; 448 1.1 skrll unsigned int cpusse4a:1; 449 1.1.1.9 christos unsigned int cpulzcnt:1; 450 1.1.1.9 christos unsigned int cpupopcnt:1; 451 1.1.1.10 christos unsigned int cpumonitor:1; 452 1.1 skrll unsigned int cpusse4_1:1; 453 1.1 skrll unsigned int cpusse4_2:1; 454 1.1.1.3 christos unsigned int cpuavx2:1; 455 1.1.1.4 christos unsigned int cpuavx512cd:1; 456 1.1.1.4 christos unsigned int cpuavx512er:1; 457 1.1.1.4 christos unsigned int cpuavx512pf:1; 458 1.1.1.4 christos unsigned int cpuavx512dq:1; 459 1.1.1.4 christos unsigned int cpuavx512bw:1; 460 1.1.1.4 christos unsigned int cpuiamcu:1; 461 1.1 skrll unsigned int cpuxsave:1; 462 1.1.1.2 christos unsigned int cpuxsaveopt:1; 463 1.1 skrll unsigned int cpuaes:1; 464 1.1.1.10 christos unsigned int cpupclmulqdq:1; 465 1.1 skrll unsigned int cpufma:1; 466 1.1.1.2 christos unsigned int cpufma4:1; 467 1.1.1.2 christos unsigned int cpuxop:1; 468 1.1.1.2 christos unsigned int cpulwp:1; 469 1.1.1.3 christos unsigned int cpubmi:1; 470 1.1.1.3 christos unsigned int cputbm:1; 471 1.1 skrll unsigned int cpumovbe:1; 472 1.1.1.4 christos unsigned int cpucx16:1; 473 1.1.1.10 christos unsigned int cpulahf_sahf:1; 474 1.1 skrll unsigned int cpuept:1; 475 1.1.1.2 christos unsigned int cpurdtscp:1; 476 1.1.1.2 christos unsigned int cpufsgsbase:1; 477 1.1.1.2 christos unsigned int cpurdrnd:1; 478 1.1.1.2 christos unsigned int cpuf16c:1; 479 1.1.1.3 christos unsigned int cpubmi2:1; 480 1.1.1.3 christos unsigned int cpurtm:1; 481 1.1.1.3 christos unsigned int cpuinvpcid:1; 482 1.1.1.3 christos unsigned int cpuvmfunc:1; 483 1.1.1.4 christos unsigned int cpumpx:1; 484 1.1.1.3 christos unsigned int cpurdseed:1; 485 1.1.1.3 christos unsigned int cpuadx:1; 486 1.1.1.3 christos unsigned int cpuprfchw:1; 487 1.1.1.4 christos unsigned int cpusmap:1; 488 1.1.1.4 christos unsigned int cpusha:1; 489 1.1.1.10 christos unsigned int cpusha512:1; 490 1.1.1.10 christos unsigned int cpusm3:1; 491 1.1.1.10 christos unsigned int cpusm4:1; 492 1.1.1.4 christos unsigned int cpuclflushopt:1; 493 1.1.1.4 christos unsigned int cpuxsaves:1; 494 1.1.1.4 christos unsigned int cpuxsavec:1; 495 1.1.1.4 christos unsigned int cpuprefetchwt1:1; 496 1.1.1.4 christos unsigned int cpuse1:1; 497 1.1.1.4 christos unsigned int cpuclwb:1; 498 1.1.1.4 christos unsigned int cpuavx512ifma:1; 499 1.1.1.4 christos unsigned int cpuavx512vbmi:1; 500 1.1.1.6 christos unsigned int cpuavx512_4fmaps:1; 501 1.1.1.6 christos unsigned int cpuavx512_4vnniw:1; 502 1.1.1.6 christos unsigned int cpuavx512_vpopcntdq:1; 503 1.1.1.6 christos unsigned int cpuavx512_vbmi2:1; 504 1.1.1.6 christos unsigned int cpuavx512_vnni:1; 505 1.1.1.6 christos unsigned int cpuavx512_bitalg:1; 506 1.1.1.8 christos unsigned int cpuavx512_bf16:1; 507 1.1.1.8 christos unsigned int cpuavx512_vp2intersect:1; 508 1.1.1.12 christos unsigned int cpuavx512_bmm:1; 509 1.1.1.9 christos unsigned int cputdx:1; 510 1.1.1.9 christos unsigned int cpuavx_vnni:1; 511 1.1.1.9 christos unsigned int cpuavx512_fp16:1; 512 1.1.1.10 christos unsigned int cpuprefetchi:1; 513 1.1.1.10 christos unsigned int cpuavx_ifma:1; 514 1.1.1.10 christos unsigned int cpuavx_vnni_int8:1; 515 1.1.1.10 christos unsigned int cpuavx_vnni_int16:1; 516 1.1.1.10 christos unsigned int cpucmpccxadd:1; 517 1.1.1.10 christos unsigned int cpuwrmsrns:1; 518 1.1.1.10 christos unsigned int cpumsrlist:1; 519 1.1.1.10 christos unsigned int cpuavx_ne_convert:1; 520 1.1.1.10 christos unsigned int cpurao_int:1; 521 1.1.1.10 christos unsigned int cpufred:1; 522 1.1.1.10 christos unsigned int cpulkgs:1; 523 1.1.1.10 christos unsigned int cpuuser_msr:1; 524 1.1.1.11 christos unsigned int cpumsr_imm:1; 525 1.1.1.11 christos unsigned int cpumovrs:1; 526 1.1.1.4 christos unsigned int cpumwaitx:1; 527 1.1.1.4 christos unsigned int cpuclzero:1; 528 1.1.1.4 christos unsigned int cpuospke:1; 529 1.1.1.5 christos unsigned int cpurdpid:1; 530 1.1.1.6 christos unsigned int cpuptwrite:1; 531 1.1.1.7 christos unsigned int cpuibt:1; 532 1.1.1.7 christos unsigned int cpushstk:1; 533 1.1.1.9 christos unsigned int cpuamx_int8:1; 534 1.1.1.9 christos unsigned int cpuamx_bf16:1; 535 1.1.1.10 christos unsigned int cpuamx_fp16:1; 536 1.1.1.10 christos unsigned int cpuamx_complex:1; 537 1.1.1.11 christos unsigned int cpuamx_tf32:1; 538 1.1.1.11 christos unsigned int cpuamx_fp8:1; 539 1.1.1.11 christos unsigned int cpuamx_movrs:1; 540 1.1.1.11 christos unsigned int cpuamx_avx512:1; 541 1.1.1.9 christos unsigned int cpuamx_tile:1; 542 1.1.1.6 christos unsigned int cpugfni:1; 543 1.1.1.6 christos unsigned int cpuvaes:1; 544 1.1.1.6 christos unsigned int cpuvpclmulqdq:1; 545 1.1.1.7 christos unsigned int cpuwbnoinvd:1; 546 1.1.1.7 christos unsigned int cpupconfig:1; 547 1.1.1.10 christos unsigned int cpupbndkb:1; 548 1.1.1.7 christos unsigned int cpuwaitpkg:1; 549 1.1.1.9 christos unsigned int cpuuintr:1; 550 1.1.1.7 christos unsigned int cpucldemote:1; 551 1.1.1.7 christos unsigned int cpumovdiri:1; 552 1.1.1.7 christos unsigned int cpumovdir64b:1; 553 1.1.1.8 christos unsigned int cpuenqcmd:1; 554 1.1.1.9 christos unsigned int cpuserialize:1; 555 1.1.1.8 christos unsigned int cpurdpru:1; 556 1.1.1.8 christos unsigned int cpumcommit:1; 557 1.1.1.9 christos unsigned int cpusev_es:1; 558 1.1.1.9 christos unsigned int cputsxldtrk:1; 559 1.1.1.9 christos unsigned int cpukl:1; 560 1.1.1.9 christos unsigned int cpuwidekl:1; 561 1.1.1.9 christos unsigned int cpuhreset:1; 562 1.1.1.9 christos unsigned int cpuinvlpgb:1; 563 1.1.1.9 christos unsigned int cputlbsync:1; 564 1.1.1.9 christos unsigned int cpusnp:1; 565 1.1.1.10 christos unsigned int cpurmpquery:1; 566 1.1.1.11 christos unsigned int cpurmpread:1; 567 1.1.1.12 christos unsigned int cpuapx_nci:1; 568 1.1.1.12 christos unsigned int cpuapx_ndd:1; 569 1.1.1.12 christos unsigned int cpuapx_nf:1; 570 1.1.1.10 christos CPU_FLAGS_COMMON; 571 1.1 skrll #ifdef CpuUnused 572 1.1 skrll unsigned int unused:(CpuNumOfBits - CpuUnused); 573 1.1 skrll #endif 574 1.1 skrll } bitfield; 575 1.1 skrll unsigned int array[CpuNumOfUints]; 576 1.1 skrll } i386_cpu_flags; 577 1.1 skrll 578 1.1 skrll /* Position of opcode_modifier bits. */ 579 1.1 skrll 580 1.1.1.2 christos enum 581 1.1.1.2 christos { 582 1.1.1.2 christos /* has direction bit. */ 583 1.1.1.2 christos D = 0, 584 1.1.1.8 christos /* set if operands can be both bytes and words/dwords/qwords, encoded the 585 1.1.1.8 christos canonical way; the base_opcode field should hold the encoding for byte 586 1.1.1.8 christos operands */ 587 1.1.1.2 christos W, 588 1.1.1.6 christos /* load form instruction. Must be placed before store form. */ 589 1.1.1.6 christos Load, 590 1.1.1.2 christos /* insn has a modrm byte. */ 591 1.1.1.2 christos Modrm, 592 1.1.1.8 christos /* special case for jump insns; value has to be 1 */ 593 1.1.1.8 christos #define JUMP 1 594 1.1.1.2 christos /* call and jump */ 595 1.1.1.8 christos #define JUMP_DWORD 2 596 1.1.1.2 christos /* loop and jecxz */ 597 1.1.1.8 christos #define JUMP_BYTE 3 598 1.1.1.2 christos /* special case for intersegment leaps/calls */ 599 1.1.1.8 christos #define JUMP_INTERSEGMENT 4 600 1.1.1.8 christos /* absolute address for jump */ 601 1.1.1.8 christos #define JUMP_ABSOLUTE 5 602 1.1.1.8 christos Jump, 603 1.1.1.2 christos /* FP insn memory format bit, sized by 0x4 */ 604 1.1.1.2 christos FloatMF, 605 1.1.1.2 christos /* needs size prefix if in 32-bit mode */ 606 1.1.1.8 christos #define SIZE16 1 607 1.1.1.2 christos /* needs size prefix if in 16-bit mode */ 608 1.1.1.8 christos #define SIZE32 2 609 1.1.1.2 christos /* needs size prefix if in 64-bit mode */ 610 1.1.1.8 christos #define SIZE64 3 611 1.1.1.8 christos Size, 612 1.1.1.10 christos /* Check that operand sizes match. */ 613 1.1.1.10 christos CheckOperandSize, 614 1.1.1.10 christos /* any memory size */ 615 1.1.1.10 christos #define ANY_SIZE 1 616 1.1.1.10 christos /* fake an extra reg operand for clr, imul and special register 617 1.1.1.10 christos processing for some instructions. */ 618 1.1.1.10 christos #define REG_KLUDGE 2 619 1.1.1.10 christos /* deprecated fp insn, gets a warning */ 620 1.1.1.10 christos #define UGH 3 621 1.1.1.10 christos /* An implicit xmm0 as the first operand */ 622 1.1.1.10 christos #define IMPLICIT_1ST_XMM0 4 623 1.1.1.11 christos /* One of the operands denotes a sequence of registers, with insn-dependent 624 1.1.1.11 christos constraint on the first register number. It implicitly denotes e.g. the 625 1.1.1.11 christos register group of {x,y,z}mmN - {x,y,z}mm(N + 3), in which case N ought to 626 1.1.1.11 christos be a multiple of 4. 627 1.1.1.10 christos */ 628 1.1.1.11 christos #define IMPLICIT_GROUP 5 629 1.1.1.10 christos /* Default mask isn't allowed. */ 630 1.1.1.11 christos #define NO_DEFAULT_MASK 6 631 1.1.1.10 christos /* Address prefix changes register operand */ 632 1.1.1.11 christos #define ADDR_PREFIX_OP_REG 7 633 1.1.1.9 christos /* Instrucion requires that destination must be distinct from source 634 1.1.1.9 christos registers. */ 635 1.1.1.11 christos #define DISTINCT_DEST 8 636 1.1.1.10 christos /* Instruction updates stack pointer implicitly. */ 637 1.1.1.11 christos #define IMPLICIT_STACK_OP 9 638 1.1.1.11 christos /* Instruction zeroes upper part of register. */ 639 1.1.1.11 christos #define ZERO_UPPER 10 640 1.1.1.11 christos /* Instruction support SCC. */ 641 1.1.1.11 christos #define SCC 11 642 1.1.1.11 christos /* Instruction requires EVEX.NF to be 1. */ 643 1.1.1.11 christos #define EVEX_NF 12 644 1.1.1.10 christos OperandConstraint, 645 1.1.1.2 christos /* instruction ignores operand size prefix and in Intel mode ignores 646 1.1.1.2 christos mnemonic size suffix check. */ 647 1.1.1.9 christos #define IGNORESIZE 1 648 1.1.1.2 christos /* default insn size depends on mode */ 649 1.1.1.9 christos #define DEFAULTSIZE 2 650 1.1.1.9 christos MnemonicSize, 651 1.1.1.2 christos /* b suffix on instruction illegal */ 652 1.1.1.2 christos No_bSuf, 653 1.1.1.2 christos /* w suffix on instruction illegal */ 654 1.1.1.2 christos No_wSuf, 655 1.1.1.2 christos /* l suffix on instruction illegal */ 656 1.1.1.2 christos No_lSuf, 657 1.1.1.2 christos /* s suffix on instruction illegal */ 658 1.1.1.2 christos No_sSuf, 659 1.1.1.2 christos /* q suffix on instruction illegal */ 660 1.1.1.2 christos No_qSuf, 661 1.1.1.2 christos /* instruction needs FWAIT */ 662 1.1.1.2 christos FWait, 663 1.1.1.8 christos /* IsString provides for a quick test for string instructions, and 664 1.1.1.8 christos its actual value also indicates which of the operands (if any) 665 1.1.1.8 christos requires use of the %es segment. */ 666 1.1.1.8 christos #define IS_STRING_ES_OP0 2 667 1.1.1.8 christos #define IS_STRING_ES_OP1 3 668 1.1.1.2 christos IsString, 669 1.1.1.8 christos /* RegMem is for instructions with a modrm byte where the register 670 1.1.1.8 christos destination operand should be encoded in the mod and regmem fields. 671 1.1.1.8 christos Normally, it will be encoded in the reg field. We add a RegMem 672 1.1.1.8 christos flag to indicate that it should be encoded in the regmem field. */ 673 1.1.1.8 christos RegMem, 674 1.1.1.4 christos /* quick test if branch instruction is MPX supported */ 675 1.1.1.4 christos BNDPrefixOk, 676 1.1.1.9 christos #define PrefixNone 0 677 1.1.1.9 christos #define PrefixRep 1 678 1.1.1.12 christos #define PrefixRepe 2 679 1.1.1.12 christos #define PrefixHLERelease 3 /* Okay with an XRELEASE (0xf3) prefix. */ 680 1.1.1.12 christos #define PrefixNoTrack 4 681 1.1.1.9 christos /* Prefixes implying "LOCK okay" must come after Lock. All others have 682 1.1.1.9 christos to come before. */ 683 1.1.1.12 christos #define PrefixLock 5 684 1.1.1.12 christos #define PrefixHLELock 6 /* Okay with a LOCK prefix. */ 685 1.1.1.12 christos #define PrefixHLEAny 7 /* Okay with or without a LOCK prefix. */ 686 1.1.1.9 christos PrefixOk, 687 1.1.1.2 christos /* opcode is a prefix */ 688 1.1.1.2 christos IsPrefix, 689 1.1.1.2 christos /* instruction has extension in 8 bit imm */ 690 1.1.1.2 christos ImmExt, 691 1.1.1.2 christos /* instruction don't need Rex64 prefix. */ 692 1.1.1.2 christos NoRex64, 693 1.1.1.2 christos /* insn has VEX prefix: 694 1.1.1.6 christos 1: 128bit VEX prefix (or operand dependent). 695 1.1.1.2 christos 2: 256bit VEX prefix. 696 1.1.1.2 christos 3: Scalar VEX prefix. 697 1.1.1.2 christos */ 698 1.1.1.2 christos #define VEX128 1 699 1.1.1.2 christos #define VEX256 2 700 1.1.1.2 christos #define VEXScalar 3 701 1.1.1.2 christos Vex, 702 1.1.1.2 christos /* How to encode VEX.vvvv: 703 1.1.1.11 christos 1: VEX.vvvv encodes the src1 register operand. 704 1.1.1.11 christos 2: VEX.vvvv encodes the src2 register operand. 705 1.1.1.11 christos 3: VEX.vvvv encodes the dest register operand. 706 1.1.1.2 christos */ 707 1.1.1.11 christos #define VexVVVV_SRC1 1 708 1.1.1.11 christos #define VexVVVV_SRC2 2 709 1.1.1.11 christos #define VexVVVV_DST 3 710 1.1.1.11 christos 711 1.1.1.2 christos VexVVVV, 712 1.1.1.2 christos /* How the VEX.W bit is used: 713 1.1.1.2 christos 0: Set by the REX.W bit. 714 1.1.1.2 christos 1: VEX.W0. Should always be 0. 715 1.1.1.2 christos 2: VEX.W1. Should always be 1. 716 1.1.1.8 christos 3: VEX.WIG. The VEX.W bit is ignored. 717 1.1.1.2 christos */ 718 1.1.1.2 christos #define VEXW0 1 719 1.1.1.2 christos #define VEXW1 2 720 1.1.1.8 christos #define VEXWIG 3 721 1.1.1.2 christos VexW, 722 1.1.1.9 christos /* Opcode prefix (values chosen to be usable directly in 723 1.1.1.9 christos VEX/XOP/EVEX pp fields): 724 1.1.1.9 christos 0: None 725 1.1.1.9 christos 1: Add 0x66 opcode prefix. 726 1.1.1.9 christos 2: Add 0xf3 opcode prefix. 727 1.1.1.9 christos 3: Add 0xf2 opcode prefix. 728 1.1.1.9 christos */ 729 1.1.1.9 christos #define PREFIX_NONE 0 730 1.1.1.9 christos #define PREFIX_0X66 1 731 1.1.1.9 christos #define PREFIX_0XF3 2 732 1.1.1.9 christos #define PREFIX_0XF2 3 733 1.1.1.9 christos OpcodePrefix, 734 1.1.1.9 christos /* Instruction with a mandatory SIB byte: 735 1.1.1.3 christos 1: 128bit vector register. 736 1.1.1.3 christos 2: 256bit vector register. 737 1.1.1.4 christos 3: 512bit vector register. 738 1.1.1.3 christos */ 739 1.1.1.9 christos #define VECSIB128 1 740 1.1.1.9 christos #define VECSIB256 2 741 1.1.1.9 christos #define VECSIB512 3 742 1.1.1.9 christos #define SIBMEM 4 743 1.1.1.9 christos SIB, 744 1.1.1.9 christos 745 1.1.1.2 christos /* SSE to AVX support required */ 746 1.1.1.2 christos SSE2AVX, 747 1.1.1.4 christos 748 1.1.1.4 christos /* insn has EVEX prefix: 749 1.1.1.4 christos 1: 512bit EVEX prefix. 750 1.1.1.4 christos 2: 128bit EVEX prefix. 751 1.1.1.4 christos 3: 256bit EVEX prefix. 752 1.1.1.4 christos 4: Length-ignored (LIG) EVEX prefix. 753 1.1.1.7 christos 5: Length determined from actual operands. 754 1.1.1.10 christos 6: L'L = 3 (reserved, .insn only) 755 1.1.1.4 christos */ 756 1.1.1.4 christos #define EVEX512 1 757 1.1.1.4 christos #define EVEX128 2 758 1.1.1.4 christos #define EVEX256 3 759 1.1.1.4 christos #define EVEXLIG 4 760 1.1.1.7 christos #define EVEXDYN 5 761 1.1.1.10 christos #define EVEX_L3 6 762 1.1.1.4 christos EVex, 763 1.1.1.4 christos 764 1.1.1.10 christos /* AVX512 masking support */ 765 1.1.1.4 christos Masking, 766 1.1.1.4 christos 767 1.1.1.8 christos /* AVX512 broadcast support. The number of bytes to broadcast is 768 1.1.1.8 christos 1 << (Broadcast - 1): 769 1.1.1.8 christos 1: Byte broadcast. 770 1.1.1.8 christos 2: Word broadcast. 771 1.1.1.8 christos 3: Dword broadcast. 772 1.1.1.8 christos 4: Qword broadcast. 773 1.1.1.8 christos */ 774 1.1.1.8 christos #define BYTE_BROADCAST 1 775 1.1.1.8 christos #define WORD_BROADCAST 2 776 1.1.1.8 christos #define DWORD_BROADCAST 3 777 1.1.1.8 christos #define QWORD_BROADCAST 4 778 1.1.1.4 christos Broadcast, 779 1.1.1.4 christos 780 1.1.1.4 christos /* Static rounding control is supported. */ 781 1.1.1.4 christos StaticRounding, 782 1.1.1.4 christos 783 1.1.1.4 christos /* Supress All Exceptions is supported. */ 784 1.1.1.4 christos SAE, 785 1.1.1.4 christos 786 1.1.1.8 christos /* Compressed Disp8*N attribute. */ 787 1.1.1.8 christos #define DISP8_SHIFT_VL 7 788 1.1.1.4 christos Disp8MemShift, 789 1.1.1.4 christos 790 1.1.1.7 christos /* Support encoding optimization. */ 791 1.1.1.7 christos Optimize, 792 1.1.1.7 christos 793 1.1.1.10 christos /* Language dialect. NOTE: Order matters! */ 794 1.1.1.10 christos #define INTEL_SYNTAX 1 795 1.1.1.10 christos #define ATT_SYNTAX 2 796 1.1.1.10 christos #define ATT_MNEMONIC 3 797 1.1.1.10 christos Dialect, 798 1.1.1.10 christos 799 1.1.1.11 christos /* Mnemonic suffix permitted in Intel syntax. */ 800 1.1.1.11 christos IntelSuffix, 801 1.1.1.11 christos 802 1.1.1.9 christos /* ISA64: Don't change the order without other code adjustments. 803 1.1.1.9 christos 0: Common to AMD64 and Intel64. 804 1.1.1.9 christos 1: AMD64. 805 1.1.1.9 christos 2: Intel64. 806 1.1.1.9 christos 3: Only in Intel64. 807 1.1.1.9 christos */ 808 1.1.1.9 christos #define AMD64 1 809 1.1.1.9 christos #define INTEL64 2 810 1.1.1.9 christos #define INTEL64ONLY 3 811 1.1.1.9 christos ISA64, 812 1.1.1.10 christos 813 1.1.1.10 christos /* egprs (r16-r31) on instruction illegal. We also use it to judge 814 1.1.1.10 christos whether the instruction supports pseudo-prefix {rex2}. */ 815 1.1.1.10 christos NoEgpr, 816 1.1.1.10 christos 817 1.1.1.10 christos /* No CSPAZO flags update indication. */ 818 1.1.1.10 christos NF, 819 1.1.1.10 christos 820 1.1.1.10 christos /* Instrucion requires REX2 prefix. */ 821 1.1.1.10 christos Rex2, 822 1.1.1.10 christos 823 1.1.1.2 christos /* The last bitfield in i386_opcode_modifier. */ 824 1.1.1.8 christos Opcode_Modifier_Num 825 1.1.1.2 christos }; 826 1.1 skrll 827 1.1 skrll typedef struct i386_opcode_modifier 828 1.1 skrll { 829 1.1 skrll unsigned int d:1; 830 1.1 skrll unsigned int w:1; 831 1.1.1.6 christos unsigned int load:1; 832 1.1 skrll unsigned int modrm:1; 833 1.1.1.8 christos unsigned int jump:3; 834 1.1 skrll unsigned int floatmf:1; 835 1.1.1.8 christos unsigned int size:2; 836 1.1.1.10 christos unsigned int checkoperandsize:1; 837 1.1.1.10 christos unsigned int operandconstraint:4; 838 1.1.1.9 christos unsigned int mnemonicsize:2; 839 1.1 skrll unsigned int no_bsuf:1; 840 1.1 skrll unsigned int no_wsuf:1; 841 1.1 skrll unsigned int no_lsuf:1; 842 1.1 skrll unsigned int no_ssuf:1; 843 1.1 skrll unsigned int no_qsuf:1; 844 1.1 skrll unsigned int fwait:1; 845 1.1.1.8 christos unsigned int isstring:2; 846 1.1.1.8 christos unsigned int regmem:1; 847 1.1.1.4 christos unsigned int bndprefixok:1; 848 1.1.1.9 christos unsigned int prefixok:3; 849 1.1 skrll unsigned int isprefix:1; 850 1.1 skrll unsigned int immext:1; 851 1.1 skrll unsigned int norex64:1; 852 1.1.1.2 christos unsigned int vex:2; 853 1.1.1.2 christos unsigned int vexvvvv:2; 854 1.1.1.2 christos unsigned int vexw:2; 855 1.1.1.9 christos unsigned int opcodeprefix:2; 856 1.1.1.9 christos unsigned int sib:3; 857 1.1 skrll unsigned int sse2avx:1; 858 1.1.1.4 christos unsigned int evex:3; 859 1.1.1.10 christos unsigned int masking:1; 860 1.1.1.8 christos unsigned int broadcast:3; 861 1.1.1.4 christos unsigned int staticrounding:1; 862 1.1.1.4 christos unsigned int sae:1; 863 1.1.1.4 christos unsigned int disp8memshift:3; 864 1.1.1.7 christos unsigned int optimize:1; 865 1.1.1.10 christos unsigned int dialect:2; 866 1.1.1.11 christos unsigned int intelsuffix:1; 867 1.1.1.9 christos unsigned int isa64:2; 868 1.1.1.10 christos unsigned int noegpr:1; 869 1.1.1.10 christos unsigned int nf:1; 870 1.1.1.10 christos unsigned int rex2:1; 871 1.1 skrll } i386_opcode_modifier; 872 1.1 skrll 873 1.1.1.8 christos /* Operand classes. */ 874 1.1.1.8 christos 875 1.1.1.8 christos #define CLASS_WIDTH 4 876 1.1.1.8 christos enum operand_class 877 1.1.1.8 christos { 878 1.1.1.8 christos ClassNone, 879 1.1.1.11 christos Reg, /* GPRs, distinguished by operand size */ 880 1.1.1.8 christos SReg, /* Segment register */ 881 1.1.1.11 christos RegFP, /* FP regs */ 882 1.1.1.8 christos RegCR, /* Control register */ 883 1.1.1.8 christos RegDR, /* Debug register */ 884 1.1.1.8 christos RegTR, /* Test register */ 885 1.1.1.8 christos RegMMX, /* MMX register */ 886 1.1.1.8 christos RegSIMD, /* XMM/YMM/ZMM registers, distinguished by operand size */ 887 1.1.1.8 christos RegMask, /* Vector Mask register */ 888 1.1.1.8 christos RegBND, /* Bound register */ 889 1.1.1.8 christos }; 890 1.1.1.8 christos 891 1.1.1.8 christos /* Special operand instances. */ 892 1.1.1.8 christos 893 1.1.1.8 christos #define INSTANCE_WIDTH 3 894 1.1.1.8 christos enum operand_instance 895 1.1.1.8 christos { 896 1.1.1.8 christos InstanceNone, 897 1.1.1.8 christos Accum, /* Accumulator %al/%ax/%eax/%rax/%st(0)/%xmm0 */ 898 1.1.1.8 christos RegC, /* %cl / %cx / %ecx / %rcx, e.g. register to hold shift count */ 899 1.1.1.8 christos RegD, /* %dl / %dx / %edx / %rdx, e.g. register to hold I/O port addr */ 900 1.1.1.8 christos RegB, /* %bl / %bx / %ebx / %rbx */ 901 1.1.1.8 christos }; 902 1.1.1.8 christos 903 1.1 skrll /* Position of operand_type bits. */ 904 1.1 skrll 905 1.1.1.2 christos enum 906 1.1.1.2 christos { 907 1.1.1.8 christos /* Class and Instance */ 908 1.1.1.8 christos ClassInstance = CLASS_WIDTH + INSTANCE_WIDTH - 1, 909 1.1.1.2 christos /* 1 bit immediate */ 910 1.1.1.2 christos Imm1, 911 1.1.1.2 christos /* 8 bit immediate */ 912 1.1.1.2 christos Imm8, 913 1.1.1.2 christos /* 8 bit immediate sign extended */ 914 1.1.1.2 christos Imm8S, 915 1.1.1.2 christos /* 16 bit immediate */ 916 1.1.1.2 christos Imm16, 917 1.1.1.2 christos /* 32 bit immediate */ 918 1.1.1.2 christos Imm32, 919 1.1.1.2 christos /* 32 bit immediate sign extended */ 920 1.1.1.2 christos Imm32S, 921 1.1.1.2 christos /* 64 bit immediate */ 922 1.1.1.2 christos Imm64, 923 1.1.1.2 christos /* 8bit/16bit/32bit displacements are used in different ways, 924 1.1.1.2 christos depending on the instruction. For jumps, they specify the 925 1.1.1.2 christos size of the PC relative displacement, for instructions with 926 1.1.1.2 christos memory operand, they specify the size of the offset relative 927 1.1.1.2 christos to the base register, and for instructions with memory offset 928 1.1.1.2 christos such as `mov 1234,%al' they specify the size of the offset 929 1.1.1.2 christos relative to the segment base. */ 930 1.1.1.2 christos /* 8 bit displacement */ 931 1.1.1.2 christos Disp8, 932 1.1.1.2 christos /* 16 bit displacement */ 933 1.1.1.2 christos Disp16, 934 1.1.1.9 christos /* 32 bit displacement (64-bit: sign-extended) */ 935 1.1.1.2 christos Disp32, 936 1.1.1.2 christos /* 64 bit displacement */ 937 1.1.1.2 christos Disp64, 938 1.1.1.2 christos /* Register which can be used for base or index in memory operand. */ 939 1.1.1.2 christos BaseIndex, 940 1.1.1.8 christos /* BYTE size. */ 941 1.1.1.2 christos Byte, 942 1.1.1.8 christos /* WORD size. 2 byte */ 943 1.1.1.2 christos Word, 944 1.1.1.8 christos /* DWORD size. 4 byte */ 945 1.1.1.2 christos Dword, 946 1.1.1.8 christos /* FWORD size. 6 byte */ 947 1.1.1.2 christos Fword, 948 1.1.1.8 christos /* QWORD size. 8 byte */ 949 1.1.1.2 christos Qword, 950 1.1.1.8 christos /* TBYTE size. 10 byte */ 951 1.1.1.2 christos Tbyte, 952 1.1.1.8 christos /* XMMWORD size. */ 953 1.1.1.2 christos Xmmword, 954 1.1.1.8 christos /* YMMWORD size. */ 955 1.1.1.2 christos Ymmword, 956 1.1.1.8 christos /* ZMMWORD size. */ 957 1.1.1.4 christos Zmmword, 958 1.1.1.9 christos /* TMMWORD size. */ 959 1.1.1.9 christos Tmmword, 960 1.1.1.2 christos /* Unspecified memory size. */ 961 1.1.1.2 christos Unspecified, 962 1.1.1.2 christos 963 1.1.1.8 christos /* The number of bits in i386_operand_type. */ 964 1.1.1.8 christos OTNum 965 1.1.1.2 christos }; 966 1.1 skrll 967 1.1 skrll #define OTNumOfUints \ 968 1.1.1.8 christos ((OTNum - 1) / sizeof (unsigned int) / CHAR_BIT + 1) 969 1.1 skrll #define OTNumOfBits \ 970 1.1 skrll (OTNumOfUints * sizeof (unsigned int) * CHAR_BIT) 971 1.1 skrll 972 1.1 skrll /* If you get a compiler error for zero width of the unused field, 973 1.1 skrll comment it out. */ 974 1.1.1.8 christos #define OTUnused OTNum 975 1.1 skrll 976 1.1 skrll typedef union i386_operand_type 977 1.1 skrll { 978 1.1 skrll struct 979 1.1 skrll { 980 1.1.1.8 christos unsigned int class:CLASS_WIDTH; 981 1.1.1.8 christos unsigned int instance:INSTANCE_WIDTH; 982 1.1 skrll unsigned int imm1:1; 983 1.1 skrll unsigned int imm8:1; 984 1.1 skrll unsigned int imm8s:1; 985 1.1 skrll unsigned int imm16:1; 986 1.1 skrll unsigned int imm32:1; 987 1.1 skrll unsigned int imm32s:1; 988 1.1 skrll unsigned int imm64:1; 989 1.1 skrll unsigned int disp8:1; 990 1.1 skrll unsigned int disp16:1; 991 1.1 skrll unsigned int disp32:1; 992 1.1 skrll unsigned int disp64:1; 993 1.1 skrll unsigned int baseindex:1; 994 1.1 skrll unsigned int byte:1; 995 1.1 skrll unsigned int word:1; 996 1.1 skrll unsigned int dword:1; 997 1.1 skrll unsigned int fword:1; 998 1.1 skrll unsigned int qword:1; 999 1.1 skrll unsigned int tbyte:1; 1000 1.1 skrll unsigned int xmmword:1; 1001 1.1 skrll unsigned int ymmword:1; 1002 1.1.1.4 christos unsigned int zmmword:1; 1003 1.1.1.9 christos unsigned int tmmword:1; 1004 1.1 skrll unsigned int unspecified:1; 1005 1.1 skrll #ifdef OTUnused 1006 1.1 skrll unsigned int unused:(OTNumOfBits - OTUnused); 1007 1.1 skrll #endif 1008 1.1 skrll } bitfield; 1009 1.1 skrll unsigned int array[OTNumOfUints]; 1010 1.1 skrll } i386_operand_type; 1011 1.1 skrll 1012 1.1.1.2 christos typedef struct insn_template 1013 1.1 skrll { 1014 1.1 skrll /* instruction name sans width suffix ("mov" for movl insns) */ 1015 1.1.1.10 christos unsigned int mnem_off; 1016 1.1.1.10 christos 1017 1.1.1.10 christos /* Bitfield arrangement is such that individual fields can be easily 1018 1.1.1.10 christos extracted (in native builds at least) - either by at most a masking 1019 1.1.1.10 christos operation (base_opcode, operands), or by just a (signed) right shift 1020 1.1.1.10 christos (extension_opcode). Please try to maintain this property. */ 1021 1.1 skrll 1022 1.1 skrll /* base_opcode is the fundamental opcode byte without optional 1023 1.1 skrll prefix(es). */ 1024 1.1.1.9 christos unsigned int base_opcode:16; 1025 1.1 skrll #define Opcode_D 0x2 /* Direction bit: 1026 1.1 skrll set if Reg --> Regmem; 1027 1.1 skrll unset if Regmem --> Reg. */ 1028 1.1.1.10 christos #define Opcode_FloatR 0x8 /* ModR/M bit to swap src/dest for float insns. */ 1029 1.1.1.10 christos #define Opcode_FloatD 0x4 /* Direction bit for float insns. */ 1030 1.1.1.10 christos #define Opcode_ExtD 0x1 /* Direction bit for extended opcode space insns. */ 1031 1.1.1.8 christos #define Opcode_SIMD_IntD 0x10 /* Direction bit for SIMD int insns. */ 1032 1.1.1.9 christos /* The next value is arbitrary, as long as it's non-zero and distinct 1033 1.1.1.9 christos from all other values above. */ 1034 1.1.1.9 christos #define Opcode_VexW 0xf /* Operand order controlled by VEX.W. */ 1035 1.1.1.9 christos 1036 1.1.1.10 christos /* how many operands */ 1037 1.1.1.10 christos unsigned int operands:3; 1038 1.1.1.10 christos 1039 1.1.1.10 christos /* opcode space */ 1040 1.1.1.10 christos unsigned int opcode_space:4; 1041 1.1.1.10 christos /* Opcode encoding space (values chosen to be usable directly in 1042 1.1.1.11 christos VEX/XOP mmmmm and EVEX mmm fields): 1043 1.1.1.10 christos 0: Base opcode space. 1044 1.1.1.10 christos 1: 0F opcode prefix / space. 1045 1.1.1.10 christos 2: 0F38 opcode prefix / space. 1046 1.1.1.10 christos 3: 0F3A opcode prefix / space. 1047 1.1.1.11 christos 4: MAP4 opcode prefix / space. 1048 1.1.1.11 christos 5: MAP5 opcode prefix / space. 1049 1.1.1.11 christos 6: MAP6 opcode prefix / space. 1050 1.1.1.11 christos 7: MAP7 opcode prefix / space. 1051 1.1.1.10 christos 8: XOP 08 opcode space. 1052 1.1.1.10 christos 9: XOP 09 opcode space. 1053 1.1.1.10 christos A: XOP 0A opcode space. 1054 1.1.1.10 christos */ 1055 1.1.1.10 christos #define SPACE_BASE 0 1056 1.1.1.10 christos #define SPACE_0F 1 1057 1.1.1.10 christos #define SPACE_0F38 2 1058 1.1.1.10 christos #define SPACE_0F3A 3 1059 1.1.1.11 christos #define SPACE_MAP4 4 1060 1.1.1.11 christos #define SPACE_MAP5 5 1061 1.1.1.11 christos #define SPACE_MAP6 6 1062 1.1.1.11 christos #define SPACE_MAP7 7 1063 1.1.1.10 christos #define SPACE_XOP08 8 1064 1.1.1.10 christos #define SPACE_XOP09 9 1065 1.1.1.10 christos #define SPACE_XOP0A 0xA 1066 1.1.1.10 christos 1067 1.1.1.9 christos /* (Fake) base opcode value for pseudo prefixes. */ 1068 1.1.1.9 christos #define PSEUDO_PREFIX 0 1069 1.1 skrll 1070 1.1 skrll /* extension_opcode is the 3 bit extension for group <n> insns. 1071 1.1 skrll This field is also used to store the 8-bit opcode suffix for the 1072 1.1 skrll AMD 3DNow! instructions. 1073 1.1.1.3 christos If this template has no extension opcode (the usual case) use None 1074 1.1.1.2 christos Instructions */ 1075 1.1.1.9 christos signed int extension_opcode:9; 1076 1.1.1.9 christos #define None (-1) /* If no extension_opcode is possible. */ 1077 1.1 skrll 1078 1.1.1.9 christos /* Pseudo prefixes. */ 1079 1.1.1.9 christos #define Prefix_Disp8 0 /* {disp8} */ 1080 1.1.1.9 christos #define Prefix_Disp16 1 /* {disp16} */ 1081 1.1.1.9 christos #define Prefix_Disp32 2 /* {disp32} */ 1082 1.1.1.9 christos #define Prefix_Load 3 /* {load} */ 1083 1.1.1.9 christos #define Prefix_Store 4 /* {store} */ 1084 1.1.1.9 christos #define Prefix_VEX 5 /* {vex} */ 1085 1.1.1.9 christos #define Prefix_VEX3 6 /* {vex3} */ 1086 1.1.1.9 christos #define Prefix_EVEX 7 /* {evex} */ 1087 1.1.1.9 christos #define Prefix_REX 8 /* {rex} */ 1088 1.1.1.10 christos #define Prefix_REX2 9 /* {rex2} */ 1089 1.1.1.10 christos #define Prefix_NoOptimize 10 /* {nooptimize} */ 1090 1.1.1.11 christos #define Prefix_NF 11 /* {nf} */ 1091 1.1.1.11 christos #define Prefix_NoImm8s 12 /* {noimm8s} */ 1092 1.1 skrll 1093 1.1 skrll /* the bits in opcode_modifier are used to generate the final opcode from 1094 1.1 skrll the base_opcode. These bits also are used to detect alternate forms of 1095 1.1 skrll the same instruction */ 1096 1.1 skrll i386_opcode_modifier opcode_modifier; 1097 1.1 skrll 1098 1.1.1.10 christos /* cpu feature attributes */ 1099 1.1.1.10 christos i386_cpu_attr cpu, cpu_any; 1100 1.1.1.9 christos 1101 1.1 skrll /* operand_types[i] describes the type of operand i. This is made 1102 1.1 skrll by OR'ing together all of the possible type masks. (e.g. 1103 1.1 skrll 'operand_types[i] = Reg|Imm' specifies that operand i can be 1104 1.1 skrll either a register or an immediate operand. */ 1105 1.1 skrll i386_operand_type operand_types[MAX_OPERANDS]; 1106 1.1 skrll } 1107 1.1.1.2 christos insn_template; 1108 1.1 skrll 1109 1.1 skrll /* these are for register name --> number & type hash lookup */ 1110 1.1 skrll typedef struct 1111 1.1 skrll { 1112 1.1.1.10 christos char reg_name[8]; 1113 1.1 skrll i386_operand_type reg_type; 1114 1.1 skrll unsigned char reg_flags; 1115 1.1 skrll #define RegRex 0x1 /* Extended register. */ 1116 1.1 skrll #define RegRex64 0x2 /* Extended 8 bit register. */ 1117 1.1.1.4 christos #define RegVRex 0x4 /* Extended vector register. */ 1118 1.1.1.10 christos #define RegRex2 0x8 /* Extended GPRs R16R31 register. */ 1119 1.1 skrll unsigned char reg_num; 1120 1.1.1.8 christos #define RegIP ((unsigned char ) ~0) 1121 1.1 skrll /* EIZ and RIZ are fake index registers. */ 1122 1.1.1.8 christos #define RegIZ (RegIP - 1) 1123 1.1 skrll /* FLAT is a fake segment register (Intel mode). */ 1124 1.1 skrll #define RegFlat ((unsigned char) ~0) 1125 1.1.1.11 christos unsigned char dw2_regnum[2]; 1126 1.1.1.11 christos #define Dw2Inval 0xff 1127 1.1 skrll } 1128 1.1 skrll reg_entry; 1129