diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2012-01-20 20:53:50 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2012-01-20 20:53:50 +0000 |
commit | a501d77eeba717f6d54dce44f286f9e3aad83144 (patch) | |
tree | f43d8ee355afd45a51c5198c90b73035471a3adf /gas/config/tc-i386.c | |
parent | e825046fcf0193aad44b1f3d1a8514190278b85d (diff) | |
download | gdb-a501d77eeba717f6d54dce44f286f9e3aad83144.zip gdb-a501d77eeba717f6d54dce44f286f9e3aad83144.tar.gz gdb-a501d77eeba717f6d54dce44f286f9e3aad83144.tar.bz2 |
Add .d8 suffix support to x86 assembler
gas/
2012-01-20 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (_i386_insn): Replace disp32_encoding with
disp_encoding.
(md_assemble): Updated.
(output_branch): Likewise.
(parse_insn): Support .d8 suffix.
(build_modrm_byte): Fake zero displacement for .d8 and .d32
suffixes.
* doc/c-i386.texi: Document .d8 suffix.
gas/testsuite/
2012-01-20 H.J. Lu <hongjiu.lu@intel.com>
* gas/i386/disp32.s: Add tests for .d8 suffix.
* gas/i386/x86-64-disp32.s: Likewise.
* gas/i386/disp32.d: Updated.
* gas/i386/x86-64-disp32.d: Likewise.
Diffstat (limited to 'gas/config/tc-i386.c')
-rw-r--r-- | gas/config/tc-i386.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 9e83a4d..dbac2ce 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -280,8 +280,13 @@ struct _i386_insn /* Swap operand in encoding. */ unsigned int swap_operand; - /* Force 32bit displacement in encoding. */ - unsigned int disp32_encoding; + /* Prefer 8bit or 32bit displacement in encoding. */ + enum + { + disp_encoding_default = 0, + disp_encoding_8bit, + disp_encoding_32bit + } disp_encoding; /* Error message. */ enum i386_error error; @@ -3053,7 +3058,7 @@ md_assemble (char *line) /* Don't optimize displacement for movabs since it only takes 64bit displacement. */ if (i.disp_operands - && !i.disp32_encoding + && i.disp_encoding != disp_encoding_32bit && (flag_code != CODE_64BIT || strcmp (mnemonic, "movabs") != 0)) optimize_disp (); @@ -3332,11 +3337,15 @@ parse_insn (char *line, char *mnemonic) encoding. */ if (mnem_p - 2 == dot_p && dot_p[1] == 's') i.swap_operand = 1; + else if (mnem_p - 3 == dot_p + && dot_p[1] == 'd' + && dot_p[2] == '8') + i.disp_encoding = disp_encoding_8bit; else if (mnem_p - 4 == dot_p && dot_p[1] == 'd' && dot_p[2] == '3' && dot_p[3] == '2') - i.disp32_encoding = 1; + i.disp_encoding = disp_encoding_32bit; else goto check_suffix; mnem_p = dot_p; @@ -5698,7 +5707,19 @@ build_modrm_byte (void) || i.reloc[op] == BFD_RELOC_X86_64_TLSDESC_CALL)) i.rm.mode = 0; else - i.rm.mode = mode_from_disp_size (i.types[op]); + { + if (!fake_zero_displacement + && !i.disp_operands + && i.disp_encoding) + { + fake_zero_displacement = 1; + if (i.disp_encoding == disp_encoding_8bit) + i.types[op].bitfield.disp8 = 1; + else + i.types[op].bitfield.disp32 = 1; + } + i.rm.mode = mode_from_disp_size (i.types[op]); + } } if (fake_zero_displacement) @@ -5900,7 +5921,7 @@ output_branch (void) offsetT off; code16 = flag_code == CODE_16BIT ? CODE16 : 0; - size = i.disp32_encoding ? BIG : SMALL; + size = i.disp_encoding == disp_encoding_32bit ? BIG : SMALL; prefix = 0; if (i.prefix[DATA_PREFIX] != 0) |