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

--- Comment #15 from Christophe Lyon <clyon at gcc dot gnu.org> ---

> Well obviously that won't work.  But if you build the interrupt routine with
> a d16 system and then call a function from it that requires d32 then that
> should still work if running on a d32 CPU.

Thanks, I hadnt' thought of this combination.

> 
> I think we can probably make that work, but it's probably a bit of a dance
> to get it all right.  Hence the suggestion that this be done in a library
> function.

I suspect I'll have to iterate a few times to get that function right: I
haven't yet checked the interactions with the secure/non-secure modes,
LSPEN/ASPEN (I've noticed CMSE code in GCC that takes care of FP registers).

So what about adding a simple warning along the lines of comment #5 and comment
#6, like the one I posted (comment #8, but maybe it should also make sure to
call __aeabi_memcpy instead of memcpy?)

Then a second step would allow not to use -mgeneral-regs-only and save whatever
is needed. I am wondering whether we could introduce other attributes such as:
- "irq-nosave-fp-regs" basically saying the user does not want to save FP
registers; this would clear the warning
- "irq-save-fp-regs", asking the compiler to save all the needed regs despite
the penalty; this would also avoid the warning

At least that would make users think about their code, but we'd needed to
document that properly :-)

I've noticed that several existing tests fail because of my new warning if the
target defaults to float-abi=hard, depending on the default cpu/mode:

    gcc.misc-tests/arm-isr.c (test for excess errors)
    gcc.target/arm/empty_fiq_handler.c (test for excess errors)
    gcc.target/arm/interrupt-1.c (test for excess errors)
    gcc.target/arm/interrupt-2.c (test for excess errors)
    gcc.target/arm/pr70830.c (test for excess errors)

so I'd need to change their attribute or compile them with -mgeneral-regs-only

Reply via email to