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