On Tue, Aug 1, 2017 at 11:23 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Tue, Aug 1, 2017 at 2:11 PM, Uros Bizjak <ubiz...@gmail.com> wrote: >> On Tue, Aug 1, 2017 at 11:05 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >>> On Tue, Aug 1, 2017 at 1:49 PM, Uros Bizjak <ubiz...@gmail.com> wrote: >>>> On Tue, Aug 1, 2017 at 9:46 PM, H.J. Lu <hongjiu...@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.