two_byte_opcodes.isa (6582:7e1af04f4ead) two_byte_opcodes.isa (6584:5355f44912f6)
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: Inst::LLDT(Ew);
97 0x3: Inst::LTR(Ew);
98 0x4: verr_Mw_or_Rv();
99 0x5: verw_Mw_or_Rv();
100 //0x6: jmpe_Ev(); // IA-64
101 default: Inst::UD2();
102 }
103 //0x01: group7(); // Ugly, ugly, ugly...
104 0x01: decode MODRM_MOD {
105 0x3: decode MODRM_REG {
106 0x0: decode MODRM_RM {
107 0x1: vmcall();
108 0x2: vmlaunch();
109 0x3: vmresume();
110 0x4: vmxoff();
111 default: Inst::UD2();
112 }
113 0x1: decode MODRM_RM {
114 0x0: monitor();
115 0x1: mwait();
116 default: Inst::UD2();
117 }
118 0x3: decode MODRM_RM {
119 0x0: vmrun();
120 0x1: vmmcall();
121 0x2: vmload();
122 0x3: vmsave();
123 0x4: stgi();
124 0x5: clgi();
125 0x6: skinit();
126 0x7: invlpga();
127 }
128 0x4: Inst::SMSW(Rv);
129 0x6: Inst::LMSW(Rv);
130 0x7: decode MODRM_RM {
131 0x0: Inst::SWAPGS();
132 0x1: rdtscp();
133 default: Inst::UD2();
134 }
135 default: Inst::UD2();
136 }
137 default: decode MODRM_REG {
138 0x0: sgdt_Ms();
139 0x1: sidt_Ms();
140 0x2: decode MODE_SUBMODE {
141 0x0: Inst::LGDT(M);
142 default: decode OPSIZE {
143 // 16 bit operand sizes are special, but only
144 // in legacy and compatability modes.
145 0x2: Inst::LGDT_16(M);
146 default: Inst::LGDT(M);
147 }
148 }
149 0x3: decode MODE_SUBMODE {
150 0x0: Inst::LIDT(M);
151 default: decode OPSIZE {
152 // 16 bit operand sizes are special, but only
153 // in legacy and compatability modes.
154 0x2: Inst::LIDT_16(M);
155 default: Inst::LIDT(M);
156 }
157 }
158 0x4: Inst::SMSW(Mw);
159 0x6: Inst::LMSW(Mw);
160 0x7: Inst::INVLPG(M);
161 default: Inst::UD2();
162 }
163 }
164 0x02: lar_Gv_Ew();
165 0x03: lsl_Gv_Ew();
166 // sandpile.org doesn't seem to know what this is...? We'll
167 // use it for pseudo instructions. We've got 16 bits of space
168 // to play with so there can be quite a few pseudo
169 // instructions.
170 //0x04: loadall_or_reset_or_hang();
171 0x4: decode IMMEDIATE {
172 format BasicOperate {
173#if FULL_SYSTEM
174 0x00: m5arm({{
175 PseudoInst::arm(xc->tcBase());
176 }}, IsNonSpeculative);
177 0x01: m5quiesce({{
178 PseudoInst::quiesce(xc->tcBase());
179 }}, IsNonSpeculative);
180 0x02: m5quiesceNs({{
181 PseudoInst::quiesceNs(xc->tcBase(), Rdi);
182 }}, IsNonSpeculative);
183 0x03: m5quiesceCycle({{
184 PseudoInst::quiesceCycles(xc->tcBase(), Rdi);
185 }}, IsNonSpeculative);
186 0x04: m5quiesceTime({{
187 Rax = PseudoInst::quiesceTime(xc->tcBase());
188 }}, IsNonSpeculative);
189#endif
190 0x07: m5rpns({{
191 Rax = PseudoInst::rpns(xc->tcBase());
192 }}, IsNonSpeculative);
193 0x21: m5exit({{
194 PseudoInst::m5exit(xc->tcBase(), Rdi);
195 }}, IsNonSpeculative);
196#if FULL_SYSTEM
197 0x30: m5initparam({{
198 Rax = xc->tcBase()->getCpuPtr()->
199 system->init_param;
200 }}, IsNonSpeculative);
201 0x31: m5loadsymbol({{
202 PseudoInst::loadsymbol(xc->tcBase());
203 }}, IsNonSpeculative);
204#endif
205 0x40: m5resetstats({{
206 PseudoInst::resetstats(xc->tcBase(), Rdi, Rsi);
207 }}, IsNonSpeculative);
208 0x41: m5dumpstats({{
209 PseudoInst::dumpstats(xc->tcBase(), Rdi, Rsi);
210 }}, IsNonSpeculative);
211 0x42: m5dumpresetstats({{
212 PseudoInst::dumpresetstats(xc->tcBase(), Rdi, Rsi);
213 }}, IsNonSpeculative);
214 0x43: m5checkpoint({{
215 PseudoInst::m5checkpoint(xc->tcBase(), Rdi, Rsi);
216 }}, IsNonSpeculative);
217#if FULL_SYSTEM
218 0x50: m5readfile({{
219 Rax = PseudoInst::readfile(
220 xc->tcBase(), Rdi, Rsi, Rdx);
221 }}, IsNonSpeculative);
222#endif
223 0x51: m5debugbreak({{
224 PseudoInst::debugbreak(xc->tcBase());
225 }}, IsNonSpeculative);
226 0x52: m5switchcpu({{
227 PseudoInst::switchcpu(xc->tcBase());
228 }}, IsNonSpeculative);
229#if FULL_SYSTEM
230 0x53: m5addsymbol({{
231 PseudoInst::addsymbol(xc->tcBase(), Rdi, Rsi);
232 }}, IsNonSpeculative);
233#endif
234 0x54: m5panic({{
235 panic("M5 panic instruction called at pc=%#x.\n",
236 xc->readPC());
237 }}, IsNonSpeculative);
238 0x55: m5reserved1({{
239 warn("M5 reserved opcode 1 ignored.\n");
240 }}, IsNonSpeculative);
241 0x56: m5reserved2({{
242 warn("M5 reserved opcode 2 ignored.\n");
243 }}, IsNonSpeculative);
244 0x57: m5reserved3({{
245 warn("M5 reserved opcode 3 ignored.\n");
246 }}, IsNonSpeculative);
247 0x58: m5reserved4({{
248 warn("M5 reserved opcode 4 ignored.\n");
249 }}, IsNonSpeculative);
250 0x59: m5reserved5({{
251 warn("M5 reserved opcode 5 ignored.\n");
252 }}, IsNonSpeculative);
253 default: Inst::UD2();
254 }
255 }
256#if FULL_SYSTEM
257 0x05: decode MODE_MODE {
258 0x0: decode MODE_SUBMODE {
259 0x0: Inst::SYSCALL_64();
260 0x1: Inst::SYSCALL_COMPAT();
261 }
262 0x1: Inst::SYSCALL_LEGACY();
263 }
264#else
265 0x05: SyscallInst::syscall('xc->syscall(Rax)', IsSyscall);
266#endif
267 0x06: Inst::CLTS();
268 0x07: decode MODE_SUBMODE {
269 0x0: decode OPSIZE {
270 // Return to 64 bit mode.
271 0x8: Inst::SYSRET_TO_64();
272 // Return to compatibility mode.
273 default: Inst::SYSRET_TO_COMPAT();
274 }
275 default: Inst::SYSRET_NON_64();
276 }
277 }
278 0x01: decode OPCODE_OP_BOTTOM3 {
279 0x0: invd();
280 0x1: wbinvd();
281 0x2: Inst::UD2();
282 0x3: Inst::UD2();
283 0x4: Inst::UD2();
284 0x5: Inst::PREFETCH(Mb);
285 0x6: FailUnimpl::femms();
286 0x7: FailUnimpl::threednow();
287 }
288 format Inst{
289 0x02: decode LEGACY_DECODEVAL {
290 // no prefix
291 0x0: decode OPCODE_OP_BOTTOM3 {
292 0x0: MOVUPS(Vo,Wo);
293 0x1: MOVUPS(Wo,Vo);
294 0x2: decode MODRM_MOD {
295 0x3: MOVHLPS(Vq,VRq);
296 default: MOVLPS(Vq,Mq);
297 }
298 0x3: MOVLPS(Mq,Vq);
299 0x4: UNPCKLPS(Vps,Wq);
300 0x5: UNPCKHPS(Vpd,Wq);
301 0x6: decode MODRM_MOD {
302 0x3: MOVLHPS(Vq,VRq);
303 default: MOVHPS(Vq,Mq);
304 }
305 0x7: MOVHPS(Mq,Vq);
306 }
307 // repe (0xF3)
308 0x4: decode OPCODE_OP_BOTTOM3 {
309 0x0: WarnUnimpl::movss_Vd_Wd();
310 0x1: WarnUnimpl::movss_Wd_Vd();
311 0x2: WarnUnimpl::movsldup_Vo_Wo();
312 0x6: WarnUnimpl::movshdup_Vo_Wo();
313 default: UD2();
314 }
315 // operand size (0x66)
316 0x1: decode OPCODE_OP_BOTTOM3 {
317 0x0: MOVUPD(Vo,Wo);
318 0x1: MOVUPD(Wo,Vo);
319 0x2: MOVLPD(Vq,Mq);
320 0x3: MOVLPD(Mq,Vq);
321 0x4: UNPCKLPD(Vo,Wq);
322 0x5: UNPCKHPD(Vo,Wo);
323 0x6: MOVHPD(Vq,Mq);
324 0x7: MOVHPD(Mq,Vq);
325 }
326 // repne (0xF2)
327 0x8: decode OPCODE_OP_BOTTOM3 {
328 0x0: MOVSD(Vq,Wq);
329 0x1: MOVSD(Wq,Vq);
330 0x2: MOVDDUP(Vo,Wq);
331 default: UD2();
332 }
333 default: UD2();
334 }
335 0x03: decode OPCODE_OP_BOTTOM3 {
336 //group17();
337 0x0: decode MODRM_REG {
338 0x0: WarnUnimpl::prefetch_nta();
339 0x1: PREFETCH_T0(Mb);
340 0x2: WarnUnimpl::prefetch_t1();
341 0x3: WarnUnimpl::prefetch_t2();
342 default: HINT_NOP();
343 }
344 0x1: HINT_NOP();
345 0x2: HINT_NOP();
346 0x3: HINT_NOP();
347 0x4: HINT_NOP();
348 0x5: HINT_NOP();
349 0x6: HINT_NOP();
350 0x7: HINT_NOP();
351 }
352 0x04: decode LEGACY_DECODEVAL {
353 // no prefix
354 0x0: decode OPCODE_OP_BOTTOM3 {
355 0x0: MOV(Rd,Cd);
356 0x1: MOV(Rd,Dd);
357 0x2: MOV(Cd,Rd);
358 0x3: MOV(Dd,Rd);
359 0x4: WarnUnimpl::mov_Rd_Td();
360 0x6: WarnUnimpl::mov_Td_Rd();
361 default: UD2();
362 }
363 // lock prefix (0xF0)
364 0x2: decode OPCODE_OP_BOTTOM3 {
365 0x0: WarnUnimpl::mov_Rd_CR8D();
366 0x2: WarnUnimpl::mov_CR8D_Rd();
367 }
368 default: UD2();
369 }
370 }
371 0x05: decode LEGACY_DECODEVAL {
372 // no prefix
373 0x0: decode OPCODE_OP_BOTTOM3 {
374 //These moves should really use size o (octword), but
375 //because they are split in two, they use q (quadword).
376 0x0: Inst::MOVAPS(Vq,Wq);
377 0x1: Inst::MOVAPS(Wq,Vq);
378 0x2: Inst::CVTPI2PS(Vq,Qq);
379 0x3: movntps_Mo_Vo();
380 0x4: cvttps2pi_Pq_Wq();
381 0x5: cvtpS2pi_Pq_Wq();
382 0x6: ucomiss_Vd_Wd();
383 0x7: comiss_Vd_Wd();
384 }
385 // repe (0xF3)
386 0x4: decode OPCODE_OP_BOTTOM3 {
387 0x2: Inst::CVTSI2SS(Vd,Ed);
388 0x4: cvttss2si_Gd_Wd();
389 0x5: cvtss2si_Gd_Wd();
390 default: Inst::UD2();
391 }
392 // operand size (0x66)
393 0x1: decode OPCODE_OP_BOTTOM3 {
394 0x0: Inst::MOVAPD(Vo,Wo);
395 0x1: Inst::MOVAPD(Wo,Vo);
396 0x2: Inst::CVTPI2PD(Vo,Qq);
397 0x3: movntpd_Mo_Vo();
398 0x4: cvttpd2pi_Pq_Wo();
399 0x5: cvtpd2pi_Pq_Wo();
400 0x6: Inst::UCOMISD(Vq,Wq);
401 0x7: comisd_Vq_Wq();
402 }
403 // repne (0xF2)
404 0x8: decode OPCODE_OP_BOTTOM3 {
405 // The size of the V operand should be q, not dp
406 0x2: Inst::CVTSI2SD(Vdp,Edp);
407 // The size of the W operand should be q, not dp
408 0x4: Inst::CVTTSD2SI(Gdp,Wdp);
409 0x5: cvtsd2si_Gd_Wq();
410 default: Inst::UD2();
411 }
412 default: Inst::UD2();
413 }
414 0x06: decode OPCODE_OP_BOTTOM3 {
415 0x0: Inst::WRMSR();
416 0x1: Inst::RDTSC();
417 0x2: Inst::RDMSR();
418 0x3: rdpmc();
419#if FULL_SYSTEM
420 0x4: sysenter();
421#else
422 0x4: SyscallInst::sysenter('xc->syscall(Rax)', IsSyscall);
423#endif
424 0x5: sysexit();
425 0x6: Inst::UD2();
426 0x7: getsec();
427 }
428 0x07: decode OPCODE_OP_BOTTOM3 {
429 0x0: three_byte_opcode();
430 0x1: three_byte_opcode();
431 0x2: three_byte_opcode();
432 0x3: three_byte_opcode();
433 0x4: three_byte_opcode();
434 0x5: three_byte_opcode();
435 0x6: three_byte_opcode();
436 0x7: three_byte_opcode();
437 }
438 format Inst {
439 0x08: decode OPCODE_OP_BOTTOM3 {
440 0x0: CMOVO(Gv,Ev);
441 0x1: CMOVNO(Gv,Ev);
442 0x2: CMOVB(Gv,Ev);
443 0x3: CMOVNB(Gv,Ev);
444 0x4: CMOVZ(Gv,Ev);
445 0x5: CMOVNZ(Gv,Ev);
446 0x6: CMOVBE(Gv,Ev);
447 0x7: CMOVNBE(Gv,Ev);
448 }
449 0x09: decode OPCODE_OP_BOTTOM3 {
450 0x0: CMOVS(Gv,Ev);
451 0x1: CMOVNS(Gv,Ev);
452 0x2: CMOVP(Gv,Ev);
453 0x3: CMOVNP(Gv,Ev);
454 0x4: CMOVL(Gv,Ev);
455 0x5: CMOVNL(Gv,Ev);
456 0x6: CMOVLE(Gv,Ev);
457 0x7: CMOVNLE(Gv,Ev);
458 }
459 0x0A: decode LEGACY_DECODEVAL {
460 // no prefix
461 0x0: decode OPCODE_OP_BOTTOM3 {
462 0x0: WarnUnimpl::movmskps_Gd_VRo();
463 0x1: SQRTPS(Vo,Wo);
464 0x2: WarnUnimpl::rqsrtps_Vo_Wo();
465 0x3: WarnUnimpl::rcpps_Vo_Wo();
466 0x4: ANDPS(Vo,Wo);
467 0x5: ANDNPS(Vo,Wo);
468 0x6: ORPS(Vo,Wo);
469 0x7: XORPS(Vo,Wo);
470 }
471 // repe (0xF3)
472 0x4: decode OPCODE_OP_BOTTOM3 {
473 0x1: SQRTSS(Vd,Wd);
474 0x2: WarnUnimpl::rsqrtss_Vd_Wd();
475 0x3: WarnUnimpl::rcpss_Vd_Wd();
476 default: UD2();
477 }
478 // operand size (0x66)
479 0x1: decode OPCODE_OP_BOTTOM3 {
480 0x0: WarnUnimpl::movmskpd_Gd_VRo();
481 0x1: SQRTPD(Vo,Wo);
482 0x4: ANDPD(Vo,Wo);
483 0x5: ANDNPD(Vo,Wo);
484 0x6: ORPD(Vo,Wo);
485 //This really should be type o, but it works on q sized
486 //chunks at a time.
487 0x7: XORPD(Vq,Wq);
488 default: UD2();
489 }
490 // repne (0xF2)
491 0x8: decode OPCODE_OP_BOTTOM3 {
492 0x1: SQRTSD(Vq,Wq);
493 default: UD2();
494 }
495 default: UD2();
496 }
497 0x0B: decode LEGACY_DECODEVAL {
498 // no prefix
499 0x0: decode OPCODE_OP_BOTTOM3 {
500 0x0: ADDPS(Vo,Wo);
501 0x1: MULPS(Vo,Wo);
502 0x2: CVTPS2PD(Vo,Wq);
503 0x3: CVTDQ2PS(Vo,Wo);
504 0x4: SUBPS(Vo,Wo);
505 0x5: MINPS(Vo,Wo);
506 0x6: DIVPS(Vo,Wo);
507 0x7: MAXPS(Vo,Wo);
508 }
509 // repe (0xF3)
510 0x4: decode OPCODE_OP_BOTTOM3 {
511 0x0: ADDSS(Vd,Wd);
512 0x1: MULSS(Vd,Wd);
513 0x2: CVTSS2SD(Vq,Wd);
514 0x3: WarnUnimpl::cvttps2dq_Vo_Wo();
515 0x4: SUBSS(Vd,Wd);
516 0x5: MINSS(Vd,Wd);
517 0x6: DIVSS(Vd,Wd);
518 0x7: MAXSS(Vd,Wd);
519 }
520 // operand size (0x66)
521 0x1: decode OPCODE_OP_BOTTOM3 {
522 0x0: ADDPD(Vo,Wo);
523 0x1: MULPD(Vo,Wo);
524 0x2: CVTPD2PS(Vo,Wo);
525 0x3: WarnUnimpl::cvtps2dq_Vo_Wo();
526 0x4: SUBPD(Vo,Wo);
527 0x5: MINPD(Vo,Wo);
528 0x6: DIVPD(Vo,Wo);
529 0x7: MAXPD(Vo,Wo);
530 }
531 // repne (0xF2)
532 0x8: decode OPCODE_OP_BOTTOM3 {
533 0x0: ADDSD(Vq,Wq);
534 0x1: MULSD(Vq,Wq);
535 0x2: CVTSD2SS(Vd,Wq);
536 0x4: SUBSD(Vq,Wq);
537 0x5: MINSD(Vq,Wq);
538 0x6: DIVSD(Vq,Wq);
539 0x7: MAXSD(Vq,Wq);
540 default: UD2();
541 }
542 default: UD2();
543 }
544 0x0C: decode LEGACY_DECODEVAL {
545 // no prefix
546 0x0: decode OPCODE_OP_BOTTOM3 {
547 0x0: PUNPCKLBW(Pq,Qd);
548 0x1: PUNPCKLWD(Pq,Qd);
549 0x2: PUNPCKLDQ(Pq,Qd);
550 0x3: PACKSSWB(Pq,Qq);
551 0x4: PCMPGTB(Pq,Qq);
552 0x5: PCMPGTW(Pq,Qq);
553 0x6: PCMPGTD(Pq,Qq);
554 0x7: PACKUSWB(Pq,Qq);
555 }
556 // operand size (0x66)
557 0x1: decode OPCODE_OP_BOTTOM3 {
558 0x0: PUNPCKLBW(Vo,Wq);
559 0x1: PUNPCKLWD(Vo,Wq);
560 0x2: PUNPCKLDQ(Vo,Wq);
561 0x3: PACKSSWB(Vo,Wo);
562 0x4: PCMPGTB(Vo,Wo);
563 0x5: PCMPGTW(Vo,Wo);
564 0x6: PCMPGTD(Vo,Wo);
565 0x7: PACKUSWB(Vo,Wo);
566 }
567 default: UD2();
568 }
569 0x0D: decode LEGACY_DECODEVAL {
570 // no prefix
571 0x0: decode OPCODE_OP_BOTTOM3 {
572 0x0: PUNPCKHBW(Pq,Qq);
573 0x1: PUNPCKHWD(Pq,Qq);
574 0x2: PUNPCKHDQ(Pq,Qq);
575 0x3: PACKSSDW(Pq,Qq);
576 0x6: MOVD(Pq,Edp);
577 0x7: MOVQ(Pq,Qq);
578 default: UD2();
579 }
580 // repe (0xF3)
581 0x4: decode OPCODE_OP_BOTTOM3 {
582 0x7: WarnUnimpl::movdqu_Vo_Wo();
583 default: UD2();
584 }
585 // operand size (0x66)
586 0x1: decode OPCODE_OP_BOTTOM3 {
587 0x0: PUNPCKHBW(Vo,Wo);
588 0x1: PUNPCKHWD(Vo,Wo);
589 0x2: PUNPCKHDQ(Vo,Wo);
590 0x3: PACKSSDW(Vo,Wo);
591 0x4: PUNPCKLQDQ(Vo,Wq);
592 0x5: PUNPCKHQDQ(Vo,Wq);
593 0x6: WarnUnimpl::movd_Vo_Ed();
594 0x7: WarnUnimpl::movdqa_Vo_Wo();
595 }
596 default: UD2();
597 }
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: Inst::LLDT(Ew);
97 0x3: Inst::LTR(Ew);
98 0x4: verr_Mw_or_Rv();
99 0x5: verw_Mw_or_Rv();
100 //0x6: jmpe_Ev(); // IA-64
101 default: Inst::UD2();
102 }
103 //0x01: group7(); // Ugly, ugly, ugly...
104 0x01: decode MODRM_MOD {
105 0x3: decode MODRM_REG {
106 0x0: decode MODRM_RM {
107 0x1: vmcall();
108 0x2: vmlaunch();
109 0x3: vmresume();
110 0x4: vmxoff();
111 default: Inst::UD2();
112 }
113 0x1: decode MODRM_RM {
114 0x0: monitor();
115 0x1: mwait();
116 default: Inst::UD2();
117 }
118 0x3: decode MODRM_RM {
119 0x0: vmrun();
120 0x1: vmmcall();
121 0x2: vmload();
122 0x3: vmsave();
123 0x4: stgi();
124 0x5: clgi();
125 0x6: skinit();
126 0x7: invlpga();
127 }
128 0x4: Inst::SMSW(Rv);
129 0x6: Inst::LMSW(Rv);
130 0x7: decode MODRM_RM {
131 0x0: Inst::SWAPGS();
132 0x1: rdtscp();
133 default: Inst::UD2();
134 }
135 default: Inst::UD2();
136 }
137 default: decode MODRM_REG {
138 0x0: sgdt_Ms();
139 0x1: sidt_Ms();
140 0x2: decode MODE_SUBMODE {
141 0x0: Inst::LGDT(M);
142 default: decode OPSIZE {
143 // 16 bit operand sizes are special, but only
144 // in legacy and compatability modes.
145 0x2: Inst::LGDT_16(M);
146 default: Inst::LGDT(M);
147 }
148 }
149 0x3: decode MODE_SUBMODE {
150 0x0: Inst::LIDT(M);
151 default: decode OPSIZE {
152 // 16 bit operand sizes are special, but only
153 // in legacy and compatability modes.
154 0x2: Inst::LIDT_16(M);
155 default: Inst::LIDT(M);
156 }
157 }
158 0x4: Inst::SMSW(Mw);
159 0x6: Inst::LMSW(Mw);
160 0x7: Inst::INVLPG(M);
161 default: Inst::UD2();
162 }
163 }
164 0x02: lar_Gv_Ew();
165 0x03: lsl_Gv_Ew();
166 // sandpile.org doesn't seem to know what this is...? We'll
167 // use it for pseudo instructions. We've got 16 bits of space
168 // to play with so there can be quite a few pseudo
169 // instructions.
170 //0x04: loadall_or_reset_or_hang();
171 0x4: decode IMMEDIATE {
172 format BasicOperate {
173#if FULL_SYSTEM
174 0x00: m5arm({{
175 PseudoInst::arm(xc->tcBase());
176 }}, IsNonSpeculative);
177 0x01: m5quiesce({{
178 PseudoInst::quiesce(xc->tcBase());
179 }}, IsNonSpeculative);
180 0x02: m5quiesceNs({{
181 PseudoInst::quiesceNs(xc->tcBase(), Rdi);
182 }}, IsNonSpeculative);
183 0x03: m5quiesceCycle({{
184 PseudoInst::quiesceCycles(xc->tcBase(), Rdi);
185 }}, IsNonSpeculative);
186 0x04: m5quiesceTime({{
187 Rax = PseudoInst::quiesceTime(xc->tcBase());
188 }}, IsNonSpeculative);
189#endif
190 0x07: m5rpns({{
191 Rax = PseudoInst::rpns(xc->tcBase());
192 }}, IsNonSpeculative);
193 0x21: m5exit({{
194 PseudoInst::m5exit(xc->tcBase(), Rdi);
195 }}, IsNonSpeculative);
196#if FULL_SYSTEM
197 0x30: m5initparam({{
198 Rax = xc->tcBase()->getCpuPtr()->
199 system->init_param;
200 }}, IsNonSpeculative);
201 0x31: m5loadsymbol({{
202 PseudoInst::loadsymbol(xc->tcBase());
203 }}, IsNonSpeculative);
204#endif
205 0x40: m5resetstats({{
206 PseudoInst::resetstats(xc->tcBase(), Rdi, Rsi);
207 }}, IsNonSpeculative);
208 0x41: m5dumpstats({{
209 PseudoInst::dumpstats(xc->tcBase(), Rdi, Rsi);
210 }}, IsNonSpeculative);
211 0x42: m5dumpresetstats({{
212 PseudoInst::dumpresetstats(xc->tcBase(), Rdi, Rsi);
213 }}, IsNonSpeculative);
214 0x43: m5checkpoint({{
215 PseudoInst::m5checkpoint(xc->tcBase(), Rdi, Rsi);
216 }}, IsNonSpeculative);
217#if FULL_SYSTEM
218 0x50: m5readfile({{
219 Rax = PseudoInst::readfile(
220 xc->tcBase(), Rdi, Rsi, Rdx);
221 }}, IsNonSpeculative);
222#endif
223 0x51: m5debugbreak({{
224 PseudoInst::debugbreak(xc->tcBase());
225 }}, IsNonSpeculative);
226 0x52: m5switchcpu({{
227 PseudoInst::switchcpu(xc->tcBase());
228 }}, IsNonSpeculative);
229#if FULL_SYSTEM
230 0x53: m5addsymbol({{
231 PseudoInst::addsymbol(xc->tcBase(), Rdi, Rsi);
232 }}, IsNonSpeculative);
233#endif
234 0x54: m5panic({{
235 panic("M5 panic instruction called at pc=%#x.\n",
236 xc->readPC());
237 }}, IsNonSpeculative);
238 0x55: m5reserved1({{
239 warn("M5 reserved opcode 1 ignored.\n");
240 }}, IsNonSpeculative);
241 0x56: m5reserved2({{
242 warn("M5 reserved opcode 2 ignored.\n");
243 }}, IsNonSpeculative);
244 0x57: m5reserved3({{
245 warn("M5 reserved opcode 3 ignored.\n");
246 }}, IsNonSpeculative);
247 0x58: m5reserved4({{
248 warn("M5 reserved opcode 4 ignored.\n");
249 }}, IsNonSpeculative);
250 0x59: m5reserved5({{
251 warn("M5 reserved opcode 5 ignored.\n");
252 }}, IsNonSpeculative);
253 default: Inst::UD2();
254 }
255 }
256#if FULL_SYSTEM
257 0x05: decode MODE_MODE {
258 0x0: decode MODE_SUBMODE {
259 0x0: Inst::SYSCALL_64();
260 0x1: Inst::SYSCALL_COMPAT();
261 }
262 0x1: Inst::SYSCALL_LEGACY();
263 }
264#else
265 0x05: SyscallInst::syscall('xc->syscall(Rax)', IsSyscall);
266#endif
267 0x06: Inst::CLTS();
268 0x07: decode MODE_SUBMODE {
269 0x0: decode OPSIZE {
270 // Return to 64 bit mode.
271 0x8: Inst::SYSRET_TO_64();
272 // Return to compatibility mode.
273 default: Inst::SYSRET_TO_COMPAT();
274 }
275 default: Inst::SYSRET_NON_64();
276 }
277 }
278 0x01: decode OPCODE_OP_BOTTOM3 {
279 0x0: invd();
280 0x1: wbinvd();
281 0x2: Inst::UD2();
282 0x3: Inst::UD2();
283 0x4: Inst::UD2();
284 0x5: Inst::PREFETCH(Mb);
285 0x6: FailUnimpl::femms();
286 0x7: FailUnimpl::threednow();
287 }
288 format Inst{
289 0x02: decode LEGACY_DECODEVAL {
290 // no prefix
291 0x0: decode OPCODE_OP_BOTTOM3 {
292 0x0: MOVUPS(Vo,Wo);
293 0x1: MOVUPS(Wo,Vo);
294 0x2: decode MODRM_MOD {
295 0x3: MOVHLPS(Vq,VRq);
296 default: MOVLPS(Vq,Mq);
297 }
298 0x3: MOVLPS(Mq,Vq);
299 0x4: UNPCKLPS(Vps,Wq);
300 0x5: UNPCKHPS(Vpd,Wq);
301 0x6: decode MODRM_MOD {
302 0x3: MOVLHPS(Vq,VRq);
303 default: MOVHPS(Vq,Mq);
304 }
305 0x7: MOVHPS(Mq,Vq);
306 }
307 // repe (0xF3)
308 0x4: decode OPCODE_OP_BOTTOM3 {
309 0x0: WarnUnimpl::movss_Vd_Wd();
310 0x1: WarnUnimpl::movss_Wd_Vd();
311 0x2: WarnUnimpl::movsldup_Vo_Wo();
312 0x6: WarnUnimpl::movshdup_Vo_Wo();
313 default: UD2();
314 }
315 // operand size (0x66)
316 0x1: decode OPCODE_OP_BOTTOM3 {
317 0x0: MOVUPD(Vo,Wo);
318 0x1: MOVUPD(Wo,Vo);
319 0x2: MOVLPD(Vq,Mq);
320 0x3: MOVLPD(Mq,Vq);
321 0x4: UNPCKLPD(Vo,Wq);
322 0x5: UNPCKHPD(Vo,Wo);
323 0x6: MOVHPD(Vq,Mq);
324 0x7: MOVHPD(Mq,Vq);
325 }
326 // repne (0xF2)
327 0x8: decode OPCODE_OP_BOTTOM3 {
328 0x0: MOVSD(Vq,Wq);
329 0x1: MOVSD(Wq,Vq);
330 0x2: MOVDDUP(Vo,Wq);
331 default: UD2();
332 }
333 default: UD2();
334 }
335 0x03: decode OPCODE_OP_BOTTOM3 {
336 //group17();
337 0x0: decode MODRM_REG {
338 0x0: WarnUnimpl::prefetch_nta();
339 0x1: PREFETCH_T0(Mb);
340 0x2: WarnUnimpl::prefetch_t1();
341 0x3: WarnUnimpl::prefetch_t2();
342 default: HINT_NOP();
343 }
344 0x1: HINT_NOP();
345 0x2: HINT_NOP();
346 0x3: HINT_NOP();
347 0x4: HINT_NOP();
348 0x5: HINT_NOP();
349 0x6: HINT_NOP();
350 0x7: HINT_NOP();
351 }
352 0x04: decode LEGACY_DECODEVAL {
353 // no prefix
354 0x0: decode OPCODE_OP_BOTTOM3 {
355 0x0: MOV(Rd,Cd);
356 0x1: MOV(Rd,Dd);
357 0x2: MOV(Cd,Rd);
358 0x3: MOV(Dd,Rd);
359 0x4: WarnUnimpl::mov_Rd_Td();
360 0x6: WarnUnimpl::mov_Td_Rd();
361 default: UD2();
362 }
363 // lock prefix (0xF0)
364 0x2: decode OPCODE_OP_BOTTOM3 {
365 0x0: WarnUnimpl::mov_Rd_CR8D();
366 0x2: WarnUnimpl::mov_CR8D_Rd();
367 }
368 default: UD2();
369 }
370 }
371 0x05: decode LEGACY_DECODEVAL {
372 // no prefix
373 0x0: decode OPCODE_OP_BOTTOM3 {
374 //These moves should really use size o (octword), but
375 //because they are split in two, they use q (quadword).
376 0x0: Inst::MOVAPS(Vq,Wq);
377 0x1: Inst::MOVAPS(Wq,Vq);
378 0x2: Inst::CVTPI2PS(Vq,Qq);
379 0x3: movntps_Mo_Vo();
380 0x4: cvttps2pi_Pq_Wq();
381 0x5: cvtpS2pi_Pq_Wq();
382 0x6: ucomiss_Vd_Wd();
383 0x7: comiss_Vd_Wd();
384 }
385 // repe (0xF3)
386 0x4: decode OPCODE_OP_BOTTOM3 {
387 0x2: Inst::CVTSI2SS(Vd,Ed);
388 0x4: cvttss2si_Gd_Wd();
389 0x5: cvtss2si_Gd_Wd();
390 default: Inst::UD2();
391 }
392 // operand size (0x66)
393 0x1: decode OPCODE_OP_BOTTOM3 {
394 0x0: Inst::MOVAPD(Vo,Wo);
395 0x1: Inst::MOVAPD(Wo,Vo);
396 0x2: Inst::CVTPI2PD(Vo,Qq);
397 0x3: movntpd_Mo_Vo();
398 0x4: cvttpd2pi_Pq_Wo();
399 0x5: cvtpd2pi_Pq_Wo();
400 0x6: Inst::UCOMISD(Vq,Wq);
401 0x7: comisd_Vq_Wq();
402 }
403 // repne (0xF2)
404 0x8: decode OPCODE_OP_BOTTOM3 {
405 // The size of the V operand should be q, not dp
406 0x2: Inst::CVTSI2SD(Vdp,Edp);
407 // The size of the W operand should be q, not dp
408 0x4: Inst::CVTTSD2SI(Gdp,Wdp);
409 0x5: cvtsd2si_Gd_Wq();
410 default: Inst::UD2();
411 }
412 default: Inst::UD2();
413 }
414 0x06: decode OPCODE_OP_BOTTOM3 {
415 0x0: Inst::WRMSR();
416 0x1: Inst::RDTSC();
417 0x2: Inst::RDMSR();
418 0x3: rdpmc();
419#if FULL_SYSTEM
420 0x4: sysenter();
421#else
422 0x4: SyscallInst::sysenter('xc->syscall(Rax)', IsSyscall);
423#endif
424 0x5: sysexit();
425 0x6: Inst::UD2();
426 0x7: getsec();
427 }
428 0x07: decode OPCODE_OP_BOTTOM3 {
429 0x0: three_byte_opcode();
430 0x1: three_byte_opcode();
431 0x2: three_byte_opcode();
432 0x3: three_byte_opcode();
433 0x4: three_byte_opcode();
434 0x5: three_byte_opcode();
435 0x6: three_byte_opcode();
436 0x7: three_byte_opcode();
437 }
438 format Inst {
439 0x08: decode OPCODE_OP_BOTTOM3 {
440 0x0: CMOVO(Gv,Ev);
441 0x1: CMOVNO(Gv,Ev);
442 0x2: CMOVB(Gv,Ev);
443 0x3: CMOVNB(Gv,Ev);
444 0x4: CMOVZ(Gv,Ev);
445 0x5: CMOVNZ(Gv,Ev);
446 0x6: CMOVBE(Gv,Ev);
447 0x7: CMOVNBE(Gv,Ev);
448 }
449 0x09: decode OPCODE_OP_BOTTOM3 {
450 0x0: CMOVS(Gv,Ev);
451 0x1: CMOVNS(Gv,Ev);
452 0x2: CMOVP(Gv,Ev);
453 0x3: CMOVNP(Gv,Ev);
454 0x4: CMOVL(Gv,Ev);
455 0x5: CMOVNL(Gv,Ev);
456 0x6: CMOVLE(Gv,Ev);
457 0x7: CMOVNLE(Gv,Ev);
458 }
459 0x0A: decode LEGACY_DECODEVAL {
460 // no prefix
461 0x0: decode OPCODE_OP_BOTTOM3 {
462 0x0: WarnUnimpl::movmskps_Gd_VRo();
463 0x1: SQRTPS(Vo,Wo);
464 0x2: WarnUnimpl::rqsrtps_Vo_Wo();
465 0x3: WarnUnimpl::rcpps_Vo_Wo();
466 0x4: ANDPS(Vo,Wo);
467 0x5: ANDNPS(Vo,Wo);
468 0x6: ORPS(Vo,Wo);
469 0x7: XORPS(Vo,Wo);
470 }
471 // repe (0xF3)
472 0x4: decode OPCODE_OP_BOTTOM3 {
473 0x1: SQRTSS(Vd,Wd);
474 0x2: WarnUnimpl::rsqrtss_Vd_Wd();
475 0x3: WarnUnimpl::rcpss_Vd_Wd();
476 default: UD2();
477 }
478 // operand size (0x66)
479 0x1: decode OPCODE_OP_BOTTOM3 {
480 0x0: WarnUnimpl::movmskpd_Gd_VRo();
481 0x1: SQRTPD(Vo,Wo);
482 0x4: ANDPD(Vo,Wo);
483 0x5: ANDNPD(Vo,Wo);
484 0x6: ORPD(Vo,Wo);
485 //This really should be type o, but it works on q sized
486 //chunks at a time.
487 0x7: XORPD(Vq,Wq);
488 default: UD2();
489 }
490 // repne (0xF2)
491 0x8: decode OPCODE_OP_BOTTOM3 {
492 0x1: SQRTSD(Vq,Wq);
493 default: UD2();
494 }
495 default: UD2();
496 }
497 0x0B: decode LEGACY_DECODEVAL {
498 // no prefix
499 0x0: decode OPCODE_OP_BOTTOM3 {
500 0x0: ADDPS(Vo,Wo);
501 0x1: MULPS(Vo,Wo);
502 0x2: CVTPS2PD(Vo,Wq);
503 0x3: CVTDQ2PS(Vo,Wo);
504 0x4: SUBPS(Vo,Wo);
505 0x5: MINPS(Vo,Wo);
506 0x6: DIVPS(Vo,Wo);
507 0x7: MAXPS(Vo,Wo);
508 }
509 // repe (0xF3)
510 0x4: decode OPCODE_OP_BOTTOM3 {
511 0x0: ADDSS(Vd,Wd);
512 0x1: MULSS(Vd,Wd);
513 0x2: CVTSS2SD(Vq,Wd);
514 0x3: WarnUnimpl::cvttps2dq_Vo_Wo();
515 0x4: SUBSS(Vd,Wd);
516 0x5: MINSS(Vd,Wd);
517 0x6: DIVSS(Vd,Wd);
518 0x7: MAXSS(Vd,Wd);
519 }
520 // operand size (0x66)
521 0x1: decode OPCODE_OP_BOTTOM3 {
522 0x0: ADDPD(Vo,Wo);
523 0x1: MULPD(Vo,Wo);
524 0x2: CVTPD2PS(Vo,Wo);
525 0x3: WarnUnimpl::cvtps2dq_Vo_Wo();
526 0x4: SUBPD(Vo,Wo);
527 0x5: MINPD(Vo,Wo);
528 0x6: DIVPD(Vo,Wo);
529 0x7: MAXPD(Vo,Wo);
530 }
531 // repne (0xF2)
532 0x8: decode OPCODE_OP_BOTTOM3 {
533 0x0: ADDSD(Vq,Wq);
534 0x1: MULSD(Vq,Wq);
535 0x2: CVTSD2SS(Vd,Wq);
536 0x4: SUBSD(Vq,Wq);
537 0x5: MINSD(Vq,Wq);
538 0x6: DIVSD(Vq,Wq);
539 0x7: MAXSD(Vq,Wq);
540 default: UD2();
541 }
542 default: UD2();
543 }
544 0x0C: decode LEGACY_DECODEVAL {
545 // no prefix
546 0x0: decode OPCODE_OP_BOTTOM3 {
547 0x0: PUNPCKLBW(Pq,Qd);
548 0x1: PUNPCKLWD(Pq,Qd);
549 0x2: PUNPCKLDQ(Pq,Qd);
550 0x3: PACKSSWB(Pq,Qq);
551 0x4: PCMPGTB(Pq,Qq);
552 0x5: PCMPGTW(Pq,Qq);
553 0x6: PCMPGTD(Pq,Qq);
554 0x7: PACKUSWB(Pq,Qq);
555 }
556 // operand size (0x66)
557 0x1: decode OPCODE_OP_BOTTOM3 {
558 0x0: PUNPCKLBW(Vo,Wq);
559 0x1: PUNPCKLWD(Vo,Wq);
560 0x2: PUNPCKLDQ(Vo,Wq);
561 0x3: PACKSSWB(Vo,Wo);
562 0x4: PCMPGTB(Vo,Wo);
563 0x5: PCMPGTW(Vo,Wo);
564 0x6: PCMPGTD(Vo,Wo);
565 0x7: PACKUSWB(Vo,Wo);
566 }
567 default: UD2();
568 }
569 0x0D: decode LEGACY_DECODEVAL {
570 // no prefix
571 0x0: decode OPCODE_OP_BOTTOM3 {
572 0x0: PUNPCKHBW(Pq,Qq);
573 0x1: PUNPCKHWD(Pq,Qq);
574 0x2: PUNPCKHDQ(Pq,Qq);
575 0x3: PACKSSDW(Pq,Qq);
576 0x6: MOVD(Pq,Edp);
577 0x7: MOVQ(Pq,Qq);
578 default: UD2();
579 }
580 // repe (0xF3)
581 0x4: decode OPCODE_OP_BOTTOM3 {
582 0x7: WarnUnimpl::movdqu_Vo_Wo();
583 default: UD2();
584 }
585 // operand size (0x66)
586 0x1: decode OPCODE_OP_BOTTOM3 {
587 0x0: PUNPCKHBW(Vo,Wo);
588 0x1: PUNPCKHWD(Vo,Wo);
589 0x2: PUNPCKHDQ(Vo,Wo);
590 0x3: PACKSSDW(Vo,Wo);
591 0x4: PUNPCKLQDQ(Vo,Wq);
592 0x5: PUNPCKHQDQ(Vo,Wq);
593 0x6: WarnUnimpl::movd_Vo_Ed();
594 0x7: WarnUnimpl::movdqa_Vo_Wo();
595 }
596 default: UD2();
597 }
598 }
599 0x0E: decode LEGACY_DECODEVAL {
600 // no prefix
601 0x0: decode OPCODE_OP_BOTTOM3 {
602 0x0: pshufw_Pq_Qq_Ib();
603 //0x1: group13_pshimw();
604 0x1: decode MODRM_REG {
605 0x2: decode LEGACY_OP {
606 0x0: psrlw_PRq_Ib();
607 0x1: psrlw_VRo_Ib();
598 0x0E: decode LEGACY_DECODEVAL {
599 // no prefix
600 0x0: decode OPCODE_OP_BOTTOM3 {
601 0x0: WarnUnimpl::pshufw_Pq_Qq_Ib();
602 //0x1: group13_pshimw();
603 0x1: decode MODRM_REG {
604 0x2: decode LEGACY_OP {
605 0x0: PSRLW(PRq,Ib);
606 0x1: PSRLW(VRo,Ib);
607 }
608 0x4: decode LEGACY_OP {
609 0x0: PSRAW(PRq,Ib);
610 0x1: PSRAW(VRo,Ib);
611 }
612 0x6: decode LEGACY_OP {
613 0x0: PSLLW(PRq,Ib);
614 0x1: PSLLW(VRo,Ib);
615 }
616 default: UD2();
608 }
617 }
609 0x4: decode LEGACY_OP {
610 0x0: psraw_PRq_Ib();
611 0x1: psraw_VRo_Ib();
618 //0x2: group14_pshimd();
619 0x2: decode MODRM_REG {
620 0x2: decode LEGACY_OP {
621 0x0: PSRLD(PRq,Ib);
622 0x1: PSRLD(VRo,Ib);
623 }
624 0x4: decode LEGACY_OP {
625 0x0: PSRAD(PRq,Ib);
626 0x1: PSRAD(VRo,Ib);
627 }
628 0x6: decode LEGACY_OP {
629 0x0: PSLLD(PRq,Ib);
630 0x1: PSLLD(VRo,Ib);
631 }
632 default: UD2();
612 }
633 }
613 0x6: decode LEGACY_OP {
614 0x0: psllw_PRq_Ib();
615 0x1: psllw_VRo_Ib();
634 //0x3: group15_pshimq();
635 0x3: decode MODRM_REG {
636 0x2: decode LEGACY_OP {
637 0x0: PSRLQ(PRq,Ib);
638 0x1: PSRLQ(VRo,Ib);
639 }
640 0x3: decode LEGACY_OP {
641 0x0: UD2();
642 0x1: WarnUnimpl::psrldq_VRo_Ib();
643 }
644 0x6: decode LEGACY_OP {
645 0x0: PSLLQ(PRq,Ib);
646 0x1: PSLLQ(VRo,Ib);
647 }
648 0x7: decode LEGACY_OP {
649 0x0: UD2();
650 0x1: WarnUnimpl::pslldq_VRo_Ib();
651 }
652 default: Inst::UD2();
616 }
653 }
617 default: Inst::UD2();
654 0x4: Inst::PCMPEQB(Pq,Qq);
655 0x5: Inst::PCMPEQW(Pq,Qq);
656 0x6: Inst::PCMPEQD(Pq,Qq);
657 0x7: WarnUnimpl::emms();
618 }
658 }
619 //0x2: group14_pshimd();
620 0x2: decode MODRM_REG {
621 0x2: decode LEGACY_OP {
622 0x0: psrld_PRq_Ib();
623 0x1: psrld_VRo_Ib();
624 }
625 0x4: decode LEGACY_OP {
626 0x0: psrad_PRq_Ib();
627 0x1: psrad_VRo_Ib();
628 }
629 0x6: decode LEGACY_OP {
630 0x0: pslld_PRq_Ib();
631 0x1: pslld_VRo_Ib();
632 }
633 default: Inst::UD2();
659 // repe (0xF3)
660 0x4: decode OPCODE_OP_BOTTOM3 {
661 0x0: WarnUnimpl::pshufhw_Vo_Wo_Ib();
662 default: UD2();
634 }
663 }
635 //0x3: group15_pshimq();
636 0x3: decode MODRM_REG {
637 0x2: decode LEGACY_OP {
638 0x0: psrlq_PRq_Ib();
639 0x1: psrlq_VRo_Ib();
664 // operand size (0x66)
665 0x1: decode OPCODE_OP_BOTTOM3 {
666 0x0: WarnUnimpl::pshufd_Vo_Wo_Ib();
667 //0x1: group13_pshimw();
668 0x1: decode MODRM_REG {
669 0x2: decode LEGACY_OP {
670 0x0: PSRLW(PRq,Ib);
671 0x1: PSRLW(VRo,Ib);
672 }
673 0x4: decode LEGACY_OP {
674 0x0: PSRAW(PRq,Ib);
675 0x1: PSRAW(VRo,Ib);
676 }
677 0x6: decode LEGACY_OP {
678 0x0: PSLLW(PRq,Ib);
679 0x1: PSLLW(VRo,Ib);
680 }
681 default: Inst::UD2();
640 }
682 }
641 0x3: decode LEGACY_OP {
642 0x0: Inst::UD2();
643 0x1: psrldq_VRo_Ib();
683 //0x2: group14_pshimd();
684 0x2: decode MODRM_REG {
685 0x2: decode LEGACY_OP {
686 0x0: PSRLD(PRq,Ib);
687 0x1: PSRLD(VRo,Ib);
688 }
689 0x4: decode LEGACY_OP {
690 0x0: PSRAD(PRq,Ib);
691 0x1: PSRAD(VRo,Ib);
692 }
693 0x6: decode LEGACY_OP {
694 0x0: PSLLD(PRq,Ib);
695 0x1: PSLLD(VRo,Ib);
696 }
697 default: UD2();
644 }
698 }
645 0x6: decode LEGACY_OP {
646 0x0: psllq_PRq_Ib();
647 0x1: psllq_VRo_Ib();
699 //0x3: group15_pshimq();
700 0x3: decode MODRM_REG {
701 0x2: decode LEGACY_OP {
702 0x0: PSRLQ(PRq,Ib);
703 0x1: PSRLQ(VRo,Ib);
704 }
705 0x3: decode LEGACY_OP {
706 0x0: UD2();
707 0x1: WarnUnimpl::psrldq_VRo_Ib();
708 }
709 0x6: decode LEGACY_OP {
710 0x0: PSLLQ(PRq,Ib);
711 0x1: PSLLQ(VRo,Ib);
712 }
713 0x7: decode LEGACY_OP {
714 0x0: UD2();
715 0x1: WarnUnimpl::pslldq_VRo_Ib();
716 }
717 default: UD2();
648 }
718 }
649 0x7: decode LEGACY_OP {
650 0x0: Inst::UD2();
651 0x1: pslldq_VRo_Ib();
652 }
653 default: Inst::UD2();
719 0x4: PCMPEQB(Vo,Wo);
720 0x5: PCMPEQW(Vo,Wo);
721 0x6: PCMPEQD(Vo,Wo);
722 default: UD2();
654 }
723 }
655 0x4: Inst::PCMPEQB(Pq,Qq);
656 0x5: Inst::PCMPEQW(Pq,Qq);
657 0x6: Inst::PCMPEQD(Pq,Qq);
658 0x7: emms();
724 // repne (0xF2)
725 0x8: decode OPCODE_OP_BOTTOM3 {
726 0x0: WarnUnimpl::pshuflw_Vo_Wo_Ib();
727 default: UD2();
728 }
729 default: UD2();
659 }
730 }
660 // repe (0xF3)
661 0x4: decode OPCODE_OP_BOTTOM3 {
662 0x0: pshufhw_Vo_Wo_Ib();
663 default: Inst::UD2();
664 }
665 // operand size (0x66)
666 0x1: decode OPCODE_OP_BOTTOM3 {
667 0x0: pshufd_Vo_Wo_Ib();
668 //0x1: group13_pshimw();
669 0x1: decode MODRM_REG {
670 0x2: decode LEGACY_OP {
671 0x0: psrlw_PRq_Ib();
672 0x1: psrlw_VRo_Ib();
673 }
674 0x4: decode LEGACY_OP {
675 0x0: psraw_PRq_Ib();
676 0x1: psraw_VRo_Ib();
677 }
678 0x6: decode LEGACY_OP {
679 0x0: psllw_PRq_Ib();
680 0x1: psllw_VRo_Ib();
681 }
682 default: Inst::UD2();
731 0x0F: decode LEGACY_DECODEVAL {
732 // no prefix
733 0x0: decode OPCODE_OP_BOTTOM3 {
734 0x0: WarnUnimpl::vmread_Ed_or_Eq_Gd_or_Gq();
735 0x1: WarnUnimpl::vmwrite_Gd_or_Gq_Ed_or_Eq();
736 0x6: MOVD(Edp,Pdp);
737 0x7: MOVQ(Qq,Pq);
738 default: UD2();
683 }
739 }
684 //0x2: group14_pshimd();
685 0x2: decode MODRM_REG {
686 0x2: decode LEGACY_OP {
687 0x0: psrld_PRq_Ib();
688 0x1: psrld_VRo_Ib();
689 }
690 0x4: decode LEGACY_OP {
691 0x0: psrad_PRq_Ib();
692 0x1: psrad_VRo_Ib();
693 }
694 0x6: decode LEGACY_OP {
695 0x0: pslld_PRq_Ib();
696 0x1: pslld_VRo_Ib();
697 }
698 default: Inst::UD2();
740 // repe (0xF3)
741 0x4: decode OPCODE_OP_BOTTOM3 {
742 0x6: MOVQ(Vq,Wq);
743 0x7: WarnUnimpl::movdqu_Wo_Vo();
744 default: UD2();
699 }
745 }
700 //0x3: group15_pshimq();
701 0x3: decode MODRM_REG {
702 0x2: decode LEGACY_OP {
703 0x0: psrlq_PRq_Ib();
704 0x1: psrlq_VRo_Ib();
705 }
706 0x3: decode LEGACY_OP {
707 0x0: Inst::UD2();
708 0x1: psrldq_VRo_Ib();
709 }
710 0x6: decode LEGACY_OP {
711 0x0: psllq_PRq_Ib();
712 0x1: psllq_VRo_Ib();
713 }
714 0x7: decode LEGACY_OP {
715 0x0: Inst::UD2();
716 0x1: pslldq_VRo_Ib();
717 }
718 default: Inst::UD2();
746 // operand size (0x66)
747 0x1: decode OPCODE_OP_BOTTOM3 {
748 0x4: WarnUnimpl::haddpd_Vo_Wo();
749 0x5: WarnUnimpl::hsubpd_Vo_Wo();
750 0x6: WarnUnimpl::movd_Ed_Vd();
751 0x7: WarnUnimpl::movdqa_Wo_Vo();
752 default: UD2();
719 }
753 }
720 0x4: Inst::PCMPEQB(Vo,Wo);
721 0x5: Inst::PCMPEQW(Vo,Wo);
722 0x6: Inst::PCMPEQD(Vo,Wo);
723 default: Inst::UD2();
754 // repne (0xF2)
755 0x8: decode OPCODE_OP_BOTTOM3 {
756 0x4: WarnUnimpl::haddps_Vo_Wo();
757 0x5: WarnUnimpl::hsubps_Vo_Wo();
758 default: UD2();
759 }
760 default: UD2();
724 }
761 }
725 // repne (0xF2)
726 0x8: decode OPCODE_OP_BOTTOM3 {
727 0x0: pshuflw_Vo_Wo_Ib();
728 default: Inst::UD2();
729 }
730 default: Inst::UD2();
731 }
732 0x0F: decode LEGACY_DECODEVAL {
733 // no prefix
734 0x0: decode OPCODE_OP_BOTTOM3 {
735 0x0: vmread_Ed_or_Eq_Gd_or_Gq();
736 0x1: vmwrite_Gd_or_Gq_Ed_or_Eq();
737 0x6: Inst::MOVD(Edp,Pdp);
738 0x7: Inst::MOVQ(Qq,Pq);
739 default: Inst::UD2();
740 }
741 // repe (0xF3)
742 0x4: decode OPCODE_OP_BOTTOM3 {
743 0x6: Inst::MOVQ(Vq,Wq);
744 0x7: movdqu_Wo_Vo();
745 default: Inst::UD2();
746 }
747 // operand size (0x66)
748 0x1: decode OPCODE_OP_BOTTOM3 {
749 0x4: haddpd_Vo_Wo();
750 0x5: hsubpd_Vo_Wo();
751 0x6: movd_Ed_Vd();
752 0x7: movdqa_Wo_Vo();
753 default: Inst::UD2();
754 }
755 // repne (0xF2)
756 0x8: decode OPCODE_OP_BOTTOM3 {
757 0x4: haddps_Vo_Wo();
758 0x5: hsubps_Vo_Wo();
759 default: Inst::UD2();
760 }
761 default: Inst::UD2();
762 }
763 format Inst {
764 0x10: decode OPCODE_OP_BOTTOM3 {
765 0x0: JO(Jz);
766 0x1: JNO(Jz);
767 0x2: JB(Jz);
768 0x3: JNB(Jz);
769 0x4: JZ(Jz);
770 0x5: JNZ(Jz);
771 0x6: JBE(Jz);
772 0x7: JNBE(Jz);
773 }
774 0x11: decode OPCODE_OP_BOTTOM3 {
775 0x0: JS(Jz);
776 0x1: JNS(Jz);
777 0x2: JP(Jz);
778 0x3: JNP(Jz);
779 0x4: JL(Jz);
780 0x5: JNL(Jz);
781 0x6: JLE(Jz);
782 0x7: JNLE(Jz);
783 }
784 0x12: decode OPCODE_OP_BOTTOM3 {
785 0x0: SETO(Eb);
786 0x1: SETNO(Eb);
787 0x2: SETB(Eb);
788 0x3: SETNB(Eb);
789 0x4: SETZ(Eb);
790 0x5: SETNZ(Eb);
791 0x6: SETBE(Eb);
792 0x7: SETNBE(Eb);
793 }
794 0x13: decode OPCODE_OP_BOTTOM3 {
795 0x0: SETS(Eb);
796 0x1: SETNS(Eb);
797 0x2: SETP(Eb);
798 0x3: SETNP(Eb);
799 0x4: SETL(Eb);
800 0x5: SETNL(Eb);
801 0x6: SETLE(Eb);
802 0x7: SETNLE(Eb);
803 }
804 }
805 0x14: decode OPCODE_OP_BOTTOM3 {
806 0x0: push_fs();
807 0x1: pop_fs();
808 0x2: CPUIDInst::CPUID({{
809 CpuidResult result;
810 success = doCpuid(xc->tcBase(), bits(Rax, 31, 0), result);
811 Rax = result.rax;
812 Rbx = result.rbx;
813 Rcx = result.rcx;
814 Rdx = result.rdx;
815 }});
816 0x3: Inst::BT(Ev,Gv);
817 0x4: Inst::SHLD(Ev,Gv,Ib);
818 0x5: Inst::SHLD(Ev,Gv);
819 0x6: xbts_and_cmpxchg();
820 0x7: ibts_and_cmpxchg();
821 }
822 0x15: decode OPCODE_OP_BOTTOM3 {
823 0x0: push_gs();
824 0x1: pop_gs();
825 0x2: rsm_smm();
826 0x3: Inst::BTS(Ev,Gv);
827 0x4: Inst::SHRD(Ev,Gv,Ib);
828 0x5: Inst::SHRD(Ev,Gv);
829 //0x6: group16();
830 0x6: decode MODRM_REG {
831 0x0: fxsave();
832 0x1: fxrstor();
833 0x2: ldmxcsr();
834 0x3: stmxcsr();
835 0x4: Inst::UD2();
836 0x5: decode MODRM_MOD {
837 0x3: BasicOperate::LFENCE(
838 {{/*Nothing*/}}, IsReadBarrier);
839 default: Inst::UD2();
840 }
841 0x6: decode MODRM_MOD {
842 0x3: BasicOperate::MFENCE(
843 {{/*Nothing*/}}, IsMemBarrier);
844 default: Inst::UD2();
845 }
846 0x7: decode MODRM_MOD {
847 0x3: BasicOperate::SFENCE(
848 {{/*Nothing*/}}, IsWriteBarrier);
849 default: Inst::UD2();
850 }
851 }
852 0x7: Inst::IMUL(Gv,Ev);
853 }
854 0x16: decode OPCODE_OP_BOTTOM3 {
855 0x0: Inst::CMPXCHG(Eb,Gb);
856 0x1: Inst::CMPXCHG(Ev,Gv);
857 0x2: lss_Gz_Mp();
858 0x3: Inst::BTR(Ev,Gv);
859 0x4: lfs_Gz_Mp();
860 0x5: lgs_Gz_Mp();
861 //The size of the second operand in these instructions should
862 //really be "b" or "w", but it's set to v in order to have a
863 //consistent register size. This shouldn't affect behavior.
864 0x6: Inst::MOVZX_B(Gv,Ev);
865 0x7: Inst::MOVZX_W(Gv,Ev);
866 }
867 0x17: decode OPCODE_OP_BOTTOM3 {
868 0x0: jmpe_Jz(); // IA-64?
869 format Inst {
870 //0x1: group11_UD2();
871 0x1: UD2();
872 //0x2: group8_Ev_Ib();
873 0x2: decode MODRM_REG {
874 0x4: BT(Ev,Ib);
875 0x5: BTS(Ev,Ib);
876 0x6: BTR(Ev,Ib);
877 0x7: BTC(Ev,Ib);
878 default: UD2();
879 }
880 0x3: BTC(Ev,Gv);
881 }
882 0x4: Inst::BSF(Gv,Ev);
883 0x5: Inst::BSR(Gv,Ev);
884 //The size of the second operand in these instructions should
885 //really be "b" or "w", but it's set to v in order to have a
886 //consistent register size. This shouldn't affect behavior.
887 0x6: Inst::MOVSX_B(Gv,Ev);
888 0x7: Inst::MOVSX_W(Gv,Ev);
889 }
890 format Inst {
891 0x18: decode OPCODE_OP_BOTTOM3 {
892 0x0: XADD(Eb,Gb);
893 0x1: XADD(Ev,Gv);
894 //0x7: group9();
895 0x7: decode MODRM_REG {
896 //Also CMPXCHG16B
897 0x1: CMPXCHG8B(Mdp);
898 0x6: decode LEGACY_OP {
899 0x1: WarnUnimpl::vmclear_Mq();
900 default: decode LEGACY_REP {
901 0x1: WarnUnimpl::vmxon_Mq();
902 0x0: WarnUnimpl::vmptrld_Mq();
903 }
904 }
905 0x7: WarnUnimpl::vmptrst_Mq();
906 default: UD2();
907 }
908 default: decode LEGACY_DECODEVAL {
909 // no prefix
910 0x0: decode OPCODE_OP_BOTTOM3 {
911 0x2: WarnUnimpl::cmpccps_Vo_Wo_Ib();
912 0x3: CVTDQ2PS(Vo,Wo);
913 0x4: SUBPS(Vo,Wo);
914 0x5: MINPS(Vo,Wo);
915 0x6: DIVPS(Vo,Wo);
916 }
917 // repe (0xF3)
918 0x4: decode OPCODE_OP_BOTTOM3 {
919 0x2: WarnUnimpl::cmpccss_Vd_Wd_Ib();
920 default: UD2();
921 }
922 // operand size (0x66)
923 0x1: decode OPCODE_OP_BOTTOM3 {
924 0x2: WarnUnimpl::cmpccpd_Vo_Wo_Ib();
925 0x4: SUBPD(Vo,Wo);
926 0x5: MINPD(Vo,Wo);
927 0x6: DIVPD(Vo,Wo);
928 default: UD2();
929 }
930 // repne (0xF2)
931 0x8: decode OPCODE_OP_BOTTOM3 {
932 0x2: WarnUnimpl::cmpccsd_Vq_Wq_Ib();
933 default: UD2();
934 }
935 default: UD2();
936 }
937 }
938 0x19: decode OPSIZE {
939 4: BSWAP_D(Bd);
940 8: BSWAP_Q(Bq);
941 default: UD2();
942 }
943 }
944 0x1A: decode LEGACY_DECODEVAL {
945 // no prefix
946 0x0: decode OPCODE_OP_BOTTOM3 {
762 0x10: decode OPCODE_OP_BOTTOM3 {
763 0x0: JO(Jz);
764 0x1: JNO(Jz);
765 0x2: JB(Jz);
766 0x3: JNB(Jz);
767 0x4: JZ(Jz);
768 0x5: JNZ(Jz);
769 0x6: JBE(Jz);
770 0x7: JNBE(Jz);
771 }
772 0x11: decode OPCODE_OP_BOTTOM3 {
773 0x0: JS(Jz);
774 0x1: JNS(Jz);
775 0x2: JP(Jz);
776 0x3: JNP(Jz);
777 0x4: JL(Jz);
778 0x5: JNL(Jz);
779 0x6: JLE(Jz);
780 0x7: JNLE(Jz);
781 }
782 0x12: decode OPCODE_OP_BOTTOM3 {
783 0x0: SETO(Eb);
784 0x1: SETNO(Eb);
785 0x2: SETB(Eb);
786 0x3: SETNB(Eb);
787 0x4: SETZ(Eb);
788 0x5: SETNZ(Eb);
789 0x6: SETBE(Eb);
790 0x7: SETNBE(Eb);
791 }
792 0x13: decode OPCODE_OP_BOTTOM3 {
793 0x0: SETS(Eb);
794 0x1: SETNS(Eb);
795 0x2: SETP(Eb);
796 0x3: SETNP(Eb);
797 0x4: SETL(Eb);
798 0x5: SETNL(Eb);
799 0x6: SETLE(Eb);
800 0x7: SETNLE(Eb);
801 }
802 }
803 0x14: decode OPCODE_OP_BOTTOM3 {
804 0x0: push_fs();
805 0x1: pop_fs();
806 0x2: CPUIDInst::CPUID({{
807 CpuidResult result;
808 success = doCpuid(xc->tcBase(), bits(Rax, 31, 0), result);
809 Rax = result.rax;
810 Rbx = result.rbx;
811 Rcx = result.rcx;
812 Rdx = result.rdx;
813 }});
814 0x3: Inst::BT(Ev,Gv);
815 0x4: Inst::SHLD(Ev,Gv,Ib);
816 0x5: Inst::SHLD(Ev,Gv);
817 0x6: xbts_and_cmpxchg();
818 0x7: ibts_and_cmpxchg();
819 }
820 0x15: decode OPCODE_OP_BOTTOM3 {
821 0x0: push_gs();
822 0x1: pop_gs();
823 0x2: rsm_smm();
824 0x3: Inst::BTS(Ev,Gv);
825 0x4: Inst::SHRD(Ev,Gv,Ib);
826 0x5: Inst::SHRD(Ev,Gv);
827 //0x6: group16();
828 0x6: decode MODRM_REG {
829 0x0: fxsave();
830 0x1: fxrstor();
831 0x2: ldmxcsr();
832 0x3: stmxcsr();
833 0x4: Inst::UD2();
834 0x5: decode MODRM_MOD {
835 0x3: BasicOperate::LFENCE(
836 {{/*Nothing*/}}, IsReadBarrier);
837 default: Inst::UD2();
838 }
839 0x6: decode MODRM_MOD {
840 0x3: BasicOperate::MFENCE(
841 {{/*Nothing*/}}, IsMemBarrier);
842 default: Inst::UD2();
843 }
844 0x7: decode MODRM_MOD {
845 0x3: BasicOperate::SFENCE(
846 {{/*Nothing*/}}, IsWriteBarrier);
847 default: Inst::UD2();
848 }
849 }
850 0x7: Inst::IMUL(Gv,Ev);
851 }
852 0x16: decode OPCODE_OP_BOTTOM3 {
853 0x0: Inst::CMPXCHG(Eb,Gb);
854 0x1: Inst::CMPXCHG(Ev,Gv);
855 0x2: lss_Gz_Mp();
856 0x3: Inst::BTR(Ev,Gv);
857 0x4: lfs_Gz_Mp();
858 0x5: lgs_Gz_Mp();
859 //The size of the second operand in these instructions should
860 //really be "b" or "w", but it's set to v in order to have a
861 //consistent register size. This shouldn't affect behavior.
862 0x6: Inst::MOVZX_B(Gv,Ev);
863 0x7: Inst::MOVZX_W(Gv,Ev);
864 }
865 0x17: decode OPCODE_OP_BOTTOM3 {
866 0x0: jmpe_Jz(); // IA-64?
867 format Inst {
868 //0x1: group11_UD2();
869 0x1: UD2();
870 //0x2: group8_Ev_Ib();
871 0x2: decode MODRM_REG {
872 0x4: BT(Ev,Ib);
873 0x5: BTS(Ev,Ib);
874 0x6: BTR(Ev,Ib);
875 0x7: BTC(Ev,Ib);
876 default: UD2();
877 }
878 0x3: BTC(Ev,Gv);
879 }
880 0x4: Inst::BSF(Gv,Ev);
881 0x5: Inst::BSR(Gv,Ev);
882 //The size of the second operand in these instructions should
883 //really be "b" or "w", but it's set to v in order to have a
884 //consistent register size. This shouldn't affect behavior.
885 0x6: Inst::MOVSX_B(Gv,Ev);
886 0x7: Inst::MOVSX_W(Gv,Ev);
887 }
888 format Inst {
889 0x18: decode OPCODE_OP_BOTTOM3 {
890 0x0: XADD(Eb,Gb);
891 0x1: XADD(Ev,Gv);
892 //0x7: group9();
893 0x7: decode MODRM_REG {
894 //Also CMPXCHG16B
895 0x1: CMPXCHG8B(Mdp);
896 0x6: decode LEGACY_OP {
897 0x1: WarnUnimpl::vmclear_Mq();
898 default: decode LEGACY_REP {
899 0x1: WarnUnimpl::vmxon_Mq();
900 0x0: WarnUnimpl::vmptrld_Mq();
901 }
902 }
903 0x7: WarnUnimpl::vmptrst_Mq();
904 default: UD2();
905 }
906 default: decode LEGACY_DECODEVAL {
907 // no prefix
908 0x0: decode OPCODE_OP_BOTTOM3 {
909 0x2: WarnUnimpl::cmpccps_Vo_Wo_Ib();
910 0x3: CVTDQ2PS(Vo,Wo);
911 0x4: SUBPS(Vo,Wo);
912 0x5: MINPS(Vo,Wo);
913 0x6: DIVPS(Vo,Wo);
914 }
915 // repe (0xF3)
916 0x4: decode OPCODE_OP_BOTTOM3 {
917 0x2: WarnUnimpl::cmpccss_Vd_Wd_Ib();
918 default: UD2();
919 }
920 // operand size (0x66)
921 0x1: decode OPCODE_OP_BOTTOM3 {
922 0x2: WarnUnimpl::cmpccpd_Vo_Wo_Ib();
923 0x4: SUBPD(Vo,Wo);
924 0x5: MINPD(Vo,Wo);
925 0x6: DIVPD(Vo,Wo);
926 default: UD2();
927 }
928 // repne (0xF2)
929 0x8: decode OPCODE_OP_BOTTOM3 {
930 0x2: WarnUnimpl::cmpccsd_Vq_Wq_Ib();
931 default: UD2();
932 }
933 default: UD2();
934 }
935 }
936 0x19: decode OPSIZE {
937 4: BSWAP_D(Bd);
938 8: BSWAP_Q(Bq);
939 default: UD2();
940 }
941 }
942 0x1A: decode LEGACY_DECODEVAL {
943 // no prefix
944 0x0: decode OPCODE_OP_BOTTOM3 {
947 0x1: psrlw_Pq_Qq();
948 0x2: psrld_Pq_Qq();
949 0x3: psrlq_Pq_Qq();
945 0x1: Inst::PSRLW(Pq,Qq);
946 0x2: Inst::PSRLD(Pq,Qq);
947 0x3: Inst::PSRLQ(Pq,Qq);
950 0x4: Inst::PADDQ(Pq,Qq);
951 0x5: Inst::PMULLW(Pq,Qq);
952 0x7: pmovmskb_Gd_PRq();
953 default: Inst::UD2();
954 }
955 // repe (0xF3)
956 0x4: decode OPCODE_OP_BOTTOM3 {
957 0x6: movq2dq_Vo_PRq();
958 default: Inst::UD2();
959 }
960 // operand size (0x66)
961 0x1: decode OPCODE_OP_BOTTOM3 {
962 0x0: addsubpd_Vo_Wo();
948 0x4: Inst::PADDQ(Pq,Qq);
949 0x5: Inst::PMULLW(Pq,Qq);
950 0x7: pmovmskb_Gd_PRq();
951 default: Inst::UD2();
952 }
953 // repe (0xF3)
954 0x4: decode OPCODE_OP_BOTTOM3 {
955 0x6: movq2dq_Vo_PRq();
956 default: Inst::UD2();
957 }
958 // operand size (0x66)
959 0x1: decode OPCODE_OP_BOTTOM3 {
960 0x0: addsubpd_Vo_Wo();
963 0x1: psrlw_Vo_Wo();
964 0x2: psrld_Vo_Wo();
965 0x3: psrlq_Vo_Wo();
961 0x1: Inst::PSRLW(Vo,Wo);
962 0x2: Inst::PSRLD(Vo,Wo);
963 0x3: Inst::PSRLQ(Vo,Wo);
966 0x4: Inst::PADDQ(Vo,Wo);
967 0x5: Inst::PMULLW(Vo,Wo);
968 0x6: Inst::MOVQ(Wq,Vq);
969 0x7: pmovmskb_Gd_VRo();
970 }
971 // repne (0xF2)
972 0x8: decode OPCODE_OP_BOTTOM3 {
973 0x0: addsubps_Vo_Wo();
974 0x6: movdq2q_Pq_VRq();
975 default: Inst::UD2();
976 }
977 default: Inst::UD2();
978 }
979 format Inst {
980 0x1B: decode LEGACY_DECODEVAL {
981 // no prefix
982 0x0: decode OPCODE_OP_BOTTOM3 {
983 0x0: PSUBUSB(Pq,Qq);
984 0x1: PSUBUSW(Pq,Qq);
985 0x2: PMINUB(Pq,Qq);
986 0x3: PAND(Pq,Qq);
987 0x4: PADDUSB(Pq,Qq);
988 0x5: PADDUSW(Pq,Qq);
989 0x6: PMAXUB(Pq,Qq);
990 0x7: PANDN(Pq,Qq);
991 }
992 // operand size (0x66)
993 0x1: decode OPCODE_OP_BOTTOM3 {
994 0x0: PSUBUSB(Vo,Wo);
995 0x1: PSUBUSW(Vo,Wo);
996 0x2: PMINUB(Vo,Wo);
997 0x3: PAND(Vo,Wo);
998 0x4: PADDUSB(Vo,Wo);
999 0x5: PADDUSW(Vo,Wo);
1000 0x6: PMAXUB(Vo,Wo);
1001 0x7: PANDN(Vo,Wo);
1002 }
1003 default: UD2();
1004 }
1005 }
1006 0x1C: decode LEGACY_DECODEVAL {
1007 // no prefix
1008 0x0: decode OPCODE_OP_BOTTOM3 {
1009 0x0: pavgb_Pq_Qq();
964 0x4: Inst::PADDQ(Vo,Wo);
965 0x5: Inst::PMULLW(Vo,Wo);
966 0x6: Inst::MOVQ(Wq,Vq);
967 0x7: pmovmskb_Gd_VRo();
968 }
969 // repne (0xF2)
970 0x8: decode OPCODE_OP_BOTTOM3 {
971 0x0: addsubps_Vo_Wo();
972 0x6: movdq2q_Pq_VRq();
973 default: Inst::UD2();
974 }
975 default: Inst::UD2();
976 }
977 format Inst {
978 0x1B: decode LEGACY_DECODEVAL {
979 // no prefix
980 0x0: decode OPCODE_OP_BOTTOM3 {
981 0x0: PSUBUSB(Pq,Qq);
982 0x1: PSUBUSW(Pq,Qq);
983 0x2: PMINUB(Pq,Qq);
984 0x3: PAND(Pq,Qq);
985 0x4: PADDUSB(Pq,Qq);
986 0x5: PADDUSW(Pq,Qq);
987 0x6: PMAXUB(Pq,Qq);
988 0x7: PANDN(Pq,Qq);
989 }
990 // operand size (0x66)
991 0x1: decode OPCODE_OP_BOTTOM3 {
992 0x0: PSUBUSB(Vo,Wo);
993 0x1: PSUBUSW(Vo,Wo);
994 0x2: PMINUB(Vo,Wo);
995 0x3: PAND(Vo,Wo);
996 0x4: PADDUSB(Vo,Wo);
997 0x5: PADDUSW(Vo,Wo);
998 0x6: PMAXUB(Vo,Wo);
999 0x7: PANDN(Vo,Wo);
1000 }
1001 default: UD2();
1002 }
1003 }
1004 0x1C: decode LEGACY_DECODEVAL {
1005 // no prefix
1006 0x0: decode OPCODE_OP_BOTTOM3 {
1007 0x0: pavgb_Pq_Qq();
1010 0x1: psraw_Pq_Qq();
1011 0x2: psrad_Pq_Qq();
1008 0x1: Inst::PSRAW(Pq,Qq);
1009 0x2: Inst::PSRAD(Pq,Qq);
1012 0x3: pavgw_Pq_Qq();
1013 0x4: Inst::PMULHUW(Pq,Qq);
1014 0x5: Inst::PMULHW(Pq,Qq);
1015 0x7: movntq_Mq_Pq();
1016 default: Inst::UD2();
1017 }
1018 // repe (0xF3)
1019 0x4: decode OPCODE_OP_BOTTOM3 {
1020 0x6: Inst::CVTDQ2PD(Vo,Wq);
1021 default: Inst::UD2();
1022 }
1023 // operand size (0x66)
1024 0x1: decode OPCODE_OP_BOTTOM3 {
1025 0x0: pavgb_Vo_Wo();
1010 0x3: pavgw_Pq_Qq();
1011 0x4: Inst::PMULHUW(Pq,Qq);
1012 0x5: Inst::PMULHW(Pq,Qq);
1013 0x7: movntq_Mq_Pq();
1014 default: Inst::UD2();
1015 }
1016 // repe (0xF3)
1017 0x4: decode OPCODE_OP_BOTTOM3 {
1018 0x6: Inst::CVTDQ2PD(Vo,Wq);
1019 default: Inst::UD2();
1020 }
1021 // operand size (0x66)
1022 0x1: decode OPCODE_OP_BOTTOM3 {
1023 0x0: pavgb_Vo_Wo();
1026 0x1: psraw_Vo_Wo();
1027 0x2: psrad_Vo_Wo();
1024 0x1: Inst::PSRAW(Vo,Wo);
1025 0x2: Inst::PSRAD(Vo,Wo);
1028 0x3: pavgw_Vo_Wo();
1029 0x4: Inst::PMULHUW(Vo,Wo);
1030 0x5: Inst::PMULHW(Vo,Wo);
1031 0x6: cvttpd2dq_Vo_Wo();
1032 0x7: movntdq_Mo_Vo();
1033 }
1034 // repne (0xF2)
1035 0x8: decode OPCODE_OP_BOTTOM3 {
1036 0x6: cvtpd2dq_Vo_Wo();
1037 default: Inst::UD2();
1038 }
1039 default: Inst::UD2();
1040 }
1041 format Inst {
1042 0x1D: decode LEGACY_DECODEVAL {
1043 // no prefix
1044 0x0: decode OPCODE_OP_BOTTOM3 {
1045 0x0: PSUBSB(Pq,Qq);
1046 0x1: PSUBSW(Pq,Qq);
1047 0x2: PMINSW(Pq,Qq);
1048 0x3: POR(Pq,Qq);
1049 0x4: PADDSB(Pq,Qq);
1050 0x5: PADDSW(Pq,Qq);
1051 0x6: PMAXSW(Pq,Qq);
1052 0x7: PXOR(Pq,Qq);
1053 }
1054 // operand size (0x66)
1055 0x1: decode OPCODE_OP_BOTTOM3 {
1056 0x0: PSUBSB(Vo,Wo);
1057 0x1: PSUBSW(Vo,Wo);
1058 0x2: PMINSW(Vo,Wo);
1059 0x3: POR(Vo,Wo);
1060 0x4: PADDSB(Vo,Wo);
1061 0x5: PADDSW(Vo,Wo);
1062 0x6: PMAXSW(Vo,Wo);
1063 0x7: PXOR(Vo,Wo);
1064 }
1065 default: UD2();
1066 }
1067 }
1068 0x1E: decode LEGACY_DECODEVAL {
1069 // no prefix
1070 0x0: decode OPCODE_OP_BOTTOM3 {
1026 0x3: pavgw_Vo_Wo();
1027 0x4: Inst::PMULHUW(Vo,Wo);
1028 0x5: Inst::PMULHW(Vo,Wo);
1029 0x6: cvttpd2dq_Vo_Wo();
1030 0x7: movntdq_Mo_Vo();
1031 }
1032 // repne (0xF2)
1033 0x8: decode OPCODE_OP_BOTTOM3 {
1034 0x6: cvtpd2dq_Vo_Wo();
1035 default: Inst::UD2();
1036 }
1037 default: Inst::UD2();
1038 }
1039 format Inst {
1040 0x1D: decode LEGACY_DECODEVAL {
1041 // no prefix
1042 0x0: decode OPCODE_OP_BOTTOM3 {
1043 0x0: PSUBSB(Pq,Qq);
1044 0x1: PSUBSW(Pq,Qq);
1045 0x2: PMINSW(Pq,Qq);
1046 0x3: POR(Pq,Qq);
1047 0x4: PADDSB(Pq,Qq);
1048 0x5: PADDSW(Pq,Qq);
1049 0x6: PMAXSW(Pq,Qq);
1050 0x7: PXOR(Pq,Qq);
1051 }
1052 // operand size (0x66)
1053 0x1: decode OPCODE_OP_BOTTOM3 {
1054 0x0: PSUBSB(Vo,Wo);
1055 0x1: PSUBSW(Vo,Wo);
1056 0x2: PMINSW(Vo,Wo);
1057 0x3: POR(Vo,Wo);
1058 0x4: PADDSB(Vo,Wo);
1059 0x5: PADDSW(Vo,Wo);
1060 0x6: PMAXSW(Vo,Wo);
1061 0x7: PXOR(Vo,Wo);
1062 }
1063 default: UD2();
1064 }
1065 }
1066 0x1E: decode LEGACY_DECODEVAL {
1067 // no prefix
1068 0x0: decode OPCODE_OP_BOTTOM3 {
1071 0x1: psllw_Pq_Qq();
1072 0x2: pslld_Pq_Qq();
1073 0x3: psllq_Pq_Qq();
1069 0x1: Inst::PSLLW(Pq,Qq);
1070 0x2: Inst::PSLLD(Pq,Qq);
1071 0x3: Inst::PSLLQ(Pq,Qq);
1074 0x4: Inst::PMULUDQ(Pq,Qq);
1075 0x5: pmaddwd_Pq_Qq();
1076 0x6: Inst::PSADBW(Pq,Qq);
1077 0x7: maskmovq_Pq_PRq();
1078 default: Inst::UD2();
1079 }
1080 // operand size (0x66)
1081 0x1: decode OPCODE_OP_BOTTOM3 {
1072 0x4: Inst::PMULUDQ(Pq,Qq);
1073 0x5: pmaddwd_Pq_Qq();
1074 0x6: Inst::PSADBW(Pq,Qq);
1075 0x7: maskmovq_Pq_PRq();
1076 default: Inst::UD2();
1077 }
1078 // operand size (0x66)
1079 0x1: decode OPCODE_OP_BOTTOM3 {
1082 0x1: psllw_Vo_Wo();
1083 0x2: pslld_Vo_Wo();
1084 0x3: psllq_Vo_Wo();
1080 0x1: Inst::PSLLW(Vo,Wo);
1081 0x2: Inst::PSLLD(Vo,Wo);
1082 0x3: Inst::PSLLQ(Vo,Wo);
1085 0x4: Inst::PMULUDQ(Vo,Wo);
1086 0x5: pmaddwd_Vo_Wo();
1087 0x6: Inst::PSADBW(Vo,Wo);
1088 0x7: maskmovdqu_Vo_VRo();
1089 default: Inst::UD2();
1090 }
1091 // repne (0xF2)
1092 0x8: decode OPCODE_OP_BOTTOM3 {
1093 0x0: lddqu_Vo_Mo();
1094 default: Inst::UD2();
1095 }
1096 default: Inst::UD2();
1097 }
1098 format Inst {
1099 0x1F: decode LEGACY_DECODEVAL {
1100 // no prefix
1101 0x0: decode OPCODE_OP_BOTTOM3 {
1102 0x0: PSUBB(Pq,Qq);
1103 0x1: PSUBW(Pq,Qq);
1104 0x2: PSUBD(Pq,Qq);
1105 0x3: PSUBQ(Pq,Qq);
1106 0x4: PADDB(Pq,Qq);
1107 0x5: PADDW(Pq,Qq);
1108 0x6: PADDD(Pq,Qq);
1109 0x7: UD2();
1110 }
1111 // operand size (0x66)
1112 0x1: decode OPCODE_OP_BOTTOM3 {
1113 0x0: PSUBB(Vo,Wo);
1114 0x1: PSUBW(Vo,Wo);
1115 0x2: PSUBD(Vo,Wo);
1116 0x3: PSUBQ(Vo,Wo);
1117 0x4: PADDB(Vo,Wo);
1118 0x5: PADDW(Vo,Wo);
1119 0x6: PADDD(Vo,Wo);
1120 0x7: UD2();
1121 }
1122 default: UD2();
1123 }
1124 }
1125 default: FailUnimpl::twoByteOps();
1126 }
1127 }
1128 default: M5InternalError::error(
1129 {{"Unexpected first opcode byte in two byte opcode!"}});
1130}
1083 0x4: Inst::PMULUDQ(Vo,Wo);
1084 0x5: pmaddwd_Vo_Wo();
1085 0x6: Inst::PSADBW(Vo,Wo);
1086 0x7: maskmovdqu_Vo_VRo();
1087 default: Inst::UD2();
1088 }
1089 // repne (0xF2)
1090 0x8: decode OPCODE_OP_BOTTOM3 {
1091 0x0: lddqu_Vo_Mo();
1092 default: Inst::UD2();
1093 }
1094 default: Inst::UD2();
1095 }
1096 format Inst {
1097 0x1F: decode LEGACY_DECODEVAL {
1098 // no prefix
1099 0x0: decode OPCODE_OP_BOTTOM3 {
1100 0x0: PSUBB(Pq,Qq);
1101 0x1: PSUBW(Pq,Qq);
1102 0x2: PSUBD(Pq,Qq);
1103 0x3: PSUBQ(Pq,Qq);
1104 0x4: PADDB(Pq,Qq);
1105 0x5: PADDW(Pq,Qq);
1106 0x6: PADDD(Pq,Qq);
1107 0x7: UD2();
1108 }
1109 // operand size (0x66)
1110 0x1: decode OPCODE_OP_BOTTOM3 {
1111 0x0: PSUBB(Vo,Wo);
1112 0x1: PSUBW(Vo,Wo);
1113 0x2: PSUBD(Vo,Wo);
1114 0x3: PSUBQ(Vo,Wo);
1115 0x4: PADDB(Vo,Wo);
1116 0x5: PADDW(Vo,Wo);
1117 0x6: PADDD(Vo,Wo);
1118 0x7: UD2();
1119 }
1120 default: UD2();
1121 }
1122 }
1123 default: FailUnimpl::twoByteOps();
1124 }
1125 }
1126 default: M5InternalError::error(
1127 {{"Unexpected first opcode byte in two byte opcode!"}});
1128}