This is the mail archive of the gcc-patches@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]

patch for exception handlers in PIC code on ARM


The PIC register may need to be reloaded when control passes to an exception 
handler.  I haven't actually been able to bootstrap this patch on the mainline 
owing to other problems, but an equivalent causes no regressions in my 2.93.3 
tree.

p.

2001-01-12  Philip Blundell  <philb@gnu.org>

	* config/arm/arm.c (arm_finalize_pic): New arg "prologue".
	(is_pic): Delete.
	* config/arm/arm-protos.h (arm_finalize_pic): Update prototype.
	(is_pic): Delete declaration.
	* config/arm/arm.h (FINALIZE_PIC): Update call to above.
	(OUTPUT_INT_ADDR_CONST): Remove special handling of PIC address.
	* config/arm/arm.md (exception_receiver): New.
	(builtin_setjmp_receiver): Likewise.

Index: arm-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm-protos.h,v
retrieving revision 1.17
diff -u -p -u -r1.17 arm-protos.h
--- arm-protos.h	2001/01/05 16:15:59	1.17
+++ arm-protos.h	2001/01/13 19:57:46
@@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA.  */
 extern void   arm_override_options	PARAMS ((void));
 extern int    use_return_insn		PARAMS ((int));
 extern int    arm_regno_class 		PARAMS ((int));
-extern void   arm_finalize_pic		PARAMS ((void));
+extern void   arm_finalize_pic		PARAMS ((int));
 extern int    arm_volatile_func		PARAMS ((void));
 extern const char * arm_output_epilogue	PARAMS ((int));
 extern void   output_func_epilogue	PARAMS ((int));
@@ -52,7 +52,6 @@ extern int    arm_split_constant	PARAMS 
 extern RTX_CODE arm_canonicalize_comparison PARAMS ((RTX_CODE, rtx *));
 extern int    legitimate_pic_operand_p	PARAMS ((rtx));
 extern rtx    legitimize_pic_address	PARAMS ((rtx, enum machine_mode, rtx));
-extern int    is_pic			PARAMS ((rtx));
 extern int    arm_rtx_costs		PARAMS ((rtx, RTX_CODE, RTX_CODE));
 extern int    arm_adjust_cost		PARAMS ((rtx, rtx, rtx, int));
 extern int    const_double_rtx_ok_for_fpu	PARAMS ((rtx));
Index: arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.133
diff -u -p -u -r1.133 arm.c
--- arm.c	2001/01/08 15:33:05	1.133
+++ arm.c	2001/01/13 19:58:41
@@ -2227,22 +2227,16 @@ legitimize_pic_address (orig, mode, reg)
   return orig;
 }
 
-static rtx pic_rtx;
-
-int
-is_pic (x)
-     rtx x;
-{
-  if (x == pic_rtx)
-    return 1;
-  return 0;
-}
-
+/* 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).  */
 void
-arm_finalize_pic ()
+arm_finalize_pic (int prologue)
 {
 #ifndef AOF_ASSEMBLER
-  rtx l1, pic_tmp, pic_tmp2, seq;
+  rtx l1, pic_tmp, pic_tmp2, seq, pic_rtx;
   rtx global_offset_table;
 
   if (current_function_uses_pic_offset_table == 0 || TARGET_SINGLE_PIC_BASE)
@@ -2279,7 +2273,10 @@ arm_finalize_pic ()
 
   seq = gen_sequence ();
   end_sequence ();
-  emit_insn_after (seq, get_insns ());
+  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.  */
Index: arm.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.97
diff -u -p -u -r1.97 arm.h
--- arm.h	2001/01/08 15:33:05	1.97
+++ arm.h	2001/01/13 19:59:00
@@ -2523,7 +2523,7 @@ extern const char * arm_pic_register_str
    data addresses in memory.  */
 #define PIC_OFFSET_TABLE_REGNUM arm_pic_register
 
-#define FINALIZE_PIC arm_finalize_pic ()
+#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.  */
@@ -2851,18 +2851,9 @@ extern int making_const_table;
   else						\
     THUMB_PRINT_OPERAND_ADDRESS (STREAM, X)
      
-/* Handles PIC addr specially */
 #define OUTPUT_INT_ADDR_CONST(STREAM, X) 				\
   {									\
-    if (flag_pic && GET_CODE (X) == CONST && is_pic (X))		\
-      {									\
-	output_addr_const (STREAM, XEXP (XEXP (XEXP (X, 0), 0), 0));	\
-	fputs (" - (", STREAM);						\
-	output_addr_const (STREAM, XEXP (XEXP (XEXP (X, 0), 1), 0));	\
-	fputs (")", STREAM);						\
-      }									\
-    else								\
-      output_addr_const (STREAM, X);					\
+    output_addr_const (STREAM, X);					\
 									\
     /* Mark symbols as position independent.  We only do this in the	\
       .text segment, not in the .data segment. */			\
Index: arm.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.md,v
retrieving revision 1.75
diff -u -p -u -r1.75 arm.md
--- arm.md	2001/01/08 15:33:06	1.75
+++ arm.md	2001/01/13 19:59:19
@@ -4238,6 +4238,24 @@
   [(set_attr "predicable" "yes")]
 )
 
+(define_expand "exception_receiver"
+  [(const_int 0)]
+  "flag_pic"
+  "
+{
+  arm_finalize_pic (0);
+  DONE;
+}")
+
+(define_expand "builtin_setjmp_receiver"
+  [(label_ref (match_operand 0 "" ""))]
+  "flag_pic"
+  "
+{
+  arm_finalize_pic (0);
+  DONE;
+}")
+
 ;; If copying one reg to another we can set the condition codes according to
 ;; its value.  Such a move is common after a return from subroutine and the
 ;; result is being tested against zero.



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