[PATCH v2] x86: Add {imm8}/{imm16}/{imm32} pseudo prefixes
Jan Beulich
jbeulich@suse.com
Tue Mar 25 16:20:44 GMT 2025
On 25.03.2025 17:07, H.J. Lu wrote:
> On Tue, Mar 25, 2025, 12:37 AM Jan Beulich <jbeulich@suse.com> wrote:
>
>> On 24.03.2025 19:41, H.J. Lu wrote:
>>> On Mon, Mar 24, 2025 at 9:27 AM Jan Beulich <jbeulich@suse.com> wrote:
>>>>
>>>> On 24.03.2025 17:24, H.J. Lu wrote:
>>>>> Instruction templates with only sign-extended 8-bit immediate operand
>>>>> also have a second template with full-operand-size immediate operand
>>>>> under a different opcode. Add {imm8}, {imm16} and {imm32} pseudo
>>>>> prefixes as a hint to control immediate size. Don't match the first
>>>>> template if {imm16} or {imm32} are used.
>>>>>
>>>>> gas/
>>>>>
>>>>> PR gas/32811
>>>>> * config/tc-i386.c (pseudo_prefixes): Add avoid_imm8s.
>>>>> (operand_size_match): Return false for templates with only sign-
>>>>> extended 8-bit immediate operand if {imm16} or {imm32} are used.
>>>>> (parse_insn): Handle Prefix_Imm8, Prefix_Imm16 and Prefix_Imm32.
>>>>> * doc/c-i386.texi: Document {imm8}, {imm16} and {imm32}.
>>>>> * testsuite/gas/i386/pseudos.s: Add tests for {imm8}, {imm16}
>>>>> and {imm32}.
>>>>> * testsuite/gas/i386/x86-64-pseudos.s: Likewise.
>>>>> * testsuite/gas/i386/pseudos.d: Updated.
>>>>> * testsuite/gas/i386/x86-64-pseudos.d: Likewise.
>>>>>
>>>>> opcodes/
>>>>>
>>>>> PR gas/32811
>>>>> * opcodes/i386-opc.h (Prefix_Imm8): New.
>>>>> (Prefix_Imm16): Likewise.
>>>>> (Prefix_Imm32): Likewise.
>>>>> * i386-opc.tbl: Add {imm8}, {imm16} and {imm32} pseudo prefixes.
>>>>> * i386-mnem.h: Regenerated.
>>>>> * i386-tbl.h: Likewise.
>>>>>
>>>>> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
>>>>
>>>> What's the difference to v1? Importantly {imm16} and {imm32} are still
>> there,
>>>
>>> full-operand-size and avoid_imm8s.
>>>
>>>> when imo they should be suitably folded.
>>>>
>>>
>>> {imm16} and {imm32} are the same internally. But for users,
>>>
>>> {imm16} add $0,%bx
>>> {imm8} add $0,%bx
>>>
>>> are quite clearer than other alternatives.
>>
>> And
>>
>> {imm16} add $0,%ebx
>>
>> is, I'm sorry to say so, rubbish. Which however we happily accept to mean
>>
>> {imm32} add $0,%ebx
>>
>> Thinking about it, unlike {disp8} - what exact purpose does {imm8} serve?
>> We encode with the smallest possible immediate anyway. {disp8} is useful
>> to request a displacement when none would be needed, yet the same situation
>> doesn't arise for immediates afaict. Hence the sole use looks to be to
>> "override" an earlier {imm16} or {imm32}. I'm not entirely certain that's
>> worth it.
>
> How about {noimm8s}?
I guess I wouldn't strongly object if you meant to use it, but to me that's
yet more clumsy than the {immw} I suggested.
Jan
More information about the Binutils
mailing list