On 7/23/24 2:19 PM, Georg-Johann Lay wrote:
This patch adds support for arguments to the signal and interrupt
function attributes.  It allows to specify the ISR by means of the
associated IRQ number, in extension to the current attributes that
require to specify the ISR name like "__vector_1" as (assembly) name
for the function.  The new feature is more convenient, e.g. when the
ISR is implemented by a class method or in a namespace.  There is no
requirement that the ISR is externally visible.  The syntax is like:

__attribute__((signal(1, 2, ...), signal(3, 4, ...)))
[static] void isr_function (void)
{
     // Code
}

Ok for trunk?

Johann

--

AVR target 116056 - Support attribute signal(n) and interrupt(n).

This patch adds support for arguments to the signal and interrupt
function attributes.  It allows to specify the ISR by means of the
associated IRQ number, in extension to the current attributes that
require to specify the ISR name like "__vector_1" as (assembly) name
for the function.  The new feature is more convenient, e.g. when the
ISR is implemented by a class method or in a namespace.  There is no
requirement that the ISR is externally visible.  The syntax is like:

__attribute__((signal(1, 2, ...), signal(3, 4, ...)))
[static] void isr_function (void)
{
     // Code
}

     PR target/116056
gcc/
     * config/avr/avr.h (ASM_DECLARE_FUNCTION_NAME): New define.
     * config/avr/avr-protos.h (avr_declare_function_name): New proto.
     * config/avr/avr-c.cc (avr_cpu_cpp_builtins) <__HAVE_SIGNAL_N__>: New
     built-in macro.
     * config/avr/avr.cc (avr_declare_function_name): New function.
     (avr_attribute_table) <signal,interrupt>: Allow any number of args.
     (avr_insert_attributes): Check validity of "signal" and "interrupt"
     arguments.
     (avr_foreach_function_attribute, avr_interrupt_signal_function)
     (avr_isr_number, avr_asm_isr_alias, avr_handle_isr_attribute):
     New static functions.
     (avr_interrupt_function): New from avr_interrupt_function_p.
     Adjust callers.
     (avr_signal_function): New from avr_signal_function_p.
     Adjust callers.
     (avr_set_current_function): Only diagnose non-__vector ISR names
     when "signal" or "interrupt" attribute has no args.
     (struct avr_fun_cookie): New.
     * doc/extend.texi (AVR Function Attributes): Document
     signal(num) and interrupt(num).
     * doc/invoke.texi (AVR Built-in Macros) <__HAVE_SIGNAL_N__>: Document.
gcc/testsuite/
     * gcc.target/avr/torture/signal_n-1.c: New test.
     * gcc.target/avr/torture/signal_n-2.c: New test.
     * gcc.target/avr/torture/signal_n-3.c: New test.
     * gcc.target/avr/torture/signal_n-4.cpp: New test.
Just a couple whitespace nits.


+  avr_foreach_function_attribute (func, attr_name,
+    [] (tree, tree attr, void *cookie)
+    {
+      int*pcook = (int*) cookie;
Whitespace nit "int *pcook = (int *) cookie" would be better
+


+
+static void
+avr_asm_isr_alias (tree /*func*/, tree attr, void *pv)
+{
+  avr_fun_cookie*cookie = (avr_fun_cookie*) pv;
Similarly.



No need to wait for another review. Just fix the whitespace issues and you're good to go.

jeff




Reply via email to