[PATCH, ARM] Use a pseudo for the PIC base

Richard Earnshaw Richard.Earnshaw@buzzard.freeserve.co.uk
Tue Jan 17 20:52:00 GMT 2006


This patch changes the ARM back-end to use a pseudo as the PIC base 
register.  This can be a big win when the function is a leaf function, or 
when the register being used as the base is expensive (eg in Thumb, where 
high registers have limited valid uses and low registers are in short 
supply).

It seems that contrary to traditional belief no further changes to the 
mid-end code are needed.

On code size Thumb code with -fpic comes out about 1.6% smaller with this 
patch.  ARM code does come out a bit larger (even at -Os), but this is 
generally compensated for by using fewer spills or a smaller stack frame 
(it seems the major reason for this is either register allocation issues, 
or worse jump threading).

Tested on arm-elf and bootstraped/tested on arm-netbsdelf.  The native 
bootstrap was additionally performed using a BOOT_CFLAGS setting of "-O2 
-g -fpic" to further exercise the new code.  No regressions.

2006-01-17  Richard Earnshaw  <rearnsha@arm.com>

	PR target/592
	PR middle-end/11135
	* arm.h (struct machine_function): Add pic_reg.
	* arm.c (arm_pic_register): Make unsigned.
	(arm_override_options): Only set arm_pic_register if
	TARGET_SINGLE_PIC_BASE.
	(use_return_insn): Only test for a pic register if it is fixed.
	(arm_compute_save_reg0_reg12_mask): Likewise.
	(thumb_compute_save_reg_mask): Likewise.
	(legitimate_pic_operand): Factor out some known invariants.
	(legitimize_pic_address): If we don't have a fixed pic register,
	then set up a pseudo in the function entry sequence.  Handle the
	pic base being in a pseudo.
	(arm_load_pic_register): Handle the pic register being in a pseudo.
	(arm_expand_prologue): Only set up the pic register if it is fixed.
	(thumb_expand_prologue): Likewise.
	* arm.md (pic_load_addr_based): Handle the pic base being a pseudo.
	(pic_load_addr_based_insn): Likewise.
	(builtin_setjmp_receiver): Don't restore the pic base if it isn't
	fixed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic.patch
Type: text/x-patch
Size: 16209 bytes
Desc: pic.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060117/c68e7c79/attachment.bin>


More information about the Gcc-patches mailing list