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: [PATCH] i386: Add some naked attribute tests


On Tue, Aug 1, 2017 at 11:23 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Aug 1, 2017 at 2:11 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> On Tue, Aug 1, 2017 at 11:05 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Tue, Aug 1, 2017 at 1:49 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>>> On Tue, Aug 1, 2017 at 9:46 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>>>> Add some tests for implementing interrupt handlers with naked attribute.
>>>>>
>>>>> OK for trunk?
>>>>>
>>>>> H.J.
>>>>> ---
>>>>>         * gcc.dg/guality/pr25967-1.c: New test.
>>>>>         * gcc.dg/guality/pr25967-2.c: Likewise.
>>>>>         * gcc.dg/torture/pr25967-1.c: Likewise.
>>>>>         * gcc.dg/torture/pr25967-2.c: Likewise.
>>>>
>>>> OK with a small change below.
>>>>
>>>
>>>>> +void
>>>>> +fn (void)
>>>>> +{
>>>>> +  struct interrupt_frame *frame;
>>>>> +  uword_t error;
>>>>> +  asm ("lea " WORD_SIZE "(%%" STACK_POINTER "), %0" : "=r" (frame) : );
>>>>> +  asm ("mov (%%" STACK_POINTER "), %0" : "=r" (error) : );
>>>>
>>>> The above two asm needs to be volatile. They are not "simple" asm, and
>>>> access stack pointer behind the compilers back. And please merge them
>>>> to one multi-line volatile asm statement.
>>>>
>>>
>>>
>>> This is what I am checking in.
>>
>> OTOH, these asms can be avoided with something like:
>>
>> --cut here--
>> typedef unsigned int uword_t __attribute__ ((mode (__word__)));
>>
>> struct interrupt_frame
>> {
>>   uword_t ip;
>>   uword_t cs;
>>   uword_t flags;
>>   uword_t sp;
>>   uword_t ss;
>> };
>>
>> void
>> __attribute__((naked))
>> test (void)
>> {
>>   register uword_t sp __asm__("sp");
>>
>>   long *error = (long *) sp;
>>   struct interrupt_frame *frame
>>     = (struct interrupt_frame *) (sp + sizeof (uword_t));
>>
>>   ...
>>
>
> How about this?  OK for trunk?

Even better.

Can we introduce asm_goto to the jmp in the main asm?

Uros.


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