17087Snate@binkert.org// Copyright (c) 2007-2008 The Hewlett-Packard Development Company
210959Sdavid.hashe@amd.com// Copyright (c) 2012-2013 AMD
37087Snate@binkert.org// All rights reserved.
47087Snate@binkert.org//
57087Snate@binkert.org// The license below extends only to copyright in the software and shall
67087Snate@binkert.org// not be construed as granting a license to any other intellectual
77087Snate@binkert.org// property including but not limited to intellectual property relating
87087Snate@binkert.org// to a hardware implementation of the functionality of the software
97087Snate@binkert.org// licensed hereunder.  You may use the software subject to the license
107087Snate@binkert.org// terms below provided that you ensure that this notice is replicated
117087Snate@binkert.org// unmodified and in its entirety in all distributions of the software,
127087Snate@binkert.org// modified or unmodified, in source code or in binary form.
137087Snate@binkert.org//
145331Sgblack@eecs.umich.edu// Copyright (c) 2008 The Regents of The University of Michigan
155331Sgblack@eecs.umich.edu// All rights reserved.
165331Sgblack@eecs.umich.edu//
175331Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
185331Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
195331Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
205331Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
215331Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
225331Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
235331Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
245331Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
255331Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
265331Sgblack@eecs.umich.edu// this software without specific prior written permission.
275331Sgblack@eecs.umich.edu//
285331Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
295331Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
305331Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
315331Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
325331Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
335331Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
345331Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
355331Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
365331Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
375331Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
385331Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
395331Sgblack@eecs.umich.edu//
405331Sgblack@eecs.umich.edu// Authors: Gabe Black
415331Sgblack@eecs.umich.edu
424276Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////
434276Sgblack@eecs.umich.edu//
444276Sgblack@eecs.umich.edu// Decode the two byte opcodes
454276Sgblack@eecs.umich.edu//
4610593Sgabeblack@google.com'X86ISA::TwoByteOpcode': decode OPCODE_OP_TOP5 {
4710593Sgabeblack@google.com    format WarnUnimpl {
4810593Sgabeblack@google.com        0x00: decode OPCODE_OP_BOTTOM3 {
4910593Sgabeblack@google.com            //0x00: group6();
5010593Sgabeblack@google.com            0x00: decode MODRM_REG {
5110593Sgabeblack@google.com                0x0: sldt_Mw_or_Rv();
5210593Sgabeblack@google.com                0x1: str_Mw_or_Rv();
5310593Sgabeblack@google.com                0x2: Inst::LLDT(Ew);
5410593Sgabeblack@google.com                0x3: Inst::LTR(Ew);
5510593Sgabeblack@google.com                0x4: verr_Mw_or_Rv();
5610593Sgabeblack@google.com                0x5: verw_Mw_or_Rv();
5710593Sgabeblack@google.com                //0x6: jmpe_Ev(); // IA-64
5810593Sgabeblack@google.com                default: Inst::UD2();
5910593Sgabeblack@google.com            }
6010593Sgabeblack@google.com            //0x01: group7(); // Ugly, ugly, ugly...
6110593Sgabeblack@google.com            0x01: decode MODRM_REG {
6210593Sgabeblack@google.com                0x0: decode MODRM_MOD {
6310593Sgabeblack@google.com                    0x3: decode MODRM_RM {
6410593Sgabeblack@google.com                        0x1: vmcall();
6510593Sgabeblack@google.com                        0x2: vmlaunch();
6610593Sgabeblack@google.com                        0x3: vmresume();
6710593Sgabeblack@google.com                        0x4: vmxoff();
6810593Sgabeblack@google.com                        default: Inst::UD2();
6910593Sgabeblack@google.com                    }
7010593Sgabeblack@google.com                    default: sgdt_Ms();
715238Sgblack@eecs.umich.edu                }
7210593Sgabeblack@google.com                0x1: decode MODRM_MOD {
7310593Sgabeblack@google.com                    0x3: decode MODRM_RM {
7410593Sgabeblack@google.com                        0x0: MonitorInst::monitor({{
7510593Sgabeblack@google.com                           xc->armMonitor(Rax);
7610593Sgabeblack@google.com                        }});
7710593Sgabeblack@google.com                        0x1: MwaitInst::mwait({{
7810593Sgabeblack@google.com                           uint64_t m = 0;          //mem
7910593Sgabeblack@google.com                           unsigned s = 0x8;        //size
8010593Sgabeblack@google.com                           unsigned f = 0;          //flags
8110593Sgabeblack@google.com                           readMemAtomic(xc, traceData,
8210593Sgabeblack@google.com                                         xc->getAddrMonitor()->vAddr,
8310593Sgabeblack@google.com                                         m, s, f);
8410593Sgabeblack@google.com                           xc->mwaitAtomic(xc->tcBase());
8510593Sgabeblack@google.com                           MicroHalt hltObj(machInst, mnemonic, 0x0);
8610593Sgabeblack@google.com                           hltObj.execute(xc, traceData);
8710593Sgabeblack@google.com                        }});
8810593Sgabeblack@google.com                        default: Inst::UD2();
896611Sgblack@eecs.umich.edu                    }
9010593Sgabeblack@google.com                    default: sidt_Ms();
9110593Sgabeblack@google.com                }
9210593Sgabeblack@google.com                0x2: decode MODRM_MOD {
9310593Sgabeblack@google.com                    0x3: decode MODRM_RM {
9410593Sgabeblack@google.com                        0x0: xgetbv();
9510593Sgabeblack@google.com                        0x1: xsetbv();
966611Sgblack@eecs.umich.edu                    }
9710593Sgabeblack@google.com                    default: decode MODE_SUBMODE {
9810593Sgabeblack@google.com                        0x0: Inst::LGDT(M);
9910593Sgabeblack@google.com                        default: decode OPSIZE {
10010593Sgabeblack@google.com                            // 16 bit operand sizes are special, but only
10110593Sgabeblack@google.com                            // in legacy and compatability modes.
10210593Sgabeblack@google.com                            0x2: Inst::LGDT_16(M);
10310593Sgabeblack@google.com                            default: Inst::LGDT(M);
1046611Sgblack@eecs.umich.edu                        }
1056611Sgblack@eecs.umich.edu                    }
10610593Sgabeblack@google.com                }
10710593Sgabeblack@google.com                0x3: decode MODRM_MOD {
10810593Sgabeblack@google.com                    0x3: decode MODRM_RM {
10910593Sgabeblack@google.com                        0x0: vmrun();
11010593Sgabeblack@google.com                        0x1: vmmcall();
11110593Sgabeblack@google.com                        0x2: vmload();
11210593Sgabeblack@google.com                        0x3: vmsave();
11310593Sgabeblack@google.com                        0x4: stgi();
11410593Sgabeblack@google.com                        0x5: clgi();
11510593Sgabeblack@google.com                        0x6: skinit();
11610593Sgabeblack@google.com                        0x7: invlpga();
11710593Sgabeblack@google.com                    }
11810593Sgabeblack@google.com                    default: decode MODE_SUBMODE {
11910593Sgabeblack@google.com                        0x0: Inst::LIDT(M);
12010593Sgabeblack@google.com                        default: decode OPSIZE {
12110593Sgabeblack@google.com                            // 16 bit operand sizes are special, but only
12210593Sgabeblack@google.com                            // in legacy and compatability modes.
12310593Sgabeblack@google.com                            0x2: Inst::LIDT_16(M);
12410593Sgabeblack@google.com                            default: Inst::LIDT(M);
1255292Sgblack@eecs.umich.edu                        }
1266611Sgblack@eecs.umich.edu                    }
1275238Sgblack@eecs.umich.edu                }
12810593Sgabeblack@google.com                0x4: decode MODRM_MOD {
12910593Sgabeblack@google.com                    0x3: Inst::SMSW(Rv);
13010593Sgabeblack@google.com                    default: Inst::SMSW(Mw);
13110593Sgabeblack@google.com                }
13210593Sgabeblack@google.com                0x6: Inst::LMSW(Ew);
13310593Sgabeblack@google.com                0x7: decode MODRM_MOD {
13410593Sgabeblack@google.com                    0x3: decode MODRM_RM {
13510593Sgabeblack@google.com                        0x0: Inst::SWAPGS();
13612586Sgabeblack@google.com                        0x1: Inst::RDTSCP();
1375789Sgblack@eecs.umich.edu                        default: Inst::UD2();
1385789Sgblack@eecs.umich.edu                    }
13910593Sgabeblack@google.com                    default: Inst::INVLPG(M);
1405908Sgblack@eecs.umich.edu                }
1414276Sgblack@eecs.umich.edu            }
14210593Sgabeblack@google.com            0x02: lar_Gv_Ew();
14310593Sgabeblack@google.com            0x03: lsl_Gv_Ew();
14410593Sgabeblack@google.com            // sandpile.org doesn't seem to know what this is...? We'll
14510593Sgabeblack@google.com            // use it for pseudo instructions. We've got 16 bits of space
14610593Sgabeblack@google.com            // to play with so there can be quite a few pseudo
14710593Sgabeblack@google.com            // instructions.
14810593Sgabeblack@google.com            //0x04: loadall_or_reset_or_hang();
14910593Sgabeblack@google.com            0x4: decode IMMEDIATE {
15010593Sgabeblack@google.com                format BasicOperate {
15110593Sgabeblack@google.com                    0x00: m5arm({{
15210593Sgabeblack@google.com                        PseudoInst::arm(xc->tcBase());
15310593Sgabeblack@google.com                    }}, IsNonSpeculative);
15410593Sgabeblack@google.com                    0x01: m5quiesce({{
15510593Sgabeblack@google.com                        PseudoInst::quiesce(xc->tcBase());
15610593Sgabeblack@google.com                    }}, IsNonSpeculative, IsQuiesce);
15710593Sgabeblack@google.com                    0x02: m5quiesceNs({{
15810593Sgabeblack@google.com                        PseudoInst::quiesceNs(xc->tcBase(), Rdi);
15910593Sgabeblack@google.com                    }}, IsNonSpeculative, IsQuiesce);
16010593Sgabeblack@google.com                    0x03: m5quiesceCycle({{
16110593Sgabeblack@google.com                        PseudoInst::quiesceCycles(xc->tcBase(), Rdi);
16210593Sgabeblack@google.com                    }}, IsNonSpeculative, IsQuiesce);
16310593Sgabeblack@google.com                    0x04: m5quiesceTime({{
16410593Sgabeblack@google.com                        Rax = PseudoInst::quiesceTime(xc->tcBase());
16510593Sgabeblack@google.com                    }}, IsNonSpeculative);
16610593Sgabeblack@google.com                    0x07: m5rpns({{
16710593Sgabeblack@google.com                        Rax = PseudoInst::rpns(xc->tcBase());
16810593Sgabeblack@google.com                    }}, IsNonSpeculative);
16910593Sgabeblack@google.com                    0x21: m5exit({{
17010593Sgabeblack@google.com                        PseudoInst::m5exit(xc->tcBase(), Rdi);
17110593Sgabeblack@google.com                    }}, IsNonSpeculative);
17210593Sgabeblack@google.com                    0x22: m5fail({{
17310593Sgabeblack@google.com                        PseudoInst::m5fail(xc->tcBase(), Rdi, Rsi);
17410593Sgabeblack@google.com                    }}, IsNonSpeculative);
17510593Sgabeblack@google.com                    0x30: m5initparam({{
17611289Sgabor.dozsa@arm.com                        Rax = PseudoInst::initParam(xc->tcBase(), Rdi, Rsi);
17710593Sgabeblack@google.com                    }}, IsNonSpeculative);
17810593Sgabeblack@google.com                    0x31: m5loadsymbol({{
17910593Sgabeblack@google.com                        PseudoInst::loadsymbol(xc->tcBase());
18010593Sgabeblack@google.com                    }}, IsNonSpeculative);
18110593Sgabeblack@google.com                    0x40: m5resetstats({{
18210593Sgabeblack@google.com                        PseudoInst::resetstats(xc->tcBase(), Rdi, Rsi);
18310593Sgabeblack@google.com                    }}, IsNonSpeculative);
18410593Sgabeblack@google.com                    0x41: m5dumpstats({{
18510593Sgabeblack@google.com                        PseudoInst::dumpstats(xc->tcBase(), Rdi, Rsi);
18610593Sgabeblack@google.com                    }}, IsNonSpeculative);
18710593Sgabeblack@google.com                    0x42: m5dumpresetstats({{
18810593Sgabeblack@google.com                        PseudoInst::dumpresetstats(xc->tcBase(), Rdi, Rsi);
18910593Sgabeblack@google.com                    }}, IsNonSpeculative);
19010593Sgabeblack@google.com                    0x43: m5checkpoint({{
19110593Sgabeblack@google.com                        PseudoInst::m5checkpoint(xc->tcBase(), Rdi, Rsi);
19210593Sgabeblack@google.com                    }}, IsNonSpeculative);
19310593Sgabeblack@google.com                    0x50: m5readfile({{
19410593Sgabeblack@google.com                        Rax = PseudoInst::readfile(
19510593Sgabeblack@google.com                            xc->tcBase(), Rdi, Rsi, Rdx);
19610593Sgabeblack@google.com                    }}, IsNonSpeculative);
19710593Sgabeblack@google.com                    0x51: m5debugbreak({{
19810593Sgabeblack@google.com                        PseudoInst::debugbreak(xc->tcBase());
19910593Sgabeblack@google.com                    }}, IsNonSpeculative);
20010593Sgabeblack@google.com                    0x52: m5switchcpu({{
20110593Sgabeblack@google.com                        PseudoInst::switchcpu(xc->tcBase());
20210593Sgabeblack@google.com                    }}, IsNonSpeculative);
20310593Sgabeblack@google.com                    0x53: m5addsymbol({{
20410593Sgabeblack@google.com                        PseudoInst::addsymbol(xc->tcBase(), Rdi, Rsi);
20510593Sgabeblack@google.com                    }}, IsNonSpeculative);
20610593Sgabeblack@google.com                    0x54: m5panic({{
20710593Sgabeblack@google.com                        panic("M5 panic instruction called at pc = %#x.\n",
20810593Sgabeblack@google.com                              RIP);
20910593Sgabeblack@google.com                    }}, IsNonSpeculative);
21010593Sgabeblack@google.com                    0x55: m5reserved1({{
21110593Sgabeblack@google.com                        warn("M5 reserved opcode 1 ignored.\n");
21210593Sgabeblack@google.com                    }}, IsNonSpeculative);
21310593Sgabeblack@google.com                    0x56: m5reserved2({{
21410593Sgabeblack@google.com                        warn("M5 reserved opcode 2 ignored.\n");
21510593Sgabeblack@google.com                    }}, IsNonSpeculative);
21610593Sgabeblack@google.com                    0x57: m5reserved3({{
21710593Sgabeblack@google.com                        warn("M5 reserved opcode 3 ignored.\n");
21810593Sgabeblack@google.com                    }}, IsNonSpeculative);
21910593Sgabeblack@google.com                    0x58: m5reserved4({{
22010593Sgabeblack@google.com                        warn("M5 reserved opcode 4 ignored.\n");
22110593Sgabeblack@google.com                    }}, IsNonSpeculative);
22210593Sgabeblack@google.com                    0x59: m5reserved5({{
22310593Sgabeblack@google.com                        warn("M5 reserved opcode 5 ignored.\n");
22410593Sgabeblack@google.com                    }}, IsNonSpeculative);
22510593Sgabeblack@google.com                    0x5a: m5_work_begin({{
22610593Sgabeblack@google.com                        PseudoInst::workbegin(xc->tcBase(), Rdi, Rsi);
22710593Sgabeblack@google.com                    }}, IsNonSpeculative);
22810593Sgabeblack@google.com                    0x5b: m5_work_end({{
22910593Sgabeblack@google.com                        PseudoInst::workend(xc->tcBase(), Rdi, Rsi);
23010593Sgabeblack@google.com                    }}, IsNonSpeculative);
23111703Smichael.lebeane@amd.com                    0x62: m5togglesync({{
23211703Smichael.lebeane@amd.com                        PseudoInst::togglesync(xc->tcBase());
23311703Smichael.lebeane@amd.com                    }}, IsNonSpeculative, IsQuiesce);
2346616Sgblack@eecs.umich.edu                    default: Inst::UD2();
2356616Sgblack@eecs.umich.edu                }
2364276Sgblack@eecs.umich.edu            }
23710593Sgabeblack@google.com            0x05: decode FullSystemInt {
23811877Sbrandon.potter@amd.com                0: SyscallInst::syscall('xc->syscall(Rax, &fault)',
23911877Sbrandon.potter@amd.com                                        IsSyscall, IsNonSpeculative,
24011877Sbrandon.potter@amd.com                                        IsSerializeAfter);
24110593Sgabeblack@google.com                default: decode MODE_MODE {
24210593Sgabeblack@google.com                    0x0: decode MODE_SUBMODE {
24310593Sgabeblack@google.com                        0x0: Inst::SYSCALL_64();
24410593Sgabeblack@google.com                        0x1: Inst::SYSCALL_COMPAT();
24510593Sgabeblack@google.com                    }
24610593Sgabeblack@google.com                    0x1: Inst::SYSCALL_LEGACY();
24710593Sgabeblack@google.com                }
24810593Sgabeblack@google.com            }
24910593Sgabeblack@google.com            0x06: Inst::CLTS();
25010593Sgabeblack@google.com            0x07: decode MODE_SUBMODE {
25110593Sgabeblack@google.com                0x0: decode OPSIZE {
25210593Sgabeblack@google.com                    // Return to 64 bit mode.
25310593Sgabeblack@google.com                    0x8: Inst::SYSRET_TO_64();
25410593Sgabeblack@google.com                    // Return to compatibility mode.
25510593Sgabeblack@google.com                    default: Inst::SYSRET_TO_COMPAT();
25610593Sgabeblack@google.com                }
25710593Sgabeblack@google.com                default: Inst::SYSRET_NON_64();
25810593Sgabeblack@google.com            }
25910593Sgabeblack@google.com        }
26010593Sgabeblack@google.com        0x01: decode OPCODE_OP_BOTTOM3 {
26110593Sgabeblack@google.com            0x0: invd();
26210593Sgabeblack@google.com            0x1: wbinvd();
26310593Sgabeblack@google.com            0x2: Inst::UD2();
26410593Sgabeblack@google.com            0x3: Inst::UD2();
26510593Sgabeblack@google.com            0x4: Inst::UD2();
26610593Sgabeblack@google.com            0x5: Inst::PREFETCH(Mb);
26710593Sgabeblack@google.com            0x6: FailUnimpl::femms();
26810593Sgabeblack@google.com            0x7: decode IMMEDIATE {
26910593Sgabeblack@google.com                0x0C: pi2fw_Pq_Qq();
27010593Sgabeblack@google.com                0x0D: pi2fd_Pq_Qq();
27110593Sgabeblack@google.com                0x1C: pf2iw_Pq_Qq();
27210593Sgabeblack@google.com                0x1D: pf2id_Pq_Qq();
27310593Sgabeblack@google.com                0x8A: pfnacc_Pq_Qq();
27410593Sgabeblack@google.com                0x8E: pfpnacc_Pq_Qq();
27510593Sgabeblack@google.com                0x90: pfcmpge_Pq_Qq();
27610593Sgabeblack@google.com                0x94: pfmin_Pq_Qq();
27710593Sgabeblack@google.com                0x96: pfrcp_Pq_Qq();
27810593Sgabeblack@google.com                0x97: pfrsqrt_Pq_Qq();
27910593Sgabeblack@google.com                0x9A: Inst::PFSUB(Pq,Qq);
28010593Sgabeblack@google.com                0x9E: pfadd_Pq_Qq();
28110593Sgabeblack@google.com                0xA0: pfcmpgt_Pq_Qq();
28210593Sgabeblack@google.com                0xA4: pfmax_Pq_Qq();
28310593Sgabeblack@google.com                0xA6: pfrcpit1_Pq_Qq();
28410593Sgabeblack@google.com                0xA7: pfrsqit1_Pq_Qq();
28510593Sgabeblack@google.com                0xAA: Inst::PFSUBR(Pq,Qq);
28610593Sgabeblack@google.com                0xAE: pfacc_Pq_Qq();
28710593Sgabeblack@google.com                0xB0: pfcmpeq_Pq_Qq();
28810593Sgabeblack@google.com                0xB4: Inst::PFMUL(Pq,Qq);
28910593Sgabeblack@google.com                0xB6: pfrcpit2_Pq_Qq();
29010593Sgabeblack@google.com                0xB7: Inst::PMULHRW(Pq,Qq);
29110593Sgabeblack@google.com                0xBB: pswapd_Pq_Qq();
29210593Sgabeblack@google.com                0xBF: pavgusb_Pq_Qq();
29310593Sgabeblack@google.com                default: Inst::UD2();
29410593Sgabeblack@google.com            }
29510593Sgabeblack@google.com        }
29610593Sgabeblack@google.com        format Inst{
29710593Sgabeblack@google.com            0x02: decode LEGACY_DECODEVAL {
29810593Sgabeblack@google.com                // no prefix
29910593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
30010593Sgabeblack@google.com                    0x0: MOVUPS(Vo,Wo);
30110593Sgabeblack@google.com                    0x1: MOVUPS(Wo,Vo);
30210593Sgabeblack@google.com                    0x2: decode MODRM_MOD {
30310593Sgabeblack@google.com                        0x3: MOVHLPS(Vps,VRq);
30410593Sgabeblack@google.com                        default: MOVLPS(Vps,Mq);
30510593Sgabeblack@google.com                    }
30610593Sgabeblack@google.com                    0x3: MOVLPS(Mq,Vps);
30710593Sgabeblack@google.com                    0x4: UNPCKLPS(Vps,Wq);
30810593Sgabeblack@google.com                    0x5: UNPCKHPS(Vps,Wq);
30910593Sgabeblack@google.com                    0x6: decode MODRM_MOD {
31010593Sgabeblack@google.com                        0x3: MOVLHPS(Vps,VRq);
31110593Sgabeblack@google.com                        default: MOVHPS(Vps,Mq);
31210593Sgabeblack@google.com                    }
31310593Sgabeblack@google.com                    0x7: MOVHPS(Mq,Vq);
31410593Sgabeblack@google.com                }
31510593Sgabeblack@google.com                // repe (0xF3)
31610593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
31710593Sgabeblack@google.com                    0x0: MOVSS(Vd,Wd);
31810593Sgabeblack@google.com                    0x1: MOVSS(Wd,Vd);
31910593Sgabeblack@google.com                    0x2: WarnUnimpl::movsldup_Vo_Wo();
32010593Sgabeblack@google.com                    0x6: WarnUnimpl::movshdup_Vo_Wo();
32110593Sgabeblack@google.com                    default: UD2();
32210593Sgabeblack@google.com                }
32310593Sgabeblack@google.com                // operand size (0x66)
32410593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
32510593Sgabeblack@google.com                    0x0: MOVUPD(Vo,Wo);
32610593Sgabeblack@google.com                    0x1: MOVUPD(Wo,Vo);
32710593Sgabeblack@google.com                    0x2: MOVLPD(Vq,Mq);
32810593Sgabeblack@google.com                    0x3: MOVLPD(Mq,Vq);
32910593Sgabeblack@google.com                    0x4: UNPCKLPD(Vo,Wq);
33010593Sgabeblack@google.com                    0x5: UNPCKHPD(Vo,Wo);
33110593Sgabeblack@google.com                    0x6: MOVHPD(Vq,Mq);
33210593Sgabeblack@google.com                    0x7: MOVHPD(Mq,Vq);
33310593Sgabeblack@google.com            }
33410593Sgabeblack@google.com                // repne (0xF2)
33510593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
33610593Sgabeblack@google.com                    0x0: MOVSD(Vq,Wq);
33710593Sgabeblack@google.com                    0x1: MOVSD(Wq,Vq);
33810593Sgabeblack@google.com                    0x2: MOVDDUP(Vo,Wq);
33910593Sgabeblack@google.com                    default: UD2();
34010593Sgabeblack@google.com                }
34110593Sgabeblack@google.com                default: UD2();
34210593Sgabeblack@google.com            }
34310593Sgabeblack@google.com            0x03: decode OPCODE_OP_BOTTOM3 {
34410593Sgabeblack@google.com                //group16();
34510593Sgabeblack@google.com                0x0: decode MODRM_REG {
34610593Sgabeblack@google.com                    0x0: WarnUnimpl::prefetch_nta();
34710593Sgabeblack@google.com                    0x1: PREFETCH_T0(Mb);
34810593Sgabeblack@google.com                    0x2: WarnUnimpl::prefetch_t1();
34910593Sgabeblack@google.com                    0x3: WarnUnimpl::prefetch_t2();
35010593Sgabeblack@google.com                    default: HINT_NOP();
35110593Sgabeblack@google.com                }
35210593Sgabeblack@google.com                0x1: HINT_NOP();
35310593Sgabeblack@google.com                0x2: HINT_NOP();
35410593Sgabeblack@google.com                0x3: HINT_NOP();
35510593Sgabeblack@google.com                0x4: HINT_NOP();
35610593Sgabeblack@google.com                0x5: HINT_NOP();
35710593Sgabeblack@google.com                0x6: HINT_NOP();
35810593Sgabeblack@google.com                0x7: HINT_NOP();
35910593Sgabeblack@google.com            }
36010593Sgabeblack@google.com            0x04: decode LEGACY_DECODEVAL {
36110593Sgabeblack@google.com                // no prefix
36210593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
36312170Sgabeblack@google.com                    0x0: CondInst::MOV(
36412205Sbaz21@cam.ac.uk                        {{isValidMiscReg(MISCREG_CR(MODRM_REG))}},Rd,Cd);
36510593Sgabeblack@google.com                    0x1: MOV(Rd,Dd);
36612170Sgabeblack@google.com                    0x2: CondInst::MOV(
36712170Sgabeblack@google.com                        {{isValidMiscReg(MISCREG_CR(MODRM_REG))}},Cd,Rd);
36810593Sgabeblack@google.com                    0x3: MOV(Dd,Rd);
36910593Sgabeblack@google.com                    default: UD2();
37010593Sgabeblack@google.com                }
37110959Sdavid.hashe@amd.com                // operand size (0x66)
37210959Sdavid.hashe@amd.com                0x1: decode OPCODE_OP_BOTTOM3 {
37310959Sdavid.hashe@amd.com                    0x0: MOV(Rd,Cd);
37410959Sdavid.hashe@amd.com                    0x2: MOV(Cd,Rd);
37510959Sdavid.hashe@amd.com                }
37610593Sgabeblack@google.com                default: UD2();
37710593Sgabeblack@google.com            }
37810593Sgabeblack@google.com            0x05: decode LEGACY_DECODEVAL {
37910593Sgabeblack@google.com                // no prefix
38010593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
38110593Sgabeblack@google.com                    //These moves should really use size o (octword), but
38210593Sgabeblack@google.com                    //because they are split in two, they use q (quadword).
38310593Sgabeblack@google.com                    0x0: MOVAPS(Vq,Wq);
38410593Sgabeblack@google.com                    0x1: MOVAPS(Wq,Vq);
38510593Sgabeblack@google.com                    0x2: CVTPI2PS(Vq,Qq);
38614289SPouya.Fotouhi@amd.com                    //Non-temporal hint is ignored since we don't have
38714289SPouya.Fotouhi@amd.com                    //proper support for it in the memory system.
38812683Ssteve.reinhardt@amd.com                    0x3: MOVNTPS(Mq,Vq);
38910593Sgabeblack@google.com                    0x4: CVTTPS2PI(Pq,Wq);
39010593Sgabeblack@google.com                    0x5: CVTPS2PI(Pq,Wq);
39110593Sgabeblack@google.com                    0x6: UCOMISS(Vd,Wd);
39210593Sgabeblack@google.com                    0x7: COMISS(Vd,Wd);
39310593Sgabeblack@google.com                }
39410593Sgabeblack@google.com                // repe (0xF3)
39510593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
39610593Sgabeblack@google.com                    0x2: CVTSI2SS(Vd,Ed);
39710593Sgabeblack@google.com                    0x4: CVTTSS2SI(Gd,Wd);
39810593Sgabeblack@google.com                    0x5: CVTSS2SI(Gd,Wd);
39910593Sgabeblack@google.com                    default: UD2();
40010593Sgabeblack@google.com                }
40110593Sgabeblack@google.com                // operand size (0x66)
40210593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
40310593Sgabeblack@google.com                    0x0: MOVAPD(Vo,Wo);
40410593Sgabeblack@google.com                    0x1: MOVAPD(Wo,Vo);
40510593Sgabeblack@google.com                    0x2: CVTPI2PD(Vo,Qq);
40614289SPouya.Fotouhi@amd.com                    //Non-temporal hint is ignored since we don't have
40714289SPouya.Fotouhi@amd.com                    //proper support for it in the memory system.
40812683Ssteve.reinhardt@amd.com                    0x3: MOVNTPD(Mq,Vq);
40910593Sgabeblack@google.com                    0x4: CVTTPD2PI(Pq,Wo);
41010593Sgabeblack@google.com                    0x5: CVTPD2PI(Pq,Wo);
41110593Sgabeblack@google.com                    0x6: UCOMISD(Vq,Wq);
41210593Sgabeblack@google.com                    0x7: COMISD(Vq,Wq);
41310593Sgabeblack@google.com                }
41410593Sgabeblack@google.com                // repne (0xF2)
41510593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
41610593Sgabeblack@google.com                    // The size of the V operand should be q, not dp
41710593Sgabeblack@google.com                    0x2: CVTSI2SD(Vdp,Edp);
41810593Sgabeblack@google.com                    // The size of the W operand should be q, not dp
41910593Sgabeblack@google.com                    0x4: CVTTSD2SI(Gdp,Wdp);
42010593Sgabeblack@google.com                    0x5: CVTSD2SI(Gd,Wq);
42110593Sgabeblack@google.com                    default: UD2();
42210593Sgabeblack@google.com                }
42310593Sgabeblack@google.com                default: UD2();
42410593Sgabeblack@google.com            }
42510593Sgabeblack@google.com        }
42610593Sgabeblack@google.com        0x06: decode OPCODE_OP_BOTTOM3 {
42710593Sgabeblack@google.com            0x0: Inst::WRMSR();
42810593Sgabeblack@google.com            0x1: Inst::RDTSC();
42910593Sgabeblack@google.com            0x2: Inst::RDMSR();
43010593Sgabeblack@google.com            0x3: rdpmc();
43110593Sgabeblack@google.com            0x4: decode FullSystemInt {
43211877Sbrandon.potter@amd.com                0: SyscallInst::sysenter('xc->syscall(Rax, &fault)',
43311877Sbrandon.potter@amd.com                                         IsSyscall, IsNonSpeculative,
43411877Sbrandon.potter@amd.com                                         IsSerializeAfter);
43510593Sgabeblack@google.com                default: sysenter();
43610593Sgabeblack@google.com            }
43710593Sgabeblack@google.com            0x5: sysexit();
43810593Sgabeblack@google.com            0x6: Inst::UD2();
43910593Sgabeblack@google.com            0x7: getsec();
44010593Sgabeblack@google.com        }
44110593Sgabeblack@google.com        0x07: decode OPCODE_OP_BOTTOM3 {
44210593Sgabeblack@google.com            0x0: M5InternalError::error(
44310593Sgabeblack@google.com                {{"Three byte opcode shouldn't be handled by "
44410593Sgabeblack@google.com                  "two_byte_opcodes.isa!"}});
44510593Sgabeblack@google.com            0x2: M5InternalError::error(
44610593Sgabeblack@google.com                {{"Three byte opcode shouldn't be handled by "
44710593Sgabeblack@google.com                  "two_byte_opcodes.isa!"}});
44810593Sgabeblack@google.com            default: UD2();
44910593Sgabeblack@google.com        }
45010593Sgabeblack@google.com        format Inst {
45110593Sgabeblack@google.com            0x08: decode OPCODE_OP_BOTTOM3 {
45210593Sgabeblack@google.com                0x0: CMOVO(Gv,Ev);
45310593Sgabeblack@google.com                0x1: CMOVNO(Gv,Ev);
45410593Sgabeblack@google.com                0x2: CMOVB(Gv,Ev);
45510593Sgabeblack@google.com                0x3: CMOVNB(Gv,Ev);
45610593Sgabeblack@google.com                0x4: CMOVZ(Gv,Ev);
45710593Sgabeblack@google.com                0x5: CMOVNZ(Gv,Ev);
45810593Sgabeblack@google.com                0x6: CMOVBE(Gv,Ev);
45910593Sgabeblack@google.com                0x7: CMOVNBE(Gv,Ev);
46010593Sgabeblack@google.com            }
46110593Sgabeblack@google.com            0x09: decode OPCODE_OP_BOTTOM3 {
46210593Sgabeblack@google.com                0x0: CMOVS(Gv,Ev);
46310593Sgabeblack@google.com                0x1: CMOVNS(Gv,Ev);
46410593Sgabeblack@google.com                0x2: CMOVP(Gv,Ev);
46510593Sgabeblack@google.com                0x3: CMOVNP(Gv,Ev);
46610593Sgabeblack@google.com                0x4: CMOVL(Gv,Ev);
46710593Sgabeblack@google.com                0x5: CMOVNL(Gv,Ev);
46810593Sgabeblack@google.com                0x6: CMOVLE(Gv,Ev);
46910593Sgabeblack@google.com                0x7: CMOVNLE(Gv,Ev);
47010593Sgabeblack@google.com            }
47110593Sgabeblack@google.com            0x0A: decode LEGACY_DECODEVAL {
47210593Sgabeblack@google.com                // no prefix
47310593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
47410593Sgabeblack@google.com                    0x0: MOVMSKPS(Gd,VRo);
47510593Sgabeblack@google.com                    0x1: SQRTPS(Vo,Wo);
47610593Sgabeblack@google.com                    0x2: WarnUnimpl::rqsrtps_Vo_Wo();
47711160Ssteve.reinhardt@amd.com                    0x3: RCPPS(Vo,Wo);
47810593Sgabeblack@google.com                    0x4: ANDPS(Vo,Wo);
47910593Sgabeblack@google.com                    0x5: ANDNPS(Vo,Wo);
48010593Sgabeblack@google.com                    0x6: ORPS(Vo,Wo);
48110593Sgabeblack@google.com                    0x7: XORPS(Vo,Wo);
48210593Sgabeblack@google.com                }
48310593Sgabeblack@google.com                // repe (0xF3)
48410593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
48510593Sgabeblack@google.com                    0x1: SQRTSS(Vd,Wd);
48610593Sgabeblack@google.com                    0x2: WarnUnimpl::rsqrtss_Vd_Wd();
48711160Ssteve.reinhardt@amd.com                    0x3: RCPSS(Vd,Wd);
48810593Sgabeblack@google.com                    default: UD2();
48910593Sgabeblack@google.com                }
49010593Sgabeblack@google.com                // operand size (0x66)
49110593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
49210593Sgabeblack@google.com                    0x0: MOVMSKPD(Gd,VRo);
49310593Sgabeblack@google.com                    0x1: SQRTPD(Vo,Wo);
49410593Sgabeblack@google.com                    0x4: ANDPD(Vo,Wo);
49510593Sgabeblack@google.com                    0x5: ANDNPD(Vo,Wo);
49610593Sgabeblack@google.com                    0x6: ORPD(Vo,Wo);
49710593Sgabeblack@google.com                    0x7: XORPD(Vo,Wo);
49810593Sgabeblack@google.com                    default: UD2();
49910593Sgabeblack@google.com                }
50010593Sgabeblack@google.com                // repne (0xF2)
50110593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
50210593Sgabeblack@google.com                    0x1: SQRTSD(Vq,Wq);
50310593Sgabeblack@google.com                    default: UD2();
50410593Sgabeblack@google.com                }
50510593Sgabeblack@google.com                default: UD2();
50610593Sgabeblack@google.com            }
50710593Sgabeblack@google.com            0x0B: decode LEGACY_DECODEVAL {
50810593Sgabeblack@google.com                // no prefix
50910593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
51010593Sgabeblack@google.com                    0x0: ADDPS(Vo,Wo);
51110593Sgabeblack@google.com                    0x1: MULPS(Vo,Wo);
51210593Sgabeblack@google.com                    0x2: CVTPS2PD(Vo,Wq);
51310593Sgabeblack@google.com                    0x3: CVTDQ2PS(Vo,Wo);
51410593Sgabeblack@google.com                    0x4: SUBPS(Vo,Wo);
51510593Sgabeblack@google.com                    0x5: MINPS(Vo,Wo);
51610593Sgabeblack@google.com                    0x6: DIVPS(Vo,Wo);
51710593Sgabeblack@google.com                    0x7: MAXPS(Vo,Wo);
51810593Sgabeblack@google.com                }
51910593Sgabeblack@google.com                // repe (0xF3)
52010593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
52110593Sgabeblack@google.com                    0x0: ADDSS(Vd,Wd);
52210593Sgabeblack@google.com                    0x1: MULSS(Vd,Wd);
52310593Sgabeblack@google.com                    0x2: CVTSS2SD(Vq,Wd);
52410593Sgabeblack@google.com                    0x3: CVTTPS2DQ(Vo,Wo);
52510593Sgabeblack@google.com                    0x4: SUBSS(Vd,Wd);
52610593Sgabeblack@google.com                    0x5: MINSS(Vd,Wd);
52710593Sgabeblack@google.com                    0x6: DIVSS(Vd,Wd);
52810593Sgabeblack@google.com                    0x7: MAXSS(Vd,Wd);
52910593Sgabeblack@google.com                }
53010593Sgabeblack@google.com                // operand size (0x66)
53110593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
53210593Sgabeblack@google.com                    0x0: ADDPD(Vo,Wo);
53310593Sgabeblack@google.com                    0x1: MULPD(Vo,Wo);
53410593Sgabeblack@google.com                    0x2: CVTPD2PS(Vo,Wo);
53510593Sgabeblack@google.com                    0x3: CVTPS2DQ(Vo,Wo);
53610593Sgabeblack@google.com                    0x4: SUBPD(Vo,Wo);
53710593Sgabeblack@google.com                    0x5: MINPD(Vo,Wo);
53810593Sgabeblack@google.com                    0x6: DIVPD(Vo,Wo);
53910593Sgabeblack@google.com                    0x7: MAXPD(Vo,Wo);
54010593Sgabeblack@google.com                }
54110593Sgabeblack@google.com                // repne (0xF2)
54210593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
54310593Sgabeblack@google.com                    0x0: ADDSD(Vq,Wq);
54410593Sgabeblack@google.com                    0x1: MULSD(Vq,Wq);
54510593Sgabeblack@google.com                    0x2: CVTSD2SS(Vd,Wq);
54610593Sgabeblack@google.com                    0x4: SUBSD(Vq,Wq);
54710593Sgabeblack@google.com                    0x5: MINSD(Vq,Wq);
54810593Sgabeblack@google.com                    0x6: DIVSD(Vq,Wq);
54910593Sgabeblack@google.com                    0x7: MAXSD(Vq,Wq);
55010593Sgabeblack@google.com                    default: UD2();
55110593Sgabeblack@google.com                }
55210593Sgabeblack@google.com                default: UD2();
55310593Sgabeblack@google.com            }
55410593Sgabeblack@google.com            0x0C: decode LEGACY_DECODEVAL {
55510593Sgabeblack@google.com                // no prefix
55610593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
55710593Sgabeblack@google.com                    0x0: PUNPCKLBW(Pq,Qd);
55810593Sgabeblack@google.com                    0x1: PUNPCKLWD(Pq,Qd);
55910593Sgabeblack@google.com                    0x2: PUNPCKLDQ(Pq,Qd);
56010593Sgabeblack@google.com                    0x3: PACKSSWB(Pq,Qq);
56110593Sgabeblack@google.com                    0x4: PCMPGTB(Pq,Qq);
56210593Sgabeblack@google.com                    0x5: PCMPGTW(Pq,Qq);
56310593Sgabeblack@google.com                    0x6: PCMPGTD(Pq,Qq);
56410593Sgabeblack@google.com                    0x7: PACKUSWB(Pq,Qq);
56510593Sgabeblack@google.com                }
56610593Sgabeblack@google.com                // operand size (0x66)
56710593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
56810593Sgabeblack@google.com                    0x0: PUNPCKLBW(Vo,Wq);
56910593Sgabeblack@google.com                    0x1: PUNPCKLWD(Vo,Wq);
57010593Sgabeblack@google.com                    0x2: PUNPCKLDQ(Vo,Wq);
57110593Sgabeblack@google.com                    0x3: PACKSSWB(Vo,Wo);
57210593Sgabeblack@google.com                    0x4: PCMPGTB(Vo,Wo);
57310593Sgabeblack@google.com                    0x5: PCMPGTW(Vo,Wo);
57410593Sgabeblack@google.com                    0x6: PCMPGTD(Vo,Wo);
57510593Sgabeblack@google.com                    0x7: PACKUSWB(Vo,Wo);
57610593Sgabeblack@google.com                }
57710593Sgabeblack@google.com                default: UD2();
57810593Sgabeblack@google.com            }
57910593Sgabeblack@google.com            0x0D: decode LEGACY_DECODEVAL {
58010593Sgabeblack@google.com                // no prefix
58110593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
58210593Sgabeblack@google.com                    0x0: PUNPCKHBW(Pq,Qq);
58310593Sgabeblack@google.com                    0x1: PUNPCKHWD(Pq,Qq);
58410593Sgabeblack@google.com                    0x2: PUNPCKHDQ(Pq,Qq);
58510593Sgabeblack@google.com                    0x3: PACKSSDW(Pq,Qq);
58610593Sgabeblack@google.com                    0x6: MOVD(Pq,Edp);
58710593Sgabeblack@google.com                    0x7: MOVQ(Pq,Qq);
58810593Sgabeblack@google.com                    default: UD2();
58910593Sgabeblack@google.com                }
59010593Sgabeblack@google.com                // repe (0xF3)
59110593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
59210593Sgabeblack@google.com                    0x7: MOVDQU(Vo,Wo);
59310593Sgabeblack@google.com                    default: UD2();
59410593Sgabeblack@google.com                }
59510593Sgabeblack@google.com                // operand size (0x66)
59610593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
59710593Sgabeblack@google.com                    0x0: PUNPCKHBW(Vo,Wo);
59810593Sgabeblack@google.com                    0x1: PUNPCKHWD(Vo,Wo);
59910593Sgabeblack@google.com                    0x2: PUNPCKHDQ(Vo,Wo);
60010593Sgabeblack@google.com                    0x3: PACKSSDW(Vo,Wo);
60110593Sgabeblack@google.com                    0x4: PUNPCKLQDQ(Vo,Wq);
60210593Sgabeblack@google.com                    0x5: PUNPCKHQDQ(Vo,Wq);
60310593Sgabeblack@google.com                    0x6: MOVD(Vo,Edp);
60410593Sgabeblack@google.com                    0x7: MOVDQA(Vo,Wo);
60510593Sgabeblack@google.com                }
60610593Sgabeblack@google.com                default: UD2();
60710593Sgabeblack@google.com            }
60810593Sgabeblack@google.com            0x0E: decode LEGACY_DECODEVAL {
60910593Sgabeblack@google.com                // no prefix
61010593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
61110593Sgabeblack@google.com                    0x0: PSHUFW(Pq,Qq,Ib);
61210593Sgabeblack@google.com                    //0x1: group12_pshimw();
61310593Sgabeblack@google.com                    0x1: decode MODRM_REG {
61410593Sgabeblack@google.com                        0x2: PSRLW(PRq,Ib);
61510593Sgabeblack@google.com                        0x4: PSRAW(PRq,Ib);
61610593Sgabeblack@google.com                        0x6: PSLLW(PRq,Ib);
61710593Sgabeblack@google.com                        default: UD2();
61810593Sgabeblack@google.com                    }
61910593Sgabeblack@google.com                    //0x2: group13_pshimd();
62010593Sgabeblack@google.com                    0x2: decode MODRM_REG {
62110593Sgabeblack@google.com                        0x2: PSRLD(PRq,Ib);
62210593Sgabeblack@google.com                        0x4: PSRAD(PRq,Ib);
62310593Sgabeblack@google.com                        0x6: PSLLD(PRq,Ib);
62410593Sgabeblack@google.com                        default: UD2();
62510593Sgabeblack@google.com                    }
62610593Sgabeblack@google.com                    //0x3: group14_pshimq();
62710593Sgabeblack@google.com                    0x3: decode MODRM_REG {
62810593Sgabeblack@google.com                        0x2: PSRLQ(PRq,Ib);
62910593Sgabeblack@google.com                        0x6: PSLLQ(PRq,Ib);
63010593Sgabeblack@google.com                        default: Inst::UD2();
63110593Sgabeblack@google.com                    }
63210593Sgabeblack@google.com                    0x4: Inst::PCMPEQB(Pq,Qq);
63310593Sgabeblack@google.com                    0x5: Inst::PCMPEQW(Pq,Qq);
63410593Sgabeblack@google.com                    0x6: Inst::PCMPEQD(Pq,Qq);
63510593Sgabeblack@google.com                    0x7: Inst::EMMS();
63610593Sgabeblack@google.com                }
63710593Sgabeblack@google.com                // repe (0xF3)
63810593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
63910593Sgabeblack@google.com                    0x0: PSHUFHW(Vo,Wo,Ib);
64010593Sgabeblack@google.com                    default: UD2();
64110593Sgabeblack@google.com                }
64210593Sgabeblack@google.com                // operand size (0x66)
64310593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
64410593Sgabeblack@google.com                    0x0: PSHUFD(Vo,Wo,Ib);
64510593Sgabeblack@google.com                    //0x1: group12_pshimw();
64610593Sgabeblack@google.com                    0x1: decode MODRM_REG {
64710593Sgabeblack@google.com                        0x2: PSRLW(VRo,Ib);
64810593Sgabeblack@google.com                        0x4: PSRAW(VRo,Ib);
64910593Sgabeblack@google.com                        0x6: PSLLW(VRo,Ib);
65010593Sgabeblack@google.com                    }
65110593Sgabeblack@google.com                    //0x2: group13_pshimd();
65210593Sgabeblack@google.com                    0x2: decode MODRM_REG {
65310593Sgabeblack@google.com                        0x2: PSRLD(VRo,Ib);
65410593Sgabeblack@google.com                        0x4: PSRAD(VRo,Ib);
65510593Sgabeblack@google.com                        0x6: PSLLD(VRo,Ib);
65610593Sgabeblack@google.com                        default: UD2();
65710593Sgabeblack@google.com                    }
65810593Sgabeblack@google.com                    //0x3: group14_pshimq();
65910593Sgabeblack@google.com                    0x3: decode MODRM_REG {
66010593Sgabeblack@google.com                        0x2: PSRLQ(VRo,Ib);
66110593Sgabeblack@google.com                        0x3: PSRLDQ(VRo,Ib);
66210593Sgabeblack@google.com                        0x6: PSLLQ(VRo,Ib);
66310593Sgabeblack@google.com                        0x7: PSLLDQ(VRo,Ib);
66410593Sgabeblack@google.com                        default: UD2();
66510593Sgabeblack@google.com                    }
66610593Sgabeblack@google.com                    0x4: PCMPEQB(Vo,Wo);
66710593Sgabeblack@google.com                    0x5: PCMPEQW(Vo,Wo);
66810593Sgabeblack@google.com                    0x6: PCMPEQD(Vo,Wo);
66910593Sgabeblack@google.com                    default: UD2();
67010593Sgabeblack@google.com                }
67110593Sgabeblack@google.com                // repne (0xF2)
67210593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
67310593Sgabeblack@google.com                    0x0: PSHUFLW(Vo,Wo,Ib);
67410593Sgabeblack@google.com                    default: UD2();
67510593Sgabeblack@google.com                }
67610593Sgabeblack@google.com                default: UD2();
67710593Sgabeblack@google.com            }
67810593Sgabeblack@google.com            0x0F: decode LEGACY_DECODEVAL {
67910593Sgabeblack@google.com                // no prefix
68010593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
68110593Sgabeblack@google.com                    0x0: WarnUnimpl::vmread_Edp_Gdp();
68210593Sgabeblack@google.com                    0x1: WarnUnimpl::vmwrite_Gdp_Edp();
68310593Sgabeblack@google.com                    0x6: MOVD(Edp,Pdp);
68410593Sgabeblack@google.com                    0x7: MOVQ(Qq,Pq);
68510593Sgabeblack@google.com                    default: UD2();
68610593Sgabeblack@google.com                }
68710593Sgabeblack@google.com                // repe (0xF3)
68810593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
68910593Sgabeblack@google.com                    0x6: MOVQ(Vq,Wq);
69010593Sgabeblack@google.com                    0x7: MOVDQU(Wo,Vo);
69110593Sgabeblack@google.com                    default: UD2();
69210593Sgabeblack@google.com                }
69310593Sgabeblack@google.com                // operand size (0x66)
69410593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
69510593Sgabeblack@google.com                    0x4: HADDPD(Vo,Wo);
69610593Sgabeblack@google.com                    0x5: WarnUnimpl::hsubpd_Vo_Wo();
69710593Sgabeblack@google.com                    0x6: MOVD(Edp,Vd);
69810593Sgabeblack@google.com                    0x7: MOVDQA(Wo,Vo);
69910593Sgabeblack@google.com                    default: UD2();
70010593Sgabeblack@google.com                }
70110593Sgabeblack@google.com                // repne (0xF2)
70210593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
70310593Sgabeblack@google.com                    0x4: HADDPS(Vo,Wo);
70410593Sgabeblack@google.com                    0x5: WarnUnimpl::hsubps_Vo_Wo();
70510593Sgabeblack@google.com                    default: UD2();
70610593Sgabeblack@google.com                }
70710593Sgabeblack@google.com                default: UD2();
70810593Sgabeblack@google.com            }
70910593Sgabeblack@google.com            0x10: decode OPCODE_OP_BOTTOM3 {
71010593Sgabeblack@google.com                0x0: JO(Jz);
71110593Sgabeblack@google.com                0x1: JNO(Jz);
71210593Sgabeblack@google.com                0x2: JB(Jz);
71310593Sgabeblack@google.com                0x3: JNB(Jz);
71410593Sgabeblack@google.com                0x4: JZ(Jz);
71510593Sgabeblack@google.com                0x5: JNZ(Jz);
71610593Sgabeblack@google.com                0x6: JBE(Jz);
71710593Sgabeblack@google.com                0x7: JNBE(Jz);
71810593Sgabeblack@google.com            }
71910593Sgabeblack@google.com            0x11: decode OPCODE_OP_BOTTOM3 {
72010593Sgabeblack@google.com                0x0: JS(Jz);
72110593Sgabeblack@google.com                0x1: JNS(Jz);
72210593Sgabeblack@google.com                0x2: JP(Jz);
72310593Sgabeblack@google.com                0x3: JNP(Jz);
72410593Sgabeblack@google.com                0x4: JL(Jz);
72510593Sgabeblack@google.com                0x5: JNL(Jz);
72610593Sgabeblack@google.com                0x6: JLE(Jz);
72710593Sgabeblack@google.com                0x7: JNLE(Jz);
72810593Sgabeblack@google.com            }
72910593Sgabeblack@google.com            0x12: decode OPCODE_OP_BOTTOM3 {
73010593Sgabeblack@google.com                0x0: SETO(Eb);
73110593Sgabeblack@google.com                0x1: SETNO(Eb);
73210593Sgabeblack@google.com                0x2: SETB(Eb);
73310593Sgabeblack@google.com                0x3: SETNB(Eb);
73410593Sgabeblack@google.com                0x4: SETZ(Eb);
73510593Sgabeblack@google.com                0x5: SETNZ(Eb);
73610593Sgabeblack@google.com                0x6: SETBE(Eb);
73710593Sgabeblack@google.com                0x7: SETNBE(Eb);
73810593Sgabeblack@google.com            }
73910593Sgabeblack@google.com            0x13: decode OPCODE_OP_BOTTOM3 {
74010593Sgabeblack@google.com                0x0: SETS(Eb);
74110593Sgabeblack@google.com                0x1: SETNS(Eb);
74210593Sgabeblack@google.com                0x2: SETP(Eb);
74310593Sgabeblack@google.com                0x3: SETNP(Eb);
74410593Sgabeblack@google.com                0x4: SETL(Eb);
74510593Sgabeblack@google.com                0x5: SETNL(Eb);
74610593Sgabeblack@google.com                0x6: SETLE(Eb);
74710593Sgabeblack@google.com                0x7: SETNLE(Eb);
74810593Sgabeblack@google.com            }
74910593Sgabeblack@google.com        }
75010593Sgabeblack@google.com        0x14: decode OPCODE_OP_BOTTOM3 {
75110593Sgabeblack@google.com            0x0: push_fs();
75210593Sgabeblack@google.com            0x1: pop_fs();
75310593Sgabeblack@google.com            0x2: CPUIDInst::CPUID({{
75410593Sgabeblack@google.com                CpuidResult result;
75510593Sgabeblack@google.com                bool success = doCpuid(xc->tcBase(), bits(Rax, 31, 0),
75610593Sgabeblack@google.com                    bits(Rcx, 31, 0), result);
75710593Sgabeblack@google.com                if (success) {
75810593Sgabeblack@google.com                    Rax = result.rax;
75910593Sgabeblack@google.com                    Rbx = result.rbx;
76010593Sgabeblack@google.com                    Rcx = result.rcx;
76110593Sgabeblack@google.com                    Rdx = result.rdx;
76210593Sgabeblack@google.com                } else {
76314164Sgabeblack@google.com                    // It isn't defined what to do in this case. We used to
76414164Sgabeblack@google.com                    // leave R[abcd]x unmodified, but setting them all to 0
76514164Sgabeblack@google.com                    // seems a little safer and more predictable.
76614164Sgabeblack@google.com                    Rax = 0;
76714164Sgabeblack@google.com                    Rbx = 0;
76814164Sgabeblack@google.com                    Rcx = 0;
76914164Sgabeblack@google.com                    Rdx = 0;
77010593Sgabeblack@google.com                }
77110593Sgabeblack@google.com                }});
77210593Sgabeblack@google.com            0x3: Inst::BT(Ev,Gv);
77310593Sgabeblack@google.com            0x4: Inst::SHLD(Ev,Gv,Ib);
77410593Sgabeblack@google.com            0x5: Inst::SHLD(Ev,Gv);
77510593Sgabeblack@google.com            default: Inst::UD2();
77610593Sgabeblack@google.com        }
77710593Sgabeblack@google.com        0x15: decode OPCODE_OP_BOTTOM3 {
77810593Sgabeblack@google.com            0x0: push_gs();
77910593Sgabeblack@google.com            0x1: pop_gs();
78010593Sgabeblack@google.com            0x2: rsm_smm();
78110593Sgabeblack@google.com            0x3: Inst::BTS(Ev,Gv);
78210593Sgabeblack@google.com            0x4: Inst::SHRD(Ev,Gv,Ib);
78310593Sgabeblack@google.com            0x5: Inst::SHRD(Ev,Gv);
78410593Sgabeblack@google.com            //0x6: group15();
78510593Sgabeblack@google.com            0x6: decode MODRM_MOD {
78610593Sgabeblack@google.com                0x3: decode MODRM_REG {
78710593Sgabeblack@google.com                    0x5: BasicOperate::LFENCE(
78810593Sgabeblack@google.com                                 {{/*Nothing*/}}, IsReadBarrier);
78910593Sgabeblack@google.com                    0x6: BasicOperate::MFENCE(
79010593Sgabeblack@google.com                                 {{/*Nothing*/}}, IsMemBarrier);
79110593Sgabeblack@google.com                    0x7: BasicOperate::SFENCE(
79210593Sgabeblack@google.com                                 {{/*Nothing*/}}, IsWriteBarrier);
79310593Sgabeblack@google.com                    default: Inst::UD2();
79410593Sgabeblack@google.com                }
79510593Sgabeblack@google.com                default: decode MODRM_REG {
79610593Sgabeblack@google.com                    0x0: decode OPSIZE {
79710593Sgabeblack@google.com                        4: Inst::FXSAVE(M);
79810593Sgabeblack@google.com                        8: Inst::FXSAVE64(M);
79910593Sgabeblack@google.com                        default: fxsave();
80010593Sgabeblack@google.com                    }
80110593Sgabeblack@google.com                    0x1: decode OPSIZE {
80210593Sgabeblack@google.com                        4: Inst::FXRSTOR(M);
80310593Sgabeblack@google.com                        8: Inst::FXRSTOR64(M);
80410593Sgabeblack@google.com                        default: fxrstor();
80510593Sgabeblack@google.com                    }
80610593Sgabeblack@google.com                    0x2: Inst::LDMXCSR(Md);
80710593Sgabeblack@google.com                    0x3: Inst::STMXCSR(Md);
80810593Sgabeblack@google.com                    0x4: xsave();
80910593Sgabeblack@google.com                    0x5: xrstor();
81012463Sswapnilster@gmail.com                    0x6: decode LEGACY_DECODEVAL {
81112463Sswapnilster@gmail.com                        0x0: Inst::UD2();
81212463Sswapnilster@gmail.com                        0x1: Inst::CLWB(Mb);
81312463Sswapnilster@gmail.com                        default: Inst::UD2();
81412463Sswapnilster@gmail.com                    }
81512463Sswapnilster@gmail.com                    0x7: decode LEGACY_DECODEVAL {
81612463Sswapnilster@gmail.com                        0x0: Inst::CLFLUSH(Mb);
81712463Sswapnilster@gmail.com                        0x1: Inst::CLFLUSHOPT(Mb);
81812463Sswapnilster@gmail.com                        default: Inst::CLFLUSH(Mb);
81912463Sswapnilster@gmail.com                    }
82010593Sgabeblack@google.com                }
82110593Sgabeblack@google.com            }
82210593Sgabeblack@google.com            0x7: Inst::IMUL(Gv,Ev);
82310593Sgabeblack@google.com        }
82410593Sgabeblack@google.com        format Inst {
82510593Sgabeblack@google.com            0x16: decode OPCODE_OP_BOTTOM3 {
82610593Sgabeblack@google.com                0x0: CMPXCHG(Eb,Gb);
82710593Sgabeblack@google.com                0x1: CMPXCHG(Ev,Gv);
82810593Sgabeblack@google.com                0x2: WarnUnimpl::lss_Gz_Mp();
82910593Sgabeblack@google.com                0x3: BTR(Ev,Gv);
83010593Sgabeblack@google.com                0x4: WarnUnimpl::lfs_Gz_Mp();
83110593Sgabeblack@google.com                0x5: WarnUnimpl::lgs_Gz_Mp();
83210593Sgabeblack@google.com                //The size of the second operand in these instructions
83310593Sgabeblack@google.com                //should really be "b" or "w", but it's set to v in order
83410593Sgabeblack@google.com                //to have a consistent register size. This shouldn't
83510593Sgabeblack@google.com                //affect behavior.
83610593Sgabeblack@google.com                0x6: MOVZX_B(Gv,Ev);
83710593Sgabeblack@google.com                0x7: MOVZX_W(Gv,Ev);
83810593Sgabeblack@google.com            }
83910593Sgabeblack@google.com            0x17: decode OPCODE_OP_BOTTOM3 {
84010593Sgabeblack@google.com                0x0: decode LEGACY_REP {
84110593Sgabeblack@google.com                    0x0: WarnUnimpl::jmpe_Jz();
84210593Sgabeblack@google.com                    0x1: WarnUnimpl::popcnt_Gv_Ev();
84310593Sgabeblack@google.com                }
84410593Sgabeblack@google.com                //0x1: group10_UD2();
84510593Sgabeblack@google.com                0x1: UD2();
84610593Sgabeblack@google.com                //0x2: group8_Ev_Ib();
84710593Sgabeblack@google.com                0x2: decode MODRM_REG {
84810593Sgabeblack@google.com                    0x4: BT(Ev,Ib);
84910593Sgabeblack@google.com                    0x5: BTS(Ev,Ib);
85010593Sgabeblack@google.com                    0x6: BTR(Ev,Ib);
85110593Sgabeblack@google.com                    0x7: BTC(Ev,Ib);
85210593Sgabeblack@google.com                    default: UD2();
85310593Sgabeblack@google.com                }
85410593Sgabeblack@google.com                0x3: BTC(Ev,Gv);
85510593Sgabeblack@google.com                0x4: BSF(Gv,Ev);
85610593Sgabeblack@google.com                0x5: BSR(Gv,Ev);
85710593Sgabeblack@google.com                //The size of the second operand in these instructions
85810593Sgabeblack@google.com                //should really be "b" or "w", but it's set to v in order
85910593Sgabeblack@google.com                //to have a consistent register size. This shouldn't
86010593Sgabeblack@google.com                //affect behavior.
86110593Sgabeblack@google.com                0x6: MOVSX_B(Gv,Ev);
86210593Sgabeblack@google.com                0x7: MOVSX_W(Gv,Ev);
86310593Sgabeblack@google.com            }
86410593Sgabeblack@google.com            0x18: decode OPCODE_OP_BOTTOM3 {
86510593Sgabeblack@google.com                0x0: XADD(Eb,Gb);
86610593Sgabeblack@google.com                0x1: XADD(Ev,Gv);
86710593Sgabeblack@google.com                //0x7: group9();
86810593Sgabeblack@google.com                0x7: decode MODRM_REG {
86910593Sgabeblack@google.com                    //Also CMPXCHG16B
87010593Sgabeblack@google.com                    0x1: CMPXCHG8B(Mdp);
87110593Sgabeblack@google.com                    0x6: decode LEGACY_OP {
87210593Sgabeblack@google.com                        0x1: WarnUnimpl::vmclear_Mq();
87310593Sgabeblack@google.com                        default: decode LEGACY_REP {
87410593Sgabeblack@google.com                            0x1: WarnUnimpl::vmxon_Mq();
87510593Sgabeblack@google.com                            0x0: WarnUnimpl::vmptrld_Mq();
87610593Sgabeblack@google.com                        }
87710593Sgabeblack@google.com                    }
87810593Sgabeblack@google.com                    0x7: WarnUnimpl::vmptrst_Mq();
87910593Sgabeblack@google.com                    default: UD2();
88010593Sgabeblack@google.com                }
88110593Sgabeblack@google.com                default: decode LEGACY_DECODEVAL {
8826576Sgblack@eecs.umich.edu                    // no prefix
8836576Sgblack@eecs.umich.edu                    0x0: decode OPCODE_OP_BOTTOM3 {
88410593Sgabeblack@google.com                        0x2: CMPPS(Vo,Wo,Ib);
88514224SPouya.Fotouhi@amd.com                        //Non-temporal hint is ignored since we don't have
88614224SPouya.Fotouhi@amd.com                        //proper support for it in the memory system.
88710593Sgabeblack@google.com                        0x3: MOVNTI(Mdp,Gdp);
88810593Sgabeblack@google.com                        0x4: PINSRW(Pq,Ew,Ib);
88910593Sgabeblack@google.com                        0x5: PEXTRW(Gd,PRq,Ib);
89010593Sgabeblack@google.com                        0x6: SHUFPS(Vps,Wps,Ib);
8915020Sgblack@eecs.umich.edu                    }
8926576Sgblack@eecs.umich.edu                    // repe (0xF3)
8936576Sgblack@eecs.umich.edu                    0x4: decode OPCODE_OP_BOTTOM3 {
89410593Sgabeblack@google.com                        0x2: CMPSS(Vd,Wd,Ib);
8956576Sgblack@eecs.umich.edu                        default: UD2();
8965020Sgblack@eecs.umich.edu                    }
8976576Sgblack@eecs.umich.edu                    // operand size (0x66)
8986576Sgblack@eecs.umich.edu                    0x1: decode OPCODE_OP_BOTTOM3 {
89910593Sgabeblack@google.com                        0x2: CMPPD(Vo,Wo,Ib);
90010593Sgabeblack@google.com                        0x4: PINSRW(Vdw,Ew,Ib);
90110593Sgabeblack@google.com                        0x5: PEXTRW(Gd,VRdq,Ib);
90210593Sgabeblack@google.com                        0x6: SHUFPD(Vpd,Wpd,Ib);
90310593Sgabeblack@google.com                        default: UD2();
9046576Sgblack@eecs.umich.edu                    }
9056576Sgblack@eecs.umich.edu                    // repne (0xF2)
9066576Sgblack@eecs.umich.edu                    0x8: decode OPCODE_OP_BOTTOM3 {
90710593Sgabeblack@google.com                        0x2: CMPSD(Vq,Wq,Ib);
9086611Sgblack@eecs.umich.edu                        default: UD2();
9096611Sgblack@eecs.umich.edu                    }
9106611Sgblack@eecs.umich.edu                    default: UD2();
9115020Sgblack@eecs.umich.edu                }
9124276Sgblack@eecs.umich.edu            }
91310593Sgabeblack@google.com            0x19: decode OPSIZE {
91410593Sgabeblack@google.com                4: BSWAP_D(Bd);
91510593Sgabeblack@google.com                8: BSWAP_Q(Bq);
9166611Sgblack@eecs.umich.edu                default: UD2();
9174276Sgblack@eecs.umich.edu            }
91810593Sgabeblack@google.com            0x1A: decode LEGACY_DECODEVAL {
91910593Sgabeblack@google.com                // no prefix
92010593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
92110593Sgabeblack@google.com                    0x1: PSRLW(Pq,Qq);
92210593Sgabeblack@google.com                    0x2: PSRLD(Pq,Qq);
92310593Sgabeblack@google.com                    0x3: PSRLQ(Pq,Qq);
92410593Sgabeblack@google.com                    0x4: PADDQ(Pq,Qq);
92510593Sgabeblack@google.com                    0x5: PMULLW(Pq,Qq);
92610593Sgabeblack@google.com                    0x7: PMOVMSKB(Gd,PRq);
9275059Sgblack@eecs.umich.edu                    default: UD2();
9285020Sgblack@eecs.umich.edu                }
92910593Sgabeblack@google.com                // repe (0xF3)
93010593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
93110593Sgabeblack@google.com                    0x6: MOVQ2DQ(Vo,PRq);
9326576Sgblack@eecs.umich.edu                    default: UD2();
9335020Sgblack@eecs.umich.edu                }
93410593Sgabeblack@google.com                // operand size (0x66)
93510593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
93610632Smaxime.cscs@gmail.com                    0x0: ADDSUBPD(Vo,Wo);
93710593Sgabeblack@google.com                    0x1: PSRLW(Vo,Wo);
93810593Sgabeblack@google.com                    0x2: PSRLD(Vo,Wo);
93910593Sgabeblack@google.com                    0x3: PSRLQ(Vo,Wo);
94010593Sgabeblack@google.com                    0x4: PADDQ(Vo,Wo);
94110593Sgabeblack@google.com                    0x5: PMULLW(Vo,Wo);
94210593Sgabeblack@google.com                    0x6: MOVQ(Wq,Vq);
94310593Sgabeblack@google.com                    0x7: PMOVMSKB(Gd,VRo);
94410593Sgabeblack@google.com                }
94510593Sgabeblack@google.com                // repne (0xF2)
94610593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
94710593Sgabeblack@google.com                    0x0: WarnUnimpl::addsubps_Vo_Wo();
94810593Sgabeblack@google.com                    0x6: MOVDQ2Q(Pq,VRq);
9496576Sgblack@eecs.umich.edu                    default: UD2();
9505020Sgblack@eecs.umich.edu                }
95110593Sgabeblack@google.com                default: UD2();
95210593Sgabeblack@google.com            }
95310593Sgabeblack@google.com            0x1B: decode LEGACY_DECODEVAL {
95410593Sgabeblack@google.com                // no prefix
95510593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
95610593Sgabeblack@google.com                    0x0: PSUBUSB(Pq,Qq);
95710593Sgabeblack@google.com                    0x1: PSUBUSW(Pq,Qq);
95810593Sgabeblack@google.com                    0x2: PMINUB(Pq,Qq);
95910593Sgabeblack@google.com                    0x3: PAND(Pq,Qq);
96010593Sgabeblack@google.com                    0x4: PADDUSB(Pq,Qq);
96110593Sgabeblack@google.com                    0x5: PADDUSW(Pq,Qq);
96210593Sgabeblack@google.com                    0x6: PMAXUB(Pq,Qq);
96310593Sgabeblack@google.com                    0x7: PANDN(Pq,Qq);
96410593Sgabeblack@google.com                }
96510593Sgabeblack@google.com                // operand size (0x66)
96610593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
96710593Sgabeblack@google.com                    0x0: PSUBUSB(Vo,Wo);
96810593Sgabeblack@google.com                    0x1: PSUBUSW(Vo,Wo);
96910593Sgabeblack@google.com                    0x2: PMINUB(Vo,Wo);
97010593Sgabeblack@google.com                    0x3: PAND(Vo,Wo);
97110593Sgabeblack@google.com                    0x4: PADDUSB(Vo,Wo);
97210593Sgabeblack@google.com                    0x5: PADDUSW(Vo,Wo);
97310593Sgabeblack@google.com                    0x6: PMAXUB(Vo,Wo);
97410593Sgabeblack@google.com                    0x7: PANDN(Vo,Wo);
97510593Sgabeblack@google.com                }
97610593Sgabeblack@google.com                default: UD2();
97710593Sgabeblack@google.com            }
97810593Sgabeblack@google.com            0x1C: decode LEGACY_DECODEVAL {
97910593Sgabeblack@google.com                // no prefix
98010593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
98110593Sgabeblack@google.com                    0x0: PAVGB(Pq,Qq);
98210593Sgabeblack@google.com                    0x1: PSRAW(Pq,Qq);
98310593Sgabeblack@google.com                    0x2: PSRAD(Pq,Qq);
98410593Sgabeblack@google.com                    0x3: PAVGW(Pq,Qq);
98510593Sgabeblack@google.com                    0x4: PMULHUW(Pq,Qq);
98610593Sgabeblack@google.com                    0x5: PMULHW(Pq,Qq);
98714220SPouya.Fotouhi@amd.com                    //Non-temporal hint is ignored since we don't have
98814220SPouya.Fotouhi@amd.com                    //proper support for it in the memory system.
98914220SPouya.Fotouhi@amd.com                    0x7: MOVNTQ(Mq,Pq);
9906576Sgblack@eecs.umich.edu                    default: UD2();
9915020Sgblack@eecs.umich.edu                }
99210593Sgabeblack@google.com                // repe (0xF3)
99310593Sgabeblack@google.com                0x4: decode OPCODE_OP_BOTTOM3 {
99410593Sgabeblack@google.com                    0x6: CVTDQ2PD(Vo,Wq);
9956584Sgblack@eecs.umich.edu                    default: UD2();
9965020Sgblack@eecs.umich.edu                }
99710593Sgabeblack@google.com                // operand size (0x66)
99810593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
99910593Sgabeblack@google.com                    0x0: PAVGB(Vo,Wo);
100010593Sgabeblack@google.com                    0x1: PSRAW(Vo,Wo);
100110593Sgabeblack@google.com                    0x2: PSRAD(Vo,Wo);
100210593Sgabeblack@google.com                    0x3: PAVGW(Vo,Wo);
100310593Sgabeblack@google.com                    0x4: PMULHUW(Vo,Wo);
100410593Sgabeblack@google.com                    0x5: PMULHW(Vo,Wo);
100510593Sgabeblack@google.com                    0x6: CVTTPD2DQ(Vo,Wo);
100614220SPouya.Fotouhi@amd.com                    //MOVNTDQ should really use size o (octword), but
100714220SPouya.Fotouhi@amd.com                    //because it is split in two, we use q (quadword).
100814220SPouya.Fotouhi@amd.com                    //Non-temporal hint is ignored since we don't have
100914220SPouya.Fotouhi@amd.com                    //proper support for it in the memory system.
101014220SPouya.Fotouhi@amd.com                    0x7: MOVNTDQ(Mq,Vq);
101110593Sgabeblack@google.com                }
101210593Sgabeblack@google.com                // repne (0xF2)
101310593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
101410593Sgabeblack@google.com                    0x6: CVTPD2DQ(Vo,Wo);
10156584Sgblack@eecs.umich.edu                    default: UD2();
10165020Sgblack@eecs.umich.edu                }
101710593Sgabeblack@google.com                default: UD2();
101810593Sgabeblack@google.com            }
101910593Sgabeblack@google.com            0x1D: decode LEGACY_DECODEVAL {
102010593Sgabeblack@google.com                // no prefix
102110593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
102210593Sgabeblack@google.com                    0x0: PSUBSB(Pq,Qq);
102310593Sgabeblack@google.com                    0x1: PSUBSW(Pq,Qq);
102410593Sgabeblack@google.com                    0x2: PMINSW(Pq,Qq);
102510593Sgabeblack@google.com                    0x3: POR(Pq,Qq);
102610593Sgabeblack@google.com                    0x4: PADDSB(Pq,Qq);
102710593Sgabeblack@google.com                    0x5: PADDSW(Pq,Qq);
102810593Sgabeblack@google.com                    0x6: PMAXSW(Pq,Qq);
102910593Sgabeblack@google.com                    0x7: PXOR(Pq,Qq);
10304727Sgblack@eecs.umich.edu                }
103110593Sgabeblack@google.com                // operand size (0x66)
103210593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
103310593Sgabeblack@google.com                    0x0: PSUBSB(Vo,Wo);
103410593Sgabeblack@google.com                    0x1: PSUBSW(Vo,Wo);
103510593Sgabeblack@google.com                    0x2: PMINSW(Vo,Wo);
103610593Sgabeblack@google.com                    0x3: POR(Vo,Wo);
103710593Sgabeblack@google.com                    0x4: PADDSB(Vo,Wo);
103810593Sgabeblack@google.com                    0x5: PADDSW(Vo,Wo);
103910593Sgabeblack@google.com                    0x6: PMAXSW(Vo,Wo);
104010593Sgabeblack@google.com                    0x7: PXOR(Vo,Wo);
10414727Sgblack@eecs.umich.edu                }
104210593Sgabeblack@google.com                default: UD2();
10434276Sgblack@eecs.umich.edu            }
104410593Sgabeblack@google.com            0x1E: decode LEGACY_DECODEVAL {
104510593Sgabeblack@google.com                // no prefix
104610593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
104710593Sgabeblack@google.com                    0x1: PSLLW(Pq,Qq);
104810593Sgabeblack@google.com                    0x2: PSLLD(Pq,Qq);
104910593Sgabeblack@google.com                    0x3: PSLLQ(Pq,Qq);
105010593Sgabeblack@google.com                    0x4: PMULUDQ(Pq,Qq);
105110593Sgabeblack@google.com                    0x5: PMADDWD(Pq,Qq);
105210593Sgabeblack@google.com                    0x6: PSADBW(Pq,Qq);
105310593Sgabeblack@google.com                    0x7: MASKMOVQ(Pq,PRq);
10546576Sgblack@eecs.umich.edu                    default: UD2();
10555020Sgblack@eecs.umich.edu                }
105610593Sgabeblack@google.com                // operand size (0x66)
105710593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
105810593Sgabeblack@google.com                    0x1: PSLLW(Vo,Wo);
105910593Sgabeblack@google.com                    0x2: PSLLD(Vo,Wo);
106010593Sgabeblack@google.com                    0x3: PSLLQ(Vo,Wo);
106110593Sgabeblack@google.com                    0x4: PMULUDQ(Vo,Wo);
106210593Sgabeblack@google.com                    0x5: PMADDWD(Vo,Wo);
106310593Sgabeblack@google.com                    0x6: PSADBW(Vo,Wo);
106410593Sgabeblack@google.com                    0x7: MASKMOVDQU(Vo,VRo);
10656593Sgblack@eecs.umich.edu                    default: UD2();
10665020Sgblack@eecs.umich.edu                }
106710593Sgabeblack@google.com                // repne (0xF2)
106810593Sgabeblack@google.com                0x8: decode OPCODE_OP_BOTTOM3 {
106910593Sgabeblack@google.com                    0x0: WarnUnimpl::lddqu_Vo_Mo();
10706576Sgblack@eecs.umich.edu                    default: UD2();
10715020Sgblack@eecs.umich.edu                }
107210593Sgabeblack@google.com                default: UD2();
107310593Sgabeblack@google.com            }
107410593Sgabeblack@google.com            0x1F: decode LEGACY_DECODEVAL {
107510593Sgabeblack@google.com                // no prefix
107610593Sgabeblack@google.com                0x0: decode OPCODE_OP_BOTTOM3 {
107710593Sgabeblack@google.com                    0x0: PSUBB(Pq,Qq);
107810593Sgabeblack@google.com                    0x1: PSUBW(Pq,Qq);
107910593Sgabeblack@google.com                    0x2: PSUBD(Pq,Qq);
108010593Sgabeblack@google.com                    0x3: PSUBQ(Pq,Qq);
108110593Sgabeblack@google.com                    0x4: PADDB(Pq,Qq);
108210593Sgabeblack@google.com                    0x5: PADDW(Pq,Qq);
108310593Sgabeblack@google.com                    0x6: PADDD(Pq,Qq);
108410593Sgabeblack@google.com                    0x7: UD2();
10855022Sgblack@eecs.umich.edu                }
108610593Sgabeblack@google.com                // operand size (0x66)
108710593Sgabeblack@google.com                0x1: decode OPCODE_OP_BOTTOM3 {
108810593Sgabeblack@google.com                    0x0: PSUBB(Vo,Wo);
108910593Sgabeblack@google.com                    0x1: PSUBW(Vo,Wo);
109010593Sgabeblack@google.com                    0x2: PSUBD(Vo,Wo);
109110593Sgabeblack@google.com                    0x3: PSUBQ(Vo,Wo);
109210593Sgabeblack@google.com                    0x4: PADDB(Vo,Wo);
109310593Sgabeblack@google.com                    0x5: PADDW(Vo,Wo);
109410593Sgabeblack@google.com                    0x6: PADDD(Vo,Wo);
109510593Sgabeblack@google.com                    0x7: UD2();
10965020Sgblack@eecs.umich.edu                }
109710593Sgabeblack@google.com                default: UD2();
10984276Sgblack@eecs.umich.edu            }
10994276Sgblack@eecs.umich.edu        }
110010593Sgabeblack@google.com        default: FailUnimpl::twoByteOps();
11014276Sgblack@eecs.umich.edu    }
11024276Sgblack@eecs.umich.edu}
1103