diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-03-01 09:20:56 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-03-01 09:20:56 +0100 |
commit | 6804f42c67d97401c7ef8438727eba788fc29329 (patch) | |
tree | 804af6a60cfd4ec5d6fa26dace917328c0a40fdb /gas/config | |
parent | eb3f3841da4ea29dec13c84c241c17a7623d15ca (diff) | |
download | binutils-6804f42c67d97401c7ef8438727eba788fc29329.zip binutils-6804f42c67d97401c7ef8438727eba788fc29329.tar.gz binutils-6804f42c67d97401c7ef8438727eba788fc29329.tar.bz2 |
x86/APX: correct .insn opcode space determination when REX2 is needed
In this case spaces 0f38 and 0f3a may not be put in place. To achieve
the intended effect, operand parsing (but not operand processing) needs
pulling ahead, so we know whether eGRP-s are in use.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-i386.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 9da95c3..d169274 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -12922,13 +12922,43 @@ s_insn (int dummy ATTRIBUTE_UNUSED) } } + /* Parse operands, if any, before evaluating encoding space. */ + if (*line == ',') + { + i.memshift = -1; + + ptr = parse_operands (line + 1, &i386_mnemonics[MN__insn]); + this_operand = -1; + if (!ptr) + goto bad; + line = ptr; + + if (!i.operands) + { + as_bad (_("expecting operand after ','; got nothing")); + goto done; + } + + if (i.mem_operands > 1) + { + as_bad (_("too many memory references for `%s'"), + &i386_mnemonics[MN__insn]); + goto done; + } + + /* No need to distinguish encoding_evex and encoding_evex512. */ + if (i.encoding == encoding_evex512) + i.encoding = encoding_evex; + } + /* Trim off encoding space. */ if (j > 1 && !i.insn_opcode_space && (val >> ((j - 1) * 8)) == 0x0f) { uint8_t byte = val >> ((--j - 1) * 8); i.insn_opcode_space = SPACE_0F; - switch (byte & -(j > 1)) + switch (byte & -(j > 1 && !i.rex2_encoding + && (i.encoding != encoding_egpr || evex))) { case 0x38: i.insn_opcode_space = SPACE_0F38; @@ -12951,42 +12981,17 @@ s_insn (int dummy ATTRIBUTE_UNUSED) if (j > 2) { as_bad (_("opcode residual (%#"PRIx64") too wide"), (uint64_t) val); - goto bad; + goto done; } i.opcode_length = j; /* Handle operands, if any. */ - if (*line == ',') + if (i.operands) { i386_operand_type combined; expressionS *disp_exp = NULL; bool changed; - i.memshift = -1; - - ptr = parse_operands (line + 1, &i386_mnemonics[MN__insn]); - this_operand = -1; - if (!ptr) - goto bad; - line = ptr; - - if (!i.operands) - { - as_bad (_("expecting operand after ','; got nothing")); - goto done; - } - - if (i.mem_operands > 1) - { - as_bad (_("too many memory references for `%s'"), - &i386_mnemonics[MN__insn]); - goto done; - } - - /* No need to distinguish encoding_evex and encoding_evex512. */ - if (i.encoding == encoding_evex512) - i.encoding = encoding_evex; - if (i.encoding == encoding_egpr) { if (vex || xop) |