OLD | NEW |
1 /* Copyright 2007, 2008, 2009, 2010, 2011 | 1 /* Copyright 2007, 2008, 2009, 2010, 2011, 2012 |
2 Free Software Foundation, Inc. | 2 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of the GNU opcodes library. | 4 This file is part of the GNU opcodes library. |
5 | 5 |
6 This library is free software; you can redistribute it and/or modify | 6 This library is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 3, or (at your option) | 8 the Free Software Foundation; either version 3, or (at your option) |
9 any later version. | 9 any later version. |
10 | 10 |
11 It is distributed in the hope that it will be useful, but WITHOUT | 11 It is distributed in the hope that it will be useful, but WITHOUT |
(...skipping 27 matching lines...) Expand all Loading... |
39 const char *name; | 39 const char *name; |
40 const char *init; | 40 const char *init; |
41 } initializer; | 41 } initializer; |
42 | 42 |
43 static initializer cpu_flag_init[] = | 43 static initializer cpu_flag_init[] = |
44 { | 44 { |
45 { "CPU_UNKNOWN_FLAGS", | 45 { "CPU_UNKNOWN_FLAGS", |
46 "~(CpuL1OM|CpuK1OM)" }, | 46 "~(CpuL1OM|CpuK1OM)" }, |
47 { "CPU_GENERIC32_FLAGS", | 47 { "CPU_GENERIC32_FLAGS", |
48 "Cpu186|Cpu286|Cpu386" }, | 48 "Cpu186|Cpu286|Cpu386" }, |
49 { "CPU_GENERIC64_FLAGS", | 49 { "CPU_GENERIC64_FLAGS", |
50 "Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686|CpuClflush|Cpu387|Cpu687|CpuNop|C
puMMX|CpuSSE|CpuSSE2|CpuLM" }, | 50 "Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686|CpuClflush|Cpu387|Cpu687|CpuNop|C
puMMX|CpuSSE|CpuSSE2|CpuLM" }, |
51 { "CPU_NONE_FLAGS", | 51 { "CPU_NONE_FLAGS", |
52 "0" }, | 52 "0" }, |
53 { "CPU_I186_FLAGS", | 53 { "CPU_I186_FLAGS", |
54 "Cpu186" }, | 54 "Cpu186" }, |
55 { "CPU_I286_FLAGS", | 55 { "CPU_I286_FLAGS", |
56 "Cpu186|Cpu286" }, | 56 "Cpu186|Cpu286" }, |
57 { "CPU_I386_FLAGS", | 57 { "CPU_I386_FLAGS", |
58 "Cpu186|Cpu286|Cpu386" }, | 58 "Cpu186|Cpu286|Cpu386" }, |
59 { "CPU_I486_FLAGS", | 59 { "CPU_I486_FLAGS", |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 { "CPU_FSGSBASE_FLAGS", | 155 { "CPU_FSGSBASE_FLAGS", |
156 "CpuFSGSBase" }, | 156 "CpuFSGSBase" }, |
157 { "CPU_RDRND_FLAGS", | 157 { "CPU_RDRND_FLAGS", |
158 "CpuRdRnd" }, | 158 "CpuRdRnd" }, |
159 { "CPU_F16C_FLAGS", | 159 { "CPU_F16C_FLAGS", |
160 "CpuF16C" }, | 160 "CpuF16C" }, |
161 { "CPU_BMI2_FLAGS", | 161 { "CPU_BMI2_FLAGS", |
162 "CpuBMI2" }, | 162 "CpuBMI2" }, |
163 { "CPU_LZCNT_FLAGS", | 163 { "CPU_LZCNT_FLAGS", |
164 "CpuLZCNT" }, | 164 "CpuLZCNT" }, |
| 165 { "CPU_HLE_FLAGS", |
| 166 "CpuHLE" }, |
| 167 { "CPU_RTM_FLAGS", |
| 168 "CpuRTM" }, |
165 { "CPU_INVPCID_FLAGS", | 169 { "CPU_INVPCID_FLAGS", |
166 "CpuINVPCID" }, | 170 "CpuINVPCID" }, |
| 171 { "CPU_VMFUNC_FLAGS", |
| 172 "CpuVMFUNC" }, |
167 { "CPU_3DNOW_FLAGS", | 173 { "CPU_3DNOW_FLAGS", |
168 "CpuMMX|Cpu3dnow" }, | 174 "CpuMMX|Cpu3dnow" }, |
169 { "CPU_3DNOWA_FLAGS", | 175 { "CPU_3DNOWA_FLAGS", |
170 "CpuMMX|Cpu3dnow|Cpu3dnowA" }, | 176 "CpuMMX|Cpu3dnow|Cpu3dnowA" }, |
171 { "CPU_PADLOCK_FLAGS", | 177 { "CPU_PADLOCK_FLAGS", |
172 "CpuPadLock" }, | 178 "CpuPadLock" }, |
173 { "CPU_SVME_FLAGS", | 179 { "CPU_SVME_FLAGS", |
174 "CpuSVME" }, | 180 "CpuSVME" }, |
175 { "CPU_SSE4A_FLAGS", | 181 { "CPU_SSE4A_FLAGS", |
176 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSE4a" }, | 182 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSE4a" }, |
177 { "CPU_ABM_FLAGS", | 183 { "CPU_ABM_FLAGS", |
178 "CpuABM" }, | 184 "CpuABM" }, |
179 { "CPU_AVX_FLAGS", | 185 { "CPU_AVX_FLAGS", |
180 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSSE3|CpuSSE4_1|CpuSSE4_2|CpuAVX" }, | 186 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSSE3|CpuSSE4_1|CpuSSE4_2|CpuAVX" }, |
181 { "CPU_AVX2_FLAGS", | 187 { "CPU_AVX2_FLAGS", |
182 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSSE3|CpuSSE4_1|CpuSSE4_2|CpuAVX|CpuAVX2"
}, | 188 "CpuMMX|CpuSSE|CpuSSE2|CpuSSE3|CpuSSSE3|CpuSSE4_1|CpuSSE4_2|CpuAVX|CpuAVX2"
}, |
183 { "CPU_ANY_AVX_FLAGS", | 189 { "CPU_ANY_AVX_FLAGS", |
184 "CpuAVX|CpuAVX2" }, | 190 "CpuAVX|CpuAVX2" }, |
185 { "CPU_L1OM_FLAGS", | 191 { "CPU_L1OM_FLAGS", |
186 "unknown" }, | 192 "unknown" }, |
187 { "CPU_K1OM_FLAGS", | 193 { "CPU_K1OM_FLAGS", |
188 "unknown" }, | 194 "unknown" }, |
| 195 { "CPU_ADX_FLAGS", |
| 196 "CpuADX" }, |
| 197 { "CPU_RDSEED_FLAGS", |
| 198 "CpuRdSeed" }, |
| 199 { "CPU_PRFCHW_FLAGS", |
| 200 "CpuPRFCHW" }, |
189 }; | 201 }; |
190 | 202 |
191 static initializer operand_type_init[] = | 203 static initializer operand_type_init[] = |
192 { | 204 { |
193 { "OPERAND_TYPE_NONE", | 205 { "OPERAND_TYPE_NONE", |
194 "0" }, | 206 "0" }, |
195 { "OPERAND_TYPE_REG8", | 207 { "OPERAND_TYPE_REG8", |
196 "Reg8" }, | 208 "Reg8" }, |
197 { "OPERAND_TYPE_REG16", | 209 { "OPERAND_TYPE_REG16", |
198 "Reg16" }, | 210 "Reg16" }, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 BITFIELD (CpuTBM), | 354 BITFIELD (CpuTBM), |
343 BITFIELD (CpuLM), | 355 BITFIELD (CpuLM), |
344 BITFIELD (CpuMovbe), | 356 BITFIELD (CpuMovbe), |
345 BITFIELD (CpuEPT), | 357 BITFIELD (CpuEPT), |
346 BITFIELD (CpuRdtscp), | 358 BITFIELD (CpuRdtscp), |
347 BITFIELD (CpuFSGSBase), | 359 BITFIELD (CpuFSGSBase), |
348 BITFIELD (CpuRdRnd), | 360 BITFIELD (CpuRdRnd), |
349 BITFIELD (CpuF16C), | 361 BITFIELD (CpuF16C), |
350 BITFIELD (CpuBMI2), | 362 BITFIELD (CpuBMI2), |
351 BITFIELD (CpuLZCNT), | 363 BITFIELD (CpuLZCNT), |
| 364 BITFIELD (CpuHLE), |
| 365 BITFIELD (CpuRTM), |
352 BITFIELD (CpuINVPCID), | 366 BITFIELD (CpuINVPCID), |
| 367 BITFIELD (CpuVMFUNC), |
| 368 BITFIELD (CpuRDSEED), |
| 369 BITFIELD (CpuADX), |
| 370 BITFIELD (CpuPRFCHW), |
353 BITFIELD (Cpu64), | 371 BITFIELD (Cpu64), |
354 BITFIELD (CpuNo64), | 372 BITFIELD (CpuNo64), |
355 #ifdef CpuUnused | 373 #ifdef CpuUnused |
356 BITFIELD (CpuUnused), | 374 BITFIELD (CpuUnused), |
357 #endif | 375 #endif |
358 }; | 376 }; |
359 | 377 |
360 static bitfield opcode_modifiers[] = | 378 static bitfield opcode_modifiers[] = |
361 { | 379 { |
362 BITFIELD (D), | 380 BITFIELD (D), |
(...skipping 19 matching lines...) Expand all Loading... |
382 BITFIELD (No_lSuf), | 400 BITFIELD (No_lSuf), |
383 BITFIELD (No_sSuf), | 401 BITFIELD (No_sSuf), |
384 BITFIELD (No_qSuf), | 402 BITFIELD (No_qSuf), |
385 BITFIELD (No_ldSuf), | 403 BITFIELD (No_ldSuf), |
386 BITFIELD (FWait), | 404 BITFIELD (FWait), |
387 BITFIELD (IsString), | 405 BITFIELD (IsString), |
388 BITFIELD (IsLockable), | 406 BITFIELD (IsLockable), |
389 BITFIELD (RegKludge), | 407 BITFIELD (RegKludge), |
390 BITFIELD (FirstXmm0), | 408 BITFIELD (FirstXmm0), |
391 BITFIELD (Implicit1stXmm0), | 409 BITFIELD (Implicit1stXmm0), |
| 410 BITFIELD (RepPrefixOk), |
| 411 BITFIELD (HLEPrefixOk), |
392 BITFIELD (ToDword), | 412 BITFIELD (ToDword), |
393 BITFIELD (ToQword), | 413 BITFIELD (ToQword), |
394 BITFIELD (AddrPrefixOp0), | 414 BITFIELD (AddrPrefixOp0), |
395 BITFIELD (IsPrefix), | 415 BITFIELD (IsPrefix), |
396 BITFIELD (ImmExt), | 416 BITFIELD (ImmExt), |
397 BITFIELD (NoRex64), | 417 BITFIELD (NoRex64), |
398 BITFIELD (Rex64), | 418 BITFIELD (Rex64), |
399 BITFIELD (Ugh), | 419 BITFIELD (Ugh), |
400 BITFIELD (Vex), | 420 BITFIELD (Vex), |
401 BITFIELD (VexVVVV), | 421 BITFIELD (VexVVVV), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 { | 491 { |
472 const bitfield *xp = (const bitfield *) x; | 492 const bitfield *xp = (const bitfield *) x; |
473 const bitfield *yp = (const bitfield *) y; | 493 const bitfield *yp = (const bitfield *) y; |
474 return xp->position - yp->position; | 494 return xp->position - yp->position; |
475 } | 495 } |
476 | 496 |
477 static void | 497 static void |
478 fail (const char *message, ...) | 498 fail (const char *message, ...) |
479 { | 499 { |
480 va_list args; | 500 va_list args; |
481 | 501 |
482 va_start (args, message); | 502 va_start (args, message); |
483 fprintf (stderr, _("%s: Error: "), program_name); | 503 fprintf (stderr, _("%s: Error: "), program_name); |
484 vfprintf (stderr, message, args); | 504 vfprintf (stderr, message, args); |
485 va_end (args); | 505 va_end (args); |
486 xexit (1); | 506 xexit (1); |
487 } | 507 } |
488 | 508 |
489 static void | 509 static void |
490 process_copyright (FILE *fp) | 510 process_copyright (FILE *fp) |
491 { | 511 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 next_field (char *str, char sep, char **next, char *last) | 569 next_field (char *str, char sep, char **next, char *last) |
550 { | 570 { |
551 char *p; | 571 char *p; |
552 | 572 |
553 p = remove_leading_whitespaces (str); | 573 p = remove_leading_whitespaces (str); |
554 for (str = p; *str != sep && *str != '\0'; str++); | 574 for (str = p; *str != sep && *str != '\0'; str++); |
555 | 575 |
556 *str = '\0'; | 576 *str = '\0'; |
557 remove_trailing_whitespaces (p); | 577 remove_trailing_whitespaces (p); |
558 | 578 |
559 *next = str + 1; | 579 *next = str + 1; |
560 | 580 |
561 if (p >= last) | 581 if (p >= last) |
562 abort (); | 582 abort (); |
563 | 583 |
564 return p; | 584 return p; |
565 } | 585 } |
566 | 586 |
567 static void | 587 static void |
568 set_bitfield (const char *f, bitfield *array, int value, | 588 set_bitfield (const char *f, bitfield *array, int value, |
569 unsigned int size, int lineno) | 589 unsigned int size, int lineno) |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1058 } |
1039 } | 1059 } |
1040 | 1060 |
1041 fclose (fp); | 1061 fclose (fp); |
1042 | 1062 |
1043 fprintf (table, " { NULL, 0, 0, 0, 0,\n"); | 1063 fprintf (table, " { NULL, 0, 0, 0, 0,\n"); |
1044 | 1064 |
1045 process_i386_cpu_flag (table, "0", 0, ",", " ", -1); | 1065 process_i386_cpu_flag (table, "0", 0, ",", " ", -1); |
1046 | 1066 |
1047 process_i386_opcode_modifier (table, "0", -1); | 1067 process_i386_opcode_modifier (table, "0", -1); |
1048 | 1068 |
1049 fprintf (table, " { "); | 1069 fprintf (table, " { "); |
1050 process_i386_operand_type (table, "0", 0, "\t ", -1); | 1070 process_i386_operand_type (table, "0", 0, "\t ", -1); |
1051 fprintf (table, " } }\n"); | 1071 fprintf (table, " } }\n"); |
1052 | 1072 |
1053 fprintf (table, "};\n"); | 1073 fprintf (table, "};\n"); |
1054 } | 1074 } |
1055 | 1075 |
1056 static void | 1076 static void |
1057 process_i386_registers (FILE *table) | 1077 process_i386_registers (FILE *table) |
1058 { | 1078 { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 free (init); | 1184 free (init); |
1165 } | 1185 } |
1166 fprintf (fp, "\n"); | 1186 fprintf (fp, "\n"); |
1167 | 1187 |
1168 fclose (fp); | 1188 fclose (fp); |
1169 } | 1189 } |
1170 | 1190 |
1171 /* Program options. */ | 1191 /* Program options. */ |
1172 #define OPTION_SRCDIR 200 | 1192 #define OPTION_SRCDIR 200 |
1173 | 1193 |
1174 struct option long_options[] = | 1194 struct option long_options[] = |
1175 { | 1195 { |
1176 {"srcdir", required_argument, NULL, OPTION_SRCDIR}, | 1196 {"srcdir", required_argument, NULL, OPTION_SRCDIR}, |
1177 {"debug", no_argument, NULL, 'd'}, | 1197 {"debug", no_argument, NULL, 'd'}, |
1178 {"version", no_argument, NULL, 'V'}, | 1198 {"version", no_argument, NULL, 'V'}, |
1179 {"help", no_argument, NULL, 'h'}, | 1199 {"help", no_argument, NULL, 'h'}, |
1180 {0, no_argument, NULL, 0} | 1200 {0, no_argument, NULL, 0} |
1181 }; | 1201 }; |
1182 | 1202 |
1183 static void | 1203 static void |
1184 print_version (void) | 1204 print_version (void) |
(...skipping 10 matching lines...) Expand all Loading... |
1195 xexit (status); | 1215 xexit (status); |
1196 } | 1216 } |
1197 | 1217 |
1198 int | 1218 int |
1199 main (int argc, char **argv) | 1219 main (int argc, char **argv) |
1200 { | 1220 { |
1201 extern int chdir (char *); | 1221 extern int chdir (char *); |
1202 char *srcdir = NULL; | 1222 char *srcdir = NULL; |
1203 int c; | 1223 int c; |
1204 FILE *table; | 1224 FILE *table; |
1205 | 1225 |
1206 program_name = *argv; | 1226 program_name = *argv; |
1207 xmalloc_set_program_name (program_name); | 1227 xmalloc_set_program_name (program_name); |
1208 | 1228 |
1209 while ((c = getopt_long (argc, argv, "vVdh", long_options, 0)) != EOF) | 1229 while ((c = getopt_long (argc, argv, "vVdh", long_options, 0)) != EOF) |
1210 switch (c) | 1230 switch (c) |
1211 { | 1231 { |
1212 case OPTION_SRCDIR: | 1232 case OPTION_SRCDIR: |
1213 srcdir = optarg; | 1233 srcdir = optarg; |
1214 break; | 1234 break; |
1215 case 'V': | 1235 case 'V': |
1216 case 'v': | 1236 case 'v': |
1217 print_version (); | 1237 print_version (); |
1218 break; | 1238 break; |
1219 case 'd': | 1239 case 'd': |
1220 debug = 1; | 1240 debug = 1; |
1221 break; | 1241 break; |
1222 case 'h': | 1242 case 'h': |
1223 case '?': | 1243 case '?': |
1224 usage (stderr, 0); | 1244 usage (stderr, 0); |
1225 default: | 1245 default: |
1226 case 0: | 1246 case 0: |
1227 break; | 1247 break; |
1228 } | 1248 } |
1229 | 1249 |
1230 if (optind != argc) | 1250 if (optind != argc) |
1231 usage (stdout, 1); | 1251 usage (stdout, 1); |
1232 | 1252 |
1233 if (srcdir != NULL) | 1253 if (srcdir != NULL) |
1234 if (chdir (srcdir) != 0) | 1254 if (chdir (srcdir) != 0) |
1235 fail (_("unable to change directory to \"%s\", errno = %s\n"), | 1255 fail (_("unable to change directory to \"%s\", errno = %s\n"), |
1236 srcdir, xstrerror (errno)); | 1256 srcdir, xstrerror (errno)); |
1237 | 1257 |
1238 /* Check the unused bitfield in i386_cpu_flags. */ | 1258 /* Check the unused bitfield in i386_cpu_flags. */ |
1239 #ifndef CpuUnused | 1259 #ifndef CpuUnused |
1240 c = CpuNumOfBits - CpuMax - 1; | 1260 c = CpuNumOfBits - CpuMax - 1; |
1241 if (c) | 1261 if (c) |
1242 fail (_("%d unused bits in i386_cpu_flags.\n"), c); | 1262 fail (_("%d unused bits in i386_cpu_flags.\n"), c); |
1243 #endif | 1263 #endif |
(...skipping 22 matching lines...) Expand all Loading... |
1266 process_copyright (table); | 1286 process_copyright (table); |
1267 | 1287 |
1268 process_i386_opcodes (table); | 1288 process_i386_opcodes (table); |
1269 process_i386_registers (table); | 1289 process_i386_registers (table); |
1270 process_i386_initializers (); | 1290 process_i386_initializers (); |
1271 | 1291 |
1272 fclose (table); | 1292 fclose (table); |
1273 | 1293 |
1274 exit (0); | 1294 exit (0); |
1275 } | 1295 } |
OLD | NEW |