arm.c (require_pic_register): Handle high pic base register for thumb-1.

gcc/ChangeLog
2013-11-26  Terry Guo  <terry.guo@arm.com>

	* config/arm/arm.c (require_pic_register): Handle high pic base
	register for thumb-1.
	(arm_load_pic_register): Also initialize high pic base register.
	* doc/invoke.texi: Update documentation for option -mpic-register.

gcc/testsuite/ChangeLog
2013-11-26  Terry Guo  <terry.guo@arm.com>

	* gcc.target/arm/thumb1-pic-high-reg.c: New case.
	* gcc.target/arm/thumb1-pic-single-base.c: New case.

From-SVN: r205391
This commit is contained in:
Terry Guo 2013-11-26 11:58:37 +00:00 committed by Xuepeng Guo
parent 91f65b12bb
commit 84c44566f3
6 changed files with 55 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2013-11-26 Terry Guo <terry.guo@arm.com>
* config/arm/arm.c (require_pic_register): Handle high pic base
register for thumb-1.
(arm_load_pic_register): Also initialize high pic base register.
* doc/invoke.texi: Update documentation for option -mpic-register.
2013-11-26 Oleg Endo <olegendo@gcc.gnu.org>
PR target/58314

View File

@ -5917,7 +5917,8 @@ require_pic_register (void)
if (!crtl->uses_pic_offset_table)
{
gcc_assert (can_create_pseudo_p ());
if (arm_pic_register != INVALID_REGNUM)
if (arm_pic_register != INVALID_REGNUM
&& !(TARGET_THUMB1 && arm_pic_register > LAST_LO_REGNUM))
{
if (!cfun->machine->pic_reg)
cfun->machine->pic_reg = gen_rtx_REG (Pmode, arm_pic_register);
@ -5943,7 +5944,12 @@ require_pic_register (void)
crtl->uses_pic_offset_table = 1;
start_sequence ();
arm_load_pic_register (0UL);
if (TARGET_THUMB1 && arm_pic_register != INVALID_REGNUM
&& arm_pic_register > LAST_LO_REGNUM)
emit_move_insn (cfun->machine->pic_reg,
gen_rtx_REG (Pmode, arm_pic_register));
else
arm_load_pic_register (0UL);
seq = get_insns ();
end_sequence ();
@ -6202,6 +6208,14 @@ arm_load_pic_register (unsigned long saved_regs ATTRIBUTE_UNUSED)
emit_insn (gen_movsi (pic_offset_table_rtx, pic_tmp));
emit_insn (gen_pic_add_dot_plus_four (pic_reg, pic_reg, labelno));
}
else if (arm_pic_register != INVALID_REGNUM
&& arm_pic_register > LAST_LO_REGNUM
&& REGNO (pic_reg) <= LAST_LO_REGNUM)
{
emit_insn (gen_pic_load_addr_unified (pic_reg, pic_rtx, labelno));
emit_move_insn (gen_rtx_REG (Pmode, arm_pic_register), pic_reg);
emit_use (gen_rtx_REG (Pmode, arm_pic_register));
}
else
emit_insn (gen_pic_load_addr_unified (pic_reg, pic_rtx, labelno));
}

View File

@ -12216,8 +12216,11 @@ before execution begins.
@item -mpic-register=@var{reg}
@opindex mpic-register
Specify the register to be used for PIC addressing. The default is R10
unless stack-checking is enabled, when R9 is used.
Specify the register to be used for PIC addressing.
For standard PIC base case, the default will be any suitable register
determined by compiler. For single PIC base case, the default is
@samp{R9} if target is EABI based or stack-checking is enabled,
otherwise the default is @samp{R10}.
@item -mpic-data-is-text-relative
@opindex mpic-data-is-text-relative

View File

@ -1,3 +1,8 @@
2013-11-26 Terry Guo <terry.guo@arm.com>
* gcc.target/arm/thumb1-pic-high-reg.c: New case.
* gcc.target/arm/thumb1-pic-single-base.c: New case.
2013-11-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58700

View File

@ -0,0 +1,11 @@
/* { dg-do compile } */
/* { dg-require-effective-target arm_thumb1_ok } */
/* { dg-options "-mthumb -fpic -mpic-register=9" } */
int g_test;
int
foo (int par)
{
g_test = par;
}

View File

@ -0,0 +1,11 @@
/* { dg-do compile } */
/* { dg-require-effective-target arm_thumb1_ok } */
/* { dg-options "-mthumb -fpic -msingle-pic-base" } */
int g_test;
int
foo (int par)
{
g_test = par;
}