This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: arm/thumb bugs

[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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]