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]
Other format: [Raw text]

Re: Why Thumb-2 only allows very limited access to the PC?


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.


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