public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/66960] Add interrupt/exception attribute to x86 backend
Date: Tue, 29 Sep 2015 22:17:00 -0000	[thread overview]
Message-ID: <bug-66960-4-Hzag0YgIjY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66960-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
From

https://gcc.gnu.org/ml/gcc-patches/2015-09/msg02246.html

To be feature complete, it would be nice to have two styles of interrupt
functions, one that returns with iret, and one that returns with ret.
The point is that the user might want to call functions from a interrupt
handler and not save and restore all call clobbered registers.  By
allowing a ret style interrupt handler, calls to a ret style interrupt
routine can avoid saving and restoring all call clobbered registers.

[hjl@gnu-6 interrupt-7]$ cat call-1.i
extern void bar (void);

void
 __attribute__ ((interrupt))
fn1 (void *frame)
{
  bar ();
}

void
 __attribute__ ((interrupt))
fn2 (void *frame)
{
  bar ();
}
[hjl@gnu-6 interrupt-7]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -Wall -Wunused-parameter
-mno-push-args -mno-sse -m32 -S -o call-1.s call-1.i
[hjl@gnu-6 interrupt-7]$ cat call-1.s
        .file   "call-1.i"
        .text
        .p2align 4,,15
        .globl  fn1
        .type   fn1, @function
fn1:
.LFB3:
        .cfi_startproc
        pushl   %ecx
        .cfi_def_cfa_offset 8
        .cfi_offset 1, -8
        pushl   %edx
        .cfi_def_cfa_offset 12
        .cfi_offset 2, -12
        pushl   %eax
        .cfi_def_cfa_offset 16
        .cfi_offset 0, -16
        call    bar
        popl    %eax
        .cfi_restore 0
        .cfi_def_cfa_offset 12
        popl    %edx
        .cfi_restore 2
        .cfi_def_cfa_offset 8
        popl    %ecx
        .cfi_restore 1
        .cfi_def_cfa_offset 4
        iret
        .cfi_endproc
.LFE3:
        .size   fn1, .-fn1
        .p2align 4,,15
        .globl  fn2
        .type   fn2, @function
fn2:
.LFB1:
        .cfi_startproc
        pushl   %ecx
        .cfi_def_cfa_offset 8
        .cfi_offset 1, -8
        pushl   %edx
        .cfi_def_cfa_offset 12
        .cfi_offset 2, -12
        pushl   %eax
        .cfi_def_cfa_offset 16
        .cfi_offset 0, -16
        call    bar
        popl    %eax
        .cfi_restore 0
        .cfi_def_cfa_offset 12
        popl    %edx
        .cfi_restore 2
        .cfi_def_cfa_offset 8
        popl    %ecx
        .cfi_restore 1
        .cfi_def_cfa_offset 4
        iret
        .cfi_endproc
.LFE1:
        .size   fn2, .-fn2
        .ident  "GCC: (GNU) 6.0.0 20150929 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-6 interrupt-7]$  

Both fn1 and fn2 have to save and restore caller-saved registers.
If all registers in bar are callee-saved, fn1 and fn2 can be
much smaller.


  parent reply	other threads:[~2015-09-29 22:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21 17:07 [Bug middle-end/66960] New: Add a builtin to get the address of the current stack frame hjl.tools at gmail dot com
2015-07-21 21:46 ` [Bug target/66960] " hjl.tools at gmail dot com
2015-09-04 15:48 ` [Bug target/66960] Need a builtin function to access interrupt or exception data hjl.tools at gmail dot com
2015-09-29 22:17 ` hjl.tools at gmail dot com [this message]
2016-07-04 10:39 ` [Bug target/66960] Add interrupt attribute to x86 backend goswin-v-b at web dot de
2021-08-10 21:37 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66960-4-Hzag0YgIjY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).