1// Copyright (c) 2008 The Regents of The University of Michigan 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: redistributions of source code must retain the above copyright 7// notice, this list of conditions and the following disclaimer; 8// redistributions in binary form must reproduce the above copyright 9// notice, this list of conditions and the following disclaimer in the 10// documentation and/or other materials provided with the distribution; 11// neither the name of the copyright holders nor the names of its 12// contributors may be used to endorse or promote products derived from 13// this software without specific prior written permission. 14// 15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26// 27// Authors: Gabe Black 28 29// Copyright (c) 2007-2008 The Hewlett-Packard Development Company 30// All rights reserved. 31// 32// Redistribution and use of this software in source and binary forms, 33// with or without modification, are permitted provided that the 34// following conditions are met: 35// 36// The software must be used only for Non-Commercial Use which means any 37// use which is NOT directed to receiving any direct monetary 38// compensation for, or commercial advantage from such use. Illustrative 39// examples of non-commercial use are academic research, personal study, 40// teaching, education and corporate research & development. 41// Illustrative examples of commercial use are distributing products for 42// commercial advantage and providing services using the software for 43// commercial advantage. 44// 45// If you wish to use this software or functionality therein that may be 46// covered by patents for commercial use, please contact: 47// Director of Intellectual Property Licensing 48// Office of Strategy and Technology 49// Hewlett-Packard Company 50// 1501 Page Mill Road 51// Palo Alto, California 94304 52// 53// Redistributions of source code must retain the above copyright notice, 54// this list of conditions and the following disclaimer. Redistributions 55// in binary form must reproduce the above copyright notice, this list of 56// conditions and the following disclaimer in the documentation and/or 57// other materials provided with the distribution. Neither the name of 58// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 59// contributors may be used to endorse or promote products derived from 60// this software without specific prior written permission. No right of 61// sublicense is granted herewith. Derivatives of the software and 62// output created using the software may be prepared, but only for 63// Non-Commercial Uses. Derivatives of the software may be shared with 64// others provided: (i) the others agree to abide by the list of 65// conditions herein which includes the Non-Commercial Use restrictions; 66// and (ii) such Derivatives of the software include the above copyright 67// notice to acknowledge the contribution from this software where 68// applicable, this list of conditions and the disclaimer below. 69// 70// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 71// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 72// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 73// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 74// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 75// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 76// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 77// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 78// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 79// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 80// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 81// 82// Authors: Gabe Black 83 84//////////////////////////////////////////////////////////////////// 85// 86// Decode the two byte opcodes 87// 880x2: decode OPCODE_PREFIXA { 89 0x0F: decode OPCODE_OP_TOP5 { 90 format WarnUnimpl { 91 0x00: decode OPCODE_OP_BOTTOM3 { 92 //0x00: group6(); 93 0x00: decode MODRM_REG { 94 0x0: sldt_Mw_or_Rv(); 95 0x1: str_Mw_or_Rv(); 96 0x2: lldt_Mw_or_Rv(); 97 0x3: Inst::LTR(Ew); 98 0x4: verr_Mw_or_Rv(); 99 0x5: verw_Mw_or_Rv(); 100 //0x6: jmpe_Ev(); // IA-64 101 default: Inst::UD2(); 102 } 103 //0x01: group7(); // Ugly, ugly, ugly... 104 0x01: decode MODRM_MOD { 105 0x3: decode MODRM_REG { 106 0x0: decode MODRM_RM { 107 0x1: vmcall(); 108 0x2: vmlaunch(); 109 0x3: vmresume(); 110 0x4: vmxoff(); 111 default: Inst::UD2(); 112 } 113 0x1: decode MODRM_RM { 114 0x0: monitor(); 115 0x1: mwait(); 116 default: Inst::UD2(); 117 } 118 0x3: decode MODRM_RM { 119 0x0: vmrun(); 120 0x1: vmmcall(); 121 0x2: vmload(); 122 0x3: vmsave(); 123 0x4: stgi(); 124 0x5: clgi(); 125 0x6: skinit(); 126 0x7: invlpga(); 127 } 128 0x4: smsw_Rv(); 129 0x6: lmsw_Rv(); 130 0x7: decode MODRM_RM { 131 0x0: Inst::SWAPGS(); 132 0x1: rdtscp(); 133 default: Inst::UD2(); 134 } 135 default: Inst::UD2(); 136 } 137 default: decode MODRM_REG { 138 0x0: sgdt_Ms(); 139 0x1: sidt_Ms(); 140 0x2: decode MODE_SUBMODE { 141 0x0: Inst::LGDT(M); 142 default: decode OPSIZE { 143 // 16 bit operand sizes are special, but only 144 // in legacy and compatability modes. 145 0x2: Inst::LGDT_16(M); 146 default: Inst::LGDT(M); 147 } 148 } 149 0x3: decode MODE_SUBMODE { 150 0x0: Inst::LIDT(M); 151 default: decode OPSIZE { 152 // 16 bit operand sizes are special, but only 153 // in legacy and compatability modes. 154 0x2: Inst::LIDT_16(M); 155 default: Inst::LIDT(M); 156 } 157 } 158 0x4: smsw_Mw(); 159 0x6: lmsw_Mw(); 160 0x7: Inst::INVLPG(M); 161 default: Inst::UD2(); 162 } 163 } 164 0x02: lar_Gv_Ew(); 165 0x03: lsl_Gv_Ew(); 166 // sandpile.org doesn't seem to know what this is...? We'll 167 // use it for pseudo instructions. We've got 16 bits of space 168 // to play with so there can be quite a few pseudo 169 // instructions. 170 //0x04: loadall_or_reset_or_hang(); 171 0x4: decode IMMEDIATE { 172 format BasicOperate { 173#if FULL_SYSTEM 174 0x00: m5arm({{ 175 PseudoInst::arm(xc->tcBase()); 176 }}, IsNonSpeculative); 177 0x01: m5quiesce({{ 178 PseudoInst::quiesce(xc->tcBase()); 179 }}, IsNonSpeculative); 180 0x02: m5quiesceNs({{ 181 PseudoInst::quiesceNs(xc->tcBase(), Rdi); 182 }}, IsNonSpeculative); 183 0x03: m5quiesceCycle({{ 184 PseudoInst::quiesceCycles(xc->tcBase(), Rdi); 185 }}, IsNonSpeculative); 186 0x04: m5quiesceTime({{ 187 Rax = PseudoInst::quiesceTime(xc->tcBase()); 188 }}, IsNonSpeculative); 189#endif 190 0x07: m5rpns({{ 191 Rax = PseudoInst::rpns(xc->tcBase()); 192 }}, IsNonSpeculative); 193 0x21: m5exit({{ 194 PseudoInst::m5exit(xc->tcBase(), Rdi); 195 }}, IsNonSpeculative); 196#if FULL_SYSTEM 197 0x30: m5initparam({{ 198 Rax = xc->tcBase()->getCpuPtr()-> 199 system->init_param; 200 }}, IsNonSpeculative); 201 0x31: m5loadsymbol({{ 202 PseudoInst::loadsymbol(xc->tcBase()); 203 }}, IsNonSpeculative); 204#endif 205 0x40: m5resetstats({{ 206 PseudoInst::resetstats(xc->tcBase(), Rdi, Rsi); 207 }}, IsNonSpeculative); 208 0x41: m5dumpstats({{ 209 PseudoInst::dumpstats(xc->tcBase(), Rdi, Rsi); 210 }}, IsNonSpeculative); 211 0x42: m5dumpresetstats({{ 212 PseudoInst::dumpresetstats(xc->tcBase(), Rdi, Rsi); 213 }}, IsNonSpeculative); 214 0x43: m5checkpoint({{ 215 PseudoInst::m5checkpoint(xc->tcBase(), Rdi, Rsi); 216 }}, IsNonSpeculative); 217#if FULL_SYSTEM 218 0x50: m5readfile({{ 219 Rax = PseudoInst::readfile( 220 xc->tcBase(), Rdi, Rsi, Rdx); 221 }}, IsNonSpeculative); 222#endif 223 0x51: m5debugbreak({{ 224 PseudoInst::debugbreak(xc->tcBase()); 225 }}, IsNonSpeculative); 226 0x52: m5switchcpu({{ 227 PseudoInst::switchcpu(xc->tcBase()); 228 }}, IsNonSpeculative); 229#if FULL_SYSTEM 230 0x53: m5addsymbol({{ 231 PseudoInst::addsymbol(xc->tcBase(), Rdi, Rsi); 232 }}, IsNonSpeculative); 233#endif 234 0x54: m5panic({{ 235 panic("M5 panic instruction called at pc=%#x.\n", 236 xc->readPC()); 237 }}, IsNonSpeculative); 238 0x55: m5reserved1({{ 239 warn("M5 reserved opcode 1 ignored.\n"); 240 }}, IsNonSpeculative); 241 0x56: m5reserved2({{ 242 warn("M5 reserved opcode 2 ignored.\n"); 243 }}, IsNonSpeculative); 244 0x57: m5reserved3({{ 245 warn("M5 reserved opcode 3 ignored.\n"); 246 }}, IsNonSpeculative); 247 0x58: m5reserved4({{ 248 warn("M5 reserved opcode 4 ignored.\n"); 249 }}, IsNonSpeculative); 250 0x59: m5reserved5({{ 251 warn("M5 reserved opcode 5 ignored.\n"); 252 }}, IsNonSpeculative); 253 default: Inst::UD2(); 254 } 255 } 256#if FULL_SYSTEM
|
264#else 265 0x05: SyscallInst::syscall('xc->syscall(Rax)', IsSyscall); 266#endif 267 0x06: clts(); 268 //sandpile.org says (AMD) after sysret, so I might want to check 269 //if that means amd64 or AMD machines 270 0x07: loadall_or_sysret(); 271 } 272 0x01: decode OPCODE_OP_BOTTOM3 { 273 0x0: invd(); 274 0x1: wbinvd(); 275 0x2: Inst::UD2(); 276 0x3: Inst::UD2(); 277 0x4: Inst::UD2(); 278 0x5: prefetch(); 279 0x6: FailUnimpl::femms(); 280 0x7: FailUnimpl::threednow(); 281 } 282 0x02: decode LEGACY_DECODEVAL { 283 // no prefix 284 0x0: decode OPCODE_OP_BOTTOM3 { 285 0x0: movups_Vo_Wo(); 286 0x1: movups_Wo_Vo(); 287 0x2: decode MODRM_MOD { 288 0x3: movhlps_Vq_VRq(); 289 default: movlps_Vq_Mq(); 290 } 291 0x3: movlps_Mq_Vq(); 292 0x4: unpcklps(); 293 0x5: unpckhps(); 294 0x6: decode MODRM_MOD { 295 0x3: movlhps_Vq_VRq(); 296 default: movhps_Vq_Mq(); 297 } 298 0x7: movhps_Mq_Vq(); 299 } 300 // repe (0xF3) 301 0x4: decode OPCODE_OP_BOTTOM3 { 302 0x0: movss_Vd_Wd(); 303 0x1: movss_Wd_Vd(); 304 0x2: movsldup_Vo_Wo(); 305 0x6: movshdup_Vo_Wo(); 306 default: Inst::UD2(); 307 } 308 // operand size (0x66) 309 0x1: decode OPCODE_OP_BOTTOM3 { 310 0x0: movupd_Vo_Wo(); 311 0x1: movupd_Wo_Vo(); 312 0x2: Inst::MOVLPD(Vq,Mq); 313 0x3: Inst::MOVLPD(Mq,Vq); 314 0x4: unpcklpd_Vo_Wq(); 315 0x5: unpckhpd_Vo_Wo(); 316 0x6: movhpd_Vq_Mq(); 317 0x7: movhpd_Mq_Vq(); 318 } 319 // repne (0xF2) 320 0x8: decode OPCODE_OP_BOTTOM3 { 321 0x0: Inst::MOVSD(Vq,Wq); 322 0x1: Inst::MOVSD(Wq,Vq); 323 0x2: movddup_Vo_Wq(); 324 default: Inst::UD2(); 325 } 326 default: Inst::UD2(); 327 } 328 0x03: decode OPCODE_OP_BOTTOM3 { 329 //group17(); 330 0x0: decode MODRM_REG { 331 0x0: prefetch_nta(); 332 0x1: prefetch_t0(); 333 0x2: prefetch_t1(); 334 0x3: prefetch_t2(); 335 default: Inst::HINT_NOP(); 336 } 337 0x1: Inst::HINT_NOP(); 338 0x2: Inst::HINT_NOP(); 339 0x3: Inst::HINT_NOP(); 340 0x4: Inst::HINT_NOP(); 341 0x5: Inst::HINT_NOP(); 342 0x6: Inst::HINT_NOP(); 343 0x7: Inst::HINT_NOP(); 344 } 345 0x04: decode LEGACY_DECODEVAL { 346 // no prefix 347 0x0: decode OPCODE_OP_BOTTOM3 { 348 0x0: Inst::MOV(Rd,Cd); 349 0x1: mov_Rd_Dd(); 350 0x2: Inst::MOV(Cd,Rd); 351 0x3: mov_Dd_Rd(); 352 0x4: mov_Rd_Td(); 353 0x6: mov_Td_Rd(); 354 default: Inst::UD2(); 355 } 356 // lock prefix (0xF0) 357 0x2: decode OPCODE_OP_BOTTOM3 { 358 0x0: mov_Rd_CR8D(); 359 0x2: mov_CR8D_Rd(); 360 } 361 default: Inst::UD2(); 362 } 363 0x05: decode LEGACY_DECODEVAL { 364 // no prefix 365 0x0: decode OPCODE_OP_BOTTOM3 { 366 //These moves should really use size o (octword), but 367 //because they are split in two, they use q (quadword). 368 0x0: Inst::MOVAPS(Vq,Wq); 369 0x1: Inst::MOVAPS(Wq,Vq); 370 0x2: decode MODRM_MOD { 371 0x3: cvtpi2pS_Vq_Pq(); 372 default: cvtpi2ps_Vq_Mq(); 373 } 374 0x3: movntps_Mo_Vo(); 375 0x4: cvttps2pi_Pq_Wq(); 376 0x5: cvtpS2pi_Pq_Wq(); 377 0x6: ucomiss_Vd_Wd(); 378 0x7: comiss_Vd_Wd(); 379 } 380 // repe (0xF3) 381 0x4: decode OPCODE_OP_BOTTOM3 { 382 0x2: cvtsi2ss_Vd_Ed(); 383 0x4: cvttss2si_Gd_Wd(); 384 0x5: cvtss2si_Gd_Wd(); 385 default: Inst::UD2(); 386 } 387 // operand size (0x66) 388 0x1: decode OPCODE_OP_BOTTOM3 { 389 0x0: movapd_Vo_Wo(); 390 0x1: movapd_Wo_Vo(); 391 0x2: decode MODRM_MOD { 392 0x3: cvtpi2pd_Vo_Pq(); 393 default: cvtpi2pd_Vo_Mq(); 394 } 395 0x3: movntpd_Mo_Vo(); 396 0x4: cvttpd2pi_Pq_Wo(); 397 0x5: cvtpd2pi_Pq_Wo(); 398 0x6: Inst::UCOMISD(Vq,Wq); 399 0x7: comisd_Vq_Wq(); 400 } 401 // repne (0xF2) 402 0x8: decode OPCODE_OP_BOTTOM3 { 403 // The size of the V operand should be q, not dp 404 0x2: Inst::CVTSI2SD(Vdp,Edp); 405 // The size of the W operand should be q, not dp 406 0x4: Inst::CVTTSD2SI(Gdp,Wdp); 407 0x5: cvtsd2si_Gd_Wq(); 408 default: Inst::UD2(); 409 } 410 default: Inst::UD2(); 411 } 412 0x06: decode OPCODE_OP_BOTTOM3 { 413 0x0: Inst::WRMSR(); 414 0x1: Inst::RDTSC(); 415 0x2: Inst::RDMSR(); 416 0x3: rdpmc(); 417 0x4: sysenter(); 418 0x5: sysexit(); 419 0x6: Inst::UD2(); 420 0x7: getsec(); 421 } 422 0x07: decode OPCODE_OP_BOTTOM3 { 423 0x0: three_byte_opcode(); 424 0x1: three_byte_opcode(); 425 0x2: three_byte_opcode(); 426 0x3: three_byte_opcode(); 427 0x4: three_byte_opcode(); 428 0x5: three_byte_opcode(); 429 0x6: three_byte_opcode(); 430 0x7: three_byte_opcode(); 431 } 432 format Inst { 433 0x08: decode OPCODE_OP_BOTTOM3 { 434 0x0: CMOVO(Gv,Ev); 435 0x1: CMOVNO(Gv,Ev); 436 0x2: CMOVB(Gv,Ev); 437 0x3: CMOVNB(Gv,Ev); 438 0x4: CMOVZ(Gv,Ev); 439 0x5: CMOVNZ(Gv,Ev); 440 0x6: CMOVBE(Gv,Ev); 441 0x7: CMOVNBE(Gv,Ev); 442 } 443 0x09: decode OPCODE_OP_BOTTOM3 { 444 0x0: CMOVS(Gv,Ev); 445 0x1: CMOVNS(Gv,Ev); 446 0x2: CMOVP(Gv,Ev); 447 0x3: CMOVNP(Gv,Ev); 448 0x4: CMOVL(Gv,Ev); 449 0x5: CMOVNL(Gv,Ev); 450 0x6: CMOVLE(Gv,Ev); 451 0x7: CMOVNLE(Gv,Ev); 452 } 453 } 454 0x0A: decode LEGACY_DECODEVAL { 455 // no prefix 456 0x0: decode OPCODE_OP_BOTTOM3 { 457 0x0: movmskps_Gd_VRo(); 458 0x1: sqrtps_Vo_Wo(); 459 0x2: rqsrtps_Vo_Wo(); 460 0x3: rcpps_Vo_Wo(); 461 0x4: andps_Vo_Wo(); 462 0x5: andnps_Vo_Wo(); 463 0x6: orps_Vo_Wo(); 464 0x7: xorps_Vo_Wo(); 465 } 466 // repe (0xF3) 467 0x4: decode OPCODE_OP_BOTTOM3 { 468 0x1: sqrtss_Vd_Wd(); 469 0x2: rsqrtss_Vd_Wd(); 470 0x3: rcpss_Vd_Wd(); 471 default: Inst::UD2(); 472 } 473 // operand size (0x66) 474 0x1: decode OPCODE_OP_BOTTOM3 { 475 0x0: movmskpd_Gd_VRo(); 476 0x1: sqrtpd_Vo_Wo(); 477 0x4: andpd_Vo_Wo(); 478 0x5: andnpd_Vo_Wo(); 479 0x6: orpd_Vo_Wo(); 480 //This really should be type o, but it works on q sized 481 //chunks at a time. 482 0x7: Inst::XORPD(Vq,Wq); 483 default: Inst::UD2(); 484 } 485 format Inst { 486 // repne (0xF2) 487 0x8: decode OPCODE_OP_BOTTOM3 { 488 0x1: SQRTSD(Vq,Wq); 489 default: UD2(); 490 } 491 default: UD2(); 492 } 493 } 494 0x0B: decode LEGACY_DECODEVAL { 495 // no prefix 496 0x0: decode OPCODE_OP_BOTTOM3 { 497 0x0: addps_Vo_Wo(); 498 0x1: mulps_Vo_Wo(); 499 0x2: cvtps2pd_Vo_Wq(); 500 0x3: cvtdq2ps_Vo_Wo(); 501 0x4: subps_Vo_Wo(); 502 0x5: minps_Vo_Wo(); 503 0x6: divps_Vo_Wo(); 504 0x7: maxps_Vo_Wo(); 505 } 506 // repe (0xF3) 507 0x4: decode OPCODE_OP_BOTTOM3 { 508 0x0: addss_Vd_Wd(); 509 0x1: mulss_Vd_Wd(); 510 0x2: cvtss2sd_Vq_Wd(); 511 0x3: cvttps2dq_Vo_Wo(); 512 0x4: subss_Vd_Wd(); 513 0x5: minss_Vd_Wd(); 514 0x6: divss_Vd_Wd(); 515 0x7: maxss_Vd_Wd(); 516 } 517 // operand size (0x66) 518 0x1: decode OPCODE_OP_BOTTOM3 { 519 0x0: addpd_Vo_Wo(); 520 0x1: mulpd_Vo_Wo(); 521 0x2: cvtpd2ps_Vo_Wo(); 522 0x3: cvtps2dq_Vo_Wo(); 523 0x4: subpd_Vo_Wo(); 524 0x5: minpd_Vo_Wo(); 525 0x6: divpd_Vo_Wo(); 526 0x7: maxpd_Vo_Wo(); 527 } 528 // repne (0xF2) 529 0x8: decode OPCODE_OP_BOTTOM3 { 530 0x0: Inst::ADDSD(Vq,Wq); 531 0x1: Inst::MULSD(Vq,Wq); 532 0x2: cvtsd2ss_Vd_Wq(); 533 0x4: Inst::SUBSD(Vq,Wq); 534 0x5: minsd_Vq_Wq(); 535 0x6: Inst::DIVSD(Vq,Wq); 536 0x7: maxsd_Vq_Wq(); 537 default: Inst::UD2(); 538 } 539 default: Inst::UD2(); 540 } 541 0x0C: decode LEGACY_DECODEVAL { 542 // no prefix 543 0x0: decode OPCODE_OP_BOTTOM3 { 544 0x0: punpcklbw_Pq_Qd(); 545 0x1: punpcklwd_Pq_Qd(); 546 0x2: punpckldq_Pq_Qd(); 547 0x3: packsswb_Pq_Qq(); 548 0x4: pcmpgtb_Pq_Qq(); 549 0x5: pcmpgtw_Pq_Qq(); 550 0x6: pcmpgtd_Pq_Qq(); 551 0x7: packuswb_Pq_Qq(); 552 } 553 // operand size (0x66) 554 0x1: decode OPCODE_OP_BOTTOM3 { 555 0x0: punpcklbw_Vo_Wq(); 556 0x1: punpcklwd_Vo_Wq(); 557 0x2: punpckldq_Vo_Wq(); 558 0x3: packsswb_Vo_Wo(); 559 0x4: pcmpgtb_Vo_Wo(); 560 0x5: pcmpgtw_Vo_Wo(); 561 0x6: pcmpgtd_Vo_Wo(); 562 0x7: packuswb_Vo_Wo(); 563 } 564 default: Inst::UD2(); 565 } 566 0x0D: decode LEGACY_DECODEVAL { 567 // no prefix 568 0x0: decode OPCODE_OP_BOTTOM3 { 569 0x0: punpckhbw_Pq_Qq(); 570 0x1: punpckhwd_Pq_Qq(); 571 0x2: punpckhdq_Pq_Qq(); 572 0x3: packssdw_Pq_Qq(); 573 0x6: movd_Pq_Ed(); 574 0x7: movq_Pq_Qq(); 575 default: Inst::UD2(); 576 } 577 // repe (0xF3) 578 0x4: decode OPCODE_OP_BOTTOM3 { 579 0x7: movdqu_Vo_Wo(); 580 default: Inst::UD2(); 581 } 582 // operand size (0x66) 583 0x1: decode OPCODE_OP_BOTTOM3 { 584 0x0: punpckhbw_Vo_Wo(); 585 0x1: punpckhwd_Vo_Wo(); 586 0x2: punpckhdq_Vo_Wo(); 587 0x3: packssdw_Vo_Wo(); 588 0x4: punpcklqdq_Vo_Wq(); 589 0x5: punpcklqdq_Vo_Wq(); 590 0x6: movd_Vo_Ed(); 591 0x7: movdqa_Vo_Wo(); 592 } 593 default: Inst::UD2(); 594 } 595 0x0E: decode LEGACY_DECODEVAL { 596 // no prefix 597 0x0: decode OPCODE_OP_BOTTOM3 { 598 0x0: pshufw_Pq_Qq_Ib(); 599 //0x1: group13_pshimw(); 600 0x1: decode MODRM_REG { 601 0x2: decode LEGACY_OP { 602 0x0: psrlw_PRq_Ib(); 603 0x1: psrlw_VRo_Ib(); 604 } 605 0x4: decode LEGACY_OP { 606 0x0: psraw_PRq_Ib(); 607 0x1: psraw_VRo_Ib(); 608 } 609 0x6: decode LEGACY_OP { 610 0x0: psllw_PRq_Ib(); 611 0x1: psllw_VRo_Ib(); 612 } 613 default: Inst::UD2(); 614 } 615 //0x2: group14_pshimd(); 616 0x2: decode MODRM_REG { 617 0x2: decode LEGACY_OP { 618 0x0: psrld_PRq_Ib(); 619 0x1: psrld_VRo_Ib(); 620 } 621 0x4: decode LEGACY_OP { 622 0x0: psrad_PRq_Ib(); 623 0x1: psrad_VRo_Ib(); 624 } 625 0x6: decode LEGACY_OP { 626 0x0: pslld_PRq_Ib(); 627 0x1: pslld_VRo_Ib(); 628 } 629 default: Inst::UD2(); 630 } 631 //0x3: group15_pshimq(); 632 0x3: decode MODRM_REG { 633 0x2: decode LEGACY_OP { 634 0x0: psrlq_PRq_Ib(); 635 0x1: psrlq_VRo_Ib(); 636 } 637 0x3: decode LEGACY_OP { 638 0x0: Inst::UD2(); 639 0x1: psrldq_VRo_Ib(); 640 } 641 0x6: decode LEGACY_OP { 642 0x0: psllq_PRq_Ib(); 643 0x1: psllq_VRo_Ib(); 644 } 645 0x7: decode LEGACY_OP { 646 0x0: Inst::UD2(); 647 0x1: pslldq_VRo_Ib(); 648 } 649 default: Inst::UD2(); 650 } 651 0x4: pcmpeqb_Pq_Qq(); 652 0x5: pcmpeqw_Pq_Qq(); 653 0x6: pcmpeqd_Pq_Qq(); 654 0x7: emms(); 655 } 656 // repe (0xF3) 657 0x4: decode OPCODE_OP_BOTTOM3 { 658 0x0: pshufhw_Vo_Wo_Ib(); 659 default: Inst::UD2(); 660 } 661 // operand size (0x66) 662 0x1: decode OPCODE_OP_BOTTOM3 { 663 0x0: pshufd_Vo_Wo_Ib(); 664 //0x1: group13_pshimw(); 665 0x1: decode MODRM_REG { 666 0x2: decode LEGACY_OP { 667 0x0: psrlw_PRq_Ib(); 668 0x1: psrlw_VRo_Ib(); 669 } 670 0x4: decode LEGACY_OP { 671 0x0: psraw_PRq_Ib(); 672 0x1: psraw_VRo_Ib(); 673 } 674 0x6: decode LEGACY_OP { 675 0x0: psllw_PRq_Ib(); 676 0x1: psllw_VRo_Ib(); 677 } 678 default: Inst::UD2(); 679 } 680 //0x2: group14_pshimd(); 681 0x2: decode MODRM_REG { 682 0x2: decode LEGACY_OP { 683 0x0: psrld_PRq_Ib(); 684 0x1: psrld_VRo_Ib(); 685 } 686 0x4: decode LEGACY_OP { 687 0x0: psrad_PRq_Ib(); 688 0x1: psrad_VRo_Ib(); 689 } 690 0x6: decode LEGACY_OP { 691 0x0: pslld_PRq_Ib(); 692 0x1: pslld_VRo_Ib(); 693 } 694 default: Inst::UD2(); 695 } 696 //0x3: group15_pshimq(); 697 0x3: decode MODRM_REG { 698 0x2: decode LEGACY_OP { 699 0x0: psrlq_PRq_Ib(); 700 0x1: psrlq_VRo_Ib(); 701 } 702 0x3: decode LEGACY_OP { 703 0x0: Inst::UD2(); 704 0x1: psrldq_VRo_Ib(); 705 } 706 0x6: decode LEGACY_OP { 707 0x0: psllq_PRq_Ib(); 708 0x1: psllq_VRo_Ib(); 709 } 710 0x7: decode LEGACY_OP { 711 0x0: Inst::UD2(); 712 0x1: pslldq_VRo_Ib(); 713 } 714 default: Inst::UD2(); 715 } 716 0x4: pcmpeqb_Vo_Wo(); 717 0x5: pcmpeqw_Vo_Wo(); 718 0x6: pcmpeqd_Vo_Wo(); 719 default: Inst::UD2(); 720 } 721 // repne (0xF2) 722 0x8: decode OPCODE_OP_BOTTOM3 { 723 0x0: pshuflw_Vo_Wo_Ib(); 724 default: Inst::UD2(); 725 } 726 default: Inst::UD2(); 727 } 728 0x0F: decode LEGACY_DECODEVAL { 729 // no prefix 730 0x0: decode OPCODE_OP_BOTTOM3 { 731 0x0: vmread_Ed_or_Eq_Gd_or_Gq(); 732 0x1: vmwrite_Gd_or_Gq_Ed_or_Eq(); 733 0x6: mov_Ed_Pd(); 734 0x7: mov_Qq_Pq(); 735 default: Inst::UD2(); 736 } 737 // repe (0xF3) 738 0x4: decode OPCODE_OP_BOTTOM3 { 739 0x6: movq_Vo_Mq_or_Vq_Vq(); 740 0x7: movdqu_Wo_Vo(); 741 default: Inst::UD2(); 742 } 743 // operand size (0x66) 744 0x1: decode OPCODE_OP_BOTTOM3 { 745 0x4: haddpd_Vo_Wo(); 746 0x5: hsubpd_Vo_Wo(); 747 0x6: movd_Ed_Vd(); 748 0x7: movdqa_Wo_Vo(); 749 default: Inst::UD2(); 750 } 751 // repne (0xF2) 752 0x8: decode OPCODE_OP_BOTTOM3 { 753 0x4: haddps_Vo_Wo(); 754 0x5: hsubps_Vo_Wo(); 755 default: Inst::UD2(); 756 } 757 default: Inst::UD2(); 758 } 759 format Inst { 760 0x10: decode OPCODE_OP_BOTTOM3 { 761 0x0: JO(Jz); 762 0x1: JNO(Jz); 763 0x2: JB(Jz); 764 0x3: JNB(Jz); 765 0x4: JZ(Jz); 766 0x5: JNZ(Jz); 767 0x6: JBE(Jz); 768 0x7: JNBE(Jz); 769 } 770 0x11: decode OPCODE_OP_BOTTOM3 { 771 0x0: JS(Jz); 772 0x1: JNS(Jz); 773 0x2: JP(Jz); 774 0x3: JNP(Jz); 775 0x4: JL(Jz); 776 0x5: JNL(Jz); 777 0x6: JLE(Jz); 778 0x7: JNLE(Jz); 779 } 780 0x12: decode OPCODE_OP_BOTTOM3 { 781 0x0: SETO(Eb); 782 0x1: SETNO(Eb); 783 0x2: SETB(Eb); 784 0x3: SETNB(Eb); 785 0x4: SETZ(Eb); 786 0x5: SETNZ(Eb); 787 0x6: SETBE(Eb); 788 0x7: SETNBE(Eb); 789 } 790 0x13: decode OPCODE_OP_BOTTOM3 { 791 0x0: SETS(Eb); 792 0x1: SETNS(Eb); 793 0x2: SETP(Eb); 794 0x3: SETNP(Eb); 795 0x4: SETL(Eb); 796 0x5: SETNL(Eb); 797 0x6: SETLE(Eb); 798 0x7: SETNLE(Eb); 799 } 800 } 801 0x14: decode OPCODE_OP_BOTTOM3 { 802 0x0: push_fs(); 803 0x1: pop_fs(); 804 0x2: CPUIDInst::CPUID({{ 805 CpuidResult result; 806 success = doCpuid(xc->tcBase(), Rax, result); 807 Rax = result.rax; 808 Rbx = result.rbx; 809 Rcx = result.rcx; 810 Rdx = result.rdx; 811 }}); 812 0x3: Inst::BT(Ev,Gv); 813 0x4: shld_Ev_Gv_Ib(); 814 0x5: shld_Ev_Gv_rCl(); 815 0x6: xbts_and_cmpxchg(); 816 0x7: ibts_and_cmpxchg(); 817 } 818 0x15: decode OPCODE_OP_BOTTOM3 { 819 0x0: push_gs(); 820 0x1: pop_gs(); 821 0x2: rsm_smm(); 822 0x3: Inst::BTS(Ev,Gv); 823 0x4: shrd_Ev_Gv_Ib(); 824 0x5: shrd_Ev_Gv_rCl(); 825 //0x6: group16(); 826 0x6: decode MODRM_MOD { 827 0x3: decode MODRM_REG { 828 0x5: lfence(); 829 0x6: mfence(); 830 0x7: sfence(); 831 default: Inst::UD2(); 832 } 833 default: decode MODRM_REG { 834 0x0: fxsave(); 835 0x1: fxrstor(); 836 0x7: clflush(); 837 default: Inst::UD2(); 838 } 839 } 840 0x7: Inst::IMUL(Gv,Ev); 841 } 842 0x16: decode OPCODE_OP_BOTTOM3 { 843 0x0: Inst::CMPXCHG(Eb,Gb); 844 0x1: Inst::CMPXCHG(Ev,Gv); 845 0x2: lss_Gz_Mp(); 846 0x3: Inst::BTR(Ev,Gv); 847 0x4: lfs_Gz_Mp(); 848 0x5: lgs_Gz_Mp(); 849 //The size of the second operand in these instructions should 850 //really be "b" or "w", but it's set to v in order to have a 851 //consistent register size. This shouldn't affect behavior. 852 0x6: Inst::MOVZX_B(Gv,Ev); 853 0x7: Inst::MOVZX_W(Gv,Ev); 854 } 855 0x17: decode OPCODE_OP_BOTTOM3 { 856 0x0: jmpe_Jz(); // IA-64? 857 format Inst { 858 //0x1: group11_UD2(); 859 0x1: UD2(); 860 //0x2: group8_Ev_Ib(); 861 0x2: decode MODRM_REG { 862 0x4: BT(Ev,Ib); 863 0x5: BTS(Ev,Ib); 864 0x6: BTR(Ev,Ib); 865 0x7: BTC(Ev,Ib); 866 default: UD2(); 867 } 868 0x3: BTC(Ev,Gv); 869 } 870 0x4: Inst::BSF(Gv,Ev); 871 0x5: Inst::BSR(Gv,Ev); 872 //The size of the second operand in these instructions should 873 //really be "b" or "w", but it's set to v in order to have a 874 //consistent register size. This shouldn't affect behavior. 875 0x6: Inst::MOVSX_B(Gv,Ev); 876 0x7: Inst::MOVSX_W(Gv,Ev); 877 } 878 0x18: decode OPCODE_OP_BOTTOM3 { 879 0x0: Inst::XADD(Eb,Gb); 880 0x1: Inst::XADD(Ev,Gv); 881 //0x7: group9(); 882 0x7: decode MODRM_REG { 883 0x1: cmpxchg_Mq(); 884 0x6: decode LEGACY_OP { 885 0x1: vmclear_Mq(); 886 default: decode LEGACY_REP { 887 0x1: vmxon_Mq(); 888 0x0: vmptrld_Mq(); 889 } 890 } 891 0x7: vmptrst_Mq(); 892 default: Inst::UD2(); 893 } 894 default: decode LEGACY_DECODEVAL { 895 // no prefix 896 0x0: decode OPCODE_OP_BOTTOM3 { 897 0x2: cmpccps_Vo_Wo_Ib(); 898 0x3: cvtdq2ps_Vo_Wo(); 899 0x4: subps_Vo_Wo(); 900 0x5: minps_Vo_Wo(); 901 0x6: divps_Vo_Wo(); 902 } 903 // repe (0xF3) 904 0x4: decode OPCODE_OP_BOTTOM3 { 905 0x2: cmpccss_Vd_Wd_Ib(); 906 default: Inst::UD2(); 907 } 908 // operand size (0x66) 909 0x1: decode OPCODE_OP_BOTTOM3 { 910 0x2: cmpccpd_Vo_Wo_Ib(); 911 0x4: subpd_Vo_Wo(); 912 0x5: minpd_Vo_Wo(); 913 0x6: divpd_Vo_Wo(); 914 default: Inst::UD2(); 915 } 916 // repne (0xF2) 917 0x8: decode OPCODE_OP_BOTTOM3 { 918 0x2: cmpccsd_Vq_Wq_Ib(); 919 default: Inst::UD2(); 920 } 921 default: Inst::UD2(); 922 } 923 } 924 0x19: decode OPSIZE { 925 4: Inst::BSWAP_D(Bd); 926 8: Inst::BSWAP_Q(Bq); 927 default: Inst::UD2(); 928 } 929 0x1A: decode LEGACY_DECODEVAL { 930 // no prefix 931 0x0: decode OPCODE_OP_BOTTOM3 { 932 0x1: psrlw_Pq_Qq(); 933 0x2: psrld_Pq_Qq(); 934 0x3: psrlq_Pq_Qq(); 935 0x4: paddq_Pq_Qq(); 936 0x5: pmullw_Pq_Qq(); 937 0x7: pmovmskb_Gd_PRq(); 938 default: Inst::UD2(); 939 } 940 // repe (0xF3) 941 0x4: decode OPCODE_OP_BOTTOM3 { 942 0x6: movq2dq_Vo_PRq(); 943 default: Inst::UD2(); 944 } 945 // operand size (0x66) 946 0x1: decode OPCODE_OP_BOTTOM3 { 947 0x0: addsubpd_Vo_Wo(); 948 0x1: psrlw_Vo_Wo(); 949 0x2: psrld_Vo_Wo(); 950 0x3: psrlq_Vo_Wo(); 951 0x4: paddq_Vo_Wo(); 952 0x5: pmullw_Vo_Wo(); 953 0x6: decode MODRM_MOD { 954 0x3: movq_Vq_Vq(); 955 default: movq_Mq_Vq(); 956 } 957 0x7: pmovmskb_Gd_VRo(); 958 } 959 // repne (0xF2) 960 0x8: decode OPCODE_OP_BOTTOM3 { 961 0x0: addsubps_Vo_Wo(); 962 0x6: movdq2q_Pq_VRq(); 963 default: Inst::UD2(); 964 } 965 default: Inst::UD2(); 966 } 967 0x1B: decode LEGACY_DECODEVAL { 968 // no prefix 969 0x0: decode OPCODE_OP_BOTTOM3 { 970 0x0: psubusb_Pq_Qq(); 971 0x1: psubusw_Pq_Qq(); 972 0x2: pminub_Pq_Qq(); 973 0x3: pand_Pq_Qq(); 974 0x4: paddusb_Pq_Qq(); 975 0x5: paddusw_Pq_Qq(); 976 0x6: pmaxub_Pq_Qq(); 977 0x7: pandn_Pq_Qq(); 978 } 979 // operand size (0x66) 980 0x1: decode OPCODE_OP_BOTTOM3 { 981 0x0: psubusb_Vo_Wo(); 982 0x1: psubusw_Vo_Wo(); 983 0x2: pminub_Vo_Wo(); 984 0x3: pand_Vo_Wo(); 985 0x4: paddusb_Vo_Wo(); 986 0x5: paddusw_Vo_Wo(); 987 0x6: pmaxub_Vo_Wo(); 988 0x7: pandn_Vo_Wo(); 989 } 990 default: Inst::UD2(); 991 } 992 0x1C: decode LEGACY_DECODEVAL { 993 // no prefix 994 0x0: decode OPCODE_OP_BOTTOM3 { 995 0x0: pavgb_Pq_Qq(); 996 0x1: psraw_Pq_Qq(); 997 0x2: psrad_Pq_Qq(); 998 0x3: pavgw_Pq_Qq(); 999 0x4: pmulhuw_Pq_Qq(); 1000 0x5: pmulhw_Pq_Qq(); 1001 0x7: movntq_Mq_Pq(); 1002 default: Inst::UD2(); 1003 } 1004 // repe (0xF3) 1005 0x4: decode OPCODE_OP_BOTTOM3 { 1006 0x6: cvtdq2pd_Vo_Wq(); 1007 default: Inst::UD2(); 1008 } 1009 // operand size (0x66) 1010 0x1: decode OPCODE_OP_BOTTOM3 { 1011 0x0: pavgb_Vo_Wo(); 1012 0x1: psraw_Vo_Wo(); 1013 0x2: psrad_Vo_Wo(); 1014 0x3: pavgw_Vo_Wo(); 1015 0x4: pmulhuw_Vo_Wo(); 1016 0x5: pmulhw_Vo_Wo(); 1017 0x6: cvttpd2dq_Vo_Wo(); 1018 0x7: movntdq_Mo_Vo(); 1019 } 1020 // repne (0xF2) 1021 0x8: decode OPCODE_OP_BOTTOM3 { 1022 0x6: cvtpd2dq_Vo_Wo(); 1023 default: Inst::UD2(); 1024 } 1025 default: Inst::UD2(); 1026 } 1027 0x1D: decode LEGACY_DECODEVAL { 1028 // no prefix 1029 0x0: decode OPCODE_OP_BOTTOM3 { 1030 0x0: psubsb_Pq_Qq(); 1031 0x1: psubsw_Pq_Qq(); 1032 0x2: pminsw_Pq_Qq(); 1033 0x3: por_Pq_Qq(); 1034 0x4: paddsb_Pq_Qq(); 1035 0x5: paddsw_Pq_Qq(); 1036 0x6: pmaxsw_Pq_Qq(); 1037 0x7: pxor_Pq_Qq(); 1038 } 1039 // operand size (0x66) 1040 0x1: decode OPCODE_OP_BOTTOM3 { 1041 0x0: psubsb_Vo_Wo(); 1042 0x1: psubsw_Vo_Wo(); 1043 0x2: pminsw_Vo_Wo(); 1044 0x3: por_Vo_Wo(); 1045 0x4: paddsb_Vo_Wo(); 1046 0x5: paddsw_Vo_Wo(); 1047 0x6: pmaxsw_Vo_Wo(); 1048 0x7: pxor_Vo_Wo(); 1049 } 1050 default: Inst::UD2(); 1051 } 1052 0x1E: decode OPCODE_OP_BOTTOM3 { 1053 // no prefix 1054 0x0: decode OPCODE_OP_BOTTOM3 { 1055 0x1: psllw_Pq_Qq(); 1056 0x2: pslld_Pq_Qq(); 1057 0x3: psllq_Pq_Qq(); 1058 0x4: pmuludq_Pq_Qq(); 1059 0x5: pmaddwd_Pq_Qq(); 1060 0x6: psadbw_Pq_Qq(); 1061 0x7: maskmovq_Pq_PRq(); 1062 default: Inst::UD2(); 1063 } 1064 // operand size (0x66) 1065 0x1: decode OPCODE_OP_BOTTOM3 { 1066 0x1: psllw_Vo_Wo(); 1067 0x2: pslld_Vo_Wo(); 1068 0x3: psllq_Vo_Wo(); 1069 0x4: pmuludq_Vo_Wo(); 1070 0x5: pmaddwd_Vo_Wo(); 1071 0x6: psadbw_Vo_Wo(); 1072 0x7: maskmovdqu_Vo_VRo(); 1073 default: Inst::UD2(); 1074 } 1075 // repne (0xF2) 1076 0x8: decode OPCODE_OP_BOTTOM3 { 1077 0x0: lddqu_Vo_Mo(); 1078 default: Inst::UD2(); 1079 } 1080 default: Inst::UD2(); 1081 } 1082 0x1F: decode LEGACY_DECODEVAL { 1083 // no prefix 1084 0x0: decode OPCODE_OP_BOTTOM3 { 1085 0x0: psubb_Pq_Qq(); 1086 0x1: psubw_Pq_Qq(); 1087 0x2: psubd_Pq_Qq(); 1088 0x3: psubq_Pq_Qq(); 1089 0x4: paddb_Pq_Qq(); 1090 0x5: paddw_Pq_Qq(); 1091 0x6: paddd_Pq_Qq(); 1092 0x7: Inst::UD2(); 1093 } 1094 // operand size (0x66) 1095 0x1: decode OPCODE_OP_BOTTOM3 { 1096 0x0: psubb_Vo_Wo(); 1097 0x1: psubw_Vo_Wo(); 1098 0x2: psubd_Vo_Wo(); 1099 0x3: psubq_Vo_Wo(); 1100 0x4: paddb_Vo_Wo(); 1101 0x5: paddw_Vo_Wo(); 1102 0x6: paddd_Vo_Wo(); 1103 0x7: Inst::UD2(); 1104 } 1105 default: Inst::UD2(); 1106 } 1107 default: FailUnimpl::twoByteOps(); 1108 } 1109 } 1110 default: M5InternalError::error( 1111 {{"Unexpected first opcode byte in two byte opcode!"}}); 1112}
|