two_byte_opcodes.isa revision 5059
16502Snate@binkert.org// Copyright (c) 2007 The Hewlett-Packard Development Company
26502Snate@binkert.org// All rights reserved.
36502Snate@binkert.org//
46502Snate@binkert.org// Redistribution and use of this software in source and binary forms,
56502Snate@binkert.org// with or without modification, are permitted provided that the
66502Snate@binkert.org// following conditions are met:
76502Snate@binkert.org//
86502Snate@binkert.org// The software must be used only for Non-Commercial Use which means any
96502Snate@binkert.org// use which is NOT directed to receiving any direct monetary
106502Snate@binkert.org// compensation for, or commercial advantage from such use.  Illustrative
116502Snate@binkert.org// examples of non-commercial use are academic research, personal study,
126502Snate@binkert.org// teaching, education and corporate research & development.
136502Snate@binkert.org// Illustrative examples of commercial use are distributing products for
146502Snate@binkert.org// commercial advantage and providing services using the software for
156502Snate@binkert.org// commercial advantage.
166502Snate@binkert.org//
176502Snate@binkert.org// If you wish to use this software or functionality therein that may be
186502Snate@binkert.org// covered by patents for commercial use, please contact:
196502Snate@binkert.org//     Director of Intellectual Property Licensing
206502Snate@binkert.org//     Office of Strategy and Technology
216502Snate@binkert.org//     Hewlett-Packard Company
226502Snate@binkert.org//     1501 Page Mill Road
236502Snate@binkert.org//     Palo Alto, California  94304
246502Snate@binkert.org//
256502Snate@binkert.org// Redistributions of source code must retain the above copyright notice,
266502Snate@binkert.org// this list of conditions and the following disclaimer.  Redistributions
2712563Sgabeblack@google.com// in binary form must reproduce the above copyright notice, this list of
2812563Sgabeblack@google.com// conditions and the following disclaimer in the documentation and/or
296651Snate@binkert.org// other materials provided with the distribution.  Neither the name of
306502Snate@binkert.org// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
316502Snate@binkert.org// contributors may be used to endorse or promote products derived from
326502Snate@binkert.org// this software without specific prior written permission.  No right of
336502Snate@binkert.org// sublicense is granted herewith.  Derivatives of the software and
346502Snate@binkert.org// output created using the software may be prepared, but only for
356502Snate@binkert.org// Non-Commercial Uses.  Derivatives of the software may be shared with
366502Snate@binkert.org// others provided: (i) the others agree to abide by the list of
376502Snate@binkert.org// conditions herein which includes the Non-Commercial Use restrictions;
386502Snate@binkert.org// and (ii) such Derivatives of the software include the above copyright
396502Snate@binkert.org// notice to acknowledge the contribution from this software where
406502Snate@binkert.org// applicable, this list of conditions and the disclaimer below.
416502Snate@binkert.org//
426502Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
436502Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
446502Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
456502Snate@binkert.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
466502Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
476502Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
486502Snate@binkert.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
496502Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
506502Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
516502Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
526502Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
536502Snate@binkert.org//
546502Snate@binkert.org// Authors: Gabe Black
556502Snate@binkert.org
566502Snate@binkert.org////////////////////////////////////////////////////////////////////
576502Snate@binkert.org//
586502Snate@binkert.org// Decode the two byte opcodes
596502Snate@binkert.org//
606999Snate@binkert.org0x2: decode OPCODE_PREFIXA {
616999Snate@binkert.org    0x0F: decode OPCODE_OP_TOP5 {
626999Snate@binkert.org        format WarnUnimpl {
636502Snate@binkert.org            0x00: decode OPCODE_OP_BOTTOM3 {
646502Snate@binkert.org                0x00: group6();
656502Snate@binkert.org                0x01: group7();
666999Snate@binkert.org                0x02: lar_Gv_Ew();
676999Snate@binkert.org                0x03: lsl_Gv_Ew();
686502Snate@binkert.org                //sandpile.org doesn't seem to know what this is... ?
696651Snate@binkert.org                0x04: loadall_or_reset_or_hang();
706651Snate@binkert.org#if FULL_SYSTEM
716502Snate@binkert.org                0x05: syscall();
726502Snate@binkert.org#else
736502Snate@binkert.org                0x05: SyscallInst::syscall('xc->syscall(rax)', IsSyscall);
746502Snate@binkert.org#endif
756502Snate@binkert.org                0x06: clts();
766502Snate@binkert.org                //sandpile.org says (AMD) after sysret, so I might want to check
7713663Sandreas.sandberg@arm.com                //if that means amd64 or AMD machines
786502Snate@binkert.org                0x07: loadall_or_sysret();
796502Snate@binkert.org            }
806502Snate@binkert.org            0x01: decode OPCODE_OP_BOTTOM3 {
816502Snate@binkert.org                0x0: invd();
826502Snate@binkert.org                0x1: wbinvd();
836502Snate@binkert.org                0x2: Inst::UD2();
846502Snate@binkert.org                0x3: Inst::UD2();
856502Snate@binkert.org                0x4: Inst::UD2();
866502Snate@binkert.org                0x5: threednow();
876502Snate@binkert.org                0x6: threednow();
886502Snate@binkert.org                0x7: threednow();
896502Snate@binkert.org            }
906502Snate@binkert.org            0x02: decode LEGACY_DECODEVAL {
916502Snate@binkert.org                // no prefix
926502Snate@binkert.org                0x0: decode OPCODE_OP_BOTTOM3 {
936502Snate@binkert.org                    0x0: movups_Vo_Wo();
946502Snate@binkert.org                    0x1: movups_Wo_Vo();
956502Snate@binkert.org                    0x2: decode MODRM_MOD {
966502Snate@binkert.org                        0x3: movhlps_Vq_VRq();
976502Snate@binkert.org                        default: movlps_Vq_Mq();
986502Snate@binkert.org                    }
996502Snate@binkert.org                    0x3: movlps_Mq_Vq();
1006502Snate@binkert.org                    0x4: unpcklps();
1016502Snate@binkert.org                    0x5: unpckhps();
1026502Snate@binkert.org                    0x6: decode MODRM_MOD {
1036502Snate@binkert.org                        0x3: movlhps_Vq_VRq();
1046502Snate@binkert.org                        default: movhps_Vq_Mq();
1056502Snate@binkert.org                    }
1066502Snate@binkert.org                    0x7: movhps_Mq_Vq();
1076502Snate@binkert.org                }
1086502Snate@binkert.org                // repe (0xF3)
1096502Snate@binkert.org                0x4: decode OPCODE_OP_BOTTOM3 {
1106502Snate@binkert.org                    0x0: movss_Vd_Wd();
1116502Snate@binkert.org                    0x1: movss_Wd_Vd();
1126502Snate@binkert.org                    0x2: movsldup_Vo_Wo();
1136502Snate@binkert.org                    0x6: movshdup_Vo_Wo();
1146502Snate@binkert.org                    default: Inst::UD2();
1156502Snate@binkert.org                }
1166502Snate@binkert.org                // operand size (0x66)
1176502Snate@binkert.org                0x1: decode OPCODE_OP_BOTTOM3 {
1186502Snate@binkert.org                    0x0: movupd_Vo_Wo();
1196502Snate@binkert.org                    0x1: movupd_Wo_Vo();
1206502Snate@binkert.org                    0x2: Inst::MOVLPD(Vq,Mq);
1216502Snate@binkert.org                    0x3: Inst::MOVLPD(Mq,Vq);
1226502Snate@binkert.org                    0x4: unpcklpd_Vo_Wq();
1236502Snate@binkert.org                    0x5: unpckhpd_Vo_Wo();
1246502Snate@binkert.org                    0x6: movhpd_Vq_Mq();
1256502Snate@binkert.org                    0x7: movhpd_Mq_Vq();
1266502Snate@binkert.org                }
1276502Snate@binkert.org                // repne (0xF2)
1286999Snate@binkert.org                0x8: decode OPCODE_OP_BOTTOM3 {
1296502Snate@binkert.org                    0x0: Inst::MOVSD(Vq,Wq);
1306502Snate@binkert.org                    0x1: Inst::MOVSD(Wq,Vq);
1316502Snate@binkert.org                    0x2: movddup_Vo_Wq();
1326502Snate@binkert.org                    default: Inst::UD2();
1336502Snate@binkert.org                }
1346502Snate@binkert.org                default: Inst::UD2();
1356502Snate@binkert.org            }
1367672Snate@binkert.org            0x03: decode OPCODE_OP_BOTTOM3 {
1377672Snate@binkert.org                0x0: group17();
1386502Snate@binkert.org                0x1: group17();
1397672Snate@binkert.org                0x2: group17();
1407672Snate@binkert.org                0x3: group17();
1417672Snate@binkert.org                0x4: group17();
1426502Snate@binkert.org                0x5: group17();
1436502Snate@binkert.org                0x6: group17();
1446502Snate@binkert.org                0x7: group17();
1456502Snate@binkert.org            }
1466502Snate@binkert.org            0x04: decode LEGACY_DECODEVAL {
1476502Snate@binkert.org                // no prefix
1486502Snate@binkert.org                0x0: decode OPCODE_OP_BOTTOM3 {
1496502Snate@binkert.org                    0x0: mov_Rd_Cd();
1506502Snate@binkert.org                    0x1: mov_Rd_Dd();
1516502Snate@binkert.org                    0x2: mov_Cd_Rd();
1526502Snate@binkert.org                    0x3: mov_Dd_Rd();
1536502Snate@binkert.org                    0x4: mov_Rd_Td();
1546502Snate@binkert.org                    0x6: mov_Td_Rd();
1556502Snate@binkert.org                    default: Inst::UD2();
1566502Snate@binkert.org                }
15713670Sandreas.sandberg@arm.com                // lock prefix (0xF0)
1586502Snate@binkert.org                0x2: decode OPCODE_OP_BOTTOM3 {
1596502Snate@binkert.org                    0x0: mov_Rd_CR8D();
1606502Snate@binkert.org                    0x2: mov_CR8D_Rd();
1616502Snate@binkert.org                }
1626502Snate@binkert.org                default: Inst::UD2();
1636502Snate@binkert.org            }
1646502Snate@binkert.org            0x05: decode LEGACY_DECODEVAL {
1656502Snate@binkert.org                // no prefix
1666502Snate@binkert.org                0x0: decode OPCODE_OP_BOTTOM3 {
1676502Snate@binkert.org                    //These moves should really use size o (octword), but
1686502Snate@binkert.org                    //because they are split in two, they use q (quadword).
1696502Snate@binkert.org                    0x0: Inst::MOVAPS(Vq,Wq);
1706502Snate@binkert.org                    0x1: Inst::MOVAPS(Wq,Vq);
1716502Snate@binkert.org                    0x2: decode MODRM_MOD {
1726502Snate@binkert.org                        0x3: cvtpi2pS_Vq_Pq();
1736502Snate@binkert.org                        default: cvtpi2ps_Vq_Mq();
1746502Snate@binkert.org                    }
1756502Snate@binkert.org                    0x3: movntps_Mo_Vo();
1766502Snate@binkert.org                    0x4: cvttps2pi_Pq_Wq();
1776502Snate@binkert.org                    0x5: cvtpS2pi_Pq_Wq();
1786502Snate@binkert.org                    0x6: ucomiss_Vd_Wd();
1796502Snate@binkert.org                    0x7: comiss_Vd_Wd();
1806502Snate@binkert.org                }
1816502Snate@binkert.org                // repe (0xF3)
1826502Snate@binkert.org                0x4: decode OPCODE_OP_BOTTOM3 {
1836502Snate@binkert.org                    0x2: cvtsi2ss_Vd_Ed();
1846502Snate@binkert.org                    0x4: cvttss2si_Gd_Wd();
1856502Snate@binkert.org                    0x5: cvtss2si_Gd_Wd();
1866502Snate@binkert.org                    default: Inst::UD2();
1876502Snate@binkert.org                }
1886502Snate@binkert.org                // operand size (0x66)
1896502Snate@binkert.org                0x1: decode OPCODE_OP_BOTTOM3 {
1906502Snate@binkert.org                    0x0: movapd_Vo_Wo();
1916502Snate@binkert.org                    0x1: movapd_Wo_Vo();
1926502Snate@binkert.org                    0x2: decode MODRM_MOD {
1936502Snate@binkert.org                        0x3: cvtpi2pd_Vo_Pq();
1946502Snate@binkert.org                        default: cvtpi2pd_Vo_Mq();
1956502Snate@binkert.org                    }
1966502Snate@binkert.org                    0x3: movntpd_Mo_Vo();
1976502Snate@binkert.org                    0x4: cvttpd2pi_Pq_Wo();
1986502Snate@binkert.org                    0x5: cvtpd2pi_Pq_Wo();
1996502Snate@binkert.org                    0x6: Inst::UCOMISD(Vq,Wq);
2006502Snate@binkert.org                    0x7: comisd_Vq_Wq();
2016502Snate@binkert.org                }
2026502Snate@binkert.org                // repne (0xF2)
2036502Snate@binkert.org                0x8: decode OPCODE_OP_BOTTOM3 {
2046502Snate@binkert.org                    // The size of the V operand should be q, not dp
2057672Snate@binkert.org                    0x2: Inst::CVTSI2SD(Vdp,Edp);
2067672Snate@binkert.org                    // The size of the W operand should be q, not dp
2077672Snate@binkert.org                    0x4: Inst::CVTTSD2SI(Gdp,Wdp);
2087672Snate@binkert.org                    0x5: cvtsd2si_Gd_Wq();
2096502Snate@binkert.org                    default: Inst::UD2();
2107672Snate@binkert.org                }
2117672Snate@binkert.org                default: Inst::UD2();
2127672Snate@binkert.org            }
2136502Snate@binkert.org            0x06: decode OPCODE_OP_BOTTOM3 {
2146502Snate@binkert.org                0x0: wrmsr();
2156502Snate@binkert.org                0x1: rdtsc();
2166502Snate@binkert.org                0x2: rdmsr();
2176502Snate@binkert.org                0x3: rdpmc();
2186502Snate@binkert.org                0x4: sysenter();
2196502Snate@binkert.org                0x5: sysexit();
2206502Snate@binkert.org                0x6: Inst::UD2();
2216502Snate@binkert.org                0x7: getsec();
2226502Snate@binkert.org            }
2236502Snate@binkert.org            0x07: decode OPCODE_OP_BOTTOM3 {
2246502Snate@binkert.org                0x0: three_byte_opcode();
2256502Snate@binkert.org                0x1: three_byte_opcode();
2266502Snate@binkert.org                0x2: three_byte_opcode();
2276502Snate@binkert.org                0x3: three_byte_opcode();
2286502Snate@binkert.org                0x4: three_byte_opcode();
2296502Snate@binkert.org                0x5: three_byte_opcode();
2306502Snate@binkert.org                0x6: three_byte_opcode();
2316502Snate@binkert.org                0x7: three_byte_opcode();
2326502Snate@binkert.org            }
2336502Snate@binkert.org            format Inst {
2346502Snate@binkert.org                0x08: decode OPCODE_OP_BOTTOM3 {
2356502Snate@binkert.org                    0x0: CMOVO(Gv,Ev);
2366502Snate@binkert.org                    0x1: CMOVNO(Gv,Ev);
2376502Snate@binkert.org                    0x2: CMOVB(Gv,Ev);
2386502Snate@binkert.org                    0x3: CMOVNB(Gv,Ev);
2396502Snate@binkert.org                    0x4: CMOVZ(Gv,Ev);
2406502Snate@binkert.org                    0x5: CMOVNZ(Gv,Ev);
2416502Snate@binkert.org                    0x6: CMOVBE(Gv,Ev);
2426502Snate@binkert.org                    0x7: CMOVNBE(Gv,Ev);
2436502Snate@binkert.org                }
2446502Snate@binkert.org                0x09: decode OPCODE_OP_BOTTOM3 {
2456502Snate@binkert.org                    0x0: CMOVS(Gv,Ev);
2466502Snate@binkert.org                    0x1: CMOVNS(Gv,Ev);
2476502Snate@binkert.org                    0x2: CMOVP(Gv,Ev);
2486502Snate@binkert.org                    0x3: CMOVNP(Gv,Ev);
2496502Snate@binkert.org                    0x4: CMOVL(Gv,Ev);
2506502Snate@binkert.org                    0x5: CMOVNL(Gv,Ev);
2516502Snate@binkert.org                    0x6: CMOVLE(Gv,Ev);
2526502Snate@binkert.org                    0x7: CMOVNLE(Gv,Ev);
2536502Snate@binkert.org                }
2546502Snate@binkert.org            }
2556502Snate@binkert.org            0x0A: decode LEGACY_DECODEVAL {
2566502Snate@binkert.org                // no prefix
2576502Snate@binkert.org                0x0: decode OPCODE_OP_BOTTOM3 {
2586502Snate@binkert.org                    0x0: movmskps_Gd_VRo();
2596502Snate@binkert.org                    0x1: sqrtps_Vo_Wo();
2606502Snate@binkert.org                    0x2: rqsrtps_Vo_Wo();
2616502Snate@binkert.org                    0x3: rcpps_Vo_Wo();
2626502Snate@binkert.org                    0x4: andps_Vo_Wo();
2636502Snate@binkert.org                    0x5: andnps_Vo_Wo();
2646502Snate@binkert.org                    0x6: orps_Vo_Wo();
2656502Snate@binkert.org                    0x7: xorps_Vo_Wo();
2666502Snate@binkert.org                }
2676502Snate@binkert.org                // repe (0xF3)
2686502Snate@binkert.org                0x4: decode OPCODE_OP_BOTTOM3 {
2696502Snate@binkert.org                    0x1: sqrtss_Vd_Wd();
2706502Snate@binkert.org                    0x2: rsqrtss_Vd_Wd();
2716502Snate@binkert.org                    0x3: rcpss_Vd_Wd();
2726502Snate@binkert.org                    default: Inst::UD2();
2736502Snate@binkert.org                }
2746502Snate@binkert.org                // operand size (0x66)
2756502Snate@binkert.org                0x1: decode OPCODE_OP_BOTTOM3 {
2766502Snate@binkert.org                    0x0: movmskpd_Gd_VRo();
2776502Snate@binkert.org                    0x1: sqrtpd_Vo_Wo();
2786502Snate@binkert.org                    0x4: andpd_Vo_Wo();
2796502Snate@binkert.org                    0x5: andnpd_Vo_Wo();
2806502Snate@binkert.org                    0x6: orpd_Vo_Wo();
2816502Snate@binkert.org                    //This really should be type o, but it works on q sized
2826502Snate@binkert.org                    //chunks at a time.
2836502Snate@binkert.org                    0x7: Inst::XORPD(Vq,Wq);
2846502Snate@binkert.org                    default: Inst::UD2();
2856502Snate@binkert.org                }
2866502Snate@binkert.org                format Inst {
2876502Snate@binkert.org                    // repne (0xF2)
2886502Snate@binkert.org                    0x8: decode OPCODE_OP_BOTTOM3 {
2896502Snate@binkert.org                        0x1: SQRTSD(Vq,Wq);
2906502Snate@binkert.org                        default: UD2();
2916502Snate@binkert.org                    }
2926502Snate@binkert.org                    default: UD2();
2936502Snate@binkert.org                }
2946502Snate@binkert.org            }
2956502Snate@binkert.org            0x0B: decode LEGACY_DECODEVAL {
2966502Snate@binkert.org                // no prefix
2976502Snate@binkert.org                0x0: decode OPCODE_OP_BOTTOM3 {
2986502Snate@binkert.org                    0x0: addps_Vo_Wo();
29913709Sandreas.sandberg@arm.com                    0x1: mulps_Vo_Wo();
3006502Snate@binkert.org                    0x2: cvtps2pd_Vo_Wq();
3016502Snate@binkert.org                    0x3: cvtdq2ps_Vo_Wo();
3026502Snate@binkert.org                    0x4: subps_Vo_Wo();
30313709Sandreas.sandberg@arm.com                    0x5: minps_Vo_Wo();
3046502Snate@binkert.org                    0x6: divps_Vo_Wo();
3056502Snate@binkert.org                    0x7: maxps_Vo_Wo();
3066502Snate@binkert.org                }
3076502Snate@binkert.org                // repe (0xF3)
3086502Snate@binkert.org                0x4: decode OPCODE_OP_BOTTOM3 {
3096502Snate@binkert.org                    0x0: addss_Vd_Wd();
3106502Snate@binkert.org                    0x1: mulss_Vd_Wd();
3116502Snate@binkert.org                    0x2: cvtss2sd_Vq_Wd();
3126502Snate@binkert.org                    0x3: cvttps2dq_Vo_Wo();
3136502Snate@binkert.org                    0x4: subss_Vd_Wd();
3146502Snate@binkert.org                    0x5: minss_Vd_Wd();
3156502Snate@binkert.org                    0x6: divss_Vd_Wd();
3166502Snate@binkert.org                    0x7: maxss_Vd_Wd();
31712563Sgabeblack@google.com                }
318                // operand size (0x66)
319                0x1: decode OPCODE_OP_BOTTOM3 {
320                    0x0: addpd_Vo_Wo();
321                    0x1: mulpd_Vo_Wo();
322                    0x2: cvtpd2ps_Vo_Wo();
323                    0x3: cvtps2dq_Vo_Wo();
324                    0x4: subpd_Vo_Wo();
325                    0x5: minpd_Vo_Wo();
326                    0x6: divpd_Vo_Wo();
327                    0x7: maxpd_Vo_Wo();
328                }
329                // repne (0xF2)
330                0x8: decode OPCODE_OP_BOTTOM3 {
331                    0x0: Inst::ADDSD(Vq,Wq);
332                    0x1: Inst::MULSD(Vq,Wq);
333                    0x2: cvtsd2ss_Vd_Wq();
334                    0x4: Inst::SUBSD(Vq,Wq);
335                    0x5: minsd_Vq_Wq();
336                    0x6: Inst::DIVSD(Vq,Wq);
337                    0x7: maxsd_Vq_Wq();
338                    default: Inst::UD2();
339                }
340                default: Inst::UD2();
341            }
342            0x0C: decode LEGACY_DECODEVAL {
343                // no prefix
344                0x0: decode OPCODE_OP_BOTTOM3 {
345                    0x0: punpcklbw_Pq_Qd();
346                    0x1: punpcklwd_Pq_Qd();
347                    0x2: punpckldq_Pq_Qd();
348                    0x3: packsswb_Pq_Qq();
349                    0x4: pcmpgtb_Pq_Qq();
350                    0x5: pcmpgtw_Pq_Qq();
351                    0x6: pcmpgtd_Pq_Qq();
352                    0x7: packuswb_Pq_Qq();
353                }
354                // operand size (0x66)
355                0x1: decode OPCODE_OP_BOTTOM3 {
356                    0x0: punpcklbw_Vo_Wq();
357                    0x1: punpcklwd_Vo_Wq();
358                    0x2: punpckldq_Vo_Wq();
359                    0x3: packsswb_Vo_Wo();
360                    0x4: pcmpgtb_Vo_Wo();
361                    0x5: pcmpgtw_Vo_Wo();
362                    0x6: pcmpgtd_Vo_Wo();
363                    0x7: packuswb_Vo_Wo();
364                }
365                default: Inst::UD2();
366            }
367            0x0D: decode LEGACY_DECODEVAL {
368                // no prefix
369                0x0: decode OPCODE_OP_BOTTOM3 {
370                    0x0: punpckhbw_Pq_Qq();
371                    0x1: punpckhwd_Pq_Qq();
372                    0x2: punpckhdq_Pq_Qq();
373                    0x3: packssdw_Pq_Qq();
374                    0x6: movd_Pq_Ed();
375                    0x7: movq_Pq_Qq();
376                    default: Inst::UD2();
377                }
378                // repe (0xF3)
379                0x4: decode OPCODE_OP_BOTTOM3 {
380                    0x7: movdqu_Vo_Wo();
381                    default: Inst::UD2();
382                }
383                // operand size (0x66)
384                0x1: decode OPCODE_OP_BOTTOM3 {
385                    0x0: punpckhbw_Vo_Wo();
386                    0x1: punpckhwd_Vo_Wo();
387                    0x2: punpckhdq_Vo_Wo();
388                    0x3: packssdw_Vo_Wo();
389                    0x4: punpcklqdq_Vo_Wq();
390                    0x5: punpcklqdq_Vo_Wq();
391                    0x6: movd_Vo_Ed();
392                    0x7: movdqa_Vo_Wo();
393                }
394                default: Inst::UD2();
395            }
396            0x0E: decode LEGACY_DECODEVAL {
397                // no prefix
398                0x0: decode OPCODE_OP_BOTTOM3 {
399                    0x0: pshufw_Pq_Qq_Ib();
400                    0x1: group13_pshimw();
401                    0x2: group14_pshimd();
402                    0x3: group15_pshimq();
403                    0x4: pcmpeqb_Pq_Qq();
404                    0x5: pcmpeqw_Pq_Qq();
405                    0x6: pcmpeqd_Pq_Qq();
406                    0x7: emms();
407                }
408                // repe (0xF3)
409                0x4: decode OPCODE_OP_BOTTOM3 {
410                    0x0: pshufhw_Vo_Wo_Ib();
411                    default: Inst::UD2();
412                }
413                // operand size (0x66)
414                0x1: decode OPCODE_OP_BOTTOM3 {
415                    0x0: pshufd_Vo_Wo_Ib();
416                    0x1: group13_pshimw();
417                    0x2: group14_pshimd();
418                    0x3: group15_pshimq_dq();
419                    0x4: pcmpeqb_Vo_Wo();
420                    0x5: pcmpeqw_Vo_Wo();
421                    0x6: pcmpeqd_Vo_Wo();
422                    default: Inst::UD2();
423                }
424                // repne (0xF2)
425                0x8: decode OPCODE_OP_BOTTOM3 {
426                    0x0: pshuflw_Vo_Wo_Ib();
427                    default: Inst::UD2();
428                }
429                default: Inst::UD2();
430            }
431            0x0F: decode LEGACY_DECODEVAL {
432                // no prefix
433                0x0: decode OPCODE_OP_BOTTOM3 {
434                    0x0: vmread_Ed_or_Eq_Gd_or_Gq();
435                    0x1: vmwrite_Gd_or_Gq_Ed_or_Eq();
436                    0x6: mov_Ed_Pd();
437                    0x7: mov_Qq_Pq();
438                    default: Inst::UD2();
439                }
440                // repe (0xF3)
441                0x4: decode OPCODE_OP_BOTTOM3 {
442                    0x6: movq_Vo_Mq_or_Vq_Vq();
443                    0x7: movdqu_Wo_Vo();
444                    default: Inst::UD2();
445                }
446                // operand size (0x66)
447                0x1: decode OPCODE_OP_BOTTOM3 {
448                    0x4: haddpd_Vo_Wo();
449                    0x5: hsubpd_Vo_Wo();
450                    0x6: movd_Ed_Vd();
451                    0x7: movdqa_Wo_Vo();
452                    default: Inst::UD2();
453                }
454                // repne (0xF2)
455                0x8: decode OPCODE_OP_BOTTOM3 {
456                    0x4: haddps_Vo_Wo();
457                    0x5: hsubps_Vo_Wo();
458                    default: Inst::UD2();
459                }
460                default: Inst::UD2();
461            }
462            format Inst {
463                0x10: decode OPCODE_OP_BOTTOM3 {
464                    0x0: JO(Jz);
465                    0x1: JNO(Jz);
466                    0x2: JB(Jz);
467                    0x3: JNB(Jz);
468                    0x4: JZ(Jz);
469                    0x5: JNZ(Jz);
470                    0x6: JBE(Jz);
471                    0x7: JNBE(Jz);
472                }
473                0x11: decode OPCODE_OP_BOTTOM3 {
474                    0x0: JS(Jz);
475                    0x1: JNS(Jz);
476                    0x2: JP(Jz);
477                    0x3: JNP(Jz);
478                    0x4: JL(Jz);
479                    0x5: JNL(Jz);
480                    0x6: JLE(Jz);
481                    0x7: JNLE(Jz);
482                }
483                0x12: decode OPCODE_OP_BOTTOM3 {
484                    0x0: SETO(Eb);
485                    0x1: SETNO(Eb);
486                    0x2: SETB(Eb);
487                    0x3: SETNB(Eb);
488                    0x4: SETZ(Eb);
489                    0x5: SETNZ(Eb);
490                    0x6: SETBE(Eb);
491                    0x7: SETNBE(Eb);
492                }
493                0x13: decode OPCODE_OP_BOTTOM3 {
494                    0x0: SETS(Eb);
495                    0x1: SETNS(Eb);
496                    0x2: SETP(Eb);
497                    0x3: SETNP(Eb);
498                    0x4: SETL(Eb);
499                    0x5: SETNL(Eb);
500                    0x6: SETLE(Eb);
501                    0x7: SETNLE(Eb);
502                }
503            }
504            0x14: decode OPCODE_OP_BOTTOM3 {
505                0x0: push_fs();
506                0x1: pop_fs();
507                0x2: Inst::CPUID(rAd);
508                0x3: bt_Ev_Gv();
509                0x4: shld_Ev_Gv_Ib();
510                0x5: shld_Ev_Gv_rCl();
511                0x6: xbts_and_cmpxchg();
512                0x7: ibts_and_cmpxchg();
513            }
514            0x15: decode OPCODE_OP_BOTTOM3 {
515                0x0: push_gs();
516                0x1: pop_gs();
517                0x2: rsm_smm();
518                0x3: bts_Ev_Gv();
519                0x4: shrd_Ev_Gv_Ib();
520                0x5: shrd_Ev_Gv_rCl();
521                0x6: group16();
522                0x7: Inst::IMUL(Gv,Ev);
523            }
524            0x16: decode OPCODE_OP_BOTTOM3 {
525                0x0: Inst::CMPXCHG(Eb,Gb);
526                0x1: Inst::CMPXCHG(Ev,Gv);
527                0x2: lss_Gz_Mp();
528                0x3: btr_Ev_Gv();
529                0x4: lfs_Gz_Mp();
530                0x5: lgs_Gz_Mp();
531                //The size of the second operand in these instructions should
532                //really be "b" or "w", but it's set to v in order to have a
533                //consistent register size. This shouldn't affect behavior.
534                0x6: Inst::MOVZX_B(Gv,Ev);
535                0x7: Inst::MOVZX_W(Gv,Ev);
536            }
537            0x17: decode OPCODE_OP_BOTTOM3 {
538                0x0: jmpe_Jz(); // IA-64?
539                0x1: group11_UD2();
540                0x2: group8_Ev_Ib();
541                0x3: btc_Ev_Gv();
542                0x4: bsf_Gv_Ev();
543                0x5: bsr_Gv_Ev();
544                //The size of the second operand in these instructions should
545                //really be "b" or "w", but it's set to v in order to have a
546                //consistent register size. This shouldn't affect behavior.
547                0x6: Inst::MOVSX_B(Gv,Ev);
548                0x7: Inst::MOVSX_W(Gv,Ev);
549            }
550            0x18: decode OPCODE_OP_BOTTOM3 {
551                0x0: xadd_Eb_Gb();
552                0x1: xadd_Ev_Gv();
553                0x7: group9();
554                default: decode LEGACY_DECODEVAL {
555                    // no prefix
556                    0x0: decode OPCODE_OP_BOTTOM3 {
557                        0x2: cmpccps_Vo_Wo_Ib();
558                        0x3: cvtdq2ps_Vo_Wo();
559                        0x4: subps_Vo_Wo();
560                        0x5: minps_Vo_Wo();
561                        0x6: divps_Vo_Wo();
562                    }
563                    // repe (0xF3)
564                    0x4: decode OPCODE_OP_BOTTOM3 {
565                        0x2: cmpccss_Vd_Wd_Ib();
566                        default: Inst::UD2();
567                    }
568                    // operand size (0x66)
569                    0x1: decode OPCODE_OP_BOTTOM3 {
570                        0x2: cmpccpd_Vo_Wo_Ib();
571                        0x4: subpd_Vo_Wo();
572                        0x5: minpd_Vo_Wo();
573                        0x6: divpd_Vo_Wo();
574                        default: Inst::UD2();
575                    }
576                    // repne (0xF2)
577                    0x8: decode OPCODE_OP_BOTTOM3 {
578                        0x2: cmpccsd_Vq_Wq_Ib();
579                        default: Inst::UD2();
580                    }
581                    default: Inst::UD2();
582                }
583            }
584            0x19: bswap_B();
585            0x1A: decode LEGACY_DECODEVAL {
586                // no prefix
587                0x0: decode OPCODE_OP_BOTTOM3 {
588                    0x1: psrlw_Pq_Qq();
589                    0x2: psrld_Pq_Qq();
590                    0x3: psrlq_Pq_Qq();
591                    0x4: paddq_Pq_Qq();
592                    0x5: pmullw_Pq_Qq();
593                    0x7: pmovmskb_Gd_PRq();
594                    default: Inst::UD2();
595                }
596                // repe (0xF3)
597                0x4: decode OPCODE_OP_BOTTOM3 {
598                    0x6: movq2dq_Vo_PRq();
599                    default: Inst::UD2();
600                }
601                // operand size (0x66)
602                0x1: decode OPCODE_OP_BOTTOM3 {
603                    0x0: addsubpd_Vo_Wo();
604                    0x1: psrlw_Vo_Wo();
605                    0x2: psrld_Vo_Wo();
606                    0x3: psrlq_Vo_Wo();
607                    0x4: paddq_Vo_Wo();
608                    0x5: pmullw_Vo_Wo();
609                    0x6: decode MODRM_MOD {
610                        0x3: movq_Vq_Vq();
611                        default: movq_Mq_Vq();
612                    }
613                    0x7: pmovmskb_Gd_VRo();
614                }
615                // repne (0xF2)
616                0x8: decode OPCODE_OP_BOTTOM3 {
617                    0x0: addsubps_Vo_Wo();
618                    0x6: movdq2q_Pq_VRq();
619                    default: Inst::UD2();
620                }
621                default: Inst::UD2();
622            }
623            0x1B: decode LEGACY_DECODEVAL {
624                // no prefix
625                0x0: decode OPCODE_OP_BOTTOM3 {
626                    0x0: psubusb_Pq_Qq();
627                    0x1: psubusw_Pq_Qq();
628                    0x2: pminub_Pq_Qq();
629                    0x3: pand_Pq_Qq();
630                    0x4: paddusb_Pq_Qq();
631                    0x5: paddusw_Pq_Qq();
632                    0x6: pmaxub_Pq_Qq();
633                    0x7: pandn_Pq_Qq();
634                }
635                // operand size (0x66)
636                0x1: decode OPCODE_OP_BOTTOM3 {
637                    0x0: psubusb_Vo_Wo();
638                    0x1: psubusw_Vo_Wo();
639                    0x2: pminub_Vo_Wo();
640                    0x3: pand_Vo_Wo();
641                    0x4: paddusb_Vo_Wo();
642                    0x5: paddusw_Vo_Wo();
643                    0x6: pmaxub_Vo_Wo();
644                    0x7: pandn_Vo_Wo();
645                }
646                default: Inst::UD2();
647            }
648            0x1C: decode LEGACY_DECODEVAL {
649                // no prefix
650                0x0: decode OPCODE_OP_BOTTOM3 {
651                    0x0: pavgb_Pq_Qq();
652                    0x1: psraw_Pq_Qq();
653                    0x2: psrad_Pq_Qq();
654                    0x3: pavgw_Pq_Qq();
655                    0x4: pmulhuw_Pq_Qq();
656                    0x5: pmulhw_Pq_Qq();
657                    0x7: movntq_Mq_Pq();
658                    default: Inst::UD2();
659                }
660                // repe (0xF3)
661                0x4: decode OPCODE_OP_BOTTOM3 {
662                    0x6: cvtdq2pd_Vo_Wq();
663                    default: Inst::UD2();
664                }
665                // operand size (0x66)
666                0x1: decode OPCODE_OP_BOTTOM3 {
667                    0x0: pavgb_Vo_Wo();
668                    0x1: psraw_Vo_Wo();
669                    0x2: psrad_Vo_Wo();
670                    0x3: pavgw_Vo_Wo();
671                    0x4: pmulhuw_Vo_Wo();
672                    0x5: pmulhw_Vo_Wo();
673                    0x6: cvttpd2dq_Vo_Wo();
674                    0x7: movntdq_Mo_Vo();
675                }
676                // repne (0xF2)
677                0x8: decode OPCODE_OP_BOTTOM3 {
678                    0x6: cvtpd2dq_Vo_Wo();
679                    default: Inst::UD2();
680                }
681                default: Inst::UD2();
682            }
683            0x1D: decode LEGACY_DECODEVAL {
684                // no prefix
685                0x0: decode OPCODE_OP_BOTTOM3 {
686                    0x0: psubsb_Pq_Qq();
687                    0x1: psubsw_Pq_Qq();
688                    0x2: pminsw_Pq_Qq();
689                    0x3: por_Pq_Qq();
690                    0x4: paddsb_Pq_Qq();
691                    0x5: paddsw_Pq_Qq();
692                    0x6: pmaxsw_Pq_Qq();
693                    0x7: pxor_Pq_Qq();
694                }
695                // operand size (0x66)
696                0x1: decode OPCODE_OP_BOTTOM3 {
697                    0x0: psubsb_Vo_Wo();
698                    0x1: psubsw_Vo_Wo();
699                    0x2: pminsw_Vo_Wo();
700                    0x3: por_Vo_Wo();
701                    0x4: paddsb_Vo_Wo();
702                    0x5: paddsw_Vo_Wo();
703                    0x6: pmaxsw_Vo_Wo();
704                    0x7: pxor_Vo_Wo();
705                }
706                default: Inst::UD2();
707            }
708            0x1E: decode OPCODE_OP_BOTTOM3 {
709                // no prefix
710                0x0: decode OPCODE_OP_BOTTOM3 {
711                    0x1: psllw_Pq_Qq();
712                    0x2: pslld_Pq_Qq();
713                    0x3: psllq_Pq_Qq();
714                    0x4: pmuludq_Pq_Qq();
715                    0x5: pmaddwd_Pq_Qq();
716                    0x6: psadbw_Pq_Qq();
717                    0x7: maskmovq_Pq_PRq();
718                    default: Inst::UD2();
719                }
720                // operand size (0x66)
721                0x1: decode OPCODE_OP_BOTTOM3 {
722                    0x1: psllw_Vo_Wo();
723                    0x2: pslld_Vo_Wo();
724                    0x3: psllq_Vo_Wo();
725                    0x4: pmuludq_Vo_Wo();
726                    0x5: pmaddwd_Vo_Wo();
727                    0x6: psadbw_Vo_Wo();
728                    0x7: maskmovdqu_Vo_VRo();
729                    default: Inst::UD2();
730                }
731                // repne (0xF2)
732                0x8: decode OPCODE_OP_BOTTOM3 {
733                    0x0: lddqu_Vo_Mo();
734                    default: Inst::UD2();
735                }
736                default: Inst::UD2();
737            }
738            0x1F: decode LEGACY_DECODEVAL {
739                // no prefix
740                0x0: decode OPCODE_OP_BOTTOM3 {
741                    0x0: psubb_Pq_Qq();
742                    0x1: psubw_Pq_Qq();
743                    0x2: psubd_Pq_Qq();
744                    0x3: psubq_Pq_Qq();
745                    0x4: paddb_Pq_Qq();
746                    0x5: paddw_Pq_Qq();
747                    0x6: paddd_Pq_Qq();
748                    0x7: Inst::UD2();
749                }
750                // operand size (0x66)
751                0x1: decode OPCODE_OP_BOTTOM3 {
752                    0x0: psubb_Vo_Wo();
753                    0x1: psubw_Vo_Wo();
754                    0x2: psubd_Vo_Wo();
755                    0x3: psubq_Vo_Wo();
756                    0x4: paddb_Vo_Wo();
757                    0x5: paddw_Vo_Wo();
758                    0x6: paddd_Vo_Wo();
759                    0x7: Inst::UD2();
760                }
761                default: Inst::UD2();
762            }
763            default: FailUnimpl::twoByteOps();
764        }
765    }
766    default: M5InternalError::error(
767        {{"Unexpected first opcode byte in two byte opcode!"}});
768}
769