aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-02-22 06:18:27 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-02-22 06:18:39 -0800
commit6b6b680700699c15e22b6c36975729035676eef1 (patch)
tree436eba8cc606c8539c1185c14d74efb96b43a841 /gas/config
parent39334a61e63321352304cbae77b37fcba4fed662 (diff)
downloadgdb-6b6b680700699c15e22b6c36975729035676eef1.zip
gdb-6b6b680700699c15e22b6c36975729035676eef1.tar.gz
gdb-6b6b680700699c15e22b6c36975729035676eef1.tar.bz2
x86: Add {rex} pseudo prefix
Add {rex} pseudo prefix to generate a REX byte for integer and legacy vector instructions if possible. Note that this differs from the rex prefix which generates REX prefix unconditionally. gas/ * config/tc-i386.c (_i386_insn): Add rex_encoding. (md_assemble): When i.rex_encoding is true, generate a REX byte if possible. (parse_insn): Set i.rex_encoding for {rex}. * doc/c-i386.texi: Document {rex}. * testsuite/gas/i386/x86-64-pseudos.s: Add {rex} tests. * testsuite/gas/i386/x86-64-pseudos.d: Updated. opcodes/ * i386-opc.tbl: Add {rex}, * i386-tbl.h: Regenerated.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-i386.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index c67ea1f..dff42bd 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -369,6 +369,9 @@ struct _i386_insn
disp_encoding_32bit
} disp_encoding;
+ /* Prefer the REX byte in encoding. */
+ bfd_boolean rex_encoding;
+
/* How to encode vector instructions. */
enum
{
@@ -3992,6 +3995,26 @@ md_assemble (char *line)
}
}
+ if (i.rex == 0 && i.rex_encoding)
+ {
+ /* Check if we can add a REX_OPCODE byte. Look for 8 bit operand
+ that uses legacy register. If it is "hi" register, don't add
+ the REX_OPCODE byte. */
+ int x;
+ for (x = 0; x < 2; x++)
+ if (i.types[x].bitfield.reg
+ && i.types[x].bitfield.byte
+ && (i.op[x].regs->reg_flags & RegRex64) == 0
+ && i.op[x].regs->reg_num > 3)
+ {
+ i.rex_encoding = FALSE;
+ break;
+ }
+
+ if (i.rex_encoding)
+ i.rex = REX_OPCODE;
+ }
+
if (i.rex != 0)
add_prefix (REX_OPCODE | i.rex);
@@ -4104,6 +4127,10 @@ parse_insn (char *line, char *mnemonic)
/* {evex} */
i.vec_encoding = vex_encoding_evex;
break;
+ case 0x7:
+ /* {rex} */
+ i.rex_encoding = TRUE;
+ break;
default:
abort ();
}