This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[2.95] patch for ARM PIC
- To: gcc-patches at gcc dot gnu dot org
- Subject: [2.95] patch for ARM PIC
- From: Philip Blundell <philb at gnu dot org>
- Date: Sat, 07 Apr 2001 22:37:52 +0100
This patch has been installed in the trunk for a year or so. I'd like to
propose it for inclusion on the 2.95 branch as well.
p.
2000-02-09 Philip Blundell <pb@futuretv.com>
* config/arm/arm.c (legitimize_pic_address): Handle LABEL_REF
correctly.
* config/arm/arm.h (LEGITIMATE_CONSTANT_P): Allow anything when
generating PIC.
(LEGITIMATE_PIC_OPERAND): Disallow references to labels.
--- gcc/config/arm/arm.c 1999/06/19 06:34:36 1.43.4.5
+++ gcc/config/arm/arm.c 1999/07/16 09:27:53
@@ -1528,7 +1528,20 @@ legitimize_pic_address (orig, mode, reg)
return gen_rtx_PLUS (Pmode, base, offset);
}
else if (GET_CODE (orig) == LABEL_REF)
- current_function_uses_pic_offset_table = 1;
+ {
+ current_function_uses_pic_offset_table = 1;
+
+ if (NEED_PLT_GOT)
+ {
+ rtx pic_ref, address = gen_reg_rtx (Pmode);
+
+ emit_insn (gen_pic_load_addr (address, orig));
+ pic_ref = gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
+ address);
+ emit_move_insn (address, pic_ref);
+ return address;
+ }
+ }
return orig;
}
--- gcc/config/arm/arm.h 1999/06/19 05:37:07 1.34.4.3
+++ gcc/config/arm/arm.h 1999/07/16 09:28:04
@@ -1378,9 +1378,11 @@ do { \
On the ARM, allow any integer (invalid ones are removed later by insn
patterns), nice doubles and symbol_refs which refer to the function's
- constant pool XXX. */
-#define LEGITIMATE_CONSTANT_P(X) (! label_mentioned_p (X))
+ constant pool XXX.
+ When generating PIC code, allow anything. */
+#define LEGITIMATE_CONSTANT_P(X) (flag_pic || ! label_mentioned_p (X))
+
/* Symbols in the text segment can be accessed without indirecting via the
constant pool; it may take an extra binary operation, but this is still
faster than indirecting via memory. Don't do this when not optimizing,
@@ -1813,12 +1814,13 @@ extern int arm_pic_register;
#define FINALIZE_PIC arm_finalize_pic ()
-/* We can't directly access anything that contains a symbol,
+/* We can't directly access anything that contains a symbol or label,
nor can we indirect via the constant pool. */
#define LEGITIMATE_PIC_OPERAND_P(X) \
- (! symbol_mentioned_p (X) \
+ (! symbol_mentioned_p (X) && ! label_mentioned_p (X) \
&& (! CONSTANT_POOL_ADDRESS_P (X) \
- || ! symbol_mentioned_p (get_pool_constant (X))))
+ || (! symbol_mentioned_p (get_pool_constant (X))) \
+ && (! label_mentioned_p (get_pool_constant (X)))))
/* We need to know when we are making a constant pool; this determines
whether data needs to be in the GOT or can be referenced via a GOT