2003-03-21 H.J. Lu <hongjiu.lu@intel.com>
+ * config/tc-i386.c: Replace REX_MODE64, REX_EXTX, REX_EXTY
+ and REX_EXTZ with REX_W, REX_R, REX_X and REX_B respectively.
+
+2003-03-21 H.J. Lu <hongjiu.lu@intel.com>
+
PR binutils/4218
* config/tc-i386.c (match_template): Properly handle 64bit mode
"xchg %eax, %eax".
if (prefix >= REX_OPCODE && prefix < REX_OPCODE + 16
&& flag_code == CODE_64BIT)
{
- if ((i.prefix[REX_PREFIX] & prefix & REX_MODE64)
- || ((i.prefix[REX_PREFIX] & (REX_EXTX | REX_EXTY | REX_EXTZ))
- && (prefix & (REX_EXTX | REX_EXTY | REX_EXTZ))))
+ if ((i.prefix[REX_PREFIX] & prefix & REX_W)
+ || ((i.prefix[REX_PREFIX] & (REX_R | REX_X | REX_B))
+ && (prefix & (REX_R | REX_X | REX_B))))
ret = 0;
q = REX_PREFIX;
}
fprintf (stdout, " sib: base %x index %x scale %x\n",
x->sib.base, x->sib.index, x->sib.scale);
fprintf (stdout, " rex: 64bit %x extX %x extY %x extZ %x\n",
- (x->rex & REX_MODE64) != 0,
- (x->rex & REX_EXTX) != 0,
- (x->rex & REX_EXTY) != 0,
- (x->rex & REX_EXTZ) != 0);
+ (x->rex & REX_W) != 0,
+ (x->rex & REX_R) != 0,
+ (x->rex & REX_X) != 0,
+ (x->rex & REX_B) != 0);
for (i = 0; i < x->operands; i++)
{
fprintf (stdout, " #%d: ", i + 1);
}
if ((i.tm.opcode_modifier & Rex64) != 0)
- i.rex |= REX_MODE64;
+ i.rex |= REX_W;
/* For 8 bit registers we need an empty rex prefix. Also if the
instruction already has a prefix, we need to convert old
|| i.types [0] != (Acc | Reg64)
|| i.types [1] != (Acc | Reg64)
|| strcmp (i.tm.name, "xchg") != 0)
- i.rex |= REX_MODE64;
+ i.rex |= REX_W;
}
/* Size floating point instruction. */
}
i.tm.base_opcode |= (i.op[0].regs->reg_num << 3);
if ((i.op[0].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
}
else
{
/* Register goes in low 3 bits of opcode. */
i.tm.base_opcode |= i.op[op].regs->reg_num;
if ((i.op[op].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
if (!quiet_warnings && (i.tm.opcode_modifier & Ugh) != 0)
{
/* Warn about some common errors, but press on regardless.
i.rm.reg = i.op[dest].regs->reg_num;
i.rm.regmem = i.op[source].regs->reg_num;
if ((i.op[dest].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTX;
+ i.rex |= REX_R;
if ((i.op[source].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
}
else
{
i.rm.reg = i.op[source].regs->reg_num;
i.rm.regmem = i.op[dest].regs->reg_num;
if ((i.op[dest].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
if ((i.op[source].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTX;
+ i.rex |= REX_R;
}
- if (flag_code != CODE_64BIT && (i.rex & (REX_EXTX | REX_EXTZ)))
+ if (flag_code != CODE_64BIT && (i.rex & (REX_R | REX_B)))
{
if (!((i.types[0] | i.types[1]) & Control))
abort ();
- i.rex &= ~(REX_EXTX | REX_EXTZ);
+ i.rex &= ~(REX_R | REX_B);
add_prefix (LOCK_PREFIX_OPCODE);
}
}
else
i.types[op] |= Disp32S;
if ((i.index_reg->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTY;
+ i.rex |= REX_X;
}
}
/* RIP addressing for 64bit mode. */
i.rm.regmem = i.base_reg->reg_num;
if ((i.base_reg->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
i.sib.base = i.base_reg->reg_num;
/* x86-64 ignores REX prefix bit here to avoid decoder
complications. */
i.sib.index = i.index_reg->reg_num;
i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING;
if ((i.index_reg->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTY;
+ i.rex |= REX_X;
}
if (i.disp_operands
{
i.rm.regmem = i.op[op].regs->reg_num;
if ((i.op[op].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTZ;
+ i.rex |= REX_B;
}
else
{
i.rm.reg = i.op[op].regs->reg_num;
if ((i.op[op].regs->reg_flags & RegRex) != 0)
- i.rex |= REX_EXTX;
+ i.rex |= REX_R;
}
/* Now, if no memory operand has set i.rm.mode = 0, 1, 2 we
+2003-03-21 H.J. Lu <hongjiu.lu@intel.com>
+
+ * i386.h (REX_MODE64): Renamed to ...
+ (REX_W): This.
+ (REX_EXTX): Renamed to ...
+ (REX_R): This.
+ (REX_EXTY): Renamed to ...
+ (REX_X): This.
+ (REX_EXTZ): Renamed to ...
+ (REX_B): This.
+
2007-03-15 H.J. Lu <hongjiu.lu@intel.com>
* i386.h: Add entries from config/tc-i386.h and move tables
#define REX_OPCODE 0x40
/* Indicates 64 bit operand size. */
-#define REX_MODE64 8
+#define REX_W 8
/* High extension to reg field of modrm byte. */
-#define REX_EXTX 4
+#define REX_R 4
/* High extension to SIB index field. */
-#define REX_EXTY 2
+#define REX_X 2
/* High extension to base field of modrm or SIB, or reg field of opcode. */
-#define REX_EXTZ 1
+#define REX_B 1
/* max operands per insn */
#define MAX_OPERANDS 4
2003-03-21 H.J. Lu <hongjiu.lu@intel.com>
+ * i386-dis.c (REX_MODE64): Remove definition.
+ (REX_EXTX): Likewise.
+ (REX_EXTY): Likewise.
+ (REX_EXTZ): Likewise.
+ (USED_REX): Use REX_OPCODE instead of 0x40.
+ Replace REX_MODE64, REX_EXTX, REX_EXTY and REX_EXTZ with REX_W,
+ REX_R, REX_X and REX_B respectively.
+
+2003-03-21 H.J. Lu <hongjiu.lu@intel.com>
+
PR binutils/4218
* i386-dis.c (PREGRP38): New.
(dis386): Use PREGRP38 for 0x90.
static int rex;
/* Bits of REX we've already used. */
static int rex_used;
-#define REX_MODE64 8
-#define REX_EXTX 4
-#define REX_EXTY 2
-#define REX_EXTZ 1
/* Mark parts used in the REX prefix. When we are testing for
empty prefix (for 8bit register REX extension), just mask it
out. Otherwise test for REX bit is excuse for existence of REX
#define USED_REX(value) \
{ \
if (value) \
- rex_used |= (rex & value) ? (value) | 0x40 : 0; \
+ { \
+ if ((rex & value)) \
+ rex_used |= (value) | REX_OPCODE; \
+ } \
else \
- rex_used |= 0x40; \
+ rex_used |= REX_OPCODE; \
}
/* Flags for prefixes which we somehow handled when printing the
case 'D':
if (intel_syntax || !(sizeflag & SUFFIX_ALWAYS))
break;
- USED_REX (REX_MODE64);
+ USED_REX (REX_W);
if (mod == 3)
{
- if (rex & REX_MODE64)
+ if (rex & REX_W)
*obufp++ = 'q';
else if (sizeflag & DFLAG)
*obufp++ = intel_syntax ? 'd' : 'l';
case 'G':
if (intel_syntax || (obufp[-1] != 's' && !(sizeflag & SUFFIX_ALWAYS)))
break;
- if ((rex & REX_MODE64) || (sizeflag & DFLAG))
+ if ((rex & REX_W) || (sizeflag & DFLAG))
*obufp++ = 'l';
else
*obufp++ = 'w';
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case 'H':
used_prefixes |= PREFIX_FWAIT;
break;
case 'O':
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
*obufp++ = 'o';
else if (intel_syntax && (sizeflag & DFLAG))
*obufp++ = 'q';
else
*obufp++ = 'd';
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case 'T':
if (intel_syntax)
break;
if ((prefixes & PREFIX_DATA)
- || (rex & REX_MODE64)
+ || (rex & REX_W)
|| (sizeflag & SUFFIX_ALWAYS))
{
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
*obufp++ = 'q';
else
{
case 'Q':
if (intel_syntax && !alt)
break;
- USED_REX (REX_MODE64);
+ USED_REX (REX_W);
if (mod != 3 || (sizeflag & SUFFIX_ALWAYS))
{
- if (rex & REX_MODE64)
+ if (rex & REX_W)
*obufp++ = 'q';
else
{
}
break;
case 'R':
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
*obufp++ = 'q';
else if (sizeflag & DFLAG)
{
else
*obufp++ = 'w';
if (intel_syntax && !p[1]
- && ((rex & REX_MODE64) || (sizeflag & DFLAG)))
+ && ((rex & REX_W) || (sizeflag & DFLAG)))
*obufp++ = 'e';
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case 'V':
break;
if (sizeflag & SUFFIX_ALWAYS)
{
- if (rex & REX_MODE64)
+ if (rex & REX_W)
*obufp++ = 'q';
else
{
case 'Y':
if (intel_syntax)
break;
- if (rex & REX_MODE64)
+ if (rex & REX_W)
{
- USED_REX (REX_MODE64);
+ USED_REX (REX_W);
*obufp++ = 'q';
}
break;
/* implicit operand size 'l' for i386 or 'q' for x86-64 */
case 'W':
/* operand size flag for cwtl, cbtw */
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
{
if (intel_syntax)
*obufp++ = 'd';
*obufp++ = 'w';
else
*obufp++ = 'b';
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
}
/* FALLTHRU */
case v_mode:
case dq_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
oappend ("QWORD PTR ");
else if ((sizeflag & DFLAG) || bytemode == dq_mode)
oappend ("DWORD PTR ");
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case z_mode:
- if ((rex & REX_MODE64) || (sizeflag & DFLAG))
+ if ((rex & REX_W) || (sizeflag & DFLAG))
*obufp++ = 'D';
oappend ("WORD PTR ");
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case d_mode:
bfd_vma disp;
int add = 0;
int riprel = 0;
- USED_REX (REX_EXTZ);
- if (rex & REX_EXTZ)
+ USED_REX (REX_B);
+ if (rex & REX_B)
add += 8;
/* Skip mod/rm byte. */
case v_mode:
case dq_mode:
case dqw_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
oappend (names64[rm + add]);
else if ((sizeflag & DFLAG) || bytemode != v_mode)
oappend (names32[rm + add]);
/* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
scale = (*codep >> 6) & 3;
base = *codep & 7;
- USED_REX (REX_EXTY);
- if (rex & REX_EXTY)
+ USED_REX (REX_X);
+ if (rex & REX_X)
index += 8;
codep++;
}
OP_G (int bytemode, int sizeflag)
{
int add = 0;
- USED_REX (REX_EXTX);
- if (rex & REX_EXTX)
+ USED_REX (REX_R);
+ if (rex & REX_R)
add += 8;
switch (bytemode)
{
case v_mode:
case dq_mode:
case dqw_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
oappend (names64[reg + add]);
else if ((sizeflag & DFLAG) || bytemode != v_mode)
oappend (names32[reg + add]);
{
const char *s;
int add = 0;
- USED_REX (REX_EXTZ);
- if (rex & REX_EXTZ)
+ USED_REX (REX_B);
+ if (rex & REX_B)
add = 8;
switch (code)
/* Fall through. */
case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
s = names64[code - eAX_reg + add];
else if (sizeflag & DFLAG)
s = names32[code - eAX_reg + add];
break;
case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
s = names64[code - eAX_reg];
else if (sizeflag & DFLAG)
s = names32[code - eAX_reg];
used_prefixes |= (prefixes & PREFIX_DATA);
break;
case z_mode_ax_reg:
- if ((rex & REX_MODE64) || (sizeflag & DFLAG))
+ if ((rex & REX_W) || (sizeflag & DFLAG))
s = *names32;
else
s = *names16;
- if (!(rex & REX_MODE64))
+ if (!(rex & REX_W))
used_prefixes |= (prefixes & PREFIX_DATA);
break;
default:
}
/* Fall through. */
case v_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
op = get32s ();
else if (sizeflag & DFLAG)
{
mask = 0xff;
break;
case v_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
op = get64 ();
else if (sizeflag & DFLAG)
{
mask = 0xffffffff;
break;
case v_mode:
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
op = get32s ();
else if (sizeflag & DFLAG)
{
disp -= 0x100;
break;
case v_mode:
- if ((sizeflag & DFLAG) || (rex & REX_MODE64))
+ if ((sizeflag & DFLAG) || (rex & REX_W))
disp = get32s ();
else
{
OP_C (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
{
int add = 0;
- if (rex & REX_EXTX)
+ if (rex & REX_R)
{
- USED_REX (REX_EXTX);
+ USED_REX (REX_R);
add = 8;
}
else if (address_mode != mode_64bit && (prefixes & PREFIX_LOCK))
OP_D (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
{
int add = 0;
- USED_REX (REX_EXTX);
- if (rex & REX_EXTX)
+ USED_REX (REX_R);
+ if (rex & REX_R)
add = 8;
if (intel_syntax)
sprintf (scratchbuf, "db%d", reg + add);
if (prefixes & PREFIX_DATA)
{
int add = 0;
- USED_REX (REX_EXTX);
- if (rex & REX_EXTX)
+ USED_REX (REX_R);
+ if (rex & REX_R)
add = 8;
sprintf (scratchbuf, "%%xmm%d", reg + add);
}
OP_XMM (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
{
int add = 0;
- USED_REX (REX_EXTX);
- if (rex & REX_EXTX)
+ USED_REX (REX_R);
+ if (rex & REX_R)
add = 8;
sprintf (scratchbuf, "%%xmm%d", reg + add);
oappend (scratchbuf + intel_syntax);
{
int add = 0;
- USED_REX (REX_EXTZ);
- if (rex & REX_EXTZ)
+ USED_REX (REX_B);
+ if (rex & REX_B)
add = 8;
sprintf (scratchbuf, "%%xmm%d", rm + add);
}
OP_E (bytemode, sizeflag);
return;
}
- USED_REX (REX_EXTZ);
- if (rex & REX_EXTZ)
+ USED_REX (REX_B);
+ if (rex & REX_B)
add = 8;
/* Skip mod/rm byte. */
static void
CMPXCHG8B_Fixup (int bytemode, int sizeflag)
{
- USED_REX (REX_MODE64);
- if (rex & REX_MODE64)
+ USED_REX (REX_W);
+ if (rex & REX_W)
{
/* Change cmpxchg8b to cmpxchg16b. */
char *p = obuf + strlen (obuf) - 2;