This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: arm/thumb bugs
- To: Adrian von Bidder <avbidder at acter dot ch>
- Subject: Re: arm/thumb bugs
- From: Hartmut Schirmer <hartmut dot schirmer at arcormail dot de>
- Date: Tue, 13 Nov 2001 20:30:42 +0100
- Cc: gcc <gcc at gcc dot gnu dot org>
- References: <E163Mj1-0004pS-00@kc.cam.armlinux.org>
- Reply-to: hartmut dot schirmer at arcormail dot de
On Mon, 12 Nov 2001, Philip Blundell wrote:
>In message <3BF003A7.F2FE2F5@acter.ch>, Adrian von Bidder writes:
>>The switch statements translate to code like
>>.LCB6:
>> ldr r2, .L20
>> lsl r3, r3, #2
>> ldr r0, [r3, r2]
>> mov pc, r0
>> .align 2
>> .align 2
>>.L18:
>> b .L3
>> b .L10
>> ...
>>
>>when compiling with -fpic. On thumb, the branch only takes +/- 2040
>>bytes as addresses, so branches out of that range are generated quite
>>fast in big functions.
>
>It looks to me like there are bigger problems with that code than out-of-range branches. Does it actually work at all, even with small functions?
>
>You probably want to arrange to emit something like:
>
> lsl r3, r3, #2
> add r1, pc, #(.Lb - . - 4) @ adr r1, .Lb
> ldr r3, [r1, r3]
> add r3, r1
> mov pc, r3
>
>.Lb
> .word .L1 - .Lb
> .word .L2 - .Lb
> .word .L3 - .Lb
>
>.L1:
> ...
>.L2:
> ...
The SH port works this way and even chooses .byte or .word (and .long ?)
if required. You may have a look at it.
Hartmut