diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55ceca11af7c12cccf5bc4abc108cbba9a27b613..b3aa2f3cf072e2513f963acc1f3fd26c80ea2924 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2004-08-11 Paul Brook <paul@codesourcery.com> + + * config/arm/arm-protos.h (arm_finalize_pic) Rename ... + (arm_load_pic_register): ... to this. + * config/arm/arm.c (arm_finalize_pic): Rename ... + (arm_load_pic_register): ... to this. Always output insns at the + current location. Load via low reg in thumb mode. + (arm_expand_prologue): Call arm_load_pic_register. + (thumb_expand_prologue): Ditto. + * config/arm/arm.h (FINALIZE_PIC): Remove. + * config/arm/arm.md (builtin_setjmp_receiver): Call + arm_load_pic_register. + 2004-08-11 Paul Brook <paul@codesourcery.com> * arm.c (thumb_force_lr_save): Add prototype. diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 2f361cd63627888dd4316c735cf2392fdb6dce9e..b6b2fc4d81631e79c3e79f753ca2094584eae4ac 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -27,7 +27,7 @@ extern void arm_override_options (void); extern int use_return_insn (int, rtx); extern int arm_regno_class (int); -extern void arm_finalize_pic (int); +extern void arm_load_pic_register (void); extern int arm_volatile_func (void); extern const char *arm_output_epilogue (rtx); extern void arm_expand_prologue (void); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 41c27efa9110921aad09cde4599faf53eaf189f5..8493af03227a9f032949fce98dba020ee6b71527 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3012,16 +3012,14 @@ thumb_find_work_register (int live_regs_mask) abort (); } -/* Generate code to load the PIC register. PROLOGUE is true if - called from arm_expand_prologue (in which case we want the - generated insns at the start of the function); false if called - by an exception receiver that needs the PIC register reloaded - (in which case the insns are just dumped at the current location). */ + +/* Generate code to load the PIC register. */ + void -arm_finalize_pic (int prologue ATTRIBUTE_UNUSED) +arm_load_pic_register (void) { #ifndef AOF_ASSEMBLER - rtx l1, pic_tmp, pic_tmp2, seq, pic_rtx; + rtx l1, pic_tmp, pic_tmp2, pic_rtx; rtx global_offset_table; if (current_function_uses_pic_offset_table == 0 || TARGET_SINGLE_PIC_BASE) @@ -3030,7 +3028,6 @@ arm_finalize_pic (int prologue ATTRIBUTE_UNUSED) if (!flag_pic) abort (); - start_sequence (); l1 = gen_label_rtx (); global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_"); @@ -3052,23 +3049,29 @@ arm_finalize_pic (int prologue ATTRIBUTE_UNUSED) } else { - emit_insn (gen_pic_load_addr_thumb (pic_offset_table_rtx, pic_rtx)); + if (REGNO (pic_offset_table_rtx) > LAST_LO_REGNUM) + { + int reg; + + /* We will have pushed the pic register, so should always be + able to find a work register. */ + reg = thumb_find_work_register (thumb_compute_save_reg_mask ()); + pic_tmp = gen_rtx_REG (SImode, reg); + emit_insn (gen_pic_load_addr_thumb (pic_tmp, pic_rtx)); + emit_insn (gen_movsi (pic_offset_table_rtx, pic_tmp)); + } + else + emit_insn (gen_pic_load_addr_thumb (pic_offset_table_rtx, pic_rtx)); emit_insn (gen_pic_add_dot_plus_four (pic_offset_table_rtx, l1)); } - seq = get_insns (); - end_sequence (); - if (prologue) - emit_insn_after (seq, get_insns ()); - else - emit_insn (seq); - /* Need to emit this whether or not we obey regdecls, since setjmp/longjmp can cause life info to screw up. */ emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx)); #endif /* AOF_ASSEMBLER */ } + /* Return nonzero if X is valid as an ARM state addressing register. */ static int arm_address_register_rtx_p (rtx x, int strict_p) @@ -10693,6 +10696,10 @@ arm_expand_prologue (void) hard_frame_pointer_rtx)); } + + if (flag_pic) + arm_load_pic_register (); + /* If we are profiling, make sure no instructions are scheduled before the call to mcount. Similarly if the user has requested no scheduling in the prolog. */ @@ -13357,6 +13364,11 @@ thumb_expand_prologue (void) return; } + /* Load the pic recister before setting the frame pointer, so we can use r7 + as a temporary work register. */ + if (flag_pic) + arm_load_pic_register (); + offsets = arm_get_frame_offsets (); if (frame_pointer_needed) diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index c3ea52a70e8107d0ff26ca3ef7f8b8d53c512f3d..ec924105e1a045200abe5ae75f011ff1fe8514a3 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2277,8 +2277,6 @@ extern const char * arm_pic_register_string; data addresses in memory. */ #define PIC_OFFSET_TABLE_REGNUM arm_pic_register -#define FINALIZE_PIC arm_finalize_pic (1) - /* We can't directly access anything that contains a symbol, nor can we indirect via the constant pool. */ #define LEGITIMATE_PIC_OPERAND_P(X) \ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 88aea2776868c75385ab8f088b85b62be1cb9ee3..f19f8cd4ebebb3e06bec9e845e6158747e2bdaa7 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -4462,7 +4462,7 @@ "flag_pic" " { - arm_finalize_pic (0); + arm_load_pic_register (); DONE; }")