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