This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [again] switch() statements on ARM/Thumb
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Adrian von Bidder <avbidder at acter dot ch>
- Cc: Richard dot Earnshaw at arm dot com, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 10 Jan 2002 15:23:57 +0000
- Subject: Re: [again] switch() statements on ARM/Thumb
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Moved the ASM_OUTPUT_DIFF_ELT to aout.h as per your suggestion. No AOF
> support so far.
I'd like to see the AOF variant as well, so that it doesn't get forgotten.
The patch should be very similar to the aout version.
> using the testsuite in this case seems quite difficult, as the change
> affects only -mthumb -fpic and I have the simulator, no native hardware.
> However, with leaving out the thumb_subsi change and using an unspec for
> the addr, there's no chance the patch will affect other targets.
It is certainly less important now, but it is definitely good practice to
ensure that your changes don't cause any regressions in the areas you are
not changing (for example, for non-pic thumb code the patches below *must*
cause zero regressions).
> 2002-01-10 Adrian von Bidder <avbidder@acter.ch>
>
> * aout.h (ASM_OUTPUT_ADDR_DIFF_ELT): output offset if __thumb__
Sentences. Capital letter at start, full stop at end.
> * arm.md (thumbpic_casesi): new pattern for switch() statements
And again
> (UNSPEC_THUMB_ADR, *thumb_movaddr): new pattern to load the
And again
> pc-relative address of a label_ref.
>
> And while I'm at it, allow libgcc to compile for thumb:
Please don't muddle independent patches together, it makes them much
harder to analyse and approve.
> +; this should probably be rewritten similar to movaddr_insn (or unified?)
> +; it is currently just used from thumbpic_casesi
Sentences
> + unsigned long temp; \
> + __asm __volatile ( \
> + ".align 2\n" \
This probably won't work reliably; 50% of the time the above alignment
will cause zero-padding to be inserted: opcode 0x0000 is the thumb
instruction
lsl r0, r0, #0
which has the side effect of altering the condition code register. We
should probably avoid align statements like this anyway; the meaning of
align 2 is highly dependent on the target assembler flavour, which means
this probably will be wrong for a non-elf assembler -- I'm not entirely
sure of the best way of handling this (other than creating something in
libgcc which we can then call).
Does linux support using swi 0 in thumb code as meaning something like
- SWI code is now in r0
- Other arguments are shuffled down one register.
If it does, then you could code the SWI that way and avoid the need to
jump to arm mode entirely.
Follow-ups to this part in a separate mail please...
R.