[PATCH] x86: Add {imm8}/{imm16}/{imm32} pseudo prefixes

Jan Beulich jbeulich@suse.com
Mon Mar 24 09:10:32 GMT 2025


On 23.03.2025 15:44, H.J. Lu wrote:
> Instruction templates with only sign-extended 8-bit immediate operand
> also have a second template with 8-bit, 16-bit, 32-bit, 64-bit 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.

In the first sentence, why do you include "64-bit"? I'm unaware of an
insn permitting a signed-extended 8-bit immediate to also permit a 64-bit
one. (Same question on the somewhat similar code comment below.)

In how far are {imm16} and {imm32} both necessary? I'm not happy that we
have {disp16} and {disp32}, when only one of the two can possibly be used
in any one context. We just can't drop support for those. I'd prefer us
to avoid making the same mistake again. What you mean to express is
"full-operand-size immediate". I don't like {immw} very much, but I can't
think of anything better.

> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -513,6 +513,9 @@ static struct pseudo_prefixes {
>      disp_encoding_32bit
>    } disp_encoding;
>  
> +  /* Avoid sign-extended 8bit immediate in encoding.  */
> +  bool avoid_imm8s_encoding;

Any chance I could talk you into dropping "_encoding" here? The purpose
of the field is still going to be clear with the shorter name.

Jan


More information about the Binutils mailing list