From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11516 invoked by alias); 29 Sep 2015 22:17:28 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 11481 invoked by uid 48); 29 Sep 2015 22:17:23 -0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 6.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg02333.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960 --- Comment #3 from H.J. Lu --- 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.