This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [cfe-dev] RFC: Support x86 interrupt and exception handlers
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: David Chisnall <David dot Chisnall at cl dot cam dot ac dot uk>
- Cc: John Criswell <jtcriswel at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, cfe-dev at lists dot llvm dot org
- Date: Tue, 22 Sep 2015 04:47:22 -0700
- Subject: Re: [cfe-dev] RFC: Support x86 interrupt and exception handlers
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOpKPxK-79pBO-MyiMzGqd=9gxDxJdRnDvdq4UumUTakHQ at mail dot gmail dot com> <CAMe9rOp8hma_3b49oMjWeixLPTeiQFX2MUxSbftMNmfjP4A0-Q at mail dot gmail dot com> <CAMe9rOpOC43+AOBsp8CMdzhCMQrGqzjpj+zTzaZ=SDKmd4GB1w at mail dot gmail dot com> <CAMe9rOpRRuBxHXzEKhSOO67VPkUQnx=gVuMAxq0snyTFxF+gaA at mail dot gmail dot com> <560051EF dot 70405 at gmail dot com> <CAMe9rOpLcvZOLrE+4v-M+CbWs5hw0j4EpfNGuE+myoaFdhpf5Q at mail dot gmail dot com> <9038C99C-408A-4E41-AA9A-6481227BFACB at cl dot cam dot ac dot uk>
On Tue, Sep 22, 2015 at 1:41 AM, David Chisnall
<David.Chisnall@cl.cam.ac.uk> wrote:
> On 21 Sep 2015, at 21:45, H.J. Lu via cfe-dev <cfe-dev@lists.llvm.org> wrote:
>>
>> The main purpose of x86 interrupt attribute is to allow programmers
>> to write x86 interrupt/exception handlers in C WITHOUT assembly
>> stubs to avoid extra branch from assembly stubs to C functions. I
>> want to keep the number of new intrinsics to minimum without sacrificing
>> handler performance. I leave faking error code in interrupt handler to
>> the programmer.
>
> The assembly stubs have to come from somewhere. You either put them in an assembly file (most people doing embedded x86 stuff steal the ones from NetBSD), or you put them in the compiler where they can be inlined. In terms of user interface, thereâs not much difference in complexity. Having written this kind of code in the past, I can honestly say that using the assembly stubs was the least difficult part of getting them right. In terms of compiler complexity, thereâs a big difference: in one case the compiler contains nothing, in the other it contains something special for a single use case. In terms of performance, the compiler version has the potential to be faster, but if weâre going to pay for the complexity then I think that weâd need to see some strong evidence that someone else is getting a noticeable benefit.
I understand your concern. IA MCU users want to write interrupt/exception
handlers in C, just like many embedded processors. The goals are to
save code space and improve performance. Using builtin functions,
instead of adding a new way to pass parameters, makes compiler
change much simpler, since __builtin_exception_error () is the same as
__builtin_return_address (0) and __builtin_interrupt_data () is
address of __builtin_exception_error () + size of register.
--
H.J.