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: Philip Blundell <philb at gnu dot org>
- Date: Mon, 12 Nov 2001 19:26:31 +0000
- Cc: gcc <gcc at gcc dot gnu dot org>
- References: <3BEFDE95.DF1F7013@acter.ch> <3BF003A7.F2FE2F5@acter.ch>
[Get raw message]
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:
...
p.