[PATCH v2 3/4] x86: adjust segment override prefix emission

Jan Beulich jbeulich@suse.com
Fri Feb 14 12:17:00 GMT 2020
On 14.02.2020 13:08, H.J. Lu wrote:
> On Fri, Feb 14, 2020 at 3:44 AM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> Since we already suppress the prefix altogether when it's the default
>> one for the chosen addressing mode, let's do so also when instruction
>> prefix and override specified with the memory operand match. (Note that
>> insn prefix specified segment overrides never get discarded.)
>>
>> gas/
>> 2020-02-XX  Jan Beulich  <jbeulich@suse.com>
>>
>>         * config/tc-i386.c (process_operands): Also skip segment
>>         override prefix emission if it matches an already present one.
>>         * testsuite/gas/i386/prefix32.s: Add double segment override
>>         cases.
>>         * testsuite/gas/i386/prefix32.l: Adjust expectations.
>>
>> --- a/gas/config/tc-i386.c
>> +++ b/gas/config/tc-i386.c
>> @@ -7208,11 +7208,12 @@ duplicate:
>>      }
>>
>>    /* If a segment was explicitly specified, and the specified segment
>> -     is not the default, use an opcode prefix to select it.  If we
>> -     never figured out what the default segment is, then default_seg
>> -     will be zero at this point, and the specified segment prefix will
>> -     always be used.  */
>> -  if ((i.seg[0]) && (i.seg[0] != default_seg))
>> +     is neither the default nor the one already recorded from a prefix,
>> +     use an opcode prefix to select it.  If we never figured out what
>> +     the default segment is, then default_seg will be zero at this
>> +     point, and the specified segment prefix will always be used.  */
>> +  if ((i.seg[0]) && (i.seg[0] != default_seg)
>> +      && (i.seg[0]->seg_prefix != i.prefix[SEG_PREFIX]))
> 
> Since you are changing the code, please write
> 
> if (i.seg[0]
>    && i.seg[0] != default_seg
>    && i.seg[0]->seg_prefix != i.prefix[SEG_PREFIX])

Sure, will do. I simply wasn't sure whether such secondary cleanup would
be welcome.

> OK with this change.

Thanks.

Jan



More information about the Binutils mailing list