two_byte_opcodes.isa revision 11877
1// Copyright (c) 2007-2008 The Hewlett-Packard Development Company 2// Copyright (c) 2012-2013 AMD 3// All rights reserved. 4// 5// The license below extends only to copyright in the software and shall 6// not be construed as granting a license to any other intellectual 7// property including but not limited to intellectual property relating 8// to a hardware implementation of the functionality of the software 9// licensed hereunder. You may use the software subject to the license 10// terms below provided that you ensure that this notice is replicated 11// unmodified and in its entirety in all distributions of the software, 12// modified or unmodified, in source code or in binary form. 13// 14// Copyright (c) 2008 The Regents of The University of Michigan 15// All rights reserved. 16// 17// Redistribution and use in source and binary forms, with or without 18// modification, are permitted provided that the following conditions are 19// met: redistributions of source code must retain the above copyright 20// notice, this list of conditions and the following disclaimer; 21// redistributions in binary form must reproduce the above copyright 22// notice, this list of conditions and the following disclaimer in the 23// documentation and/or other materials provided with the distribution; 24// neither the name of the copyright holders nor the names of its 25// contributors may be used to endorse or promote products derived from 26// this software without specific prior written permission. 27// 28// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39// 40// Authors: Gabe Black 41 42//////////////////////////////////////////////////////////////////// 43// 44// Decode the two byte opcodes 45// 46'X86ISA::TwoByteOpcode': decode OPCODE_OP_TOP5 { 47 format WarnUnimpl { 48 0x00: decode OPCODE_OP_BOTTOM3 { 49 //0x00: group6(); 50 0x00: decode MODRM_REG { 51 0x0: sldt_Mw_or_Rv(); 52 0x1: str_Mw_or_Rv(); 53 0x2: Inst::LLDT(Ew); 54 0x3: Inst::LTR(Ew); 55 0x4: verr_Mw_or_Rv(); 56 0x5: verw_Mw_or_Rv(); 57 //0x6: jmpe_Ev(); // IA-64 58 default: Inst::UD2(); 59 } 60 //0x01: group7(); // Ugly, ugly, ugly... 61 0x01: decode MODRM_REG { 62 0x0: decode MODRM_MOD { 63 0x3: decode MODRM_RM { 64 0x1: vmcall(); 65 0x2: vmlaunch(); 66 0x3: vmresume(); 67 0x4: vmxoff(); 68 default: Inst::UD2(); 69 } 70 default: sgdt_Ms(); 71 } 72 0x1: decode MODRM_MOD { 73 0x3: decode MODRM_RM { 74 0x0: MonitorInst::monitor({{ 75 xc->armMonitor(Rax); 76 }}); 77 0x1: MwaitInst::mwait({{ 78 uint64_t m = 0; //mem 79 unsigned s = 0x8; //size 80 unsigned f = 0; //flags 81 readMemAtomic(xc, traceData, 82 xc->getAddrMonitor()->vAddr, 83 m, s, f); 84 xc->mwaitAtomic(xc->tcBase()); 85 MicroHalt hltObj(machInst, mnemonic, 0x0); 86 hltObj.execute(xc, traceData); 87 }}); 88 default: Inst::UD2(); 89 } 90 default: sidt_Ms(); 91 } 92 0x2: decode MODRM_MOD { 93 0x3: decode MODRM_RM { 94 0x0: xgetbv(); 95 0x1: xsetbv(); 96 } 97 default: decode MODE_SUBMODE { 98 0x0: Inst::LGDT(M); 99 default: decode OPSIZE { 100 // 16 bit operand sizes are special, but only 101 // in legacy and compatability modes. 102 0x2: Inst::LGDT_16(M); 103 default: Inst::LGDT(M); 104 } 105 } 106 } 107 0x3: decode MODRM_MOD { 108 0x3: decode MODRM_RM { 109 0x0: vmrun(); 110 0x1: vmmcall(); 111 0x2: vmload(); 112 0x3: vmsave(); 113 0x4: stgi(); 114 0x5: clgi(); 115 0x6: skinit(); 116 0x7: invlpga(); 117 } 118 default: decode MODE_SUBMODE { 119 0x0: Inst::LIDT(M); 120 default: decode OPSIZE { 121 // 16 bit operand sizes are special, but only 122 // in legacy and compatability modes. 123 0x2: Inst::LIDT_16(M); 124 default: Inst::LIDT(M); 125 } 126 } 127 } 128 0x4: decode MODRM_MOD { 129 0x3: Inst::SMSW(Rv); 130 default: Inst::SMSW(Mw); 131 } 132 0x6: Inst::LMSW(Ew); 133 0x7: decode MODRM_MOD { 134 0x3: decode MODRM_RM { 135 0x0: Inst::SWAPGS(); 136 0x1: rdtscp(); 137 default: Inst::UD2(); 138 } 139 default: Inst::INVLPG(M); 140 } 141 } 142 0x02: lar_Gv_Ew(); 143 0x03: lsl_Gv_Ew(); 144 // sandpile.org doesn't seem to know what this is...? We'll 145 // use it for pseudo instructions. We've got 16 bits of space 146 // to play with so there can be quite a few pseudo 147 // instructions. 148 //0x04: loadall_or_reset_or_hang(); 149 0x4: decode IMMEDIATE { 150 format BasicOperate { 151 0x00: m5arm({{ 152 PseudoInst::arm(xc->tcBase()); 153 }}, IsNonSpeculative); 154 0x01: m5quiesce({{ 155 PseudoInst::quiesce(xc->tcBase()); 156 }}, IsNonSpeculative, IsQuiesce); 157 0x02: m5quiesceNs({{ 158 PseudoInst::quiesceNs(xc->tcBase(), Rdi); 159 }}, IsNonSpeculative, IsQuiesce); 160 0x03: m5quiesceCycle({{ 161 PseudoInst::quiesceCycles(xc->tcBase(), Rdi); 162 }}, IsNonSpeculative, IsQuiesce); 163 0x04: m5quiesceTime({{ 164 Rax = PseudoInst::quiesceTime(xc->tcBase()); 165 }}, IsNonSpeculative); 166 0x07: m5rpns({{ 167 Rax = PseudoInst::rpns(xc->tcBase()); 168 }}, IsNonSpeculative); 169 0x21: m5exit({{ 170 PseudoInst::m5exit(xc->tcBase(), Rdi); 171 }}, IsNonSpeculative); 172 0x22: m5fail({{ 173 PseudoInst::m5fail(xc->tcBase(), Rdi, Rsi); 174 }}, IsNonSpeculative); 175 0x30: m5initparam({{ 176 Rax = PseudoInst::initParam(xc->tcBase(), Rdi, Rsi); 177 }}, IsNonSpeculative); 178 0x31: m5loadsymbol({{ 179 PseudoInst::loadsymbol(xc->tcBase()); 180 }}, IsNonSpeculative); 181 0x40: m5resetstats({{ 182 PseudoInst::resetstats(xc->tcBase(), Rdi, Rsi); 183 }}, IsNonSpeculative); 184 0x41: m5dumpstats({{ 185 PseudoInst::dumpstats(xc->tcBase(), Rdi, Rsi); 186 }}, IsNonSpeculative); 187 0x42: m5dumpresetstats({{ 188 PseudoInst::dumpresetstats(xc->tcBase(), Rdi, Rsi); 189 }}, IsNonSpeculative); 190 0x43: m5checkpoint({{ 191 PseudoInst::m5checkpoint(xc->tcBase(), Rdi, Rsi); 192 }}, IsNonSpeculative); 193 0x50: m5readfile({{ 194 Rax = PseudoInst::readfile( 195 xc->tcBase(), Rdi, Rsi, Rdx); 196 }}, IsNonSpeculative); 197 0x51: m5debugbreak({{ 198 PseudoInst::debugbreak(xc->tcBase()); 199 }}, IsNonSpeculative); 200 0x52: m5switchcpu({{ 201 PseudoInst::switchcpu(xc->tcBase()); 202 }}, IsNonSpeculative); 203 0x53: m5addsymbol({{ 204 PseudoInst::addsymbol(xc->tcBase(), Rdi, Rsi); 205 }}, IsNonSpeculative); 206 0x54: m5panic({{ 207 panic("M5 panic instruction called at pc = %#x.\n", 208 RIP); 209 }}, IsNonSpeculative); 210 0x55: m5reserved1({{ 211 warn("M5 reserved opcode 1 ignored.\n"); 212 }}, IsNonSpeculative); 213 0x56: m5reserved2({{ 214 warn("M5 reserved opcode 2 ignored.\n"); 215 }}, IsNonSpeculative); 216 0x57: m5reserved3({{ 217 warn("M5 reserved opcode 3 ignored.\n"); 218 }}, IsNonSpeculative); 219 0x58: m5reserved4({{ 220 warn("M5 reserved opcode 4 ignored.\n"); 221 }}, IsNonSpeculative); 222 0x59: m5reserved5({{ 223 warn("M5 reserved opcode 5 ignored.\n"); 224 }}, IsNonSpeculative); 225 0x5a: m5_work_begin({{ 226 PseudoInst::workbegin(xc->tcBase(), Rdi, Rsi); 227 }}, IsNonSpeculative); 228 0x5b: m5_work_end({{ 229 PseudoInst::workend(xc->tcBase(), Rdi, Rsi); 230 }}, IsNonSpeculative); 231 0x62: m5togglesync({{ 232 PseudoInst::togglesync(xc->tcBase()); 233 }}, IsNonSpeculative, IsQuiesce); 234 default: Inst::UD2(); 235 } 236 } 237 0x05: decode FullSystemInt { 238 0: SyscallInst::syscall('xc->syscall(Rax, &fault)', 239 IsSyscall, IsNonSpeculative, 240 IsSerializeAfter); 241 default: decode MODE_MODE { 242 0x0: decode MODE_SUBMODE { 243 0x0: Inst::SYSCALL_64(); 244 0x1: Inst::SYSCALL_COMPAT(); 245 } 246 0x1: Inst::SYSCALL_LEGACY(); 247 } 248 } 249 0x06: Inst::CLTS(); 250 0x07: decode MODE_SUBMODE { 251 0x0: decode OPSIZE { 252 // Return to 64 bit mode. 253 0x8: Inst::SYSRET_TO_64(); 254 // Return to compatibility mode. 255 default: Inst::SYSRET_TO_COMPAT(); 256 } 257 default: Inst::SYSRET_NON_64(); 258 } 259 } 260 0x01: decode OPCODE_OP_BOTTOM3 { 261 0x0: invd(); 262 0x1: wbinvd(); 263 0x2: Inst::UD2(); 264 0x3: Inst::UD2(); 265 0x4: Inst::UD2(); 266 0x5: Inst::PREFETCH(Mb); 267 0x6: FailUnimpl::femms(); 268 0x7: decode IMMEDIATE { 269 0x0C: pi2fw_Pq_Qq(); 270 0x0D: pi2fd_Pq_Qq(); 271 0x1C: pf2iw_Pq_Qq(); 272 0x1D: pf2id_Pq_Qq(); 273 0x8A: pfnacc_Pq_Qq(); 274 0x8E: pfpnacc_Pq_Qq(); 275 0x90: pfcmpge_Pq_Qq(); 276 0x94: pfmin_Pq_Qq(); 277 0x96: pfrcp_Pq_Qq(); 278 0x97: pfrsqrt_Pq_Qq(); 279 0x9A: Inst::PFSUB(Pq,Qq); 280 0x9E: pfadd_Pq_Qq(); 281 0xA0: pfcmpgt_Pq_Qq(); 282 0xA4: pfmax_Pq_Qq(); 283 0xA6: pfrcpit1_Pq_Qq(); 284 0xA7: pfrsqit1_Pq_Qq(); 285 0xAA: Inst::PFSUBR(Pq,Qq); 286 0xAE: pfacc_Pq_Qq(); 287 0xB0: pfcmpeq_Pq_Qq(); 288 0xB4: Inst::PFMUL(Pq,Qq); 289 0xB6: pfrcpit2_Pq_Qq(); 290 0xB7: Inst::PMULHRW(Pq,Qq); 291 0xBB: pswapd_Pq_Qq(); 292 0xBF: pavgusb_Pq_Qq(); 293 default: Inst::UD2(); 294 } 295 } 296 format Inst{ 297 0x02: decode LEGACY_DECODEVAL { 298 // no prefix 299 0x0: decode OPCODE_OP_BOTTOM3 { 300 0x0: MOVUPS(Vo,Wo); 301 0x1: MOVUPS(Wo,Vo); 302 0x2: decode MODRM_MOD { 303 0x3: MOVHLPS(Vps,VRq); 304 default: MOVLPS(Vps,Mq); 305 } 306 0x3: MOVLPS(Mq,Vps); 307 0x4: UNPCKLPS(Vps,Wq); 308 0x5: UNPCKHPS(Vps,Wq); 309 0x6: decode MODRM_MOD { 310 0x3: MOVLHPS(Vps,VRq); 311 default: MOVHPS(Vps,Mq); 312 } 313 0x7: MOVHPS(Mq,Vq); 314 } 315 // repe (0xF3) 316 0x4: decode OPCODE_OP_BOTTOM3 { 317 0x0: MOVSS(Vd,Wd); 318 0x1: MOVSS(Wd,Vd); 319 0x2: WarnUnimpl::movsldup_Vo_Wo(); 320 0x6: WarnUnimpl::movshdup_Vo_Wo(); 321 default: UD2(); 322 } 323 // operand size (0x66) 324 0x1: decode OPCODE_OP_BOTTOM3 { 325 0x0: MOVUPD(Vo,Wo); 326 0x1: MOVUPD(Wo,Vo); 327 0x2: MOVLPD(Vq,Mq); 328 0x3: MOVLPD(Mq,Vq); 329 0x4: UNPCKLPD(Vo,Wq); 330 0x5: UNPCKHPD(Vo,Wo); 331 0x6: MOVHPD(Vq,Mq); 332 0x7: MOVHPD(Mq,Vq); 333 } 334 // repne (0xF2) 335 0x8: decode OPCODE_OP_BOTTOM3 { 336 0x0: MOVSD(Vq,Wq); 337 0x1: MOVSD(Wq,Vq); 338 0x2: MOVDDUP(Vo,Wq); 339 default: UD2(); 340 } 341 default: UD2(); 342 } 343 0x03: decode OPCODE_OP_BOTTOM3 { 344 //group16(); 345 0x0: decode MODRM_REG { 346 0x0: WarnUnimpl::prefetch_nta(); 347 0x1: PREFETCH_T0(Mb); 348 0x2: WarnUnimpl::prefetch_t1(); 349 0x3: WarnUnimpl::prefetch_t2(); 350 default: HINT_NOP(); 351 } 352 0x1: HINT_NOP(); 353 0x2: HINT_NOP(); 354 0x3: HINT_NOP(); 355 0x4: HINT_NOP(); 356 0x5: HINT_NOP(); 357 0x6: HINT_NOP(); 358 0x7: HINT_NOP(); 359 } 360 0x04: decode LEGACY_DECODEVAL { 361 // no prefix 362 0x0: decode OPCODE_OP_BOTTOM3 { 363 0x0: MOV(Rd,Cd); 364 0x1: MOV(Rd,Dd); 365 0x2: MOV(Cd,Rd); 366 0x3: MOV(Dd,Rd); 367 default: UD2(); 368 } 369 // operand size (0x66) 370 0x1: decode OPCODE_OP_BOTTOM3 { 371 0x0: MOV(Rd,Cd); 372 0x2: MOV(Cd,Rd); 373 } 374 default: UD2(); 375 } 376 0x05: decode LEGACY_DECODEVAL { 377 // no prefix 378 0x0: decode OPCODE_OP_BOTTOM3 { 379 //These moves should really use size o (octword), but 380 //because they are split in two, they use q (quadword). 381 0x0: MOVAPS(Vq,Wq); 382 0x1: MOVAPS(Wq,Vq); 383 0x2: CVTPI2PS(Vq,Qq); 384 0x3: WarnUnimpl::movntps_Mo_Vo(); 385 0x4: CVTTPS2PI(Pq,Wq); 386 0x5: CVTPS2PI(Pq,Wq); 387 0x6: UCOMISS(Vd,Wd); 388 0x7: COMISS(Vd,Wd); 389 } 390 // repe (0xF3) 391 0x4: decode OPCODE_OP_BOTTOM3 { 392 0x2: CVTSI2SS(Vd,Ed); 393 0x4: CVTTSS2SI(Gd,Wd); 394 0x5: CVTSS2SI(Gd,Wd); 395 default: UD2(); 396 } 397 // operand size (0x66) 398 0x1: decode OPCODE_OP_BOTTOM3 { 399 0x0: MOVAPD(Vo,Wo); 400 0x1: MOVAPD(Wo,Vo); 401 0x2: CVTPI2PD(Vo,Qq); 402 0x3: WarnUnimpl::movntpd_Mo_Vo(); 403 0x4: CVTTPD2PI(Pq,Wo); 404 0x5: CVTPD2PI(Pq,Wo); 405 0x6: UCOMISD(Vq,Wq); 406 0x7: COMISD(Vq,Wq); 407 } 408 // repne (0xF2) 409 0x8: decode OPCODE_OP_BOTTOM3 { 410 // The size of the V operand should be q, not dp 411 0x2: CVTSI2SD(Vdp,Edp); 412 // The size of the W operand should be q, not dp 413 0x4: CVTTSD2SI(Gdp,Wdp); 414 0x5: CVTSD2SI(Gd,Wq); 415 default: UD2(); 416 } 417 default: UD2(); 418 } 419 } 420 0x06: decode OPCODE_OP_BOTTOM3 { 421 0x0: Inst::WRMSR(); 422 0x1: Inst::RDTSC(); 423 0x2: Inst::RDMSR(); 424 0x3: rdpmc(); 425 0x4: decode FullSystemInt { 426 0: SyscallInst::sysenter('xc->syscall(Rax, &fault)', 427 IsSyscall, IsNonSpeculative, 428 IsSerializeAfter); 429 default: sysenter(); 430 } 431 0x5: sysexit(); 432 0x6: Inst::UD2(); 433 0x7: getsec(); 434 } 435 0x07: decode OPCODE_OP_BOTTOM3 { 436 0x0: M5InternalError::error( 437 {{"Three byte opcode shouldn't be handled by " 438 "two_byte_opcodes.isa!"}}); 439 0x2: M5InternalError::error( 440 {{"Three byte opcode shouldn't be handled by " 441 "two_byte_opcodes.isa!"}}); 442 default: UD2(); 443 } 444 format Inst { 445 0x08: decode OPCODE_OP_BOTTOM3 { 446 0x0: CMOVO(Gv,Ev); 447 0x1: CMOVNO(Gv,Ev); 448 0x2: CMOVB(Gv,Ev); 449 0x3: CMOVNB(Gv,Ev); 450 0x4: CMOVZ(Gv,Ev); 451 0x5: CMOVNZ(Gv,Ev); 452 0x6: CMOVBE(Gv,Ev); 453 0x7: CMOVNBE(Gv,Ev); 454 } 455 0x09: decode OPCODE_OP_BOTTOM3 { 456 0x0: CMOVS(Gv,Ev); 457 0x1: CMOVNS(Gv,Ev); 458 0x2: CMOVP(Gv,Ev); 459 0x3: CMOVNP(Gv,Ev); 460 0x4: CMOVL(Gv,Ev); 461 0x5: CMOVNL(Gv,Ev); 462 0x6: CMOVLE(Gv,Ev); 463 0x7: CMOVNLE(Gv,Ev); 464 } 465 0x0A: decode LEGACY_DECODEVAL { 466 // no prefix 467 0x0: decode OPCODE_OP_BOTTOM3 { 468 0x0: MOVMSKPS(Gd,VRo); 469 0x1: SQRTPS(Vo,Wo); 470 0x2: WarnUnimpl::rqsrtps_Vo_Wo(); 471 0x3: RCPPS(Vo,Wo); 472 0x4: ANDPS(Vo,Wo); 473 0x5: ANDNPS(Vo,Wo); 474 0x6: ORPS(Vo,Wo); 475 0x7: XORPS(Vo,Wo); 476 } 477 // repe (0xF3) 478 0x4: decode OPCODE_OP_BOTTOM3 { 479 0x1: SQRTSS(Vd,Wd); 480 0x2: WarnUnimpl::rsqrtss_Vd_Wd(); 481 0x3: RCPSS(Vd,Wd); 482 default: UD2(); 483 } 484 // operand size (0x66) 485 0x1: decode OPCODE_OP_BOTTOM3 { 486 0x0: MOVMSKPD(Gd,VRo); 487 0x1: SQRTPD(Vo,Wo); 488 0x4: ANDPD(Vo,Wo); 489 0x5: ANDNPD(Vo,Wo); 490 0x6: ORPD(Vo,Wo); 491 0x7: XORPD(Vo,Wo); 492 default: UD2(); 493 } 494 // repne (0xF2) 495 0x8: decode OPCODE_OP_BOTTOM3 { 496 0x1: SQRTSD(Vq,Wq); 497 default: UD2(); 498 } 499 default: UD2(); 500 } 501 0x0B: decode LEGACY_DECODEVAL { 502 // no prefix 503 0x0: decode OPCODE_OP_BOTTOM3 { 504 0x0: ADDPS(Vo,Wo); 505 0x1: MULPS(Vo,Wo); 506 0x2: CVTPS2PD(Vo,Wq); 507 0x3: CVTDQ2PS(Vo,Wo); 508 0x4: SUBPS(Vo,Wo); 509 0x5: MINPS(Vo,Wo); 510 0x6: DIVPS(Vo,Wo); 511 0x7: MAXPS(Vo,Wo); 512 } 513 // repe (0xF3) 514 0x4: decode OPCODE_OP_BOTTOM3 { 515 0x0: ADDSS(Vd,Wd); 516 0x1: MULSS(Vd,Wd); 517 0x2: CVTSS2SD(Vq,Wd); 518 0x3: CVTTPS2DQ(Vo,Wo); 519 0x4: SUBSS(Vd,Wd); 520 0x5: MINSS(Vd,Wd); 521 0x6: DIVSS(Vd,Wd); 522 0x7: MAXSS(Vd,Wd); 523 } 524 // operand size (0x66) 525 0x1: decode OPCODE_OP_BOTTOM3 { 526 0x0: ADDPD(Vo,Wo); 527 0x1: MULPD(Vo,Wo); 528 0x2: CVTPD2PS(Vo,Wo); 529 0x3: CVTPS2DQ(Vo,Wo); 530 0x4: SUBPD(Vo,Wo); 531 0x5: MINPD(Vo,Wo); 532 0x6: DIVPD(Vo,Wo); 533 0x7: MAXPD(Vo,Wo); 534 } 535 // repne (0xF2) 536 0x8: decode OPCODE_OP_BOTTOM3 { 537 0x0: ADDSD(Vq,Wq); 538 0x1: MULSD(Vq,Wq); 539 0x2: CVTSD2SS(Vd,Wq); 540 0x4: SUBSD(Vq,Wq); 541 0x5: MINSD(Vq,Wq); 542 0x6: DIVSD(Vq,Wq); 543 0x7: MAXSD(Vq,Wq); 544 default: UD2(); 545 } 546 default: UD2(); 547 } 548 0x0C: decode LEGACY_DECODEVAL { 549 // no prefix 550 0x0: decode OPCODE_OP_BOTTOM3 { 551 0x0: PUNPCKLBW(Pq,Qd); 552 0x1: PUNPCKLWD(Pq,Qd); 553 0x2: PUNPCKLDQ(Pq,Qd); 554 0x3: PACKSSWB(Pq,Qq); 555 0x4: PCMPGTB(Pq,Qq); 556 0x5: PCMPGTW(Pq,Qq); 557 0x6: PCMPGTD(Pq,Qq); 558 0x7: PACKUSWB(Pq,Qq); 559 } 560 // operand size (0x66) 561 0x1: decode OPCODE_OP_BOTTOM3 { 562 0x0: PUNPCKLBW(Vo,Wq); 563 0x1: PUNPCKLWD(Vo,Wq); 564 0x2: PUNPCKLDQ(Vo,Wq); 565 0x3: PACKSSWB(Vo,Wo); 566 0x4: PCMPGTB(Vo,Wo); 567 0x5: PCMPGTW(Vo,Wo); 568 0x6: PCMPGTD(Vo,Wo); 569 0x7: PACKUSWB(Vo,Wo); 570 } 571 default: UD2(); 572 } 573 0x0D: decode LEGACY_DECODEVAL { 574 // no prefix 575 0x0: decode OPCODE_OP_BOTTOM3 { 576 0x0: PUNPCKHBW(Pq,Qq); 577 0x1: PUNPCKHWD(Pq,Qq); 578 0x2: PUNPCKHDQ(Pq,Qq); 579 0x3: PACKSSDW(Pq,Qq); 580 0x6: MOVD(Pq,Edp); 581 0x7: MOVQ(Pq,Qq); 582 default: UD2(); 583 } 584 // repe (0xF3) 585 0x4: decode OPCODE_OP_BOTTOM3 { 586 0x7: MOVDQU(Vo,Wo); 587 default: UD2(); 588 } 589 // operand size (0x66) 590 0x1: decode OPCODE_OP_BOTTOM3 { 591 0x0: PUNPCKHBW(Vo,Wo); 592 0x1: PUNPCKHWD(Vo,Wo); 593 0x2: PUNPCKHDQ(Vo,Wo); 594 0x3: PACKSSDW(Vo,Wo); 595 0x4: PUNPCKLQDQ(Vo,Wq); 596 0x5: PUNPCKHQDQ(Vo,Wq); 597 0x6: MOVD(Vo,Edp); 598 0x7: MOVDQA(Vo,Wo); 599 } 600 default: UD2(); 601 } 602 0x0E: decode LEGACY_DECODEVAL { 603 // no prefix 604 0x0: decode OPCODE_OP_BOTTOM3 { 605 0x0: PSHUFW(Pq,Qq,Ib); 606 //0x1: group12_pshimw(); 607 0x1: decode MODRM_REG { 608 0x2: PSRLW(PRq,Ib); 609 0x4: PSRAW(PRq,Ib); 610 0x6: PSLLW(PRq,Ib); 611 default: UD2(); 612 } 613 //0x2: group13_pshimd(); 614 0x2: decode MODRM_REG { 615 0x2: PSRLD(PRq,Ib); 616 0x4: PSRAD(PRq,Ib); 617 0x6: PSLLD(PRq,Ib); 618 default: UD2(); 619 } 620 //0x3: group14_pshimq(); 621 0x3: decode MODRM_REG { 622 0x2: PSRLQ(PRq,Ib); 623 0x6: PSLLQ(PRq,Ib); 624 default: Inst::UD2(); 625 } 626 0x4: Inst::PCMPEQB(Pq,Qq); 627 0x5: Inst::PCMPEQW(Pq,Qq); 628 0x6: Inst::PCMPEQD(Pq,Qq); 629 0x7: Inst::EMMS(); 630 } 631 // repe (0xF3) 632 0x4: decode OPCODE_OP_BOTTOM3 { 633 0x0: PSHUFHW(Vo,Wo,Ib); 634 default: UD2(); 635 } 636 // operand size (0x66) 637 0x1: decode OPCODE_OP_BOTTOM3 { 638 0x0: PSHUFD(Vo,Wo,Ib); 639 //0x1: group12_pshimw(); 640 0x1: decode MODRM_REG { 641 0x2: PSRLW(VRo,Ib); 642 0x4: PSRAW(VRo,Ib); 643 0x6: PSLLW(VRo,Ib); 644 } 645 //0x2: group13_pshimd(); 646 0x2: decode MODRM_REG { 647 0x2: PSRLD(VRo,Ib); 648 0x4: PSRAD(VRo,Ib); 649 0x6: PSLLD(VRo,Ib); 650 default: UD2(); 651 } 652 //0x3: group14_pshimq(); 653 0x3: decode MODRM_REG { 654 0x2: PSRLQ(VRo,Ib); 655 0x3: PSRLDQ(VRo,Ib); 656 0x6: PSLLQ(VRo,Ib); 657 0x7: PSLLDQ(VRo,Ib); 658 default: UD2(); 659 } 660 0x4: PCMPEQB(Vo,Wo); 661 0x5: PCMPEQW(Vo,Wo); 662 0x6: PCMPEQD(Vo,Wo); 663 default: UD2(); 664 } 665 // repne (0xF2) 666 0x8: decode OPCODE_OP_BOTTOM3 { 667 0x0: PSHUFLW(Vo,Wo,Ib); 668 default: UD2(); 669 } 670 default: UD2(); 671 } 672 0x0F: decode LEGACY_DECODEVAL { 673 // no prefix 674 0x0: decode OPCODE_OP_BOTTOM3 { 675 0x0: WarnUnimpl::vmread_Edp_Gdp(); 676 0x1: WarnUnimpl::vmwrite_Gdp_Edp(); 677 0x6: MOVD(Edp,Pdp); 678 0x7: MOVQ(Qq,Pq); 679 default: UD2(); 680 } 681 // repe (0xF3) 682 0x4: decode OPCODE_OP_BOTTOM3 { 683 0x6: MOVQ(Vq,Wq); 684 0x7: MOVDQU(Wo,Vo); 685 default: UD2(); 686 } 687 // operand size (0x66) 688 0x1: decode OPCODE_OP_BOTTOM3 { 689 0x4: HADDPD(Vo,Wo); 690 0x5: WarnUnimpl::hsubpd_Vo_Wo(); 691 0x6: MOVD(Edp,Vd); 692 0x7: MOVDQA(Wo,Vo); 693 default: UD2(); 694 } 695 // repne (0xF2) 696 0x8: decode OPCODE_OP_BOTTOM3 { 697 0x4: HADDPS(Vo,Wo); 698 0x5: WarnUnimpl::hsubps_Vo_Wo(); 699 default: UD2(); 700 } 701 default: UD2(); 702 } 703 0x10: decode OPCODE_OP_BOTTOM3 { 704 0x0: JO(Jz); 705 0x1: JNO(Jz); 706 0x2: JB(Jz); 707 0x3: JNB(Jz); 708 0x4: JZ(Jz); 709 0x5: JNZ(Jz); 710 0x6: JBE(Jz); 711 0x7: JNBE(Jz); 712 } 713 0x11: decode OPCODE_OP_BOTTOM3 { 714 0x0: JS(Jz); 715 0x1: JNS(Jz); 716 0x2: JP(Jz); 717 0x3: JNP(Jz); 718 0x4: JL(Jz); 719 0x5: JNL(Jz); 720 0x6: JLE(Jz); 721 0x7: JNLE(Jz); 722 } 723 0x12: decode OPCODE_OP_BOTTOM3 { 724 0x0: SETO(Eb); 725 0x1: SETNO(Eb); 726 0x2: SETB(Eb); 727 0x3: SETNB(Eb); 728 0x4: SETZ(Eb); 729 0x5: SETNZ(Eb); 730 0x6: SETBE(Eb); 731 0x7: SETNBE(Eb); 732 } 733 0x13: decode OPCODE_OP_BOTTOM3 { 734 0x0: SETS(Eb); 735 0x1: SETNS(Eb); 736 0x2: SETP(Eb); 737 0x3: SETNP(Eb); 738 0x4: SETL(Eb); 739 0x5: SETNL(Eb); 740 0x6: SETLE(Eb); 741 0x7: SETNLE(Eb); 742 } 743 } 744 0x14: decode OPCODE_OP_BOTTOM3 { 745 0x0: push_fs(); 746 0x1: pop_fs(); 747 0x2: CPUIDInst::CPUID({{ 748 CpuidResult result; 749 bool success = doCpuid(xc->tcBase(), bits(Rax, 31, 0), 750 bits(Rcx, 31, 0), result); 751 if (success) { 752 Rax = result.rax; 753 Rbx = result.rbx; 754 Rcx = result.rcx; 755 Rdx = result.rdx; 756 } else { 757 Rax = Rax; 758 Rbx = Rbx; 759 Rcx = Rcx; 760 Rdx = Rdx; 761 } 762 }}); 763 0x3: Inst::BT(Ev,Gv); 764 0x4: Inst::SHLD(Ev,Gv,Ib); 765 0x5: Inst::SHLD(Ev,Gv); 766 default: Inst::UD2(); 767 } 768 0x15: decode OPCODE_OP_BOTTOM3 { 769 0x0: push_gs(); 770 0x1: pop_gs(); 771 0x2: rsm_smm(); 772 0x3: Inst::BTS(Ev,Gv); 773 0x4: Inst::SHRD(Ev,Gv,Ib); 774 0x5: Inst::SHRD(Ev,Gv); 775 //0x6: group15(); 776 0x6: decode MODRM_MOD { 777 0x3: decode MODRM_REG { 778 0x5: BasicOperate::LFENCE( 779 {{/*Nothing*/}}, IsReadBarrier); 780 0x6: BasicOperate::MFENCE( 781 {{/*Nothing*/}}, IsMemBarrier); 782 0x7: BasicOperate::SFENCE( 783 {{/*Nothing*/}}, IsWriteBarrier); 784 default: Inst::UD2(); 785 } 786 default: decode MODRM_REG { 787 0x0: decode OPSIZE { 788 4: Inst::FXSAVE(M); 789 8: Inst::FXSAVE64(M); 790 default: fxsave(); 791 } 792 0x1: decode OPSIZE { 793 4: Inst::FXRSTOR(M); 794 8: Inst::FXRSTOR64(M); 795 default: fxrstor(); 796 } 797 0x2: Inst::LDMXCSR(Md); 798 0x3: Inst::STMXCSR(Md); 799 0x4: xsave(); 800 0x5: xrstor(); 801 0x6: Inst::UD2(); 802 0x7: clflush(); 803 } 804 } 805 0x7: Inst::IMUL(Gv,Ev); 806 } 807 format Inst { 808 0x16: decode OPCODE_OP_BOTTOM3 { 809 0x0: CMPXCHG(Eb,Gb); 810 0x1: CMPXCHG(Ev,Gv); 811 0x2: WarnUnimpl::lss_Gz_Mp(); 812 0x3: BTR(Ev,Gv); 813 0x4: WarnUnimpl::lfs_Gz_Mp(); 814 0x5: WarnUnimpl::lgs_Gz_Mp(); 815 //The size of the second operand in these instructions 816 //should really be "b" or "w", but it's set to v in order 817 //to have a consistent register size. This shouldn't 818 //affect behavior. 819 0x6: MOVZX_B(Gv,Ev); 820 0x7: MOVZX_W(Gv,Ev); 821 } 822 0x17: decode OPCODE_OP_BOTTOM3 { 823 0x0: decode LEGACY_REP { 824 0x0: WarnUnimpl::jmpe_Jz(); 825 0x1: WarnUnimpl::popcnt_Gv_Ev(); 826 } 827 //0x1: group10_UD2(); 828 0x1: UD2(); 829 //0x2: group8_Ev_Ib(); 830 0x2: decode MODRM_REG { 831 0x4: BT(Ev,Ib); 832 0x5: BTS(Ev,Ib); 833 0x6: BTR(Ev,Ib); 834 0x7: BTC(Ev,Ib); 835 default: UD2(); 836 } 837 0x3: BTC(Ev,Gv); 838 0x4: BSF(Gv,Ev); 839 0x5: BSR(Gv,Ev); 840 //The size of the second operand in these instructions 841 //should really be "b" or "w", but it's set to v in order 842 //to have a consistent register size. This shouldn't 843 //affect behavior. 844 0x6: MOVSX_B(Gv,Ev); 845 0x7: MOVSX_W(Gv,Ev); 846 } 847 0x18: decode OPCODE_OP_BOTTOM3 { 848 0x0: XADD(Eb,Gb); 849 0x1: XADD(Ev,Gv); 850 //0x7: group9(); 851 0x7: decode MODRM_REG { 852 //Also CMPXCHG16B 853 0x1: CMPXCHG8B(Mdp); 854 0x6: decode LEGACY_OP { 855 0x1: WarnUnimpl::vmclear_Mq(); 856 default: decode LEGACY_REP { 857 0x1: WarnUnimpl::vmxon_Mq(); 858 0x0: WarnUnimpl::vmptrld_Mq(); 859 } 860 } 861 0x7: WarnUnimpl::vmptrst_Mq(); 862 default: UD2(); 863 } 864 default: decode LEGACY_DECODEVAL { 865 // no prefix 866 0x0: decode OPCODE_OP_BOTTOM3 { 867 0x2: CMPPS(Vo,Wo,Ib); 868 0x3: MOVNTI(Mdp,Gdp); 869 0x4: PINSRW(Pq,Ew,Ib); 870 0x5: PEXTRW(Gd,PRq,Ib); 871 0x6: SHUFPS(Vps,Wps,Ib); 872 } 873 // repe (0xF3) 874 0x4: decode OPCODE_OP_BOTTOM3 { 875 0x2: CMPSS(Vd,Wd,Ib); 876 default: UD2(); 877 } 878 // operand size (0x66) 879 0x1: decode OPCODE_OP_BOTTOM3 { 880 0x2: CMPPD(Vo,Wo,Ib); 881 0x4: PINSRW(Vdw,Ew,Ib); 882 0x5: PEXTRW(Gd,VRdq,Ib); 883 0x6: SHUFPD(Vpd,Wpd,Ib); 884 default: UD2(); 885 } 886 // repne (0xF2) 887 0x8: decode OPCODE_OP_BOTTOM3 { 888 0x2: CMPSD(Vq,Wq,Ib); 889 default: UD2(); 890 } 891 default: UD2(); 892 } 893 } 894 0x19: decode OPSIZE { 895 4: BSWAP_D(Bd); 896 8: BSWAP_Q(Bq); 897 default: UD2(); 898 } 899 0x1A: decode LEGACY_DECODEVAL { 900 // no prefix 901 0x0: decode OPCODE_OP_BOTTOM3 { 902 0x1: PSRLW(Pq,Qq); 903 0x2: PSRLD(Pq,Qq); 904 0x3: PSRLQ(Pq,Qq); 905 0x4: PADDQ(Pq,Qq); 906 0x5: PMULLW(Pq,Qq); 907 0x7: PMOVMSKB(Gd,PRq); 908 default: UD2(); 909 } 910 // repe (0xF3) 911 0x4: decode OPCODE_OP_BOTTOM3 { 912 0x6: MOVQ2DQ(Vo,PRq); 913 default: UD2(); 914 } 915 // operand size (0x66) 916 0x1: decode OPCODE_OP_BOTTOM3 { 917 0x0: ADDSUBPD(Vo,Wo); 918 0x1: PSRLW(Vo,Wo); 919 0x2: PSRLD(Vo,Wo); 920 0x3: PSRLQ(Vo,Wo); 921 0x4: PADDQ(Vo,Wo); 922 0x5: PMULLW(Vo,Wo); 923 0x6: MOVQ(Wq,Vq); 924 0x7: PMOVMSKB(Gd,VRo); 925 } 926 // repne (0xF2) 927 0x8: decode OPCODE_OP_BOTTOM3 { 928 0x0: WarnUnimpl::addsubps_Vo_Wo(); 929 0x6: MOVDQ2Q(Pq,VRq); 930 default: UD2(); 931 } 932 default: UD2(); 933 } 934 0x1B: decode LEGACY_DECODEVAL { 935 // no prefix 936 0x0: decode OPCODE_OP_BOTTOM3 { 937 0x0: PSUBUSB(Pq,Qq); 938 0x1: PSUBUSW(Pq,Qq); 939 0x2: PMINUB(Pq,Qq); 940 0x3: PAND(Pq,Qq); 941 0x4: PADDUSB(Pq,Qq); 942 0x5: PADDUSW(Pq,Qq); 943 0x6: PMAXUB(Pq,Qq); 944 0x7: PANDN(Pq,Qq); 945 } 946 // operand size (0x66) 947 0x1: decode OPCODE_OP_BOTTOM3 { 948 0x0: PSUBUSB(Vo,Wo); 949 0x1: PSUBUSW(Vo,Wo); 950 0x2: PMINUB(Vo,Wo); 951 0x3: PAND(Vo,Wo); 952 0x4: PADDUSB(Vo,Wo); 953 0x5: PADDUSW(Vo,Wo); 954 0x6: PMAXUB(Vo,Wo); 955 0x7: PANDN(Vo,Wo); 956 } 957 default: UD2(); 958 } 959 0x1C: decode LEGACY_DECODEVAL { 960 // no prefix 961 0x0: decode OPCODE_OP_BOTTOM3 { 962 0x0: PAVGB(Pq,Qq); 963 0x1: PSRAW(Pq,Qq); 964 0x2: PSRAD(Pq,Qq); 965 0x3: PAVGW(Pq,Qq); 966 0x4: PMULHUW(Pq,Qq); 967 0x5: PMULHW(Pq,Qq); 968 0x7: WarnUnimpl::movntq_Mq_Pq(); 969 default: UD2(); 970 } 971 // repe (0xF3) 972 0x4: decode OPCODE_OP_BOTTOM3 { 973 0x6: CVTDQ2PD(Vo,Wq); 974 default: UD2(); 975 } 976 // operand size (0x66) 977 0x1: decode OPCODE_OP_BOTTOM3 { 978 0x0: PAVGB(Vo,Wo); 979 0x1: PSRAW(Vo,Wo); 980 0x2: PSRAD(Vo,Wo); 981 0x3: PAVGW(Vo,Wo); 982 0x4: PMULHUW(Vo,Wo); 983 0x5: PMULHW(Vo,Wo); 984 0x6: CVTTPD2DQ(Vo,Wo); 985 0x7: WarnUnimpl::movntdq_Mo_Vo(); 986 } 987 // repne (0xF2) 988 0x8: decode OPCODE_OP_BOTTOM3 { 989 0x6: CVTPD2DQ(Vo,Wo); 990 default: UD2(); 991 } 992 default: UD2(); 993 } 994 0x1D: decode LEGACY_DECODEVAL { 995 // no prefix 996 0x0: decode OPCODE_OP_BOTTOM3 { 997 0x0: PSUBSB(Pq,Qq); 998 0x1: PSUBSW(Pq,Qq); 999 0x2: PMINSW(Pq,Qq); 1000 0x3: POR(Pq,Qq); 1001 0x4: PADDSB(Pq,Qq); 1002 0x5: PADDSW(Pq,Qq); 1003 0x6: PMAXSW(Pq,Qq); 1004 0x7: PXOR(Pq,Qq); 1005 } 1006 // operand size (0x66) 1007 0x1: decode OPCODE_OP_BOTTOM3 { 1008 0x0: PSUBSB(Vo,Wo); 1009 0x1: PSUBSW(Vo,Wo); 1010 0x2: PMINSW(Vo,Wo); 1011 0x3: POR(Vo,Wo); 1012 0x4: PADDSB(Vo,Wo); 1013 0x5: PADDSW(Vo,Wo); 1014 0x6: PMAXSW(Vo,Wo); 1015 0x7: PXOR(Vo,Wo); 1016 } 1017 default: UD2(); 1018 } 1019 0x1E: decode LEGACY_DECODEVAL { 1020 // no prefix 1021 0x0: decode OPCODE_OP_BOTTOM3 { 1022 0x1: PSLLW(Pq,Qq); 1023 0x2: PSLLD(Pq,Qq); 1024 0x3: PSLLQ(Pq,Qq); 1025 0x4: PMULUDQ(Pq,Qq); 1026 0x5: PMADDWD(Pq,Qq); 1027 0x6: PSADBW(Pq,Qq); 1028 0x7: MASKMOVQ(Pq,PRq); 1029 default: UD2(); 1030 } 1031 // operand size (0x66) 1032 0x1: decode OPCODE_OP_BOTTOM3 { 1033 0x1: PSLLW(Vo,Wo); 1034 0x2: PSLLD(Vo,Wo); 1035 0x3: PSLLQ(Vo,Wo); 1036 0x4: PMULUDQ(Vo,Wo); 1037 0x5: PMADDWD(Vo,Wo); 1038 0x6: PSADBW(Vo,Wo); 1039 0x7: MASKMOVDQU(Vo,VRo); 1040 default: UD2(); 1041 } 1042 // repne (0xF2) 1043 0x8: decode OPCODE_OP_BOTTOM3 { 1044 0x0: WarnUnimpl::lddqu_Vo_Mo(); 1045 default: UD2(); 1046 } 1047 default: UD2(); 1048 } 1049 0x1F: decode LEGACY_DECODEVAL { 1050 // no prefix 1051 0x0: decode OPCODE_OP_BOTTOM3 { 1052 0x0: PSUBB(Pq,Qq); 1053 0x1: PSUBW(Pq,Qq); 1054 0x2: PSUBD(Pq,Qq); 1055 0x3: PSUBQ(Pq,Qq); 1056 0x4: PADDB(Pq,Qq); 1057 0x5: PADDW(Pq,Qq); 1058 0x6: PADDD(Pq,Qq); 1059 0x7: UD2(); 1060 } 1061 // operand size (0x66) 1062 0x1: decode OPCODE_OP_BOTTOM3 { 1063 0x0: PSUBB(Vo,Wo); 1064 0x1: PSUBW(Vo,Wo); 1065 0x2: PSUBD(Vo,Wo); 1066 0x3: PSUBQ(Vo,Wo); 1067 0x4: PADDB(Vo,Wo); 1068 0x5: PADDW(Vo,Wo); 1069 0x6: PADDD(Vo,Wo); 1070 0x7: UD2(); 1071 } 1072 default: UD2(); 1073 } 1074 } 1075 default: FailUnimpl::twoByteOps(); 1076 } 1077} 1078