This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA PATCH, i386]: Warn for 64-bit values in general-reg asm operands and error out for 8-bit values in invalid GR asm operand


On Wed, Mar 1, 2017 at 11:41 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Wed, Mar 1, 2017 at 10:00 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> On Wed, Mar 1, 2017 at 9:48 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>> On Wed, Mar 01, 2017 at 09:34:53AM +0100, Uros Bizjak wrote:
>>>> Some more thoughts on 64-bit reg on 32-bit targets warning.
>>>>
>>>> Actually, we never *print* register name for instruction that use "A"
>>>> constraint, since %eax/%edx is always implicit  The warning does not
>>>> deal with constraints, so unless we want to output DImode register
>>>> name, there is no warning.
>>>
>>> Ah, indeed, we don't have a modifier that would print the high register
>>> of a register pair (i.e. essentially print REGNO (x) + 1 instead of REGNO
>>> (x)), guess that might be useful not just for 64-bit GPR operands in 32-bit
>>> code, but also 128-bit GPR operands in 64-bit code.
>>
>> The issue here is that (modulo ax/dx with "A" constraint) we don't
>> guarantee double-register sequence order, so any change in register
>> allocation order would break any assumptions. For implicit ax/dx, user
>> should explicitly use register name (e.g. DImode operand in "rdtscp;
>> mov %0, mem" asm should be corrected to use %%eax instead of %0).
>>
>> And, yes - we should add similar warning for 128-bit GPRs. The only
>> way to use register pair with  width > machine_mode is with implicit
>> operands or with explicit regnames.
>
> Something like the following patch I'm testing:

Attached is the patch I have committed to mainline SVN after a full
bootstrap and regression test.

2017-03-01  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c (print_reg): Warn for values of
    unsupported size in integer register.

testsuite/ChangeLog:

2017-03-01  Uros Bizjak  <ubizjak@gmail.com>

    * gcc.target/i386/invsize-2.c: New test.
    * gcc.target/i386/invsize-3.c: Ditto.
    * gcc.target/i386/invsize-4.c: Ditto.
    * gcc.target/i386/pr66274.c: Expect "unsuported size" warning.
    * gcc.target/i386/stackalign/asm-1.c: Ditto.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline.

Uros.

Attachment: p.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]