Debugging: Add code to print backtrace for guest on SIGSEGV
[nativeclient.git] / ncv / ncdecode_table.c
blob2d1100546f18c223aecb6280a609f509dd006e49
1 /*
2 * Copyright 2008, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * ncdecode_intable.h - table driven decoder for Native Client.
35 * This program generates C source for the ncdecode.c decoder tables.
36 * It writes two C .h file to standard out, one for decoding and one
37 * for disassembly, that contain six decoder tables.
40 #include "native_client/include/portability.h"
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include <time.h>
44 #include <string.h>
45 #include <assert.h>
46 #define NEEDSNACLINSTTYPESTRING
47 #include "ncdecode.h"
49 typedef uint8_t bool; /* zero or non-zero */
51 #define TODO
53 /* For handling prefixes we consume the prefix byte and then
54 * record the state in this record.
56 typedef struct OpMetaInfo {
57 const char *disfmt; /* as a short string, for printing */
58 NaClInstType insttype;
59 bool mrmbyte; /* 0 or 1 */
60 uint8_t immtype; /* IMM_UNKNOWN .. IMM_DEFAULT_4 */
61 uint8_t opinmrm; /* 0 .. 8 */
62 } OpMetaInfo;
64 /* The decoder input table is an array of instruction definitions, */
65 /* defined using OpMetaInfo as defined in ncdecode.h */
66 OpMetaInfo *g_Op1ByteTable[NCDTABLESIZE];
67 /* two byte opcode tables */
68 OpMetaInfo *g_Op0FXXMetaTable[NCDTABLESIZE];
69 OpMetaInfo *g_OpF20FXXTable[NCDTABLESIZE];
70 OpMetaInfo *g_OpF30FXXTable[NCDTABLESIZE];
71 OpMetaInfo *g_Op660FXXTable[NCDTABLESIZE];
72 /* three byte opcode tables */
73 OpMetaInfo *g_Op0F0FTable[NCDTABLESIZE];
74 OpMetaInfo *g_Op0F38Table[NCDTABLESIZE];
75 OpMetaInfo *g_Op660F38Table[NCDTABLESIZE];
76 OpMetaInfo *g_OpF20F38Table[NCDTABLESIZE];
77 OpMetaInfo *g_Op0F3ATable[NCDTABLESIZE];
78 OpMetaInfo *g_Op660F3ATable[NCDTABLESIZE];
79 /* tables for opcodes in ModRM */
80 OpMetaInfo *g_ModRMOpTable[kNaClMRMGroupsRange][kModRMOpcodeGroupSize];
81 /* x87 opcode tables */
82 OpMetaInfo *g_Op87D8[NCDTABLESIZE];
83 OpMetaInfo *g_Op87D9[NCDTABLESIZE];
84 OpMetaInfo *g_Op87DA[NCDTABLESIZE];
85 OpMetaInfo *g_Op87DB[NCDTABLESIZE];
86 OpMetaInfo *g_Op87DC[NCDTABLESIZE];
87 OpMetaInfo *g_Op87DD[NCDTABLESIZE];
88 OpMetaInfo *g_Op87DE[NCDTABLESIZE];
89 OpMetaInfo *g_Op87DF[NCDTABLESIZE];
90 static OpMetaInfo DecodeUndefinedInstInfo = {
91 "undefined", NACLi_UNDEFINED, 0, IMM_NONE, 0
94 /* Note: in general all errors in this module will be fatal.
95 * To debug: use gdb or your favorite debugger.
97 static void fatal(const char *s) {
98 fprintf(stderr, "%s\n", s);
99 fprintf(stderr, "fatal error, cannot recover\n");
100 exit(-1);
103 /* operandsize == 0 implies operand size determined by operand size attributes
104 * opbytes: length of opcode, one or two bytes
105 * mrmbyte: 0 or 1, 1 if mrmbyte is present
106 * immbytes: bytes of immediate: 1, 2, 4
107 * itype: decoder treatment, an NaClInstType as in ncdecode.h
108 * disfmt: format string for disassembly
110 static OpMetaInfo *NewMetaDefn(const bool mrmbyte, const uint8_t immtype,
111 const NaClInstType itype, const char *disfmt) {
112 OpMetaInfo *imd = (OpMetaInfo *)malloc(sizeof(*imd));
113 if (imd == NULL) {
114 fatal("NewMetaDefn: malloc failed");
116 imd->insttype = itype;
117 imd->disfmt = disfmt;
118 imd->mrmbyte = mrmbyte;
119 imd->immtype = immtype;
120 imd->opinmrm = 0;
121 return imd;
124 static void EncodeOpByte1(const uint8_t byte1, const bool mrmbyte,
125 const uint8_t immtype,
126 const NaClInstType itype, const char *disfmt) {
127 g_Op1ByteTable[byte1] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
130 static void EncodeOp0F(const uint8_t byte2, const bool mrmbyte,
131 const uint8_t immtype,
132 const NaClInstType itype, const char *disfmt) {
133 g_Op0FXXMetaTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
136 static void EncodeOp660F(const uint8_t byte2, const bool mrmbyte,
137 const uint8_t immtype,
138 const NaClInstType itype, const char *disfmt) {
139 g_Op660FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
142 static void EncodeOpF20F(const uint8_t byte2, const bool mrmbyte,
143 const uint8_t immtype,
144 const NaClInstType itype, const char *disfmt) {
145 g_OpF20FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
148 static void EncodeOpF30F(const uint8_t byte2, const bool mrmbyte,
149 const uint8_t immtype,
150 const NaClInstType itype, const char *disfmt) {
151 g_OpF30FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
154 static void EncodeOp0F0F(const uint8_t byte2, const bool mrmbyte,
155 const uint8_t immtype,
156 const NaClInstType itype, const char *disfmt) {
157 g_Op0F0FTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
160 static void EncodeOp0F38(const uint8_t byte2, const bool mrmbyte,
161 const uint8_t immtype,
162 const NaClInstType itype, const char *disfmt) {
163 g_Op0F38Table[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
166 static void EncodeOp660F38(const uint8_t byte2, const bool mrmbyte,
167 const uint8_t immtype,
168 const NaClInstType itype, const char *disfmt) {
169 g_Op660F38Table[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
172 static void EncodeOpF20F38(const uint8_t byte2, const bool mrmbyte,
173 const uint8_t immtype,
174 const NaClInstType itype, const char *disfmt) {
175 g_OpF20F38Table[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
178 static void EncodeOp0F3A(const uint8_t byte2, const bool mrmbyte,
179 const uint8_t immtype,
180 const NaClInstType itype, const char *disfmt) {
181 g_Op0F3ATable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
184 static void EncodeOp660F3A(const uint8_t byte2, const bool mrmbyte,
185 const uint8_t immtype,
186 const NaClInstType itype, const char *disfmt) {
187 g_Op660F3ATable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
190 static void EncodeModRMOp(const uint8_t group, const uint8_t nnn,
191 const NaClInstType itype, const char *disfmt) {
192 OpMetaInfo *idefn = NewMetaDefn(1, IMM_NONE, itype, disfmt);
193 g_ModRMOpTable[group][nnn] = idefn;
196 static void SetOpByte1OpInMRM(const uint8_t byte1, const uint8_t group) {
197 assert(g_Op1ByteTable[byte1] != &DecodeUndefinedInstInfo);
198 g_Op1ByteTable[byte1]->opinmrm = group;
201 /* TODO - this function generates an error since it is not used */
202 #if 0
203 static void SetModRMOpImmType(const uint8_t group, const uint8_t nnn,
204 const uint8_t it) {
205 g_ModRMOpTable[group][nnn]->immtype = it;
207 #endif
208 static void SetOp0FOpInMRM(const uint8_t byte2, const uint8_t group) {
209 assert(g_Op0FXXMetaTable[byte2] != &DecodeUndefinedInstInfo);
210 g_Op0FXXMetaTable[byte2]->opinmrm = group;
213 static void SetOp66OpInMRM(const uint8_t byte2, const uint8_t group) {
214 assert(g_Op660FXXTable[byte2] != &DecodeUndefinedInstInfo);
215 g_Op660FXXTable[byte2]->opinmrm = group;
218 /* TODO - this function generates an error since it is not used */
219 #if 0
220 static void SetOpF2OpInMRM(const uint8_t byte2, const uint8_t group) {
221 assert(g_OpF20FXXTable[byte2] != &DecodeUndefinedInstInfo);
222 g_OpF20FXXTable[byte2]->opinmrm = group;
225 static void SetOpF3OpInMRM(const uint8_t byte2, const uint8_t group) {
226 assert(g_OpF30FXXTable[byte2] != &DecodeUndefinedInstInfo);
227 g_OpF30FXXTable[byte2]->opinmrm = group;
229 #endif
231 extern int asprintf(char **s, const char *fmt, ...);
232 /* note that this function accepts only one string in s */
233 static char *aprintf(const char *fmt, const char *s) {
234 char *rstring = NULL;
235 /* there will be one spare byte, because %s is replaced, but it's ok */
236 int length = strlen(fmt) + strlen(s);
237 rstring = malloc(length);
238 if (rstring != NULL) {
239 sprintf(rstring,fmt,s);
240 } else {
241 fprintf(stderr, "malloc failed in aprintf (%s, %s) \n", fmt, s);
243 return rstring;
246 static void ALUOperandVariants00_05(const uint8_t base,
247 const NaClInstType itype,
248 const char *ocstr) {
249 EncodeOpByte1(base, 1, IMM_NONE, itype, aprintf("%s $Eb, $Gb", ocstr));
250 EncodeOpByte1(base+1, 1, IMM_NONE, itype, aprintf("%s $Ev, $Gv", ocstr));
251 EncodeOpByte1(base+2, 1, IMM_NONE, itype, aprintf("%s $Gb, $Eb", ocstr));
252 EncodeOpByte1(base+3, 1, IMM_NONE, itype, aprintf("%s $Gv, $Ev", ocstr));
253 EncodeOpByte1(base+4, 0, IMM_FIXED1, itype, aprintf("%s %%al, $Ib", ocstr));
254 EncodeOpByte1(base+5, 0, IMM_DATAV, itype, aprintf("%s %%eax, $Iz", ocstr));
257 static void OneRegVariants00_07(const uint8_t base,
258 const NaClInstType itype,
259 const char *ocstr) {
260 EncodeOpByte1(base, 0, IMM_NONE, itype, aprintf("%s %%eax", ocstr));
261 EncodeOpByte1(base+1, 0, IMM_NONE, itype, aprintf("%s %%ecx", ocstr));
262 EncodeOpByte1(base+2, 0, IMM_NONE, itype, aprintf("%s %%edx", ocstr));
263 EncodeOpByte1(base+3, 0, IMM_NONE, itype, aprintf("%s %%ebx", ocstr));
264 EncodeOpByte1(base+4, 0, IMM_NONE, itype, aprintf("%s %%esp", ocstr));
265 EncodeOpByte1(base+5, 0, IMM_NONE, itype, aprintf("%s %%ebp", ocstr));
266 EncodeOpByte1(base+6, 0, IMM_NONE, itype, aprintf("%s %%esi", ocstr));
267 EncodeOpByte1(base+7, 0, IMM_NONE, itype, aprintf("%s %%edi", ocstr));
270 /* TODO - this function generates an error since it is not used */
271 #if 0
272 static char *asmprint(char **asmstr, const char *opcode,
273 const char *reg, const char *dest) {
274 if (asprintf(asmstr, "%s %s, %s", opcode, reg, dest) < 0) {
275 fatal("asprintf failed");
277 return *asmstr;
279 #endif
281 static void InitializeGlobalTables() {
282 int i, j;
283 /* pre-initialize g_Op1ByteTable */
284 for (i = 0; i < NCDTABLESIZE; i++) {
285 g_Op1ByteTable[i] = &DecodeUndefinedInstInfo;
286 g_Op0FXXMetaTable[i] = &DecodeUndefinedInstInfo;
287 g_Op660FXXTable[i] = &DecodeUndefinedInstInfo;
288 g_OpF20FXXTable[i] = &DecodeUndefinedInstInfo;
289 g_OpF30FXXTable[i] = &DecodeUndefinedInstInfo;
290 g_Op0F0FTable[i] = &DecodeUndefinedInstInfo;
291 g_Op0F38Table[i] = &DecodeUndefinedInstInfo;
292 g_Op660F38Table[i] = &DecodeUndefinedInstInfo;
293 g_OpF20F38Table[i] = &DecodeUndefinedInstInfo;
294 g_Op0F3ATable[i] = &DecodeUndefinedInstInfo;
295 g_Op660F3ATable[i] = &DecodeUndefinedInstInfo;
296 g_Op87D8[i] = &DecodeUndefinedInstInfo;
297 g_Op87D9[i] = &DecodeUndefinedInstInfo;
298 g_Op87DA[i] = &DecodeUndefinedInstInfo;
299 g_Op87DB[i] = &DecodeUndefinedInstInfo;
300 g_Op87DC[i] = &DecodeUndefinedInstInfo;
301 g_Op87DD[i] = &DecodeUndefinedInstInfo;
302 g_Op87DE[i] = &DecodeUndefinedInstInfo;
303 g_Op87DF[i] = &DecodeUndefinedInstInfo;
305 for (i = 0; i < kNaClMRMGroupsRange; i++) {
306 for (j = 0; j < 8; j++) {
307 g_ModRMOpTable[i][j] = &DecodeUndefinedInstInfo;
313 static void Encode87Op(OpMetaInfo *g87tab[],
314 const char *set1[8],
315 const char *set2[64]) {
316 int j, reg;
317 uint8_t i;
319 for (i = 0; i < 0xc0; i++) {
320 reg = modrm_reg(i);
321 if (set1[reg] == NULL) {
322 g87tab[i] = NewMetaDefn(1, IMM_NONE, NACLi_INVALID, "invalid");
323 } else {
324 g87tab[i] = NewMetaDefn(1, IMM_NONE, NACLi_X87, set1[reg]);
327 for (j = 0xc0; j < 0x100; j++) {
328 if (set2[j - 0xc0] == NULL) {
329 g87tab[j] = NewMetaDefn(1, IMM_NONE, NACLi_INVALID, "invalid");
330 } else {
331 g87tab[j] = NewMetaDefn(1, IMM_NONE, NACLi_X87, set2[j - 0xc0]);
336 static void BuildSSE4Tables() {
337 TODO;
338 EncodeOp660F(0x38, 1, IMM_NONE, NACLi_3BYTE, "SSE4");
339 EncodeOp660F(0x3A, 1, IMM_FIXED1, NACLi_3BYTE, "SSE4");
340 EncodeOpF20F(0x38, 0, IMM_NONE, NACLi_3BYTE, "SSE4");
342 EncodeOp660F38(0x00, 1, IMM_NONE, NACLi_SSSE3, "pshufb $V, $W");
343 EncodeOp660F38(0x01, 1, IMM_NONE, NACLi_SSSE3, "phaddw $V, $W");
344 EncodeOp660F38(0x02, 1, IMM_NONE, NACLi_SSSE3, "phaddd $V, $W");
345 EncodeOp660F38(0x03, 1, IMM_NONE, NACLi_SSSE3, "phaddsw $V, $W");
346 EncodeOp660F38(0x04, 1, IMM_NONE, NACLi_SSSE3, "pmaddubsw $V, $W");
347 EncodeOp660F38(0x05, 1, IMM_NONE, NACLi_SSSE3, "phsubw $V, $W");
348 EncodeOp660F38(0x06, 1, IMM_NONE, NACLi_SSSE3, "phsubd $V, $W");
349 EncodeOp660F38(0x07, 1, IMM_NONE, NACLi_SSSE3, "phsubsw $V, $W");
351 EncodeOp660F38(0x10, 1, IMM_NONE, NACLi_SSE41, "pblendvb $V, $W");
352 EncodeOp660F38(0x14, 1, IMM_NONE, NACLi_SSE41, "blendvps $V, $W");
353 EncodeOp660F38(0x15, 1, IMM_NONE, NACLi_SSE41, "blendvpd $V, $W");
354 EncodeOp660F38(0x17, 1, IMM_NONE, NACLi_SSE41, "ptest $V, $W");
356 EncodeOp660F38(0x20, 1, IMM_NONE, NACLi_SSE41, "pmovsxbw $V, $U/M");
357 EncodeOp660F38(0x21, 1, IMM_NONE, NACLi_SSE41, "pmovsxbd $V, $U/M");
358 EncodeOp660F38(0x22, 1, IMM_NONE, NACLi_SSE41, "pmovsxbq $V, $U/M");
359 EncodeOp660F38(0x23, 1, IMM_NONE, NACLi_SSE41, "pmovsxwd $V, $U/M");
360 EncodeOp660F38(0x24, 1, IMM_NONE, NACLi_SSE41, "pmovsxwq $V, $U/M");
361 EncodeOp660F38(0x25, 1, IMM_NONE, NACLi_SSE41, "pmovsxdq $V, $U/M");
363 EncodeOp660F38(0x30, 1, IMM_NONE, NACLi_SSE41, "pmovzxbw $V, $U/M");
364 EncodeOp660F38(0x31, 1, IMM_NONE, NACLi_SSE41, "pmovzxbd $V, $U/M");
365 EncodeOp660F38(0x32, 1, IMM_NONE, NACLi_SSE41, "pmovzxbq $V, $U/M");
366 EncodeOp660F38(0x33, 1, IMM_NONE, NACLi_SSE41, "pmovzxwd $V, $U/M");
367 EncodeOp660F38(0x34, 1, IMM_NONE, NACLi_SSE41, "pmovzxwq $V, $U/M");
368 EncodeOp660F38(0x35, 1, IMM_NONE, NACLi_SSE41, "pmovzxdq $V, $U/M");
369 EncodeOp660F38(0x37, 1, IMM_NONE, NACLi_SSE42, "pcmpgtq $V, $U/M");
371 EncodeOp660F38(0x40, 1, IMM_NONE, NACLi_SSE41, "pmulld $V, $W");
372 EncodeOp660F38(0x41, 1, IMM_NONE, NACLi_SSE41, "phminposuw $V, $W");
374 EncodeOp660F38(0x80, 1, IMM_NONE, NACLi_INVALID, "NVEPT $G, $M");
375 EncodeOp660F38(0x81, 1, IMM_NONE, NACLi_INVALID, "NVVPID $G, $M");
377 EncodeOp0F38(0xf0, 1, IMM_NONE, NACLi_MOVBE, "MOVBE $G, $M");
378 EncodeOp0F38(0xf1, 1, IMM_NONE, NACLi_MOVBE, "MOVBE $M, $G");
379 EncodeOpF20F38(0xf0, 1, IMM_NONE, NACLi_SSE42, "CRC32 $Gd, $Eb");
380 EncodeOpF20F38(0xf1, 1, IMM_NONE, NACLi_SSE42, "CRC32 $Gd, $Ev");
382 EncodeOp660F38(0x08, 1, IMM_NONE, NACLi_SSSE3, "psignb $V, $W");
383 EncodeOp660F38(0x09, 1, IMM_NONE, NACLi_SSSE3, "psignw $V, $W");
384 EncodeOp660F38(0x0a, 1, IMM_NONE, NACLi_SSSE3, "psignd $V, $W");
385 EncodeOp660F38(0x0b, 1, IMM_NONE, NACLi_SSSE3, "pmulhrsw $V, $W");
387 EncodeOp660F38(0x1c, 1, IMM_NONE, NACLi_SSSE3, "pabsb $V, $W");
388 EncodeOp660F38(0x1d, 1, IMM_NONE, NACLi_SSSE3, "pabsw $V, $W");
389 EncodeOp660F38(0x1e, 1, IMM_NONE, NACLi_SSSE3, "pabsd $V, $W");
391 EncodeOp660F38(0x28, 1, IMM_NONE, NACLi_SSE41, "pmuldq $V, $W");
392 EncodeOp660F38(0x29, 1, IMM_NONE, NACLi_SSE41, "pcmpeqq $V, $W");
393 EncodeOp660F38(0x2a, 1, IMM_NONE, NACLi_SSE41, "movntdqa $V, $W");
394 EncodeOp660F38(0x2b, 1, IMM_NONE, NACLi_SSE41, "packusdw $V, $W");
396 EncodeOp660F38(0x38, 1, IMM_NONE, NACLi_SSE41, "pminsb $V, $W");
397 EncodeOp660F38(0x39, 1, IMM_NONE, NACLi_SSE41, "pminsd $V, $W");
398 EncodeOp660F38(0x3a, 1, IMM_NONE, NACLi_SSE41, "pminuw $V, $W");
399 EncodeOp660F38(0x3b, 1, IMM_NONE, NACLi_SSE41, "pminud $V, $W");
400 EncodeOp660F38(0x3c, 1, IMM_NONE, NACLi_SSE41, "pmaxsb $V, $W");
401 EncodeOp660F38(0x3d, 1, IMM_NONE, NACLi_SSE41, "pmaxsd $V, $W");
402 EncodeOp660F38(0x3e, 1, IMM_NONE, NACLi_SSE41, "pmaxuw $V, $W");
403 EncodeOp660F38(0x3f, 1, IMM_NONE, NACLi_SSE41, "pmaxud $V, $W");
405 EncodeOp660F3A(0x14, 1, IMM_FIXED1, NACLi_SSE41, "pextrb $R/M, $V, $Ib");
406 EncodeOp660F3A(0x15, 1, IMM_FIXED1, NACLi_SSE41, "pextrw $R/M, $V, $Ib");
407 EncodeOp660F3A(0x16, 1, IMM_FIXED1, NACLi_SSE41, "pextrd/q $E, $V, $Ib");
408 EncodeOp660F3A(0x17, 1, IMM_FIXED1, NACLi_SSE41, "extractps $E, $V, $Ib");
410 EncodeOp660F3A(0x20, 1, IMM_FIXED1, NACLi_SSE41, "pinsrb $V, $R/M, $Ib");
411 EncodeOp660F3A(0x21, 1, IMM_FIXED1, NACLi_SSE41, "insertps $V, $U/M, $Ib");
412 EncodeOp660F3A(0x22, 1, IMM_FIXED1, NACLi_SSE41, "pinsrd/q $V, $E, $Ib");
414 EncodeOp660F3A(0x40, 1, IMM_FIXED1, NACLi_SSE41, "dpps $V, $W, $Ib");
415 EncodeOp660F3A(0x41, 1, IMM_FIXED1, NACLi_SSE41, "dppd $V, $W, $Ib");
416 EncodeOp660F3A(0x42, 1, IMM_FIXED1, NACLi_SSE41, "mpsadbw $V, $W, $Ib");
418 EncodeOp660F3A(0x60, 1, IMM_FIXED1, NACLi_SSE42, "pcmpestrm $V, $W, $Ib");
419 EncodeOp660F3A(0x61, 1, IMM_FIXED1, NACLi_SSE42, "pcmpestri $V, $W, $Ib");
420 EncodeOp660F3A(0x62, 1, IMM_FIXED1, NACLi_SSE42, "pcmpistrm $V, $W, $Ib");
421 EncodeOp660F3A(0x63, 1, IMM_FIXED1, NACLi_SSE42, "pcmpistri $V, $W, $Ib");
423 EncodeOp660F3A(0x08, 1, IMM_FIXED1, NACLi_SSE41, "roundps $V, $W, $Ib");
424 EncodeOp660F3A(0x09, 1, IMM_FIXED1, NACLi_SSE41, "roundpd $V, $W, $Ib");
425 EncodeOp660F3A(0x0a, 1, IMM_FIXED1, NACLi_SSE41, "roundss $V, $W, $Ib");
426 EncodeOp660F3A(0x0b, 1, IMM_FIXED1, NACLi_SSE41, "roundsd $V, $W, $Ib");
427 EncodeOp660F3A(0x0c, 1, IMM_FIXED1, NACLi_SSE41, "blendps $V, $W, $Ib");
428 EncodeOp660F3A(0x0d, 1, IMM_FIXED1, NACLi_SSE41, "blendpd $V, $W, $Ib");
429 EncodeOp660F3A(0x0e, 1, IMM_FIXED1, NACLi_SSE41, "pblendw $V, $W, $Ib");
430 EncodeOp660F3A(0x0f, 1, IMM_FIXED1, NACLi_SSSE3, "palignr $V, $W, $Ib");
433 static void Buildx87Tables() {
434 int i;
435 /* since these are so repetative I'm using a little bit of a hack */
436 /* to make this more concise. */
437 static const char *k87D8Table1[8] =
438 {"fadd", "fmul", "fcom", "fcomp", "fsub", "fsubr", "fdiv", "fdivr"};
439 static const char *k87D8Table2[64] = {
440 "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd",
441 "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul",
442 "fcom", "fcom", "fcom", "fcom", "fcom", "fcom", "fcom", "fcom",
443 "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp",
444 "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub",
445 "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr",
446 "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv",
447 "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr"};
449 static const char *k87D9Table1[8] =
450 {"fld", NULL, "fst", "fstp", "fldenv", "fldcw", "fnstenv", "fnstcw"};
451 static const char *k87D9Table2[64] = {
452 "fld", "fld", "fld", "fld", "fld", "fld", "fld", "fld",
453 "fxch", "fxch", "fxch", "fxch", "fxch", "fxch", "fxch", "fxch",
454 "fnop", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
455 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
456 "fchs", "fabs", NULL, NULL, "ftst", "fxam", NULL, NULL,
457 "fld1", "fldl2t", "fldl2e", "fldpi", "fldlg2", "fldln2", "fldz", NULL,
458 "f2xm1", "fyl2x", "fptan", "fpatan",
459 "fxtract", "fprem1", "fdecstp", "fincstp",
460 "fprem", "fyl2xp1", "fsqrt", "fsincos",
461 "frndint", "fscale", "fsin", "fcos" };
463 static const char *k87DATable1[8] =
464 {"fiadd", "fimul", "ficom", "ficomp", "fisub", "fisubr", "fidiv", "fidivr"};
465 static const char *k87DATable2[64] = {
466 "fcmovb", "fcmovb", "fcmovb", "fcmovb",
467 "fcmovb", "fcmovb", "fcmovb", "fcmovb",
468 "fcmove", "fcmove", "fcmove", "fcmove",
469 "fcmove", "fcmove", "fcmove", "fcmove",
470 "fcmovbe", "fcmovbe", "fcmovbe", "fcmovbe",
471 "fcmovbe", "fcmovbe", "fcmovbe", "fcmovbe",
472 "fcmovu", "fcmovu", "fcmovu", "fcmovu",
473 "fcmovu", "fcmovu", "fcmovu", "fcmovu",
474 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
475 NULL, "fucompp", NULL, NULL, NULL, NULL, NULL, NULL,
476 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
477 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
479 static const char *k87DBTable1[8] =
480 {"fild", "fisttp", "fist", "fistp", NULL, "fld", NULL, "fstp"};
481 static const char *k87DBTable2[64] = {
482 "fcmovnb", "fcmovnb", "fcmovnb", "fcmovnb",
483 "fcmovnb", "fcmovnb", "fcmovnb", "fcmovnb",
484 "fcmovne", "fcmovne", "fcmovne", "fcmovne",
485 "fcmovne", "fcmovne", "fcmovne", "fcmovne",
486 "fcmovnbe", "fcmovnbe", "fcmovnbe", "fcmovnbe",
487 "fcmovnbe", "fcmovnbe", "fcmovnbe", "fcmovnbe",
488 "fcmovnu", "fcmovnu", "fcmovnu", "fcmovnu",
489 "fcmovnu", "fcmovnu", "fcmovnu", "fcmovnu",
490 NULL, NULL, "fnclex", "fninit", NULL, NULL, NULL, NULL,
491 "fucomi", "fucomi", "fucomi", "fucomi",
492 "fucomi", "fucomi", "fucomi", "fucomi",
493 "fcomi", "fcomi", "fcomi", "fcomi",
494 "fcomi", "fcomi", "fcomi", "fcomi",
495 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
497 static const char *k87DCTable1[8] =
498 {"fadd", "fmul", "fcom", "fcomp", "fsub", "fsubr", "fdiv", "fdivr"};
499 static const char *k87DCTable2[64] = {
500 "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd",
501 "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul",
502 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
503 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
504 "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr",
505 "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub",
506 "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr",
507 "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv" };
509 static const char *k87DDTable1[8] =
510 {"fld", "fisttp", "fst", "fstp", "frstor", NULL, "fnsave", "fnstsw"};
511 static const char *k87DDTable2[64] = {
512 "ffree", "ffree", "ffree", "ffree", "ffree", "ffree", "ffree", "ffree",
513 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
514 "fst", "fst", "fst", "fst", "fst", "fst", "fst", "fst",
515 "fstp", "fstp", "fstp", "fstp", "fstp", "fstp", "fstp", "fstp",
516 "fucom", "fucom", "fucom", "fucom", "fucom", "fucom", "fucom", "fucom",
517 "fucomp", "fucomp", "fucomp", "fucomp",
518 "fucomp", "fucomp", "fucomp", "fucomp",
519 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
520 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
522 static const char *k87DETable1[8] =
523 {"fiadd", "fimul", "ficom", "ficomp", "fisub", "fisubr", "fidiv", "fidivr"};
524 static const char *k87DETable2[64] = {
525 "faddp", "faddp", "faddp", "faddp", "faddp", "faddp", "faddp", "faddp",
526 "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp",
527 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
528 NULL, "fcompp", NULL, NULL, NULL, NULL, NULL, NULL,
529 "fsubrp", "fsubrp", "fsubrp", "fsubrp",
530 "fsubrp", "fsubrp", "fsubrp", "fsubrp",
531 "fsubp", "fsubp", "fsubp", "fsubp",
532 "fsubp", "fsubp", "fsubp", "fsubp",
533 "fdivrp", "fdivrp", "fdivrp", "fdivrp",
534 "fdivrp", "fdivrp", "fdivrp", "fdivrp",
535 "fdivp", "fdivp", "fdivp", "fdivp",
536 "fdivp", "fdivp", "fdivp", "fdivp"};
538 static const char *k87DFTable1[8] =
539 {"fild", "fisttp", "fist", "fistp", "fbld", "fild", "fbstp", "fistp"};
540 static const char *k87DFTable2[64] = {
541 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
542 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
543 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
544 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
545 "fnstsw", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
546 "fucomip", "fucomip", "fucomip", "fucomip",
547 "fucomip", "fucomip", "fucomip", "fucomip",
548 "fcomip", "fcomip", "fcomip", "fcomip",
549 "fcomip", "fcomip", "fcomip", "fcomip",
550 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
552 Encode87Op(g_Op87D8, k87D8Table1, k87D8Table2);
553 Encode87Op(g_Op87D9, k87D9Table1, k87D9Table2);
554 Encode87Op(g_Op87DA, k87DATable1, k87DATable2);
555 Encode87Op(g_Op87DB, k87DBTable1, k87DBTable2);
556 Encode87Op(g_Op87DC, k87DCTable1, k87DCTable2);
557 Encode87Op(g_Op87DD, k87DDTable1, k87DDTable2);
558 Encode87Op(g_Op87DE, k87DETable1, k87DETable2);
559 Encode87Op(g_Op87DF, k87DFTable1, k87DFTable2);
560 /* fix instruction type for x87 conditional moves */
561 for (i = 0; i < 8; i++) {
562 g_Op87DA[0xc0 + i]->insttype = NACLi_FCMOV;
563 g_Op87DA[0xc8 + i]->insttype = NACLi_FCMOV;
564 g_Op87DA[0xd0 + i]->insttype = NACLi_FCMOV;
565 g_Op87DA[0xd8 + i]->insttype = NACLi_FCMOV;
566 g_Op87DB[0xc0 + i]->insttype = NACLi_FCMOV;
567 g_Op87DB[0xc8 + i]->insttype = NACLi_FCMOV;
568 g_Op87DB[0xd0 + i]->insttype = NACLi_FCMOV;
569 g_Op87DB[0xd8 + i]->insttype = NACLi_FCMOV;
573 static void BuildMetaTables() {
574 InitializeGlobalTables();
575 /* now add the real contents */
576 /* Eight opcode groups with a regular pattern... */
577 ALUOperandVariants00_05(0x00, NACLi_386L, "add");
578 ALUOperandVariants00_05(0x08, NACLi_386L, "or");
579 ALUOperandVariants00_05(0x10, NACLi_386L, "adc");
580 ALUOperandVariants00_05(0x18, NACLi_386L, "sbb");
581 ALUOperandVariants00_05(0x20, NACLi_386L, "and");
582 ALUOperandVariants00_05(0x28, NACLi_386L, "sub");
583 ALUOperandVariants00_05(0x30, NACLi_386L, "xor");
584 ALUOperandVariants00_05(0x38, NACLi_386, "cmp");
585 /* Fill in gaps between 00 and 0x40 */
586 EncodeOpByte1(0x06, 0, IMM_NONE, NACLi_ILLEGAL, "push %es");
587 EncodeOpByte1(0x16, 0, IMM_NONE, NACLi_ILLEGAL, "push %ss");
588 EncodeOpByte1(0x26, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %es]");
589 EncodeOpByte1(0x36, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %ss]");
590 EncodeOpByte1(0x07, 0, IMM_NONE, NACLi_ILLEGAL, "pop %es");
591 EncodeOpByte1(0x17, 0, IMM_NONE, NACLi_ILLEGAL, "pop %ss");
592 EncodeOpByte1(0x27, 0, IMM_NONE, NACLi_ILLEGAL, "daa");
593 EncodeOpByte1(0x37, 0, IMM_NONE, NACLi_ILLEGAL, "aaa"); /* deprecated */
594 EncodeOpByte1(0x0e, 0, IMM_NONE, NACLi_ILLEGAL, "push %cs");
595 EncodeOpByte1(0x1e, 0, IMM_NONE, NACLi_ILLEGAL, "push %ds");
596 EncodeOpByte1(0x2e, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %cs]");
597 EncodeOpByte1(0x3e, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %ds]");
598 /* 0x0f is an escape to two-byte instructions, below... */
599 EncodeOpByte1(0x0f, 0, IMM_NONE, NACLi_UNDEFINED, "[two-byte opcode]");
600 EncodeOpByte1(0x1f, 0, IMM_NONE, NACLi_ILLEGAL, "pop %ds");
601 EncodeOpByte1(0x2f, 0, IMM_NONE, NACLi_ILLEGAL, "das");
602 EncodeOpByte1(0x3f, 0, IMM_NONE, NACLi_ILLEGAL, "aas"); /* deprecated */
603 /* another easy pattern, 0x40-0x5f */
604 /* inc and dec are deprecated in x86-64; NaCl discourages their use. */
605 OneRegVariants00_07(0x40, NACLi_386L, "inc");
606 OneRegVariants00_07(0x48, NACLi_386L, "dec");
607 OneRegVariants00_07(0x50, NACLi_386, "push");
608 OneRegVariants00_07(0x58, NACLi_386, "pop");
609 /* 0x60-0x6f */
610 EncodeOpByte1(0x60, 0, IMM_NONE, NACLi_ILLEGAL, "pusha");
611 EncodeOpByte1(0x61, 0, IMM_NONE, NACLi_ILLEGAL, "popa"); /* also POPAD */
612 EncodeOpByte1(0x62, 1, IMM_NONE, NACLi_ILLEGAL, "bound $Gv, $Ma"); /* deprecated */
613 EncodeOpByte1(0x63, 1, IMM_NONE, NACLi_SYSTEM, "arpl $Ew, $Gw"); /* system */
614 EncodeOpByte1(0x64, 0, IMM_NONE, NACLi_ILLEGAL, "[seg fs]");
615 EncodeOpByte1(0x65, 0, IMM_NONE, NACLi_ILLEGAL, "[seg gs]");
616 EncodeOpByte1(0x66, 0, IMM_NONE, NACLi_ILLEGAL, "[data16]");
617 EncodeOpByte1(0x67, 0, IMM_NONE, NACLi_ILLEGAL, "[addr size]");
618 EncodeOpByte1(0x68, 0, IMM_DATAV, NACLi_386, "push $Iz");
619 EncodeOpByte1(0x69, 1, IMM_DATAV, NACLi_386, "imul $Gv, $Ev, $Iz");
620 EncodeOpByte1(0x6a, 0, IMM_FIXED1, NACLi_386, "push $Ib");
621 EncodeOpByte1(0x6b, 1, IMM_FIXED1, NACLi_386, "imul $Gv, $Ev, $Ib");
622 EncodeOpByte1(0x6c, 0, IMM_NONE, NACLi_ILLEGAL, "insb $Y, $D");
623 EncodeOpByte1(0x6d, 0, IMM_NONE, NACLi_ILLEGAL, "insw/d $Y, $D");
624 EncodeOpByte1(0x6e, 0, IMM_NONE, NACLi_ILLEGAL, "outsb $D, $X");
625 EncodeOpByte1(0x6f, 0, IMM_NONE, NACLi_ILLEGAL, "outsw/d $D, $X");
626 /* 0x70-0x77: jumps */
627 EncodeOpByte1(0x70, 0, IMM_FIXED1, NACLi_JMP8, "jo $Jb");
628 EncodeOpByte1(0x71, 0, IMM_FIXED1, NACLi_JMP8, "jno $Jb");
629 EncodeOpByte1(0x72, 0, IMM_FIXED1, NACLi_JMP8, "jb $Jb");
630 EncodeOpByte1(0x73, 0, IMM_FIXED1, NACLi_JMP8, "jnb $Jb");
631 EncodeOpByte1(0x74, 0, IMM_FIXED1, NACLi_JMP8, "jz $Jb");
632 EncodeOpByte1(0x75, 0, IMM_FIXED1, NACLi_JMP8, "jnz $Jb");
633 EncodeOpByte1(0x76, 0, IMM_FIXED1, NACLi_JMP8, "jbe $Jb");
634 EncodeOpByte1(0x77, 0, IMM_FIXED1, NACLi_JMP8, "jnbe $Jb");
635 EncodeOpByte1(0x78, 0, IMM_FIXED1, NACLi_JMP8, "js $Jb");
636 EncodeOpByte1(0x79, 0, IMM_FIXED1, NACLi_JMP8, "jns $Jb");
637 EncodeOpByte1(0x7a, 0, IMM_FIXED1, NACLi_JMP8, "jp $Jb");
638 EncodeOpByte1(0x7b, 0, IMM_FIXED1, NACLi_JMP8, "jnp $Jb");
639 EncodeOpByte1(0x7c, 0, IMM_FIXED1, NACLi_JMP8, "jl $Jb");
640 EncodeOpByte1(0x7d, 0, IMM_FIXED1, NACLi_JMP8, "jge $Jb");
641 EncodeOpByte1(0x7e, 0, IMM_FIXED1, NACLi_JMP8, "jle $Jb");
642 EncodeOpByte1(0x7f, 0, IMM_FIXED1, NACLi_JMP8, "jg $Jb");
643 /* 0x80-0x8f: Gpr1, test, xchg, mov, lea, mov, pop */
644 EncodeOpByte1(0x80, 1, IMM_FIXED1, NACLi_OPINMRM, "$group1 $Eb, $Ib");
645 SetOpByte1OpInMRM(0x80, GROUP1);
646 EncodeOpByte1(0x81, 1, IMM_DATAV, NACLi_OPINMRM, "$group1 $Ev, $Iz");
647 SetOpByte1OpInMRM(0x81, GROUP1);
648 /* The AMD manual shows 0x82 as a synonym for 0x80, however these are */
649 /* all illegal in 64-bit mode so we omit them here too. */
650 EncodeOpByte1(0x82, 1, IMM_FIXED1, NACLi_ILLEGAL, "undef");
651 /* table disagrees with objdump on 0x83? */
652 EncodeOpByte1(0x83, 1, IMM_FIXED1, NACLi_OPINMRM, "$group1 $Ev, $Ib");
653 SetOpByte1OpInMRM(0x83, GROUP1);
654 EncodeOpByte1(0x84, 1, IMM_NONE, NACLi_386, "test $E, $G");
655 EncodeOpByte1(0x85, 1, IMM_NONE, NACLi_386, "test $E, $G");
656 EncodeOpByte1(0x86, 1, IMM_NONE, NACLi_386L, "xchg $E, $G");
657 EncodeOpByte1(0x87, 1, IMM_NONE, NACLi_386L, "xchg $E, $G");
658 EncodeOpByte1(0x88, 1, IMM_NONE, NACLi_386, "mov $Eb, $Gb");
659 EncodeOpByte1(0x89, 1, IMM_NONE, NACLi_386, "mov $Ev, $Gv");
660 EncodeOpByte1(0x8a, 1, IMM_NONE, NACLi_386, "mov $Gb, $Eb");
661 EncodeOpByte1(0x8b, 1, IMM_NONE, NACLi_386, "mov $Gv, $Ev");
662 EncodeOpByte1(0x8c, 1, IMM_NONE, NACLi_ILLEGAL, "mov $E, $S");
663 EncodeOpByte1(0x8d, 1, IMM_NONE, NACLi_386, "lea $G, $M");
664 EncodeOpByte1(0x8e, 1, IMM_NONE, NACLi_ILLEGAL, "mov $S, $E");
665 EncodeOpByte1(0x8f, 1, IMM_NONE, NACLi_OPINMRM, "$group1a $Ev");
666 SetOpByte1OpInMRM(0x8f, GROUP1A);
667 /* 0x90-0x9f */
668 EncodeOpByte1(0x90, 0, IMM_NONE, NACLi_386R, "nop");
669 EncodeOpByte1(0x91, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ecx");
670 EncodeOpByte1(0x92, 0, IMM_NONE, NACLi_386L, "xchg %eax, %edx");
671 EncodeOpByte1(0x93, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ebx");
672 EncodeOpByte1(0x94, 0, IMM_NONE, NACLi_386L, "xchg %eax, %esp");
673 EncodeOpByte1(0x95, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ebp");
674 EncodeOpByte1(0x96, 0, IMM_NONE, NACLi_386L, "xchg %eax, %esi");
675 EncodeOpByte1(0x97, 0, IMM_NONE, NACLi_386L, "xchg %eax, %edi");
676 EncodeOpByte1(0x98, 0, IMM_NONE, NACLi_386, "cbw"); /* cwde cdqe */
677 EncodeOpByte1(0x99, 0, IMM_NONE, NACLi_386, "cwd"); /* cdq cqo */
678 EncodeOpByte1(0x9a, 0, IMM_FARPTR, NACLi_ILLEGAL, "lcall $A");
679 EncodeOpByte1(0x9b, 0, IMM_NONE, NACLi_X87, "wait");
680 EncodeOpByte1(0x9c, 0, IMM_NONE, NACLi_ILLEGAL, "pushf $F");
681 EncodeOpByte1(0x9d, 0, IMM_NONE, NACLi_ILLEGAL, "popf $F");
682 EncodeOpByte1(0x9e, 0, IMM_NONE, NACLi_386, "sahf");
683 EncodeOpByte1(0x9f, 0, IMM_NONE, NACLi_386, "lahf");
684 /* 0xa0-0xaf */
685 EncodeOpByte1(0xa0, 0, IMM_ADDRV, NACLi_386, "mov %al, $O");
686 EncodeOpByte1(0xa1, 0, IMM_ADDRV, NACLi_386, "mov %eax, $O");
687 EncodeOpByte1(0xa2, 0, IMM_ADDRV, NACLi_386, "mov $O, %al");
688 EncodeOpByte1(0xa3, 0, IMM_ADDRV, NACLi_386, "mov $O, %eax");
689 EncodeOpByte1(0xa4, 0, IMM_NONE, NACLi_386R, "movsb $X, $Y");
690 EncodeOpByte1(0xa5, 0, IMM_NONE, NACLi_386R, "movsw $X, $Y");
691 EncodeOpByte1(0xa6, 0, IMM_NONE, NACLi_386RE, "cmpsb $X, $Y");
692 EncodeOpByte1(0xa7, 0, IMM_NONE, NACLi_386RE, "cmpsw $X, $Y");
693 EncodeOpByte1(0xa8, 0, IMM_FIXED1, NACLi_386, "test %al, $I");
694 EncodeOpByte1(0xa9, 0, IMM_DATAV, NACLi_386, "test %eax, $I");
695 EncodeOpByte1(0xaa, 0, IMM_NONE, NACLi_386R, "stosb $Y, %al");
696 EncodeOpByte1(0xab, 0, IMM_NONE, NACLi_386R, "stosw $Y, $eax");
697 /* ISE reviewers suggested omiting lods and scas */
698 EncodeOpByte1(0xac, 0, IMM_NONE, NACLi_ILLEGAL, "lodsb %al, $X");
699 EncodeOpByte1(0xad, 0, IMM_NONE, NACLi_ILLEGAL, "lodsw %eax, $X");
700 EncodeOpByte1(0xae, 0, IMM_NONE, NACLi_386RE, "scasb %al, $X");
701 EncodeOpByte1(0xaf, 0, IMM_NONE, NACLi_386RE, "scasw %eax, $X");
702 /* 0xb0-0xbf */
703 EncodeOpByte1(0xb0, 0, IMM_FIXED1, NACLi_386, "mov %al, $Ib");
704 EncodeOpByte1(0xb1, 0, IMM_FIXED1, NACLi_386, "mov %cl, $Ib");
705 EncodeOpByte1(0xb2, 0, IMM_FIXED1, NACLi_386, "mov %dl, $Ib");
706 EncodeOpByte1(0xb3, 0, IMM_FIXED1, NACLi_386, "mov %bl, $Ib");
707 EncodeOpByte1(0xb4, 0, IMM_FIXED1, NACLi_386, "mov %ah, $Ib");
708 EncodeOpByte1(0xb5, 0, IMM_FIXED1, NACLi_386, "mov %ch, $Ib");
709 EncodeOpByte1(0xb6, 0, IMM_FIXED1, NACLi_386, "mov %dh, $Ib");
710 EncodeOpByte1(0xb7, 0, IMM_FIXED1, NACLi_386, "mov %bh, $Ib");
711 EncodeOpByte1(0xb8, 0, IMM_DATAV, NACLi_386, "mov %eax, $Iv");
712 EncodeOpByte1(0xb9, 0, IMM_DATAV, NACLi_386, "mov %ecx, $Iv");
713 EncodeOpByte1(0xba, 0, IMM_DATAV, NACLi_386, "mov %edx, $Iv");
714 EncodeOpByte1(0xbb, 0, IMM_DATAV, NACLi_386, "mov %ebx, $Iv");
715 EncodeOpByte1(0xbc, 0, IMM_DATAV, NACLi_386, "mov %esp, $Iv");
716 EncodeOpByte1(0xbd, 0, IMM_DATAV, NACLi_386, "mov %ebp, $Iv");
717 EncodeOpByte1(0xbe, 0, IMM_DATAV, NACLi_386, "mov %esi, $Iv");
718 EncodeOpByte1(0xbf, 0, IMM_DATAV, NACLi_386, "mov %edi, $Iv");
719 /* 0xc0-0xcf */
720 EncodeOpByte1(0xc0, 1, IMM_FIXED1, NACLi_OPINMRM, "$group2 $Eb, $Ib");
721 SetOpByte1OpInMRM(0xc0, GROUP2);
722 EncodeOpByte1(0xc1, 1, IMM_FIXED1, NACLi_OPINMRM, "$group2 $Ev, $Ib");
723 SetOpByte1OpInMRM(0xc1, GROUP2);
724 EncodeOpByte1(0xc2, 0, IMM_FIXED2, NACLi_RETURN, "ret $Iw");
725 EncodeOpByte1(0xc3, 0, IMM_NONE, NACLi_RETURN, "ret");
726 EncodeOpByte1(0xc4, 1, IMM_NONE, NACLi_ILLEGAL, "les $G, $M");
727 EncodeOpByte1(0xc5, 1, IMM_NONE, NACLi_ILLEGAL, "lds $G, $M");
728 EncodeOpByte1(0xc6, 1, IMM_FIXED1, NACLi_OPINMRM, "$group11 $Eb, $Ib");
729 SetOpByte1OpInMRM(0xc6, GROUP11);
730 EncodeOpByte1(0xc7, 1, IMM_DATAV, NACLi_OPINMRM, "$group11 $Ev, $Iz");
731 SetOpByte1OpInMRM(0xc7, GROUP11);
732 EncodeOpByte1(0xc8, 0, IMM_FIXED3, NACLi_ILLEGAL, "enter $I, $I");
733 EncodeOpByte1(0xc9, 0, IMM_NONE, NACLi_386, "leave");
734 EncodeOpByte1(0xca, 0, IMM_FIXED2, NACLi_RETURN, "ret (far)");
735 EncodeOpByte1(0xcb, 0, IMM_NONE, NACLi_RETURN, "ret (far)");
736 EncodeOpByte1(0xcc, 0, IMM_NONE, NACLi_ILLEGAL, "int3");
737 EncodeOpByte1(0xcd, 0, IMM_FIXED1, NACLi_ILLEGAL, "int $Iv");
738 EncodeOpByte1(0xce, 0, IMM_NONE, NACLi_ILLEGAL, "into");
739 EncodeOpByte1(0xcf, 0, IMM_NONE, NACLi_SYSTEM, "iret");
740 /* 0xd0-0xdf */
741 EncodeOpByte1(0xd0, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Eb, 1");
742 SetOpByte1OpInMRM(0xd0, GROUP2);
743 EncodeOpByte1(0xd1, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Ev, 1");
744 SetOpByte1OpInMRM(0xd1, GROUP2);
745 EncodeOpByte1(0xd2, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Eb, %cl");
746 SetOpByte1OpInMRM(0xd2, GROUP2);
747 EncodeOpByte1(0xd3, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Ev, %cl");
748 SetOpByte1OpInMRM(0xd3, GROUP2);
749 /* ISE reviewers suggested omision of AAM, AAD */
750 EncodeOpByte1(0xd4, 0, IMM_FIXED1, NACLi_ILLEGAL, "aam"); /* deprecated */
751 EncodeOpByte1(0xd5, 0, IMM_FIXED1, NACLi_ILLEGAL, "aad"); /* deprecated */
752 EncodeOpByte1(0xd6, 0, IMM_NONE, NACLi_ILLEGAL, "salc");
753 /* ISE reviewers suggested this omision */
754 EncodeOpByte1(0xd7, 0, IMM_NONE, NACLi_ILLEGAL, "xlat");
755 EncodeOpByte1(0xd8, 1, IMM_NONE, NACLi_X87, "x87");
756 EncodeOpByte1(0xd9, 1, IMM_NONE, NACLi_X87, "x87");
757 EncodeOpByte1(0xda, 1, IMM_NONE, NACLi_X87, "x87");
758 EncodeOpByte1(0xdb, 1, IMM_NONE, NACLi_X87, "x87");
759 EncodeOpByte1(0xdc, 1, IMM_NONE, NACLi_X87, "x87");
760 EncodeOpByte1(0xdd, 1, IMM_NONE, NACLi_X87, "x87");
761 EncodeOpByte1(0xde, 1, IMM_NONE, NACLi_X87, "x87");
762 EncodeOpByte1(0xdf, 1, IMM_NONE, NACLi_X87, "x87");
763 /* 0xe0-0xef */
764 /* ISE reviewers suggested making loopne, loope, loop, jcxz illegal */
765 /* There are faster alternatives on modern x86 implementations. */
766 EncodeOpByte1(0xe0, 0, IMM_FIXED1, NACLi_ILLEGAL, "loopne $Jb");
767 EncodeOpByte1(0xe1, 0, IMM_FIXED1, NACLi_ILLEGAL, "loope $Jb");
768 EncodeOpByte1(0xe2, 0, IMM_FIXED1, NACLi_ILLEGAL, "loop $Jb");
769 EncodeOpByte1(0xe3, 0, IMM_FIXED1, NACLi_ILLEGAL, "jcxz $Jb");
770 /* I/O instructions */
771 EncodeOpByte1(0xe4, 0, IMM_FIXED1, NACLi_ILLEGAL, "in %al, $I");
772 EncodeOpByte1(0xe5, 0, IMM_FIXED1, NACLi_ILLEGAL, "in %eax, $I");
773 EncodeOpByte1(0xe6, 0, IMM_FIXED1, NACLi_ILLEGAL, "out %al, $I");
774 EncodeOpByte1(0xe7, 0, IMM_FIXED1, NACLi_ILLEGAL, "out %eax, $I");
775 EncodeOpByte1(0xe8, 0, IMM_DATAV, NACLi_JMPZ, "call $Jz");
776 EncodeOpByte1(0xe9, 0, IMM_DATAV, NACLi_JMPZ, "jmp $Jz");
777 EncodeOpByte1(0xea, 0, IMM_FARPTR, NACLi_ILLEGAL, "ljmp $A");
778 EncodeOpByte1(0xeb, 0, IMM_FIXED1, NACLi_JMP8, "jmp $Jb");
779 EncodeOpByte1(0xec, 0, IMM_NONE, NACLi_ILLEGAL, "in %al, %dx");
780 EncodeOpByte1(0xed, 0, IMM_NONE, NACLi_ILLEGAL, "in %eax, %dx");
781 EncodeOpByte1(0xee, 0, IMM_NONE, NACLi_ILLEGAL, "out %dx, %al");
782 EncodeOpByte1(0xef, 0, IMM_NONE, NACLi_ILLEGAL, "out %dx, %eax");
783 /* 0xf0-0xff */
784 EncodeOpByte1(0xf0, 0, IMM_NONE, NACLi_ILLEGAL, "[lock]");
785 EncodeOpByte1(0xf1, 0, IMM_NONE, NACLi_ILLEGAL, "int1");
786 EncodeOpByte1(0xf2, 0, IMM_NONE, NACLi_ILLEGAL, "[repne]");
787 EncodeOpByte1(0xf3, 0, IMM_NONE, NACLi_ILLEGAL, "[rep]");
788 /* NaCl uses the hlt instruction for bytes that should never be */
789 /* executed. hlt causes immediate termination of the module. */
790 EncodeOpByte1(0xf4, 0, IMM_NONE, NACLi_386, "hlt");
791 EncodeOpByte1(0xf5, 0, IMM_NONE, NACLi_386, "cmc");
792 /* Note: /0 and /1 also have an immediate */
793 EncodeOpByte1(0xf6, 1, IMM_GROUP3_F6, NACLi_OPINMRM, "$group3 $Eb");
794 SetOpByte1OpInMRM(0xf6, GROUP3);
795 EncodeOpByte1(0xf7, 1, IMM_GROUP3_F7, NACLi_OPINMRM, "$group3 $Ev");
796 SetOpByte1OpInMRM(0xf7, GROUP3);
797 EncodeOpByte1(0xf8, 0, IMM_NONE, NACLi_386, "clc");
798 EncodeOpByte1(0xf9, 0, IMM_NONE, NACLi_386, "stc");
799 EncodeOpByte1(0xfa, 0, IMM_NONE, NACLi_SYSTEM, "cli");
800 EncodeOpByte1(0xfb, 0, IMM_NONE, NACLi_SYSTEM, "sti");
801 /* cld and std are generated by gcc, used for mem move operations */
802 EncodeOpByte1(0xfc, 0, IMM_NONE, NACLi_386, "cld");
803 EncodeOpByte1(0xfd, 0, IMM_NONE, NACLi_386, "std");
804 EncodeOpByte1(0xfe, 1, IMM_NONE, NACLi_OPINMRM, "$group4 $Eb");
805 SetOpByte1OpInMRM(0xfe, GROUP4);
806 /* Note: /3 and /5 are $Mp rather than $Ev */
807 EncodeOpByte1(0xff, 1, IMM_NONE, NACLi_OPINMRM, "$group5 $Ev");
808 SetOpByte1OpInMRM(0xff, GROUP5);
810 /* Opcodes encoded in the modrm field */
811 /* Anything not done explicitly is marked illegal */
812 /* group1 */
813 EncodeModRMOp(GROUP1, 0, NACLi_386L, "add");
814 EncodeModRMOp(GROUP1, 1, NACLi_386L, "or");
815 EncodeModRMOp(GROUP1, 2, NACLi_386L, "adc");
816 EncodeModRMOp(GROUP1, 3, NACLi_386L, "sbb");
817 EncodeModRMOp(GROUP1, 4, NACLi_386L, "and");
818 EncodeModRMOp(GROUP1, 5, NACLi_386L, "sub");
819 EncodeModRMOp(GROUP1, 6, NACLi_386L, "xor");
820 EncodeModRMOp(GROUP1, 7, NACLi_386, "cmp");
821 /* group1a */
822 EncodeModRMOp(GROUP1A, 0, NACLi_386, "pop $Ev");
823 /* all other group1a opcodes are illegal */
824 /* group2 */
825 EncodeModRMOp(GROUP2, 0, NACLi_386, "rol");
826 EncodeModRMOp(GROUP2, 1, NACLi_386, "ror");
827 EncodeModRMOp(GROUP2, 2, NACLi_386, "rcl");
828 EncodeModRMOp(GROUP2, 3, NACLi_386, "rcr");
829 EncodeModRMOp(GROUP2, 4, NACLi_386, "shl"); /* sal */
830 EncodeModRMOp(GROUP2, 5, NACLi_386, "shr"); /* sar */
831 /* note 2, 6 is illegal according to Intel, shl according to AMD */
832 EncodeModRMOp(GROUP2, 7, NACLi_386, "sar");
833 /* group3 */
834 EncodeModRMOp(GROUP3, 0, NACLi_386, "test $I");
835 /* this is such a weird case ... just put a special case in ncdecode.c */
836 /* note 3, 1 is handled by a special case in the decoder */
837 /* SetModRMOpImmType(3, 0, IMM_FIXED1); */
838 EncodeModRMOp(GROUP3, 2, NACLi_386L, "not");
839 EncodeModRMOp(GROUP3, 3, NACLi_386L, "neg");
840 EncodeModRMOp(GROUP3, 4, NACLi_386, "mul %eax");
841 EncodeModRMOp(GROUP3, 5, NACLi_386, "imul %eax");
842 EncodeModRMOp(GROUP3, 6, NACLi_386, "div %eax");
843 EncodeModRMOp(GROUP3, 7, NACLi_386, "idiv %eax");
844 /* group4 */
845 EncodeModRMOp(GROUP4, 0, NACLi_386L, "inc");
846 EncodeModRMOp(GROUP4, 1, NACLi_386L, "dec");
847 /* group5 */
848 EncodeModRMOp(GROUP5, 0, NACLi_386L, "inc");
849 EncodeModRMOp(GROUP5, 1, NACLi_386L, "dec");
850 EncodeModRMOp(GROUP5, 2, NACLi_INDIRECT, "call *"); /* call indirect */
851 EncodeModRMOp(GROUP5, 3, NACLi_ILLEGAL, "lcall *"); /* far call */
852 EncodeModRMOp(GROUP5, 4, NACLi_INDIRECT, "jmp *"); /* jump indirect */
853 EncodeModRMOp(GROUP5, 5, NACLi_ILLEGAL, "ljmp *"); /* far jmp */
854 EncodeModRMOp(GROUP5, 6, NACLi_386, "push");
855 /* group6 */
856 EncodeModRMOp(GROUP6, 0, NACLi_SYSTEM, "sldt");
857 EncodeModRMOp(GROUP6, 1, NACLi_SYSTEM, "str");
858 EncodeModRMOp(GROUP6, 2, NACLi_SYSTEM, "lldt");
859 EncodeModRMOp(GROUP6, 3, NACLi_SYSTEM, "ltr");
860 EncodeModRMOp(GROUP6, 4, NACLi_SYSTEM, "verr");
861 EncodeModRMOp(GROUP6, 5, NACLi_SYSTEM, "verw");
862 /* group7 */
863 EncodeModRMOp(GROUP7, 0, NACLi_SYSTEM, "sgdt");
864 EncodeModRMOp(GROUP7, 1, NACLi_SYSTEM, "sidt"); /* monitor mwait */
865 EncodeModRMOp(GROUP7, 2, NACLi_SYSTEM, "lgdt");
866 EncodeModRMOp(GROUP7, 3, NACLi_SYSTEM, "lidt");
867 EncodeModRMOp(GROUP7, 4, NACLi_SYSTEM, "smsw");
868 EncodeModRMOp(GROUP7, 6, NACLi_SYSTEM, "lmsw");
869 EncodeModRMOp(GROUP7, 7, NACLi_SYSTEM, "invlpg"); /* swapgs rdtscp */
870 /* group8 */
871 /* ISE reviewers suggested omitting bt* */
872 EncodeModRMOp(GROUP8, 4, NACLi_ILLEGAL, "bt"); /* deprecated */
873 EncodeModRMOp(GROUP8, 5, NACLi_ILLEGAL, "bts"); /* deprecated */
874 EncodeModRMOp(GROUP8, 6, NACLi_ILLEGAL, "btr"); /* deprecated */
875 EncodeModRMOp(GROUP8, 7, NACLi_ILLEGAL, "btc"); /* deprecated */
876 /* group9 */
877 /* If the effective operand size is 16 or 32 bits, cmpxchg8b is used. */
878 /* If the size is 64 bits, cmpxchg16b is used, (64-bit mode only) */
879 /* These instructions do support the LOCK prefix */
880 EncodeModRMOp(GROUP9, 1, NACLi_CMPXCHG8B, "cmpxchg8b");
881 /* group10 - all illegal */
882 /* group11 */
883 EncodeModRMOp(GROUP11, 0, NACLi_386, "mov");
884 /* group12 */
885 EncodeModRMOp(GROUP12, 2, NACLi_MMXSSE2, "psrlw");
886 EncodeModRMOp(GROUP12, 4, NACLi_MMXSSE2, "psraw");
887 EncodeModRMOp(GROUP12, 6, NACLi_MMXSSE2, "psllw");
888 /* group13 */
889 EncodeModRMOp(GROUP13, 2, NACLi_MMXSSE2, "psrld");
890 EncodeModRMOp(GROUP13, 4, NACLi_MMXSSE2, "psrad");
891 EncodeModRMOp(GROUP13, 6, NACLi_MMXSSE2, "pslld");
892 /* group14 */
893 EncodeModRMOp(GROUP14, 2, NACLi_MMXSSE2, "psrlq");
894 EncodeModRMOp(GROUP14, 3, NACLi_SSE2x, "psrldq");
895 EncodeModRMOp(GROUP14, 6, NACLi_MMXSSE2, "psllq");
896 EncodeModRMOp(GROUP14, 7, NACLi_SSE2x, "pslldq");
897 /* group15 */
898 EncodeModRMOp(GROUP15, 0, NACLi_ILLEGAL, "fxsave");
899 EncodeModRMOp(GROUP15, 1, NACLi_ILLEGAL, "fxrstor");
900 EncodeModRMOp(GROUP15, 2, NACLi_ILLEGAL, "ldmxcsr"); /* SSE */
901 EncodeModRMOp(GROUP15, 3, NACLi_ILLEGAL, "stmxcsr");
902 EncodeModRMOp(GROUP15, 4, NACLi_ILLEGAL, "invalid");
903 TODO;
904 EncodeModRMOp(GROUP15, 5, NACLi_ILLEGAL, "lfence");
905 EncodeModRMOp(GROUP15, 6, NACLi_SSE2, "mfence");
906 EncodeModRMOp(GROUP15, 7, NACLi_ILLEGAL, "sfence/clflush");
907 /* group16 - SSE prefetch instructions */
908 EncodeModRMOp(GROUP16, 0, NACLi_SSE, "prefetch NTA");
909 EncodeModRMOp(GROUP16, 1, NACLi_SSE, "prefetch T0");
910 EncodeModRMOp(GROUP16, 2, NACLi_SSE, "prefetch T1");
911 EncodeModRMOp(GROUP16, 3, NACLi_SSE, "prefetch T1");
912 EncodeModRMOp(GROUP16, 4, NACLi_ILLEGAL, "NOP (prefetch)");
913 EncodeModRMOp(GROUP16, 5, NACLi_ILLEGAL, "NOP (prefetch)");
914 EncodeModRMOp(GROUP16, 6, NACLi_ILLEGAL, "NOP (prefetch)");
915 EncodeModRMOp(GROUP16, 7, NACLi_ILLEGAL, "NOP (prefetch)");
916 /* groupp: prefetch - requires longmode or 3DNow! */
917 /* It may be the case that these can also be enabled by CPUID_ECX_PRE; */
918 /* This enabling is not supported by the validator at this time. */
919 EncodeModRMOp(GROUPP, 0, NACLi_3DNOW, "prefetch exclusive");
920 EncodeModRMOp(GROUPP, 1, NACLi_3DNOW, "prefetch modified");
921 EncodeModRMOp(GROUPP, 2, NACLi_ILLEGAL, "[prefetch reserved]");
922 EncodeModRMOp(GROUPP, 3, NACLi_ILLEGAL, "prefetch modified");
923 EncodeModRMOp(GROUPP, 4, NACLi_ILLEGAL, "[prefetch reserved]");
924 EncodeModRMOp(GROUPP, 5, NACLi_ILLEGAL, "[prefetch reserved]");
925 EncodeModRMOp(GROUPP, 6, NACLi_ILLEGAL, "[prefetch reserved]");
926 EncodeModRMOp(GROUPP, 7, NACLi_ILLEGAL, "[prefetch reserved]");
928 /* encode opbyte 2; first byte is 0x0f */
929 /* holes are undefined instructions */
930 /* This code used to allow the data16 (0x16) prefix to be used with */
931 /* any two-byte opcode, until it caused a bug. Now all allowed */
932 /* prefixes need to be added explicitly. */
933 /* See http://code.google.com/p/nativeclient/issues/detail?id=50 */
934 /* Note: /0 and /1 have $Mw/Rv instead of $Ew */
935 EncodeOp0F(0x00, 1, IMM_NONE, NACLi_OPINMRM, "$group6 $Ew");
936 SetOp0FOpInMRM(0x0, GROUP6);
937 /* Group7 is all privileged/system instructions */
938 EncodeOp0F(0x01, 1, IMM_NONE, NACLi_OPINMRM, "$group7");
939 SetOp0FOpInMRM(0x01, GROUP7);
940 EncodeOp0F(0x02, 1, IMM_NONE, NACLi_SYSTEM, "lar $G, $E");
941 EncodeOp0F(0x03, 1, IMM_NONE, NACLi_ILLEGAL, "lsl $Gv, $Ew");
942 EncodeOp0F(0x05, 0, IMM_NONE, NACLi_SYSCALL, "syscall");
943 EncodeOp0F(0x06, 0, IMM_NONE, NACLi_SYSTEM, "clts");
944 EncodeOp0F(0x07, 0, IMM_NONE, NACLi_ILLEGAL, "sysret");
945 EncodeOp0F(0x08, 0, IMM_NONE, NACLi_SYSTEM, "invd");
946 EncodeOp0F(0x09, 0, IMM_NONE, NACLi_SYSTEM, "wbinvd");
947 EncodeOp0F(0x0b, 0, IMM_NONE, NACLi_ILLEGAL, "ud2");
948 EncodeOp0F(0x0d, 1, IMM_NONE, NACLi_OPINMRM, "$groupP (prefetch)");
949 SetOp0FOpInMRM(0x0d, GROUPP);
950 EncodeOp0F(0x0e, 0, IMM_NONE, NACLi_3DNOW, "femms");
951 /* 3DNow instruction encodings use a MODRM byte and a 1-byte */
952 /* immediate which defines the opcode. */
953 EncodeOp0F(0x0f, 1, IMM_FIXED1, NACLi_3DNOW, "3DNow");
954 /* 0x10-17 appear below with the other newer opcodes ... */
955 EncodeOp0F(0x18, 1, IMM_NONE, NACLi_OPINMRM, "$group16");
956 SetOp0FOpInMRM(0x18, GROUP16);
957 /* this nop takes an MRM byte */
958 EncodeOp0F(0x1f, 1, IMM_NONE, NACLi_386, "nop");
959 EncodeOp0F(0x20, 1, IMM_NONE, NACLi_SYSTEM, "mov $C, $R");
960 EncodeOp0F(0x21, 1, IMM_NONE, NACLi_SYSTEM, "mov $D, $R");
961 EncodeOp0F(0x22, 1, IMM_NONE, NACLi_SYSTEM, "mov $R, $C");
962 EncodeOp0F(0x23, 1, IMM_NONE, NACLi_SYSTEM, "mov $R, $D");
963 /* These two seem to be a mistake */
964 /* EncodeOp0F(0x24, 0, IMM_NONE, NACLi_SYSTEM, "mov $T, $R"); */
965 /* EncodeOp0F(0x26, 0, IMM_NONE, NACLi_SYSTEM, "mov $R, $T"); */
966 /* 0x30-0x38 */
967 EncodeOp0F(0x30, 0, IMM_NONE, NACLi_RDMSR, "wrmsr");
968 EncodeOp0F(0x31, 0, IMM_NONE, NACLi_RDTSC, "rdtsc");
969 EncodeOp0F(0x32, 0, IMM_NONE, NACLi_RDMSR, "rdmsr");
970 EncodeOp0F(0x33, 0, IMM_NONE, NACLi_SYSTEM, "rdpmc");
971 EncodeOp0F(0x34, 0, IMM_NONE, NACLi_SYSENTER, "sysenter");
972 EncodeOp0F(0x35, 0, IMM_NONE, NACLi_SYSENTER, "sysexit");
973 EncodeOp0F(0x38, 1, IMM_NONE, NACLi_3BYTE, "SSSE3, SSE4");
974 EncodeOp0F(0x3a, 1, IMM_FIXED1, NACLi_3BYTE, "SSSE3, SSE4");
975 /* 0x40-0x48 */
976 EncodeOp0F(0x40, 1, IMM_NONE, NACLi_CMOV, "cmovo $Gv, $Ev");
977 EncodeOp0F(0x41, 1, IMM_NONE, NACLi_CMOV, "cmovno $Gv, $Ev");
978 EncodeOp0F(0x42, 1, IMM_NONE, NACLi_CMOV, "cmovb $Gv, $Ev");
979 EncodeOp0F(0x43, 1, IMM_NONE, NACLi_CMOV, "cmovnb $Gv, $Ev");
980 EncodeOp0F(0x44, 1, IMM_NONE, NACLi_CMOV, "cmovz $Gv, $Ev");
981 EncodeOp0F(0x45, 1, IMM_NONE, NACLi_CMOV, "cmovnz $Gv, $Ev");
982 EncodeOp0F(0x46, 1, IMM_NONE, NACLi_CMOV, "cmovbe $Gv, $Ev");
983 EncodeOp0F(0x47, 1, IMM_NONE, NACLi_CMOV, "cmovnbe $Gv, $Ev");
984 EncodeOp0F(0x48, 1, IMM_NONE, NACLi_CMOV, "cmovs $Gv, $Ev");
985 EncodeOp0F(0x49, 1, IMM_NONE, NACLi_CMOV, "cmovns $Gv, $Ev");
986 EncodeOp0F(0x4a, 1, IMM_NONE, NACLi_CMOV, "cmovp $Gv, $Ev");
987 EncodeOp0F(0x4b, 1, IMM_NONE, NACLi_CMOV, "cmovnp $Gv, $Ev");
988 EncodeOp0F(0x4c, 1, IMM_NONE, NACLi_CMOV, "cmovl $Gv, $Ev");
989 EncodeOp0F(0x4d, 1, IMM_NONE, NACLi_CMOV, "cmovnl $Gv, $Ev");
990 EncodeOp0F(0x4e, 1, IMM_NONE, NACLi_CMOV, "cmovle $Gv, $Ev");
991 EncodeOp0F(0x4f, 1, IMM_NONE, NACLi_CMOV, "cmovnle $Gv, $Ev");
992 /* repeat for 0x66 prefix */
993 EncodeOp660F(0x40, 1, IMM_NONE, NACLi_CMOV, "cmovo $Gv, $Ev");
994 EncodeOp660F(0x41, 1, IMM_NONE, NACLi_CMOV, "cmovno $Gv, $Ev");
995 EncodeOp660F(0x42, 1, IMM_NONE, NACLi_CMOV, "cmovb $Gv, $Ev");
996 EncodeOp660F(0x43, 1, IMM_NONE, NACLi_CMOV, "cmovnb $Gv, $Ev");
997 EncodeOp660F(0x44, 1, IMM_NONE, NACLi_CMOV, "cmovz $Gv, $Ev");
998 EncodeOp660F(0x45, 1, IMM_NONE, NACLi_CMOV, "cmovnz $Gv, $Ev");
999 EncodeOp660F(0x46, 1, IMM_NONE, NACLi_CMOV, "cmovbe $Gv, $Ev");
1000 EncodeOp660F(0x47, 1, IMM_NONE, NACLi_CMOV, "cmovnbe $Gv, $Ev");
1001 EncodeOp660F(0x48, 1, IMM_NONE, NACLi_CMOV, "cmovs $Gv, $Ev");
1002 EncodeOp660F(0x49, 1, IMM_NONE, NACLi_CMOV, "cmovns $Gv, $Ev");
1003 EncodeOp660F(0x4a, 1, IMM_NONE, NACLi_CMOV, "cmovp $Gv, $Ev");
1004 EncodeOp660F(0x4b, 1, IMM_NONE, NACLi_CMOV, "cmovnp $Gv, $Ev");
1005 EncodeOp660F(0x4c, 1, IMM_NONE, NACLi_CMOV, "cmovl $Gv, $Ev");
1006 EncodeOp660F(0x4d, 1, IMM_NONE, NACLi_CMOV, "cmovnl $Gv, $Ev");
1007 EncodeOp660F(0x4e, 1, IMM_NONE, NACLi_CMOV, "cmovle $Gv, $Ev");
1008 EncodeOp660F(0x4f, 1, IMM_NONE, NACLi_CMOV, "cmovnle $Gv, $Ev");
1010 /* 0x80-0x8f */
1011 EncodeOp0F(0x80, 0, IMM_DATAV, NACLi_JMPZ, "jo $Jz");
1012 EncodeOp0F(0x81, 0, IMM_DATAV, NACLi_JMPZ, "jno $Jz");
1013 EncodeOp0F(0x82, 0, IMM_DATAV, NACLi_JMPZ, "jb $Jz");
1014 EncodeOp0F(0x83, 0, IMM_DATAV, NACLi_JMPZ, "jnb $Jz");
1015 EncodeOp0F(0x84, 0, IMM_DATAV, NACLi_JMPZ, "jz $Jz");
1016 EncodeOp0F(0x85, 0, IMM_DATAV, NACLi_JMPZ, "jnz $Jz");
1017 EncodeOp0F(0x86, 0, IMM_DATAV, NACLi_JMPZ, "jbe $Jz");
1018 EncodeOp0F(0x87, 0, IMM_DATAV, NACLi_JMPZ, "jnbe $Jz");
1019 EncodeOp0F(0x88, 0, IMM_DATAV, NACLi_JMPZ, "js $Jz");
1020 EncodeOp0F(0x89, 0, IMM_DATAV, NACLi_JMPZ, "jns $Jz");
1021 EncodeOp0F(0x8a, 0, IMM_DATAV, NACLi_JMPZ, "jp $Jz");
1022 EncodeOp0F(0x8b, 0, IMM_DATAV, NACLi_JMPZ, "jnp $Jz");
1023 EncodeOp0F(0x8c, 0, IMM_DATAV, NACLi_JMPZ, "jl $Jz");
1024 EncodeOp0F(0x8d, 0, IMM_DATAV, NACLi_JMPZ, "jge $Jz");
1025 EncodeOp0F(0x8e, 0, IMM_DATAV, NACLi_JMPZ, "jle $Jz");
1026 EncodeOp0F(0x8f, 0, IMM_DATAV, NACLi_JMPZ, "jg $Jz");
1027 /* 0x90-0x9f */
1028 EncodeOp0F(0x90, 1, IMM_NONE, NACLi_386, "seto $Eb");
1029 EncodeOp0F(0x91, 1, IMM_NONE, NACLi_386, "setno $Eb");
1030 EncodeOp0F(0x92, 1, IMM_NONE, NACLi_386, "setb $Eb");
1031 EncodeOp0F(0x93, 1, IMM_NONE, NACLi_386, "setnb $Eb");
1032 EncodeOp0F(0x94, 1, IMM_NONE, NACLi_386, "setz $Eb");
1033 EncodeOp0F(0x95, 1, IMM_NONE, NACLi_386, "setnz $Eb");
1034 EncodeOp0F(0x96, 1, IMM_NONE, NACLi_386, "setbe $Eb");
1035 EncodeOp0F(0x97, 1, IMM_NONE, NACLi_386, "setnbe $Eb");
1036 EncodeOp0F(0x98, 1, IMM_NONE, NACLi_386, "sets $Eb");
1037 EncodeOp0F(0x99, 1, IMM_NONE, NACLi_386, "setns $Eb");
1038 EncodeOp0F(0x9a, 1, IMM_NONE, NACLi_386, "setp $Eb");
1039 EncodeOp0F(0x9b, 1, IMM_NONE, NACLi_386, "setnp $Eb");
1040 EncodeOp0F(0x9c, 1, IMM_NONE, NACLi_386, "setl $Eb");
1041 EncodeOp0F(0x9d, 1, IMM_NONE, NACLi_386, "setge $Eb");
1042 EncodeOp0F(0x9e, 1, IMM_NONE, NACLi_386, "setle $Eb");
1043 EncodeOp0F(0x9f, 1, IMM_NONE, NACLi_386, "setg $Eb");
1044 /* 0xa0-0xaf */
1045 EncodeOp0F(0xa0, 0, IMM_NONE, NACLi_ILLEGAL, "push %fs");
1046 EncodeOp0F(0xa1, 0, IMM_NONE, NACLi_ILLEGAL, "pop %fs");
1047 EncodeOp0F(0xa2, 0, IMM_NONE, NACLi_386, "cpuid");
1048 EncodeOp0F(0xa3, 1, IMM_NONE, NACLi_ILLEGAL, "bt $Ev, $Gv");
1049 /* ISE reviewers suggested omitting shld */
1050 EncodeOp0F(0xa4, 1, IMM_FIXED1, NACLi_386, "shld $Ev, $Gv, $Ib");
1051 EncodeOp0F(0xa5, 1, IMM_NONE, NACLi_386, "shld $Ev, $Gv, %cl");
1052 EncodeOp0F(0xa6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1053 EncodeOp0F(0xa7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1054 EncodeOp0F(0xa8, 0, IMM_NONE, NACLi_ILLEGAL, "push %gs");
1055 EncodeOp0F(0xa9, 0, IMM_NONE, NACLi_ILLEGAL, "pop %gs");
1056 EncodeOp0F(0xaa, 0, IMM_NONE, NACLi_SYSTEM, "rsm");
1057 EncodeOp0F(0xab, 1, IMM_NONE, NACLi_ILLEGAL, "bts $Ev, $Gv");
1058 /* ISE reviewers suggested omitting shrd */
1059 EncodeOp0F(0xac, 1, IMM_FIXED1, NACLi_386, "shrd $Ev, $Gv, $Ib");
1060 EncodeOp0F(0xad, 1, IMM_NONE, NACLi_386, "shrd $Ev, $Gv, %cl");
1061 /* fxsave fxrstor ldmxcsr stmxcsr clflush */
1062 /* lfence mfence sfence */
1063 /* Note: size of memory operand varies with MRM. */
1064 EncodeOp0F(0xae, 1, IMM_NONE, NACLi_OPINMRM, "$group15 $M");
1065 SetOp0FOpInMRM(0xae, GROUP15);
1066 EncodeOp0F(0xaf, 1, IMM_NONE, NACLi_386, "imul $Gv, $Ev");
1067 EncodeOp660F(0xaf, 1, IMM_NONE, NACLi_386, "imul $Gv, $Ev");
1068 /* 0xb0-0xbf */
1069 /* Note NaCl doesn't allow 16-bit cmpxchg */
1070 EncodeOp0F(0xb0, 1, IMM_NONE, NACLi_386L, "cmpxchg $E, $G");
1071 EncodeOp0F(0xb1, 1, IMM_NONE, NACLi_386L, "cmpxchg $E, $G");
1072 EncodeOp0F(0xb2, 1, IMM_NONE, NACLi_ILLEGAL, "lss $Mp");
1073 EncodeOp0F(0xb3, 1, IMM_NONE, NACLi_ILLEGAL, "btr $Ev, $Gv");
1074 EncodeOp0F(0xb4, 1, IMM_NONE, NACLi_ILLEGAL, "lfs $Mp");
1075 EncodeOp0F(0xb5, 1, IMM_NONE, NACLi_ILLEGAL, "lgs $Mp");
1076 EncodeOp0F(0xb6, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Eb");
1077 EncodeOp660F(0xb6, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Eb");
1078 EncodeOp0F(0xb7, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Ew");
1079 EncodeOp660F(0xb7, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Ew");
1081 EncodeOp0F(0xc8, 0, IMM_NONE, NACLi_386, "bswap %eax");
1082 EncodeOp0F(0xc9, 0, IMM_NONE, NACLi_386, "bswap %ecx");
1083 EncodeOp0F(0xca, 0, IMM_NONE, NACLi_386, "bswap %edx");
1084 EncodeOp0F(0xcb, 0, IMM_NONE, NACLi_386, "bswap %ebx");
1085 EncodeOp0F(0xcc, 0, IMM_NONE, NACLi_386, "bswap %esp");
1086 EncodeOp0F(0xcd, 0, IMM_NONE, NACLi_386, "bswap %ebp");
1087 EncodeOp0F(0xce, 0, IMM_NONE, NACLi_386, "bswap %esi");
1088 EncodeOp0F(0xcf, 0, IMM_NONE, NACLi_386, "bswap %edi");
1090 /* Instructions from ?? 0F 10 to ?? 0F 1F */
1091 EncodeOp0F(0x10, 1, IMM_NONE, NACLi_SSE, "movups $Vps, $Wps");
1092 EncodeOpF30F(0x10, 1, IMM_NONE, NACLi_SSE, "movss $Vss, $Wss");
1093 EncodeOp660F(0x10, 1, IMM_NONE, NACLi_SSE2, "movupd $Vpd, $Wpd");
1094 EncodeOpF20F(0x10, 1, IMM_NONE, NACLi_SSE2, "movsd $Vsd, $Wsd");
1096 EncodeOp0F(0x11, 1, IMM_NONE, NACLi_SSE, "movups $Wps, $Vps");
1097 EncodeOpF30F(0x11, 1, IMM_NONE, NACLi_SSE, "movss $Wss, $Vss");
1098 EncodeOp660F(0x11, 1, IMM_NONE, NACLi_SSE2, "movupd $Wpd, $Vpd");
1099 EncodeOpF20F(0x11, 1, IMM_NONE, NACLi_SSE2, "movsd $Wsd, $Vsd");
1101 EncodeOp0F(0x12, 1, IMM_NONE, NACLi_SSE, "movlps $Vps, $Mq"); /* or movhlps */
1102 EncodeOpF30F(0x12, 1, IMM_NONE, NACLi_SSE3, "movsldup $Vps, $Wps");
1103 EncodeOp660F(0x12, 1, IMM_NONE, NACLi_SSE2, "movlpd $Vps, $Mq");
1104 EncodeOpF20F(0x12, 1, IMM_NONE, NACLi_SSE3, "movddup $Vpd, $Wsd");
1106 EncodeOp0F(0x13, 1, IMM_NONE, NACLi_SSE, "movlps $Mq, $Vps");
1107 EncodeOpF30F(0x13, 0, IMM_NONE, NACLi_INVALID, "invalid");
1108 EncodeOp660F(0x13, 1, IMM_NONE, NACLi_SSE2, "movlpd $Mq, $Vsd");
1109 EncodeOpF20F(0x13, 0, IMM_NONE, NACLi_INVALID, "invalid");
1111 EncodeOp0F(0x14, 1, IMM_NONE, NACLi_SSE, "unpcklps $Vps, $Wq");
1112 EncodeOpF30F(0x14, 0, IMM_NONE, NACLi_INVALID, "invalid");
1113 EncodeOp660F(0x14, 1, IMM_NONE, NACLi_SSE2, "unpcklpd $Vpd, $Wq");
1114 EncodeOpF20F(0x14, 0, IMM_NONE, NACLi_INVALID, "invalid");
1116 EncodeOp0F(0x15, 1, IMM_NONE, NACLi_SSE, "unpckhps $Vps, $Wq");
1117 EncodeOpF30F(0x15, 0, IMM_NONE, NACLi_INVALID, "invalid");
1118 EncodeOp660F(0x15, 1, IMM_NONE, NACLi_SSE2, "unpckhpd $Vpd, $Wq");
1119 EncodeOpF20F(0x15, 0, IMM_NONE, NACLi_INVALID, "invalid");
1121 EncodeOp0F(0x16, 1, IMM_NONE, NACLi_SSE, "movhps $Vps, $Mq"); /* or movlhps */
1122 EncodeOpF30F(0x16, 1, IMM_NONE, NACLi_SSE3, "movshdup $Vps, $Wps");
1123 EncodeOp660F(0x16, 1, IMM_NONE, NACLi_SSE2, "movhpd $Vsd, $Mq");
1124 EncodeOpF20F(0x16, 0, IMM_NONE, NACLi_INVALID, "invalid");
1126 EncodeOp0F(0x17, 1, IMM_NONE, NACLi_SSE, "movhps $Mq, $Vps");
1127 EncodeOpF30F(0x17, 0, IMM_NONE, NACLi_INVALID, "invalid");
1128 EncodeOp660F(0x17, 1, IMM_NONE, NACLi_SSE2, "movhpd $Mq, $Vpd");
1129 EncodeOpF20F(0x17, 0, IMM_NONE, NACLi_INVALID, "invalid");
1131 /* Instructions from ?? 0F 28 to ?? 0F 2F */
1132 EncodeOp0F(0x28, 1, IMM_NONE, NACLi_SSE, "movaps $Vps, $Wps");
1133 EncodeOpF30F(0x28, 0, IMM_NONE, NACLi_INVALID, "invalid");
1134 EncodeOp660F(0x28, 1, IMM_NONE, NACLi_SSE2, "movapd $Vpd, $Wpd");
1135 EncodeOpF20F(0x28, 0, IMM_NONE, NACLi_INVALID, "invalid");
1137 EncodeOp0F(0x29, 1, IMM_NONE, NACLi_SSE, "movaps $Wps, $Vps");
1138 EncodeOpF30F(0x29, 0, IMM_NONE, NACLi_INVALID, "invalid");
1139 EncodeOp660F(0x29, 1, IMM_NONE, NACLi_SSE2, "movapd $Wpd, $Vpd");
1140 EncodeOpF20F(0x29, 0, IMM_NONE, NACLi_INVALID, "invalid");
1142 EncodeOp0F(0x2a, 1, IMM_NONE, NACLi_SSE, "cvtpi2ps $Vps, $Qq");
1143 EncodeOpF30F(0x2a, 1, IMM_NONE, NACLi_SSE, "cvtsi2ss $Vss, $Ed");
1144 EncodeOp660F(0x2a, 1, IMM_NONE, NACLi_SSE2, "cvtpi2pd $Vpd $Qq");
1145 EncodeOpF20F(0x2a, 1, IMM_NONE, NACLi_SSE2, "cvtsi2sd $Vsd, $Ed");
1147 EncodeOp0F(0x2b, 1, IMM_NONE, NACLi_SSE, "movntps $Mdq, $Vps");
1148 EncodeOpF30F(0x2b, 1, IMM_NONE, NACLi_SSE4A, "movntss $Md, $Vss");
1149 EncodeOp660F(0x2b, 1, IMM_NONE, NACLi_SSE2, "movntpd $Mdq, $Vpd");
1150 EncodeOpF20F(0x2b, 1, IMM_NONE, NACLi_SSE4A, "movntsd $Mq, $Vsd");
1152 EncodeOp0F(0x2c, 1, IMM_NONE, NACLi_SSE, "cvttps2pi $Pq, $Wps");
1153 EncodeOpF30F(0x2c, 1, IMM_NONE, NACLi_SSE, "cvttss2si $Gd, $Wss");
1154 EncodeOp660F(0x2c, 1, IMM_NONE, NACLi_SSE2, "cvttpd2pi $Pq, $Wpd");
1155 EncodeOpF20F(0x2c, 1, IMM_NONE, NACLi_SSE2, "cvttsd2si $Gd, $Wsd");
1157 EncodeOp0F(0x2d, 1, IMM_NONE, NACLi_SSE, "cvtps2pi $Pq, $Wps");
1158 EncodeOpF30F(0x2d, 1, IMM_NONE, NACLi_SSE, "cvtss2si $Gd, $Wss");
1159 EncodeOp660F(0x2d, 1, IMM_NONE, NACLi_SSE2, "cvtpd2pi $Pq, $Wpd");
1160 EncodeOpF20F(0x2d, 1, IMM_NONE, NACLi_SSE2, "cvtsd2si $Gd, $Wsd");
1162 EncodeOp0F(0x2e, 1, IMM_NONE, NACLi_SSE, "ucomiss $Vss, $Wss");
1163 EncodeOpF30F(0x2e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1164 EncodeOp660F(0x2e, 1, IMM_NONE, NACLi_SSE2, "ucomisd $Vps, $Wps");
1165 EncodeOpF20F(0x2e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1167 EncodeOp0F(0x2f, 1, IMM_NONE, NACLi_SSE, "comiss $Vps, $Wps");
1168 EncodeOpF30F(0x2f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1169 EncodeOp660F(0x2f, 1, IMM_NONE, NACLi_SSE2, "comisd $Vpd, $Wsd");
1170 EncodeOpF20F(0x2f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1172 /* Instructions from ?? 0F 38 and ?? 0F 3A are SSE4, below */
1173 /* Others from ?? 0F 39 to ?? 0F 3F are invalid */
1175 /* Instructions from ?? 0F 50 to ?? 0F 7F */
1176 EncodeOp0F(0x50, 1, IMM_NONE, NACLi_SSE, "movmskps $Gd, $VRps");
1177 EncodeOpF30F(0x50, 0, IMM_NONE, NACLi_INVALID, "invalid");
1178 EncodeOp660F(0x50, 1, IMM_NONE, NACLi_SSE2, "movmskpd $Gd, $VRpd");
1179 EncodeOpF20F(0x50, 0, IMM_NONE, NACLi_INVALID, "invalid");
1181 EncodeOp0F(0x51, 1, IMM_NONE, NACLi_SSE, "sqrtps $Vps, $Wps");
1182 EncodeOpF30F(0x51, 1, IMM_NONE, NACLi_SSE, "sqrtss $Vss, $Wss");
1183 EncodeOp660F(0x51, 1, IMM_NONE, NACLi_SSE2, "sqrtpd $Vpd, $Wpd");
1184 EncodeOpF20F(0x51, 1, IMM_NONE, NACLi_SSE2, "sqrtsd $Vsd, $Wsd");
1186 EncodeOp0F(0x52, 1, IMM_NONE, NACLi_SSE, "rsqrtps $Vps, $Wps");
1187 EncodeOpF30F(0x52, 1, IMM_NONE, NACLi_SSE, "rsqrtss $Vss, $Wss");
1188 EncodeOp660F(0x52, 0, IMM_NONE, NACLi_INVALID, "invalid");
1189 EncodeOpF20F(0x52, 0, IMM_NONE, NACLi_INVALID, "invalid");
1191 EncodeOp0F(0x53, 1, IMM_NONE, NACLi_SSE, "rcpps $Vps, $Wps");
1192 EncodeOpF30F(0x53, 1, IMM_NONE, NACLi_SSE, "rcpss $Vss, $Wss");
1193 EncodeOp660F(0x53, 0, IMM_NONE, NACLi_INVALID, "invalid");
1194 EncodeOpF20F(0x53, 0, IMM_NONE, NACLi_INVALID, "invalid");
1196 EncodeOp0F(0x54, 1, IMM_NONE, NACLi_SSE, "andps $Vps, $Wps");
1197 EncodeOpF30F(0x54, 0, IMM_NONE, NACLi_INVALID, "invalid");
1198 EncodeOp660F(0x54, 1, IMM_NONE, NACLi_SSE2, "andpd $Vpd, $Wpd");
1199 EncodeOpF20F(0x54, 0, IMM_NONE, NACLi_INVALID, "invalid");
1201 EncodeOp0F(0x55, 1, IMM_NONE, NACLi_SSE, "andnps $Vps, $Wps");
1202 EncodeOpF30F(0x55, 0, IMM_NONE, NACLi_INVALID, "invalid");
1203 EncodeOp660F(0x55, 1, IMM_NONE, NACLi_SSE2, "andnpd $Vpd, $Wpd");
1204 EncodeOpF20F(0x55, 0, IMM_NONE, NACLi_INVALID, "invalid");
1206 EncodeOp0F(0x56, 1, IMM_NONE, NACLi_SSE, "orps $Vps, $Wps");
1207 EncodeOpF30F(0x56, 1, IMM_NONE, NACLi_INVALID, "invalid");
1208 EncodeOp660F(0x56, 1, IMM_NONE, NACLi_SSE2, "orpd $Vpd, $Wpd");
1209 EncodeOpF20F(0x56, 0, IMM_NONE, NACLi_INVALID, "invalid");
1211 EncodeOp0F(0x57, 1, IMM_NONE, NACLi_SSE, "xorps $Vps, $Wps");
1212 EncodeOpF30F(0x57, 0, IMM_NONE, NACLi_INVALID, "invalid");
1213 EncodeOp660F(0x57, 1, IMM_NONE, NACLi_SSE2, "xorpd $Vpd, $Wpd");
1214 EncodeOpF20F(0x57, 0, IMM_NONE, NACLi_INVALID, "invalid");
1216 EncodeOp0F(0x58, 1, IMM_NONE, NACLi_SSE, "addps $Vps, $Wps");
1217 EncodeOpF30F(0x58, 1, IMM_NONE, NACLi_SSE, "addss $Vss, $Wss");
1218 EncodeOp660F(0x58, 1, IMM_NONE, NACLi_SSE2, "addpd $Vpd, $Wpd");
1219 EncodeOpF20F(0x58, 1, IMM_NONE, NACLi_SSE2, "addsd $Vsd, $Wsd");
1221 EncodeOp0F(0x59, 1, IMM_NONE, NACLi_SSE, "mulps $Vps, $Wps");
1222 EncodeOpF30F(0x59, 1, IMM_NONE, NACLi_SSE, "mulss $Vss, $Wss");
1223 EncodeOp660F(0x59, 1, IMM_NONE, NACLi_SSE2, "mulpd $Vpd, $Wpd");
1224 EncodeOpF20F(0x59, 1, IMM_NONE, NACLi_SSE2, "mulsd $Vsd, $Wsd");
1226 EncodeOp0F(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtps2pd $Vpd, $Wps");
1227 EncodeOpF30F(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtss2sd $Vsd, $Wss");
1228 EncodeOp660F(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtpd2ps $Vps, $Wpd");
1229 EncodeOpF20F(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtsd2ss $Vss, $Wsd");
1231 EncodeOp0F(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvtdq2ps $Vps, $Wdq");
1232 EncodeOpF30F(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvttps2dq $Vdq, $Wps");
1233 EncodeOp660F(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvtps2dq $Vdq, $Wps");
1234 EncodeOpF20F(0x5b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1236 EncodeOp0F(0x5c, 1, IMM_NONE, NACLi_SSE, "subps $Vps, $Wps");
1237 EncodeOpF30F(0x5c, 1, IMM_NONE, NACLi_SSE, "subss $Vss, $Wss");
1238 EncodeOp660F(0x5c, 1, IMM_NONE, NACLi_SSE2, "subpd $Vpd, $Wpd");
1239 EncodeOpF20F(0x5c, 1, IMM_NONE, NACLi_SSE2, "subsd $Vsd, $Wsd");
1241 EncodeOp0F(0x5d, 1, IMM_NONE, NACLi_SSE, "minps $Vps, $Wps");
1242 EncodeOpF30F(0x5d, 1, IMM_NONE, NACLi_SSE, "minss $Vss, $Wss");
1243 EncodeOp660F(0x5d, 1, IMM_NONE, NACLi_SSE2, "minpd $Vpd, $Wpd");
1244 EncodeOpF20F(0x5d, 1, IMM_NONE, NACLi_SSE2, "minsd $Vsd, $Wsd");
1246 EncodeOp0F(0x5e, 1, IMM_NONE, NACLi_SSE, "divps $Vps, $Wps");
1247 EncodeOpF30F(0x5e, 1, IMM_NONE, NACLi_SSE, "divss $Vss, $Wss");
1248 EncodeOp660F(0x5e, 1, IMM_NONE, NACLi_SSE2, "divpd $Vpd, $Wpd");
1249 EncodeOpF20F(0x5e, 1, IMM_NONE, NACLi_SSE2, "divsd $Vsd, $Wsd");
1251 EncodeOp0F(0x5f, 1, IMM_NONE, NACLi_SSE, "maxps $Vps, $Wps");
1252 EncodeOpF30F(0x5f, 1, IMM_NONE, NACLi_SSE, "maxss $Vss, $Wss");
1253 EncodeOp660F(0x5f, 1, IMM_NONE, NACLi_SSE2, "maxpd $Vpd, $Wpd");
1254 EncodeOpF20F(0x5f, 1, IMM_NONE, NACLi_SSE2, "maxsd $Vsd, $Wsd");
1256 EncodeOp0F(0x60, 1, IMM_NONE, NACLi_MMX, "punpcklbw $Pq, $Qd");
1257 EncodeOpF30F(0x60, 0, IMM_NONE, NACLi_INVALID, "invalid");
1258 EncodeOp660F(0x60, 1, IMM_NONE, NACLi_SSE2, "punpcklbw $Vdq, $Wq");
1259 EncodeOpF20F(0x60, 0, IMM_NONE, NACLi_INVALID, "invalid");
1261 EncodeOp0F(0x61, 1, IMM_NONE, NACLi_MMX, "punpcklwd $Pq, $Qd");
1262 EncodeOpF30F(0x61, 0, IMM_NONE, NACLi_INVALID, "invalid");
1263 EncodeOp660F(0x61, 1, IMM_NONE, NACLi_SSE2, "punpcklwd $Vdq, $Wq");
1264 EncodeOpF20F(0x61, 0, IMM_NONE, NACLi_INVALID, "invalid");
1266 EncodeOp0F(0x62, 1, IMM_NONE, NACLi_MMX, "punpckldq $Pq, $Qd");
1267 EncodeOpF30F(0x62, 0, IMM_NONE, NACLi_INVALID, "invalid");
1268 EncodeOp660F(0x62, 1, IMM_NONE, NACLi_SSE2, "punpckldq $Vdq, $Wq");
1269 EncodeOpF20F(0x62, 0, IMM_NONE, NACLi_INVALID, "invalid");
1271 EncodeOp0F(0x63, 1, IMM_NONE, NACLi_MMX, "packsswb $Pq, $Qq");
1272 EncodeOpF30F(0x63, 0, IMM_NONE, NACLi_INVALID, "invalid");
1273 EncodeOp660F(0x63, 1, IMM_NONE, NACLi_SSE2, "packsswb $Vdq, $Wdq");
1274 EncodeOpF20F(0x63, 0, IMM_NONE, NACLi_INVALID, "invalid");
1276 EncodeOp0F(0x64, 1, IMM_NONE, NACLi_MMX, "pcmpgtb $Pq, $Qq");
1277 EncodeOpF30F(0x64, 0, IMM_NONE, NACLi_INVALID, "invalid");
1278 EncodeOp660F(0x64, 1, IMM_NONE, NACLi_SSE2, "pcmpgtb $Vdq, $Wdq");
1279 EncodeOpF20F(0x64, 0, IMM_NONE, NACLi_INVALID, "invalid");
1281 EncodeOp0F(0x65, 1, IMM_NONE, NACLi_MMX, "pcmpgtw $Pq, $Qq");
1282 EncodeOpF30F(0x65, 0, IMM_NONE, NACLi_INVALID, "invalid");
1283 EncodeOp660F(0x65, 1, IMM_NONE, NACLi_SSE2, "pcmpgtw $Vdq, $Wdq");
1284 EncodeOpF20F(0x65, 0, IMM_NONE, NACLi_INVALID, "invalid");
1286 EncodeOp0F(0x66, 1, IMM_NONE, NACLi_MMX, "pcmpgtd $Pq, $Qq");
1287 EncodeOpF30F(0x66, 0, IMM_NONE, NACLi_INVALID, "invalid");
1288 EncodeOp660F(0x66, 1, IMM_NONE, NACLi_SSE2, "pcmpgtd $Vdq, $Wdq");
1289 EncodeOpF20F(0x66, 0, IMM_NONE, NACLi_INVALID, "invalid");
1291 EncodeOp0F(0x67, 1, IMM_NONE, NACLi_MMX, "packuswb $Pq, $Qq");
1292 EncodeOpF30F(0x67, 0, IMM_NONE, NACLi_INVALID, "invalid");
1293 EncodeOp660F(0x67, 1, IMM_NONE, NACLi_SSE2, "packuswb $Vdq, $Wdq");
1294 EncodeOpF20F(0x67, 0, IMM_NONE, NACLi_INVALID, "invalid");
1296 EncodeOp0F(0x68, 1, IMM_NONE, NACLi_MMX, "punpckhbw $Pq, $Qd");
1297 EncodeOpF30F(0x68, 0, IMM_NONE, NACLi_INVALID, "invalid");
1298 EncodeOp660F(0x68, 1, IMM_NONE, NACLi_SSE2, "punpckhbw $Vdq, $Wq");
1299 EncodeOpF20F(0x68, 0, IMM_NONE, NACLi_INVALID, "invalid");
1301 EncodeOp0F(0x69, 1, IMM_NONE, NACLi_MMX, "punpckhwd $Pq, $Qd");
1302 EncodeOpF30F(0x69, 0, IMM_NONE, NACLi_INVALID, "invalid");
1303 EncodeOp660F(0x69, 1, IMM_NONE, NACLi_SSE2, "punpckhwd $Vdq, $Wq");
1304 EncodeOpF20F(0x69, 0, IMM_NONE, NACLi_INVALID, "invalid");
1306 EncodeOp0F(0x6a, 1, IMM_NONE, NACLi_MMX, "punpckhdq $Pq, $Qd");
1307 EncodeOpF30F(0x6a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1308 EncodeOp660F(0x6a, 1, IMM_NONE, NACLi_SSE2, "punpckhdq $Vdq, $Wq");
1309 EncodeOpF20F(0x6a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1311 EncodeOp0F(0x6b, 1, IMM_NONE, NACLi_MMX, "packssdw $Pq, $Qq");
1312 EncodeOpF30F(0x6b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1313 EncodeOp660F(0x6b, 1, IMM_NONE, NACLi_SSE2, "packssdw $Vdq, $Wdq");
1314 EncodeOpF20F(0x6b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1316 EncodeOp0F(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1317 EncodeOpF30F(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1318 EncodeOp660F(0x6c, 1, IMM_NONE, NACLi_SSE2, "punpcklqdq $Vdq, $Wq");
1319 EncodeOpF20F(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1321 EncodeOp0F(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1322 EncodeOpF30F(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1323 EncodeOp660F(0x6d, 1, IMM_NONE, NACLi_SSE2, "punpckhqdq $Vdq, $Wq");
1324 EncodeOpF20F(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1326 EncodeOp0F(0x6e, 1, IMM_NONE, NACLi_MMX, "movd $Pq, $Ed");
1327 EncodeOpF30F(0x6e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1328 EncodeOp660F(0x6e, 1, IMM_NONE, NACLi_SSE2, "movd $Vdq, $Edq");
1329 EncodeOpF20F(0x6e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1331 EncodeOp0F(0x6f, 1, IMM_NONE, NACLi_MMX, "movq $Pq, $Qq");
1332 EncodeOpF30F(0x6f, 1, IMM_NONE, NACLi_SSE2, "movdqu $Vdq, $Wdq");
1333 EncodeOp660F(0x6f, 1, IMM_NONE, NACLi_SSE2, "movdqa $Vdq, $Wdq");
1334 EncodeOpF20F(0x6f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1336 EncodeOp0F(0x70, 1, IMM_FIXED1, NACLi_SSE, "pshufw $Pq, $Qq, $Ib");
1337 EncodeOpF30F(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshufhw $Vq, $Wq, $Ib");
1338 EncodeOp660F(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshufd $Vdq, $Wdq, $Ib");
1339 EncodeOpF20F(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshuflw $Vq, $Wq, $Ib");
1341 EncodeOp0F(0x71, 1, IMM_FIXED1, NACLi_OPINMRM, "$group12 $PRq, $Ib");
1342 EncodeOpF30F(0x71, 0, IMM_NONE, NACLi_INVALID, "invalid");
1343 EncodeOp660F(0x71, 1, IMM_FIXED1, NACLi_OPINMRM, "$group12 $VRdq, $Ib");
1344 EncodeOpF20F(0x71, 0, IMM_NONE, NACLi_INVALID, "invalid");
1345 SetOp0FOpInMRM(0x71, GROUP12);
1346 SetOp66OpInMRM(0x71, GROUP12);
1348 EncodeOp0F(0x72, 1, IMM_FIXED1, NACLi_OPINMRM, "$group13 $PRq, $Ib");
1349 EncodeOpF30F(0x72, 0, IMM_NONE, NACLi_INVALID, "invalid");
1350 EncodeOp660F(0x72, 1, IMM_FIXED1, NACLi_OPINMRM, "$group13 $VRdq, $Ib");
1351 EncodeOpF20F(0x72, 0, IMM_NONE, NACLi_INVALID, "invalid");
1352 SetOp0FOpInMRM(0x72, GROUP13);
1353 SetOp66OpInMRM(0x72, GROUP13);
1355 EncodeOp0F(0x73, 1, IMM_FIXED1, NACLi_OPINMRM, "$group14 $PRq, $Ib");
1356 EncodeOpF30F(0x73, 0, IMM_NONE, NACLi_INVALID, "invalid");
1357 EncodeOp660F(0x73, 1, IMM_FIXED1, NACLi_OPINMRM, "$group14 $VRdq, $Ib");
1358 EncodeOpF20F(0x73, 0, IMM_NONE, NACLi_INVALID, "invalid");
1359 SetOp0FOpInMRM(0x73, GROUP14);
1360 SetOp66OpInMRM(0x73, GROUP14);
1362 EncodeOp0F(0x74, 1, IMM_NONE, NACLi_MMX, "pcmpeqb $Pq, $Qq");
1363 EncodeOpF30F(0x74, 0, IMM_NONE, NACLi_INVALID, "invalid");
1364 EncodeOp660F(0x74, 1, IMM_NONE, NACLi_SSE2, "pcmpeqb $Vdq, $Wdq");
1365 EncodeOpF20F(0x74, 0, IMM_NONE, NACLi_INVALID, "invalid");
1367 EncodeOp0F(0x75, 1, IMM_NONE, NACLi_MMX, "pcmpeqw $Pq, $Qq");
1368 EncodeOpF30F(0x75, 0, IMM_NONE, NACLi_INVALID, "invalid");
1369 EncodeOp660F(0x75, 1, IMM_NONE, NACLi_SSE2, "pcmpeqw $Vdq, $Wdq");
1370 EncodeOpF20F(0x75, 0, IMM_NONE, NACLi_INVALID, "invalid");
1372 EncodeOp0F(0x76, 1, IMM_NONE, NACLi_MMX, "pcmpeqd $Pq, $Qq");
1373 EncodeOpF30F(0x76, 1, IMM_NONE, NACLi_INVALID, "invalid");
1374 EncodeOp660F(0x76, 1, IMM_NONE, NACLi_SSE2, "pcmpeqd $Vdq, $Wdq");
1375 EncodeOpF20F(0x76, 0, IMM_NONE, NACLi_INVALID, "invalid");
1377 EncodeOp0F(0x77, 0, IMM_NONE, NACLi_MMX, "emms");
1378 EncodeOpF30F(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1379 EncodeOp660F(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1380 EncodeOpF20F(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1382 EncodeOp0F(0x78, 0, IMM_NONE, NACLi_INVALID, "invalid");
1383 EncodeOpF30F(0x78, 0, IMM_NONE, NACLi_INVALID, "invalid");
1384 EncodeOp660F(0x78, 1, IMM_FIXED1, NACLi_OPINMRM, "$group17 $Vdq, $Ib, $Ib");
1385 SetOp66OpInMRM(0x78, GROUP17);
1386 EncodeOpF20F(0x78, 1, IMM_FIXED2, NACLi_SSE4A, "insertq $Vdq, $VRq, $Ib, $Ib");
1388 EncodeOp0F(0x79, 0, IMM_NONE, NACLi_INVALID, "invalid");
1389 EncodeOpF30F(0x79, 0, IMM_NONE, NACLi_INVALID, "invalid");
1390 EncodeOp660F(0x79, 1, IMM_NONE, NACLi_SSE4A, "extrq $Vdq, $VRq");
1391 EncodeOpF20F(0x79, 1, IMM_NONE, NACLi_SSE4A, "insertq $Vdq, $VRdq");
1393 EncodeOp0F(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1394 EncodeOpF30F(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1395 EncodeOp660F(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1396 EncodeOpF20F(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1398 EncodeOp0F(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1399 EncodeOpF30F(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1400 EncodeOp660F(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1401 EncodeOpF20F(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1403 EncodeOp0F(0x7c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1404 EncodeOpF30F(0x7c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1405 EncodeOp660F(0x7c, 1, IMM_NONE, NACLi_SSE3, "haddpd $Vpd, $Wpd");
1406 EncodeOpF20F(0x7c, 1, IMM_NONE, NACLi_SSE3, "haddps $Vps, $Wps");
1408 EncodeOp0F(0x7d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1409 EncodeOpF30F(0x7d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1410 EncodeOp660F(0x7d, 1, IMM_NONE, NACLi_SSE3, "hsubpd $Vpd, $Wpd");
1411 EncodeOpF20F(0x7d, 1, IMM_NONE, NACLi_SSE3, "hsubps $Vps, $Wps");
1413 EncodeOp0F(0x7e, 1, IMM_NONE, NACLi_MMX, "movd $Ed, $Pd");
1414 EncodeOpF30F(0x7e, 1, IMM_NONE, NACLi_SSE2, "movq $Vq, $Wq");
1415 EncodeOp660F(0x7e, 1, IMM_NONE, NACLi_SSE2, "movd $Ed, $Vd");
1416 EncodeOpF20F(0x7e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1418 EncodeOp0F(0x7f, 1, IMM_NONE, NACLi_MMX, "movq $Qq, $Pq");
1419 EncodeOpF30F(0x7f, 1, IMM_NONE, NACLi_SSE2, "movdqu $Wdq, $Vdq");
1420 EncodeOp660F(0x7f, 1, IMM_NONE, NACLi_SSE2, "movdqa $Wdq, $Vdq");
1421 EncodeOpF20F(0x7f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1423 /* Instructions from ?? 0F b8 to ?? 0F bf */
1424 EncodeOp0F(0xb8, 0, IMM_NONE, NACLi_INVALID, "reserved");
1425 EncodeOpF30F(0xb8, 1, IMM_NONE, NACLi_POPCNT, "popcnt");
1426 EncodeOpF20F(0xb8, 0, IMM_NONE, NACLi_INVALID, "reserved");
1428 EncodeOp0F(0xb9, 1, IMM_NONE, NACLi_OPINMRM, "$group10");
1429 EncodeOpF30F(0xb9, 0, IMM_NONE, NACLi_INVALID, "reserved");
1430 EncodeOpF20F(0xb9, 0, IMM_NONE, NACLi_INVALID, "reserved");
1432 EncodeOp0F(0xba, 1, IMM_FIXED1, NACLi_OPINMRM, "$group8 $Ev, $Ib");
1433 EncodeOpF30F(0xba, 0, IMM_FIXED1, NACLi_INVALID, "reserved");
1434 EncodeOpF20F(0xba, 0, IMM_NONE, NACLi_INVALID, "reserved");
1435 SetOp0FOpInMRM(0xba, GROUP8);
1437 EncodeOp0F(0xbb, 1, IMM_NONE, NACLi_ILLEGAL, "btc $Ev, $Gv");
1438 EncodeOpF30F(0xbb, 0, IMM_NONE, NACLi_INVALID, "reserved");
1439 EncodeOpF20F(0xbb, 0, IMM_NONE, NACLi_INVALID, "reserved");
1441 EncodeOp0F(0xbc, 1, IMM_NONE, NACLi_386, "bsf $Gv, $Ev");
1442 EncodeOpF30F(0xbc, 0, IMM_NONE, NACLi_INVALID, "reserved");
1443 EncodeOpF20F(0xbc, 0, IMM_NONE, NACLi_INVALID, "reserved");
1445 EncodeOp0F(0xbd, 1, IMM_NONE, NACLi_386, "bsr $Gv, $Ev");
1446 /* lzcnt is treated as a bsr on machines that don't have lzcnt */
1447 EncodeOpF30F(0xbd, 1, IMM_NONE, NACLi_LZCNT, "lzcnt $Gv, $Ev");
1448 EncodeOpF20F(0xbd, 0, IMM_NONE, NACLi_INVALID, "reserved");
1450 EncodeOp0F(0xbe, 1, IMM_NONE, NACLi_386, "movsx $Gv, $Eb");
1451 EncodeOp660F(0xbe, 1, IMM_NONE, NACLi_386, "movsx $Gv, $Eb");
1452 EncodeOpF30F(0xbe, 1, IMM_NONE, NACLi_INVALID, "reserved");
1453 EncodeOpF20F(0xbe, 1, IMM_NONE, NACLi_INVALID, "reserved");
1455 EncodeOp0F(0xbf, 1, IMM_NONE, NACLi_386, "movsx $Gv, $Ew");
1456 EncodeOp660F(0xbf, 1, IMM_NONE, NACLi_386, "movsx $Gv, $Ew");
1457 EncodeOpF30F(0xbf, 0, IMM_NONE, NACLi_INVALID, "reserved");
1458 EncodeOpF20F(0xbf, 0, IMM_NONE, NACLi_INVALID, "reserved");
1460 /* Instructions from ?? 0F C0 to ?? 0F FF */
1461 /* xadd and cmpxchg appear to be the only instructions designed */
1462 /* for use with multiple prefix bytes. We may need to create */
1463 /* a special case for this if somebody actually needs it. */
1464 EncodeOp0F(0xc0, 1, IMM_NONE, NACLi_386L, "xadd $E, $G");
1465 EncodeOp0F(0xc1, 1, IMM_NONE, NACLi_386L, "xadd $E, $G");
1467 EncodeOp0F(0xc2, 1, IMM_FIXED1, NACLi_SSE, "cmpps $V, $W, $I");
1468 EncodeOpF30F(0xc2, 1, IMM_FIXED1, NACLi_SSE, "cmpss $V, $W, $I");
1469 EncodeOp660F(0xc2, 1, IMM_FIXED1, NACLi_SSE2, "cmppd $V, $W, $I");
1470 EncodeOpF20F(0xc2, 1, IMM_FIXED1, NACLi_SSE2, "cmpsd $V, $W, $I");
1472 EncodeOp0F(0xc3, 1, IMM_NONE, NACLi_SSE2, "movnti $Md, $Gd");
1473 EncodeOpF30F(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1474 EncodeOp660F(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1475 EncodeOpF20F(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1477 EncodeOp0F(0xc4, 1, IMM_FIXED1, NACLi_SSE, "pinsrw $Pq, $Ew, $Ib");
1478 EncodeOpF30F(0xc4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1479 EncodeOp660F(0xc4, 1, IMM_FIXED1, NACLi_SSE2, "pinsrw $Vdq, $Ew, $Ib");
1480 EncodeOpF20F(0xc4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1482 EncodeOp0F(0xc5, 1, IMM_FIXED1, NACLi_SSE, "pextrw $Gd, $PRq, $Ib");
1483 EncodeOpF30F(0xc5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1484 EncodeOp660F(0xc5, 1, IMM_FIXED1, NACLi_SSE2, "pextrw $Gd, $VRdq, $Ib");
1485 EncodeOpF20F(0xc5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1487 EncodeOp0F(0xc6, 1, IMM_FIXED1, NACLi_SSE, "shufps $Vps, $Wps, $Ib");
1488 EncodeOpF30F(0xc6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1489 EncodeOp660F(0xc6, 1, IMM_FIXED1, NACLi_SSE2, "shufpd $Vpd, $Wpd, $Ib");
1490 EncodeOpF20F(0xc6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1492 EncodeOp0F(0xc7, 1, IMM_NONE, NACLi_OPINMRM, "$group9 $Mq");
1493 SetOp0FOpInMRM(0xc7, GROUP9);
1495 EncodeOp0F(0xd0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1496 EncodeOpF30F(0xd0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1497 EncodeOp660F(0xd0, 1, IMM_NONE, NACLi_SSE3, "addsubpd $Vpd, $Wpd");
1498 EncodeOpF20F(0xd0, 1, IMM_NONE, NACLi_SSE3, "addsubps $Vps, $Wps");
1500 EncodeOp0F(0xd1, 1, IMM_NONE, NACLi_MMX, "psrlw $Pq, $Qq");
1501 EncodeOpF30F(0xd1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1502 EncodeOp660F(0xd1, 1, IMM_NONE, NACLi_SSE2, "psrlw $Vdq, $Wdq");
1503 EncodeOpF20F(0xd1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1505 EncodeOp0F(0xd2, 1, IMM_NONE, NACLi_MMX, "psrld $Pq, $Qq");
1506 EncodeOpF30F(0xd2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1507 EncodeOp660F(0xd2, 1, IMM_NONE, NACLi_SSE2, "psrld $Vdq, $Wdq");
1508 EncodeOpF20F(0xd2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1510 EncodeOp0F(0xd3, 1, IMM_NONE, NACLi_MMX, "psrlq $Pq, $Qq");
1511 EncodeOpF30F(0xd3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1512 EncodeOp660F(0xd3, 1, IMM_NONE, NACLi_SSE2, "psrlq $Vdq, $Wdq");
1513 EncodeOpF20F(0xd3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1515 EncodeOp0F(0xd4, 1, IMM_NONE, NACLi_SSE2, "paddq $Pq, $Qq");
1516 EncodeOpF30F(0xd4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1517 EncodeOp660F(0xd4, 1, IMM_NONE, NACLi_SSE2, "paddq $Vdq, $Wdq");
1518 EncodeOpF20F(0xd4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1520 EncodeOp0F(0xd5, 1, IMM_NONE, NACLi_MMX, "pmullw $Pq, $Qq");
1521 EncodeOpF30F(0xd5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1522 EncodeOp660F(0xd5, 1, IMM_NONE, NACLi_SSE2, "pmullw $Vdq, $Wdq");
1523 EncodeOpF20F(0xd5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1525 EncodeOp0F(0xd6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1526 EncodeOpF30F(0xd6, 1, IMM_NONE, NACLi_SSE2, "movq2dq $Vdq, $PRq");
1527 EncodeOp660F(0xd6, 1, IMM_NONE, NACLi_SSE2, "movq $Wq, $Vq");
1528 EncodeOpF20F(0xd6, 1, IMM_NONE, NACLi_SSE2, "movdq2q $Pq, $VRq");
1530 EncodeOp0F(0xd7, 1, IMM_NONE, NACLi_SSE, "pmovmskb $Gd, $PRq");
1531 EncodeOpF30F(0xd7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1532 EncodeOp660F(0xd7, 1, IMM_NONE, NACLi_SSE2, "pmovmskb $Gd, $VRdq");
1533 EncodeOpF20F(0xd7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1535 EncodeOp0F(0xd8, 1, IMM_NONE, NACLi_MMX, "psubusb $Pq, $Qq");
1536 EncodeOpF30F(0xd8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1537 EncodeOp660F(0xd8, 1, IMM_NONE, NACLi_SSE2, "psubusb $Vdq, $Wdq");
1538 EncodeOpF20F(0xd8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1540 EncodeOp0F(0xd9, 1, IMM_NONE, NACLi_MMX, "psubusw $Pq, $Qq");
1541 EncodeOpF30F(0xd9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1542 EncodeOp660F(0xd9, 1, IMM_NONE, NACLi_SSE2, "psubusw $Vdq, $Wdq");
1543 EncodeOpF20F(0xd9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1545 EncodeOp0F(0xda, 1, IMM_NONE, NACLi_SSE, "pminub $Pq, $Qq");
1546 EncodeOpF30F(0xda, 0, IMM_NONE, NACLi_INVALID, "invalid");
1547 EncodeOp660F(0xda, 1, IMM_NONE, NACLi_SSE2, "pminub $Vdq, $Wdq");
1548 EncodeOpF20F(0xda, 0, IMM_NONE, NACLi_INVALID, "invalid");
1550 EncodeOp0F(0xdb, 1, IMM_NONE, NACLi_MMX, "pand $Pq, $Qq");
1551 EncodeOpF30F(0xdb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1552 EncodeOp660F(0xdb, 1, IMM_NONE, NACLi_SSE2, "pand $Vdq, $Wdq");
1553 EncodeOpF20F(0xdb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1555 EncodeOp0F(0xdc, 1, IMM_NONE, NACLi_MMX, "paddusb $Pq, $Qq");
1556 EncodeOpF30F(0xdc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1557 EncodeOp660F(0xdc, 1, IMM_NONE, NACLi_SSE2, "paddusb $Vdq, $Wdq");
1558 EncodeOpF20F(0xdc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1560 EncodeOp0F(0xdd, 1, IMM_NONE, NACLi_MMX, "paddusw $Pq, $Qq");
1561 EncodeOpF30F(0xdd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1562 EncodeOp660F(0xdd, 1, IMM_NONE, NACLi_SSE2, "paddusw $Vdq, $Wdq");
1563 EncodeOpF20F(0xdd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1565 EncodeOp0F(0xde, 1, IMM_NONE, NACLi_SSE, "pmaxub $Pq, $Qq");
1566 EncodeOpF30F(0xde, 0, IMM_NONE, NACLi_INVALID, "invalid");
1567 EncodeOp660F(0xde, 1, IMM_NONE, NACLi_SSE2, "pmaxub $Vdq, $Wdq");
1568 EncodeOpF20F(0xde, 0, IMM_NONE, NACLi_INVALID, "invalid");
1570 EncodeOp0F(0xdf, 1, IMM_NONE, NACLi_MMX, "pandn $Pq, $Qq");
1571 EncodeOpF30F(0xdf, 0, IMM_NONE, NACLi_INVALID, "invalid");
1572 EncodeOp660F(0xdf, 1, IMM_NONE, NACLi_SSE2, "pandn $Vdq, $Wdq");
1573 EncodeOpF20F(0xdf, 0, IMM_NONE, NACLi_INVALID, "invalid");
1575 EncodeOp0F(0xe0, 1, IMM_NONE, NACLi_SSE, "pavgb $Pq, $Qq");
1576 EncodeOpF30F(0xe0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1577 EncodeOp660F(0xe0, 1, IMM_NONE, NACLi_SSE2, "pavgb $Vdq, $Wdq");
1578 EncodeOpF20F(0xe0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1580 EncodeOp0F(0xe1, 1, IMM_NONE, NACLi_MMX, "psraw $Pq, $Qq");
1581 EncodeOpF30F(0xe1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1582 EncodeOp660F(0xe1, 1, IMM_NONE, NACLi_SSE2, "psraw $Vdq, $Wdq");
1583 EncodeOpF20F(0xe1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1585 EncodeOp0F(0xe2, 1, IMM_NONE, NACLi_MMX, "psrad $Pq, $Qq");
1586 EncodeOpF30F(0xe2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1587 EncodeOp660F(0xe2, 1, IMM_NONE, NACLi_SSE2, "psrad $Vdq, $Wdq");
1588 EncodeOpF20F(0xe2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1590 EncodeOp0F(0xe3, 1, IMM_NONE, NACLi_SSE, "pavgw $Pq, $Qq");
1591 EncodeOpF30F(0xe3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1592 EncodeOp660F(0xe3, 1, IMM_NONE, NACLi_SSE2, "pavgw $Vdq, $Wdq");
1593 EncodeOpF20F(0xe3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1595 EncodeOp0F(0xe4, 1, IMM_NONE, NACLi_SSE, "pmulhuw $Pq, $Qq");
1596 EncodeOpF30F(0xe4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1597 EncodeOp660F(0xe4, 1, IMM_NONE, NACLi_SSE2, "pmulhuw $Vdq, $Wdq");
1598 EncodeOpF20F(0xe4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1600 EncodeOp0F(0xe5, 1, IMM_NONE, NACLi_MMX, "pmulhw $Pq, $Qq");
1601 EncodeOpF30F(0xe5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1602 EncodeOp660F(0xe5, 1, IMM_NONE, NACLi_SSE2, "pmulhw $Vdq, $Wdq");
1603 EncodeOpF20F(0xe5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1605 EncodeOp0F(0xe6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1606 EncodeOpF30F(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvtdq2pd $Vpd, $Wq");
1607 EncodeOp660F(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvttpd2dq $Vq, $Wpd");
1608 EncodeOpF20F(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvtpd2dq $Vq, $Wpd");
1610 EncodeOp0F(0xe7, 1, IMM_NONE, NACLi_SSE, "movntq $Mq, $Pq");
1611 EncodeOpF30F(0xe7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1612 EncodeOp660F(0xe7, 1, IMM_NONE, NACLi_SSE2, "movntdq $Mdq, $Vdq");
1613 EncodeOpF20F(0xe7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1615 EncodeOp0F(0xe8, 1, IMM_NONE, NACLi_MMX, "psubsb $Pq, $Qq");
1616 EncodeOpF30F(0xe8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1617 EncodeOp660F(0xe8, 1, IMM_NONE, NACLi_SSE2, "psubsb $Vdq, $Wdq");
1618 EncodeOpF20F(0xe8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1620 EncodeOp0F(0xe9, 1, IMM_NONE, NACLi_MMX, "psubsw $Pq, $Qq");
1621 EncodeOpF30F(0xe9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1622 EncodeOp660F(0xe9, 1, IMM_NONE, NACLi_SSE2, "psubsw $Vdq, $Wdq");
1623 EncodeOpF20F(0xe9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1625 EncodeOp0F(0xea, 1, IMM_NONE, NACLi_SSE, "pminsw $Pq, $Qq");
1626 EncodeOpF30F(0xea, 0, IMM_NONE, NACLi_INVALID, "invalid");
1627 EncodeOp660F(0xea, 1, IMM_NONE, NACLi_SSE2, "pminsw $Vdq, $Wdq");
1628 EncodeOpF20F(0xea, 0, IMM_NONE, NACLi_INVALID, "invalid");
1630 EncodeOp0F(0xeb, 1, IMM_NONE, NACLi_MMX, "por $Pq, $Qq");
1631 EncodeOpF30F(0xeb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1632 EncodeOp660F(0xeb, 1, IMM_NONE, NACLi_SSE2, "por $Vdq, $Wdq");
1633 EncodeOpF20F(0xeb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1635 EncodeOp0F(0xec, 1, IMM_NONE, NACLi_MMX, "paddsb $Pq, $Qq");
1636 EncodeOpF30F(0xec, 0, IMM_NONE, NACLi_INVALID, "invalid");
1637 EncodeOp660F(0xec, 1, IMM_NONE, NACLi_SSE2, "paddsb $Vdq, $Wdq");
1638 EncodeOpF20F(0xec, 0, IMM_NONE, NACLi_INVALID, "invalid");
1640 EncodeOp0F(0xed, 1, IMM_NONE, NACLi_MMX, "paddsw $Pq, $Qq");
1641 EncodeOpF30F(0xed, 0, IMM_NONE, NACLi_INVALID, "invalid");
1642 EncodeOp660F(0xed, 1, IMM_NONE, NACLi_SSE2, "paddsw $Vdq, $Wdq");
1643 EncodeOpF20F(0xed, 0, IMM_NONE, NACLi_INVALID, "invalid");
1645 EncodeOp0F(0xee, 1, IMM_NONE, NACLi_SSE, "pmaxsw $Pq, $Qq");
1646 EncodeOpF30F(0xee, 0, IMM_NONE, NACLi_INVALID, "invalid");
1647 EncodeOp660F(0xee, 1, IMM_NONE, NACLi_SSE2, "pmaxsw $Vdq, $Wdq");
1648 EncodeOpF20F(0xee, 0, IMM_NONE, NACLi_INVALID, "invalid");
1650 EncodeOp0F(0xef, 1, IMM_NONE, NACLi_MMX, "pxor $Pq, $Qq");
1651 EncodeOpF30F(0xef, 0, IMM_NONE, NACLi_INVALID, "invalid");
1652 EncodeOp660F(0xef, 1, IMM_NONE, NACLi_SSE2, "pxor $Vdq, $Wdq");
1653 EncodeOpF20F(0xef, 0, IMM_NONE, NACLi_INVALID, "invalid");
1655 EncodeOp0F(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1656 EncodeOpF30F(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1657 EncodeOp660F(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1658 EncodeOpF20F(0xf0, 1, IMM_NONE, NACLi_SSE3, "lddqu $Vpd, $Mdq");
1660 EncodeOp0F(0xf1, 1, IMM_NONE, NACLi_MMX, "psllw $Pq, $Qq");
1661 EncodeOpF30F(0xf1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1662 EncodeOp660F(0xf1, 1, IMM_NONE, NACLi_SSE2, "psllw $Vdq, $Wdq");
1663 EncodeOpF20F(0xf1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1665 EncodeOp0F(0xf2, 1, IMM_NONE, NACLi_MMX, "pslld $Pq, $Qq");
1666 EncodeOpF30F(0xf2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1667 EncodeOp660F(0xf2, 1, IMM_NONE, NACLi_SSE2, "pslld $Vdq, $Wdq");
1668 EncodeOpF20F(0xf2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1670 EncodeOp0F(0xf3, 1, IMM_NONE, NACLi_MMX, "psllq $Pq, $Qq");
1671 EncodeOpF30F(0xf3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1672 EncodeOp660F(0xf3, 1, IMM_NONE, NACLi_SSE2, "psllq $Vdq, $Wdq");
1673 EncodeOpF20F(0xf3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1675 EncodeOp0F(0xf4, 1, IMM_NONE, NACLi_SSE2, "pmuludq $Pq, $Qq");
1676 EncodeOpF30F(0xf4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1677 EncodeOp660F(0xf4, 1, IMM_NONE, NACLi_SSE2, "pmuludq $Vdq, $Wdq");
1678 EncodeOpF20F(0xf4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1680 EncodeOp0F(0xf5, 1, IMM_NONE, NACLi_MMX, "pmaddwd $Pq, $Qq");
1681 EncodeOpF30F(0xf5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1682 EncodeOp660F(0xf5, 1, IMM_NONE, NACLi_SSE2, "pmaddwd $Vdq, $Wdq");
1683 EncodeOpF20F(0xf5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1685 EncodeOp0F(0xf6, 1, IMM_NONE, NACLi_SSE, "psadbw $Pq, $Qq");
1686 EncodeOpF30F(0xf6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1687 EncodeOp660F(0xf6, 1, IMM_NONE, NACLi_SSE2, "psadbw $Vdq, $Wdq");
1688 EncodeOpF20F(0xf6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1690 EncodeOp0F(0xf7, 1, IMM_NONE, NACLi_SSE, "maskmovq $Pq, $PRq");
1691 EncodeOpF30F(0xf7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1692 EncodeOp660F(0xf7, 1, IMM_NONE, NACLi_SSE2, "maskmovdqu $Vdq, $VRdq");
1693 EncodeOpF20F(0xf7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1695 EncodeOp0F(0xf8, 1, IMM_NONE, NACLi_MMX, "psubb $Pq, $Qq");
1696 EncodeOpF30F(0xf8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1697 EncodeOp660F(0xf8, 1, IMM_NONE, NACLi_SSE2, "psubb $Vdq, $Wdq");
1698 EncodeOpF20F(0xf8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1700 EncodeOp0F(0xf9, 1, IMM_NONE, NACLi_MMX, "psubw $Pq, $Qq");
1701 EncodeOpF30F(0xf9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1702 EncodeOp660F(0xf9, 1, IMM_NONE, NACLi_SSE2, "psubw $Vdq, $Wdq");
1703 EncodeOpF20F(0xf9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1705 EncodeOp0F(0xfa, 1, IMM_NONE, NACLi_MMX, "psubd $Pq, $Qq");
1706 EncodeOpF30F(0xfa, 0, IMM_NONE, NACLi_INVALID, "invalid");
1707 EncodeOp660F(0xfa, 1, IMM_NONE, NACLi_SSE2, "psubd $Vdq, $Wdq");
1708 EncodeOpF20F(0xfa, 0, IMM_NONE, NACLi_INVALID, "invalid");
1710 /* Here is an SSE2 instruction that doesn't require 0x66 */
1711 EncodeOp0F(0xfb, 1, IMM_NONE, NACLi_SSE2, "psubq $Pq, $Qq");
1712 EncodeOpF30F(0xfb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1713 EncodeOp660F(0xfb, 1, IMM_NONE, NACLi_SSE2, "psubq $Vdq, $Wdq");
1714 EncodeOpF20F(0xfb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1716 EncodeOp0F(0xfc, 1, IMM_NONE, NACLi_MMX, "paddb $Pq, $Qq");
1717 EncodeOpF30F(0xfc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1718 EncodeOp660F(0xfc, 1, IMM_NONE, NACLi_SSE2, "paddb $Vdq, $Wdq");
1719 EncodeOpF20F(0xfc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1721 EncodeOp0F(0xfd, 1, IMM_NONE, NACLi_MMX, "paddw $Pq, $Qq");
1722 EncodeOpF30F(0xfd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1723 EncodeOp660F(0xfd, 1, IMM_NONE, NACLi_SSE2, "paddw $Vdq, $Wdq");
1724 EncodeOpF20F(0xfd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1726 EncodeOp0F(0xfe, 1, IMM_NONE, NACLi_MMX, "paddd $Pq, $Qq");
1727 EncodeOpF30F(0xfe, 0, IMM_NONE, NACLi_INVALID, "invalid");
1728 EncodeOp660F(0xfe, 1, IMM_NONE, NACLi_SSE2, "paddd $Vdq, $Wdq");
1729 EncodeOpF20F(0xfe, 0, IMM_NONE, NACLi_INVALID, "invalid");
1731 EncodeOp0F(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1732 EncodeOpF30F(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1733 EncodeOp660F(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1734 EncodeOpF20F(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1736 /* three byte opcodes */
1737 /* 3DNow! */
1738 EncodeOp0F0F(0x90, 1, IMM_NONE, NACLi_3DNOW, "pfcmpge $P, $Q");
1739 EncodeOp0F0F(0x94, 1, IMM_NONE, NACLi_3DNOW, "pfmin $P, $Q");
1740 EncodeOp0F0F(0x96, 1, IMM_NONE, NACLi_3DNOW, "pfrcp $P, $Q");
1741 EncodeOp0F0F(0x97, 1, IMM_NONE, NACLi_3DNOW, "pfrsqrt $P, $Q");
1742 EncodeOp0F0F(0xa0, 1, IMM_NONE, NACLi_3DNOW, "pfcmpgt $P, $Q");
1743 EncodeOp0F0F(0xa4, 1, IMM_NONE, NACLi_3DNOW, "pfmax $P, $Q");
1744 EncodeOp0F0F(0xa6, 1, IMM_NONE, NACLi_3DNOW, "pfrcpit1 $P, $Q");
1745 EncodeOp0F0F(0xa7, 1, IMM_NONE, NACLi_3DNOW, "pfrsqit1 $P, $Q");
1746 EncodeOp0F0F(0xb0, 1, IMM_NONE, NACLi_3DNOW, "pfcmpeq $P, $Q");
1747 EncodeOp0F0F(0xb4, 1, IMM_NONE, NACLi_3DNOW, "pfmul $P, $Q");
1748 EncodeOp0F0F(0xb6, 1, IMM_NONE, NACLi_3DNOW, "pfrcpit2 $P, $Q");
1749 EncodeOp0F0F(0xb7, 1, IMM_NONE, NACLi_3DNOW, "pmulhrw $P, $Q");
1750 EncodeOp0F0F(0x0c, 1, IMM_NONE, NACLi_E3DNOW, "pi2fw $P, $Q");
1751 EncodeOp0F0F(0x0d, 1, IMM_NONE, NACLi_3DNOW, "pi2fd $P, $Q");
1752 EncodeOp0F0F(0x1c, 1, IMM_NONE, NACLi_E3DNOW, "pf2iw $P, $Q");
1753 EncodeOp0F0F(0x1d, 1, IMM_NONE, NACLi_3DNOW, "pf2id $P, $Q");
1754 EncodeOp0F0F(0x8a, 1, IMM_NONE, NACLi_E3DNOW, "pfnacc $P, $Q");
1755 EncodeOp0F0F(0x8e, 1, IMM_NONE, NACLi_E3DNOW, "pfpnacc $P, $Q");
1756 EncodeOp0F0F(0x9a, 1, IMM_NONE, NACLi_3DNOW, "pfsub $P, $Q");
1757 EncodeOp0F0F(0x9e, 1, IMM_NONE, NACLi_3DNOW, "pfadd $P, $Q");
1758 EncodeOp0F0F(0xaa, 1, IMM_NONE, NACLi_3DNOW, "pfsubr $P, $Q");
1759 EncodeOp0F0F(0xae, 1, IMM_NONE, NACLi_3DNOW, "pfacc $P, $Q");
1760 EncodeOp0F0F(0xbb, 1, IMM_NONE, NACLi_E3DNOW, "pswapd $P, $Q");
1761 EncodeOp0F0F(0xbf, 1, IMM_NONE, NACLi_3DNOW, "pavgusb $P, $Q");
1762 /* SSSE3 */
1763 EncodeOp0F38(0x00, 1, IMM_NONE, NACLi_SSSE3, "pshufb $P, $Q");
1764 EncodeOp0F38(0x01, 1, IMM_NONE, NACLi_SSSE3, "phaddw $P, $Q");
1765 EncodeOp0F38(0x02, 1, IMM_NONE, NACLi_SSSE3, "phaddd $P, $Q");
1766 EncodeOp0F38(0x03, 1, IMM_NONE, NACLi_SSSE3, "phaddsw $P, $Q");
1767 EncodeOp0F38(0x04, 1, IMM_NONE, NACLi_SSSE3, "pmaddubsw $P, $Q");
1768 EncodeOp0F38(0x05, 1, IMM_NONE, NACLi_SSSE3, "phsubw $P, $Q");
1769 EncodeOp0F38(0x06, 1, IMM_NONE, NACLi_SSSE3, "phsubd $P, $Q");
1770 EncodeOp0F38(0x07, 1, IMM_NONE, NACLi_SSSE3, "phsubsw $P, $Q");
1771 EncodeOp0F38(0x08, 1, IMM_NONE, NACLi_SSSE3, "psignb $P, $Q");
1772 EncodeOp0F38(0x09, 1, IMM_NONE, NACLi_SSSE3, "psignw $P, $Q");
1773 EncodeOp0F38(0x0a, 1, IMM_NONE, NACLi_SSSE3, "psignd $P, $Q");
1774 EncodeOp0F38(0x0b, 1, IMM_NONE, NACLi_SSSE3, "pmulhrsw $P, $Q");
1775 EncodeOp0F38(0x1c, 1, IMM_NONE, NACLi_SSSE3, "pabsb $P, $Q");
1776 EncodeOp0F38(0x1d, 1, IMM_NONE, NACLi_SSSE3, "pabsw $P, $Q");
1777 EncodeOp0F38(0x1e, 1, IMM_NONE, NACLi_SSSE3, "pabsd $P, $Q");
1778 EncodeOp0F3A(0x0f, 1, IMM_FIXED1, NACLi_SSSE3, "palignr $P, $Q, $Ib");
1780 BuildSSE4Tables();
1781 Buildx87Tables();
1784 static void PrintHeader(FILE *f, const char *argv0, const char *fname) {
1785 time_t timeofday;
1787 if (time(&timeofday) < 0) {
1788 fprintf(stderr, "time() failed\n");
1789 exit(-1);
1791 fprintf(f, "/* %s\n", fname);
1792 fprintf(f, " * THIS FILE IS AUTO-GENERATED. DO NOT EDIT.\n");
1793 fprintf(f, " * This file was auto-generated by %s on %s",
1794 argv0, ctime(&timeofday));
1795 fprintf(f, "\n");
1796 fprintf(f, " * You must include ncdecode.h before this file.\n");
1797 fprintf(f, " */\n");
1800 static void PrintDecodeTable(FILE *f) {
1801 /* now print the table */
1802 int opc;
1803 int group, nnn;
1804 OpMetaInfo *opinfo = NULL;
1805 fprintf(f, "static const struct OpInfo kDecode1ByteOp[NCDTABLESIZE] = {\n");
1807 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1808 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1809 NaClInstTypeString(g_Op1ByteTable[opc]->insttype),
1810 g_Op1ByteTable[opc]->mrmbyte,
1811 g_Op1ByteTable[opc]->immtype,
1812 g_Op1ByteTable[opc]->opinmrm,
1813 g_Op1ByteTable[opc]->disfmt);
1815 fprintf(f, "};\n\n");
1817 fprintf(f, "static const struct OpInfo kDecodeModRMOp[kNaClMRMGroupsRange]");
1818 fprintf(f, "[kModRMOpcodeGroupSize] = {\n");
1819 for (group = 0; group < kNaClMRMGroupsRange; group++) {
1820 fprintf(f, " {\n");
1821 for (nnn = 0; nnn < kModRMOpcodeGroupSize; nnn++) {
1822 fprintf(f, " /* %d, %d */ { %s, %d, %d, %d },\t/* %s */\n",
1823 group, nnn,
1824 NaClInstTypeString(g_ModRMOpTable[group][nnn]->insttype),
1825 g_ModRMOpTable[group][nnn]->mrmbyte,
1826 g_ModRMOpTable[group][nnn]->immtype,
1827 g_ModRMOpTable[group][nnn]->opinmrm,
1828 g_ModRMOpTable[group][nnn]->disfmt);
1830 fprintf(f, " },\n");
1832 fprintf(f, "};\n\n");
1834 fprintf(f, "static const struct OpInfo kDecode0FXXOp[NCDTABLESIZE] = {\n");
1835 /* now print the table */
1836 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1837 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1838 NaClInstTypeString(g_Op0FXXMetaTable[opc]->insttype),
1839 g_Op0FXXMetaTable[opc]->mrmbyte,
1840 g_Op0FXXMetaTable[opc]->immtype,
1841 g_Op0FXXMetaTable[opc]->opinmrm,
1842 g_Op0FXXMetaTable[opc]->disfmt);
1844 fprintf(f, "};\n\n");
1846 fprintf(f, "static const struct OpInfo kDecode660FXXOp[NCDTABLESIZE] = {\n");
1847 /* now print the table */
1848 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1849 opinfo = g_Op660FXXTable[opc];
1850 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1851 NaClInstTypeString(opinfo->insttype),
1852 opinfo->mrmbyte,
1853 opinfo->immtype,
1854 opinfo->opinmrm,
1855 opinfo->disfmt);
1857 fprintf(f, "};\n\n");
1859 fprintf(f, "static const struct OpInfo kDecodeF20FXXOp[NCDTABLESIZE] = {\n");
1860 /* now print the table */
1861 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1862 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1863 NaClInstTypeString(g_OpF20FXXTable[opc]->insttype),
1864 g_OpF20FXXTable[opc]->mrmbyte,
1865 g_OpF20FXXTable[opc]->immtype,
1866 g_OpF20FXXTable[opc]->opinmrm,
1867 g_OpF20FXXTable[opc]->disfmt);
1869 fprintf(f, "};\n\n");
1871 fprintf(f, "static const struct OpInfo kDecodeF30FXXOp[NCDTABLESIZE] = {\n");
1872 /* now print the table */
1873 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1874 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1875 NaClInstTypeString(g_OpF30FXXTable[opc]->insttype),
1876 g_OpF30FXXTable[opc]->mrmbyte,
1877 g_OpF30FXXTable[opc]->immtype,
1878 g_OpF30FXXTable[opc]->opinmrm,
1879 g_OpF30FXXTable[opc]->disfmt);
1881 fprintf(f, "};\n\n");
1883 /* three byte opcode tables */
1884 fprintf(f, "static const struct OpInfo kDecode0F0FOp[NCDTABLESIZE] = {\n");
1885 /* now print the table */
1886 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1887 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1888 NaClInstTypeString(g_Op0F0FTable[opc]->insttype),
1889 g_Op0F0FTable[opc]->mrmbyte,
1890 g_Op0F0FTable[opc]->immtype,
1891 g_Op0F0FTable[opc]->opinmrm,
1892 g_Op0F0FTable[opc]->disfmt);
1894 fprintf(f, "};\n\n");
1896 fprintf(f, "static const struct OpInfo kDecode0F38Op[NCDTABLESIZE] = {\n");
1897 /* now print the table */
1898 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1899 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1900 NaClInstTypeString(g_Op0F38Table[opc]->insttype),
1901 g_Op0F38Table[opc]->mrmbyte,
1902 g_Op0F38Table[opc]->immtype,
1903 g_Op0F38Table[opc]->opinmrm,
1904 g_Op0F38Table[opc]->disfmt);
1906 fprintf(f, "};\n\n");
1908 fprintf(f, "static const struct OpInfo kDecode0F3AOp[NCDTABLESIZE] = {\n");
1909 /* now print the table */
1910 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1911 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1912 NaClInstTypeString(g_Op0F3ATable[opc]->insttype),
1913 g_Op0F3ATable[opc]->mrmbyte,
1914 g_Op0F3ATable[opc]->immtype,
1915 g_Op0F3ATable[opc]->opinmrm,
1916 g_Op0F3ATable[opc]->disfmt);
1918 fprintf(f, "};\n\n");
1920 fprintf(f, "static const struct OpInfo kDecode660F38Op[NCDTABLESIZE] = {\n");
1921 /* now print the table */
1922 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1923 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1924 NaClInstTypeString(g_Op660F38Table[opc]->insttype),
1925 g_Op660F38Table[opc]->mrmbyte,
1926 g_Op660F38Table[opc]->immtype,
1927 g_Op660F38Table[opc]->opinmrm,
1928 g_Op660F38Table[opc]->disfmt);
1930 fprintf(f, "};\n\n");
1932 fprintf(f, "static const struct OpInfo kDecodeF20F38Op[NCDTABLESIZE] = {\n");
1933 /* now print the table */
1934 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1935 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1936 NaClInstTypeString(g_OpF20F38Table[opc]->insttype),
1937 g_OpF20F38Table[opc]->mrmbyte,
1938 g_OpF20F38Table[opc]->immtype,
1939 g_OpF20F38Table[opc]->opinmrm,
1940 g_OpF20F38Table[opc]->disfmt);
1942 fprintf(f, "};\n\n");
1944 fprintf(f, "static const struct OpInfo kDecode660F3AOp[NCDTABLESIZE] = {\n");
1945 /* now print the table */
1946 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1947 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1948 NaClInstTypeString(g_Op660F3ATable[opc]->insttype),
1949 g_Op660F3ATable[opc]->mrmbyte,
1950 g_Op660F3ATable[opc]->immtype,
1951 g_Op660F3ATable[opc]->opinmrm,
1952 g_Op660F3ATable[opc]->disfmt);
1954 fprintf(f, "};\n\n");
1956 fprintf(f, "\n/* x87 opcode tables*/\n");
1957 fprintf(f, "static const struct OpInfo kDecode87D8[NCDTABLESIZE] = {\n");
1958 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1959 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1960 NaClInstTypeString(g_Op87D8[opc]->insttype),
1961 g_Op87D8[opc]->mrmbyte,
1962 g_Op87D8[opc]->immtype,
1963 g_Op87D8[opc]->opinmrm,
1964 g_Op87D8[opc]->disfmt);
1966 fprintf(f, "};\n\n");
1967 fprintf(f, "static const struct OpInfo kDecode87D9[NCDTABLESIZE] = {\n");
1968 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1969 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1970 NaClInstTypeString(g_Op87D9[opc]->insttype),
1971 g_Op87D9[opc]->mrmbyte,
1972 g_Op87D9[opc]->immtype,
1973 g_Op87D9[opc]->opinmrm,
1974 g_Op87D9[opc]->disfmt);
1976 fprintf(f, "};\n\n");
1977 fprintf(f, "static const struct OpInfo kDecode87DA[NCDTABLESIZE] = {\n");
1978 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1979 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1980 NaClInstTypeString(g_Op87DA[opc]->insttype),
1981 g_Op87DA[opc]->mrmbyte,
1982 g_Op87DA[opc]->immtype,
1983 g_Op87DA[opc]->opinmrm,
1984 g_Op87DA[opc]->disfmt);
1986 fprintf(f, "};\n\n");
1987 fprintf(f, "static const struct OpInfo kDecode87DB[NCDTABLESIZE] = {\n");
1988 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1989 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1990 NaClInstTypeString(g_Op87DB[opc]->insttype),
1991 g_Op87DB[opc]->mrmbyte,
1992 g_Op87DB[opc]->immtype,
1993 g_Op87DB[opc]->opinmrm,
1994 g_Op87DB[opc]->disfmt);
1996 fprintf(f, "};\n\n");
1997 fprintf(f, "static const struct OpInfo kDecode87DC[NCDTABLESIZE] = {\n");
1998 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1999 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
2000 NaClInstTypeString(g_Op87DC[opc]->insttype),
2001 g_Op87DC[opc]->mrmbyte,
2002 g_Op87DC[opc]->immtype,
2003 g_Op87DC[opc]->opinmrm,
2004 g_Op87DC[opc]->disfmt);
2006 fprintf(f, "};\n\n");
2007 fprintf(f, "static const struct OpInfo kDecode87DD[NCDTABLESIZE] = {\n");
2008 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2009 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
2010 NaClInstTypeString(g_Op87DD[opc]->insttype),
2011 g_Op87DD[opc]->mrmbyte,
2012 g_Op87DD[opc]->immtype,
2013 g_Op87DD[opc]->opinmrm,
2014 g_Op87DD[opc]->disfmt);
2016 fprintf(f, "};\n\n");
2017 fprintf(f, "static const struct OpInfo kDecode87DE[NCDTABLESIZE] = {\n");
2018 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2019 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
2020 NaClInstTypeString(g_Op87DE[opc]->insttype),
2021 g_Op87DE[opc]->mrmbyte,
2022 g_Op87DE[opc]->immtype,
2023 g_Op87DE[opc]->opinmrm,
2024 g_Op87DE[opc]->disfmt);
2026 fprintf(f, "};\n\n");
2027 fprintf(f, "static const struct OpInfo kDecode87DF[NCDTABLESIZE] = {\n");
2028 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2029 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
2030 NaClInstTypeString(g_Op87DF[opc]->insttype),
2031 g_Op87DF[opc]->mrmbyte,
2032 g_Op87DF[opc]->immtype,
2033 g_Op87DF[opc]->opinmrm,
2034 g_Op87DF[opc]->disfmt);
2036 fprintf(f, "};\n\n");
2039 static void PrintDisasmTable(FILE *f) {
2040 int opc;
2041 int group, nnn;
2042 fprintf(f, "static const char *kDisasm1ByteOp[NCDTABLESIZE] = {\n");
2043 /* now print the table */
2045 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2046 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op1ByteTable[opc]->disfmt);
2048 fprintf(f, "};\n\n");
2050 fprintf(f, "static const char *kDisasmModRMOp[]");
2051 fprintf(f, "[kNaClMRMGroupsRange] = {\n");
2052 for (group = 0; group < kNaClMRMGroupsRange; group++) {
2053 fprintf(f, " {");
2054 for (nnn = 0; nnn < kModRMOpcodeGroupSize; nnn++) {
2055 fprintf(f, " /* %d %d */ \"%s\",\n", group, nnn,
2056 g_ModRMOpTable[group][nnn]->disfmt);
2058 fprintf(f, " },\n");
2060 fprintf(f, "};\n\n");
2062 fprintf(f, "static const char *kDisasm0FXXOp[NCDTABLESIZE] = {\n");
2063 /* now print the table */
2064 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2065 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0FXXMetaTable[opc]->disfmt);
2067 fprintf(f, "};\n\n");
2069 fprintf(f, "static const char *kDisasm660FXXOp[NCDTABLESIZE] = {\n");
2070 /* now print the table */
2071 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2072 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op660FXXTable[opc]->disfmt);
2074 fprintf(f, "};\n\n");
2076 fprintf(f, "static const char *kDisasmF20FXXOp[NCDTABLESIZE] = {\n");
2077 /* now print the table */
2078 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2079 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_OpF20FXXTable[opc]->disfmt);
2081 fprintf(f, "};\n\n");
2083 fprintf(f, "static const char *kDisasmF30FXXOp[NCDTABLESIZE] = {\n");
2084 /* now print the table */
2085 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2086 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_OpF30FXXTable[opc]->disfmt);
2088 fprintf(f, "};\n\n");
2090 /* three byte opcode tables including 3DNow */
2091 fprintf(f, "static const char *kDisasm0F0FOp[NCDTABLESIZE] = {\n");
2092 /* now print the table */
2093 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2094 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F0FTable[opc]->disfmt);
2096 fprintf(f, "};\n\n");
2097 fprintf(f, "static const char *kDisasm0F38Op[NCDTABLESIZE] = {\n");
2098 /* now print the table */
2099 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2100 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F38Table[opc]->disfmt);
2102 fprintf(f, "};\n\n");
2103 fprintf(f, "static const char *kDisasm660F38Op[NCDTABLESIZE] = {\n");
2104 /* now print the table */
2105 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2106 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op660F38Table[opc]->disfmt);
2108 fprintf(f, "};\n\n");
2109 fprintf(f, "static const char *kDisasmF20F38Op[NCDTABLESIZE] = {\n");
2110 /* now print the table */
2111 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2112 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_OpF20F38Table[opc]->disfmt);
2114 fprintf(f, "};\n\n");
2115 fprintf(f, "static const char *kDisasm0F3AOp[NCDTABLESIZE] = {\n");
2116 /* now print the table */
2117 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2118 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F3ATable[opc]->disfmt);
2120 fprintf(f, "};\n\n");
2121 fprintf(f, "static const char *kDisasm660F3AOp[NCDTABLESIZE] = {\n");
2122 /* now print the table */
2123 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2124 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op660F3ATable[opc]->disfmt);
2126 fprintf(f, "};\n\n");
2128 fprintf(f, "\n/* x87 opcode tables*/\n");
2129 fprintf(f, "static const char *kDisasm87D8[NCDTABLESIZE] = {\n");
2130 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2131 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87D8[opc]->disfmt);
2133 fprintf(f, "};\n\n");
2134 fprintf(f, "static const char *kDisasm87D9[NCDTABLESIZE] = {\n");
2135 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2136 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87D9[opc]->disfmt);
2138 fprintf(f, "};\n\n");
2139 fprintf(f, "static const char *kDisasm87DA[NCDTABLESIZE] = {\n");
2140 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2141 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DA[opc]->disfmt);
2143 fprintf(f, "};\n\n");
2144 fprintf(f, "static const char *kDisasm87DB[NCDTABLESIZE] = {\n");
2145 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2146 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DB[opc]->disfmt);
2148 fprintf(f, "};\n\n");
2149 fprintf(f, "static const char *kDisasm87DC[NCDTABLESIZE] = {\n");
2150 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2151 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DC[opc]->disfmt);
2153 fprintf(f, "};\n\n");
2154 fprintf(f, "static const char *kDisasm87DD[NCDTABLESIZE] = {\n");
2155 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2156 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DD[opc]->disfmt);
2158 fprintf(f, "};\n\n");
2159 fprintf(f, "static const char *kDisasm87DE[NCDTABLESIZE] = {\n");
2160 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2161 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DE[opc]->disfmt);
2163 fprintf(f, "};\n\n");
2164 fprintf(f, "static const char *kDisasm87DF[NCDTABLESIZE] = {\n");
2165 for (opc = 0; opc < NCDTABLESIZE; opc++) {
2166 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DF[opc]->disfmt);
2168 fprintf(f, "};\n\n");
2172 FILE *mustopen(const char *fname, const char *how) {
2173 FILE *f = fopen(fname, how);
2174 if (f == NULL) {
2175 fprintf(stderr, "could not fopen(%s, %s)\n", fname, how);
2176 fprintf(stderr, "exiting now\n");
2177 exit(-1);
2179 return f;
2182 #define DECODETAB "ncdecodetab.h"
2183 #define DISASMTAB "ncdisasmtab.h"
2184 int main(const int argc, const char *argv[]) {
2185 FILE *f;
2186 UNREFERENCED_PARAMETER(argc);
2187 BuildMetaTables();
2188 f = mustopen(DECODETAB, "w");
2189 PrintHeader(f, argv[0], DECODETAB);
2190 PrintDecodeTable(f);
2191 fclose(f);
2193 f = mustopen(DISASMTAB, "w");
2194 PrintHeader(f, argv[0], DISASMTAB);
2195 PrintDisasmTable(f);
2196 fclose(f);
2197 return 0;