[PATCH] x86: adjust immediate instruction operands handling
Jan Beulich
JBeulich@novell.com
Mon Jul 18 14:08:00 GMT 2005
Until now, it was possible to use, for example (Intel Syntax),
shl <byte-reg>, <imm8>
where <imm8> was either a forward reference or even an external
absolute.
However, it wasn't possible to do the same with 16-, 32-, or 64-bit
registers, because the immediate's size and the register and/or suffix
didn't match in size. This patch makes this consistent so that all
forms
get accepted.
Built and tested on i386-pc-linux-gnu and x86_64-unknown-linux-gnu.
Jan
gas/
2005-07-18 Jan Beulich <jbeulich@novell.com>
* config/tc-i386.c (optimize_imm): Calculate candidate
immediates
mask from guessed suffix, but mask out other immediate types
only
if at least on candidate is valid for the insn.
---
/home/jbeulich/src/binutils/mainline/2005-07-18/gas/config/tc-i386.c 2005-07-18
08:26:50.000000000 +0200
+++ 2005-07-18/gas/config/tc-i386.c 2005-07-18 14:54:46.812157928
+0200
@@ -2083,22 +2083,36 @@ optimize_imm ()
/* Symbols and expressions. */
default:
- /* Convert symbolic operand to proper sizes for matching.
*/
- switch (guess_suffix)
- {
- case QWORD_MNEM_SUFFIX:
- i.types[op] &= Imm64 | Imm32S;
- break;
- case LONG_MNEM_SUFFIX:
- i.types[op] &= Imm32;
- break;
- case WORD_MNEM_SUFFIX:
- i.types[op] &= Imm16;
- break;
- case BYTE_MNEM_SUFFIX:
- i.types[op] &= Imm8 | Imm8S;
- break;
- }
+ /* Convert symbolic operand to proper sizes for matching,
but don't
+ prevent matching a set of insns that only supports sizes
other
+ than those matching the insn suffix. */
+ {
+ unsigned int mask, allowed = 0;
+ const template *t;
+
+ for (t = current_templates->start; t <
current_templates->end; ++t)
+ allowed |= t->operand_types[op];
+ switch (guess_suffix)
+ {
+ case QWORD_MNEM_SUFFIX:
+ mask = Imm64 | Imm32S;
+ break;
+ case LONG_MNEM_SUFFIX:
+ mask = Imm32;
+ break;
+ case WORD_MNEM_SUFFIX:
+ mask = Imm16;
+ break;
+ case BYTE_MNEM_SUFFIX:
+ mask = Imm8;
+ break;
+ default:
+ mask = 0;
+ break;
+ }
+ if (mask & allowed)
+ i.types[op] &= mask;
+ }
break;
}
}
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: binutils-mainline-x86-immediates.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20050718/290408a1/attachment.ksh>
More information about the Binutils
mailing list