aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-03-12 13:06:50 +0000
committerAlan Modra <amodra@gmail.com>2004-03-12 13:06:50 +0000
commitcc0ec051656757955a79ac4b50346f6e645c35da (patch)
treeee0c68dad99dbf8e2cde2cbe990eaa17d0846723 /opcodes
parentd1f161ea0a1ea3a6d18421b20ea7d33202d9fdd8 (diff)
downloadgdb-cc0ec051656757955a79ac4b50346f6e645c35da.zip
gdb-cc0ec051656757955a79ac4b50346f6e645c35da.tar.gz
gdb-cc0ec051656757955a79ac4b50346f6e645c35da.tar.bz2
* i386-dis.c (OP_M, OP_0f0e, OP_0fae, NOP_Fixup): New functions.
(M, Mp): Use OP_M. (None, PADLOCK_SPECIAL, PADLOCK_0): Delete. (GRPPADLCK): Define. (dis386): Use NOP_Fixup on "nop". (dis386_twobyte): Use GRPPADLCK on opcode 0xa7. (twobyte_has_modrm): Set for 0xa7. (padlock_table): Delete. Move to.. (grps): ..here, using OP_0f07. Use OP_Ofae on lfence, mfence and clflush. (print_insn): Revert PADLOCK_SPECIAL code. (OP_E): Delete sfence, lfence, mfence checks. * gas/i386/katmai.d: Revert last change.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog15
-rw-r--r--opcodes/i386-dis.c116
2 files changed, 88 insertions, 43 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 06e5556..4899cd3 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,18 @@
+2004-03-12 Alan Modra <amodra@bigpond.net.au>
+
+ * i386-dis.c (OP_M, OP_0f0e, OP_0fae, NOP_Fixup): New functions.
+ (M, Mp): Use OP_M.
+ (None, PADLOCK_SPECIAL, PADLOCK_0): Delete.
+ (GRPPADLCK): Define.
+ (dis386): Use NOP_Fixup on "nop".
+ (dis386_twobyte): Use GRPPADLCK on opcode 0xa7.
+ (twobyte_has_modrm): Set for 0xa7.
+ (padlock_table): Delete. Move to..
+ (grps): ..here, using OP_0f07. Use OP_Ofae on lfence, mfence
+ and clflush.
+ (print_insn): Revert PADLOCK_SPECIAL code.
+ (OP_E): Delete sfence, lfence, mfence checks.
+
2004-03-12 Jakub Jelinek <jakub@redhat.com>
* i386-dis.c (grps): Use INVLPG_Fixup instead of OP_E for invlpg.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 3be6e19..5c8381e 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -91,6 +91,10 @@ static void OP_EM (int, int);
static void OP_EX (int, int);
static void OP_MS (int, int);
static void OP_XS (int, int);
+static void OP_M (int, int);
+static void OP_0fae (int, int);
+static void OP_0f07 (int, int);
+static void NOP_Fixup (int, int);
static void OP_3DNowSuffix (int, int);
static void OP_SIMD_Suffix (int, int);
static void SIMD_Fixup (int, int);
@@ -198,8 +202,8 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
#define indirEv OP_indirE, v_mode
#define Ew OP_E, w_mode
#define Ma OP_E, v_mode
-#define M OP_E, 0 /* lea, lgdt, etc. */
-#define Mp OP_E, 0 /* 32 or 48 bit memory operand for LDS, LES etc */
+#define M OP_M, 0 /* lea, lgdt, etc. */
+#define Mp OP_M, 0 /* 32 or 48 bit memory operand for LDS, LES etc */
#define Gb OP_G, b_mode
#define Gv OP_G, v_mode
#define Gd OP_G, d_mode
@@ -292,7 +296,6 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
#define EX OP_EX, v_mode
#define MS OP_MS, v_mode
#define XS OP_XS, v_mode
-#define None OP_E, 0
#define OPSUF OP_3DNowSuffix, 0
#define OPSIMD OP_SIMD_Suffix, 0
@@ -364,7 +367,6 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
#define USE_GROUPS 2
#define USE_PREFIX_USER_TABLE 3
#define X86_64_SPECIAL 4
-#define PADLOCK_SPECIAL 5
#define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
@@ -392,6 +394,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
#define GRP14 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
#define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
#define GRPPLOCK NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
+#define GRPPADLCK NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
#define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
#define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
@@ -429,8 +432,6 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr)
#define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
-#define PADLOCK_0 NULL, NULL, PADLOCK_SPECIAL, NULL, 0, NULL, 0
-
typedef void (*op_rtn) (int bytemode, int sizeflag);
struct dis386 {
@@ -637,8 +638,7 @@ static const struct dis386 dis386[] = {
{ "movQ", Sw, Ev, XX },
{ "popU", Ev, XX, XX },
/* 90 */
- { "nop", XX, XX, XX },
- /* FIXME: NOP with REPz prefix is called PAUSE. */
+ { "nop", NOP_Fixup, 0, XX, XX },
{ "xchgS", RMeCX, eAX, XX },
{ "xchgS", RMeDX, eAX, XX },
{ "xchgS", RMeBX, eAX, XX },
@@ -954,7 +954,7 @@ static const struct dis386 dis386_twobyte[] = {
{ "shldS", Ev, Gv, Ib },
{ "shldS", Ev, Gv, CL },
{ "(bad)", XX, XX, XX },
- { PADLOCK_0 },
+ { GRPPADLCK },
/* a8 */
{ "pushT", gs, XX, XX },
{ "popT", gs, XX, XX },
@@ -1092,7 +1092,7 @@ static const unsigned char twobyte_has_modrm[256] = {
/* 70 */ 1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1, /* 7f */
/* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
/* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
- /* a0 */ 0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1, /* af */
+ /* a0 */ 0,0,0,1,1,1,0,1,0,0,0,1,1,1,1,1, /* af */
/* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
/* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
/* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
@@ -1430,9 +1430,9 @@ static const struct dis386 grps[][8] = {
{ "ldmxcsr", Ev, XX, XX },
{ "stmxcsr", Ev, XX, XX },
{ "(bad)", XX, XX, XX },
- { "lfence", None, XX, XX },
- { "mfence", None, XX, XX },
- { "clflush", None, XX, XX },
+ { "lfence", OP_0fae, 0, XX, XX },
+ { "mfence", OP_0fae, 0, XX, XX },
+ { "clflush", OP_0fae, 0, XX, XX },
},
/* GRP14 */
{
@@ -1466,6 +1466,17 @@ static const struct dis386 grps[][8] = {
{ "xcryptofb", XX, XX, XX },
{ "(bad)", XX, XX, XX },
{ "(bad)", XX, XX, XX },
+ },
+ /* GRPPADLCK */
+ {
+ { "xstorerng", OP_0f07, 0, XX, XX },
+ { "xcryptecb", OP_0f07, 0, XX, XX },
+ { "xcryptcbc", OP_0f07, 0, XX, XX },
+ { "(bad)", OP_0f07, 0, XX, XX },
+ { "xcryptcfb", OP_0f07, 0, XX, XX },
+ { "xcryptofb", OP_0f07, 0, XX, XX },
+ { "(bad)", OP_0f07, 0, XX, XX },
+ { "(bad)", OP_0f07, 0, XX, XX },
}
};
@@ -1710,19 +1721,6 @@ static const struct dis386 x86_64_table[][2] = {
},
};
-static const struct dis386 padlock_table[][8] = {
- {
- { "xstorerng", XX, XX, XX },
- { "xcryptecb", XX, XX, XX },
- { "xcryptcbc", XX, XX, XX },
- { "(bad)", XX, XX, XX },
- { "xcryptcfb", XX, XX, XX },
- { "xcryptofb", XX, XX, XX },
- { "(bad)", XX, XX, XX },
- { "(bad)", XX, XX, XX },
- },
-};
-
#define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
static void
@@ -2221,12 +2219,6 @@ print_insn (bfd_vma pc, disassemble_info *info)
dp = &x86_64_table[dp->bytemode2][mode_64bit];
break;
- case PADLOCK_SPECIAL:
- FETCH_DATA (info, codep + 1);
- index = (*codep++ >> 3) & 0x07;
- dp = &padlock_table[dp->bytemode2][index];
- break;
-
default:
oappend (INTERNAL_DISASSEMBLER_ERROR);
break;
@@ -3069,17 +3061,6 @@ OP_E (int bytemode, int sizeflag)
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case 0:
- if (codep[-2] == 0xAE && codep[-1] == 0xF8)
- /* sfence */
- strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
- else if (codep[-2] == 0xAE && codep[-1] == 0xF0)
- /* mfence */
- ;
- else if (codep[-2] == 0xAE && codep[-1] == 0xe8)
- /* lfence */
- ;
- else
- BadOp (); /* bad sfence,lea,lds,les,lfs,lgs,lss modrm */
break;
default:
oappend (INTERNAL_DISASSEMBLER_ERROR);
@@ -3982,6 +3963,55 @@ OP_XS (int bytemode, int sizeflag)
BadOp ();
}
+static void
+OP_M (int bytemode, int sizeflag)
+{
+ if (mod == 3)
+ BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
+ else
+ OP_E (bytemode, sizeflag);
+}
+
+static void
+OP_0f07 (int bytemode, int sizeflag)
+{
+ if (mod != 3 || rm != 0)
+ BadOp ();
+ else
+ OP_E (bytemode, sizeflag);
+}
+
+static void
+OP_0fae (int bytemode, int sizeflag)
+{
+ if (mod == 3)
+ {
+ if (reg == 7)
+ strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
+
+ if (reg < 5 || rm != 0)
+ {
+ BadOp (); /* bad sfence, mfence, or lfence */
+ return;
+ }
+ }
+ else if (reg != 7)
+ {
+ BadOp (); /* bad clflush */
+ return;
+ }
+
+ OP_E (bytemode, sizeflag);
+}
+
+static void
+NOP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
+{
+ /* NOP with REPZ prefix is called PAUSE. */
+ if (prefixes == PREFIX_REPZ)
+ strcpy (obuf, "pause");
+}
+
static const char *const Suffix3DNow[] = {
/* 00 */ NULL, NULL, NULL, NULL,
/* 04 */ NULL, NULL, NULL, NULL,