So thumb2 can also use the instructions similar to thumb1, right? It potentially has better performance and smaller code size.
thanks Carrot On Tue, Jan 5, 2010 at 7:06 PM, Richard Earnshaw <rearn...@arm.com> wrote: > > On Tue, 2010-01-05 at 15:42 +0800, Carrot Wei wrote: >> Hi >> >> In function arm_load_pic_register in file arm.c there are following code: >> >> if (TARGET_ARM) >> { >> ... >> } >> else if (TARGET_THUMB2) >> { >> /* Thumb-2 only allows very limited access to the PC. Calculate the >> address in a temporary register. */ >> if (arm_pic_register != INVALID_REGNUM) >> { >> pic_tmp = gen_rtx_REG (SImode, >> thumb_find_work_register (saved_regs)); >> } >> else >> { >> gcc_assert (can_create_pseudo_p ()); >> pic_tmp = gen_reg_rtx (Pmode); >> } >> >> emit_insn (gen_pic_load_addr_thumb2 (pic_reg, pic_rtx)); >> emit_insn (gen_pic_load_dot_plus_four (pic_tmp, labelno)); >> emit_insn (gen_addsi3 (pic_reg, pic_reg, pic_tmp)); >> } >> else /* TARGET_THUMB1 */ >> { >> ... >> } >> >> The comment said "Thumb-2 only allows very limited access to the PC. >> Calculate the address in a temporary register.". So the generated code >> is a little more complex than thumb1. Could anybody help to give more >> explanation on the limitation thumb2 has compared to thumb1? >> >> The generated instructions by this function for thumb1 is listed >> following, both instructions are available under thumb2. >> >> ldr r3, .L2 >> .LPIC0: >> add r3, pc > > I didn't write the comment, but I think the limitation is relative to > ARM not thumb1. Thumb2 code generator is a variation on the ARM code > generator, so the author was most likely thinking of that rather than > Thumb1. > > R. > >