OSDN Git Service

* config/sparc/sparc.md (nonlocal_goto_receiver): Remove.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2000 14:55:19 +0000 (14:55 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Oct 2000 14:55:19 +0000 (14:55 +0000)
(prologue, exception_receiver, builtin_setjmp_receiver): New
patterns.
* config/sparc/sparc.h (FINALIZE_PIC): Remove.
* config/sparc/sparc-protos.h (finalize_pic): Remove.
(load_pic_register): New prototype.
* config/sparc/sparc.c (pic_setup_code): Remove.
(finalize_pic): Rename to...
(load_pic_register): ...this function.
Don't look for nonlocal_goto_receivers and emit pic setup code
directly.  Don't check current_function_uses_pic_offset_table.

* gcc.dg/20001012-1.c: New test.
* gcc.dg/20001012-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36859 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/sparc/sparc-protos.h
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h
gcc/config/sparc/sparc.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20001012-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/20001012-2.c [new file with mode: 0644]

index 8fdca97..0bd5e1e 100644 (file)
@@ -1,3 +1,17 @@
+2000-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/sparc/sparc.md (nonlocal_goto_receiver): Remove.
+       (prologue, exception_receiver, builtin_setjmp_receiver): New
+       patterns.
+       * config/sparc/sparc.h (FINALIZE_PIC): Remove.
+       * config/sparc/sparc-protos.h (finalize_pic): Remove.
+       (load_pic_register): New prototype.
+       * config/sparc/sparc.c (pic_setup_code): Remove.
+       (finalize_pic): Rename to...
+       (load_pic_register): ...this function.
+       Don't look for nonlocal_goto_receivers and emit pic setup code
+       directly.  Don't check current_function_uses_pic_offset_table.
+
 2000-10-13  Richard Earnshaw <rearnsha@arm.com>
 
        * tree.h (struct obstack): Declare.
index 52d95f8..fe7f678 100644 (file)
@@ -51,7 +51,7 @@ extern enum direction function_arg_padding PARAMS ((enum machine_mode, tree));
 #endif /* TREE_CODE */
 
 extern void ultrasparc_sched_init PARAMS ((FILE *, int));
-extern void finalize_pic PARAMS ((void));
+extern void load_pic_register PARAMS ((void));
 extern void order_regs_for_local_alloc PARAMS ((void));
 extern void output_function_epilogue PARAMS ((FILE *, int, int));
 extern void output_function_prologue PARAMS ((FILE *, int, int));
index ec3329b..a6364ab 100644 (file)
@@ -127,7 +127,6 @@ char sparc_leaf_regs[] =
 static const char *frame_base_name;
 static int frame_base_offset;
 
-static rtx pic_setup_code      PARAMS ((void));
 static void sparc_init_modes   PARAMS ((void));
 static int save_regs           PARAMS ((FILE *, int, int, const char *,
                                       int, int, int));
@@ -2830,34 +2829,15 @@ legitimize_pic_address (orig, mode, reg)
   return orig;
 }
 
-/* Return the RTX for insns to set the PIC register.  */
-
-static rtx
-pic_setup_code ()
-{
-  rtx seq;
-
-  start_sequence ();
-  emit_insn (gen_get_pc (pic_offset_table_rtx, global_offset_table,
-                        get_pc_symbol));
-  seq = gen_sequence ();
-  end_sequence ();
-
-  return seq;
-}
-
-/* Emit special PIC prologues and epilogues.  */
+/* Emit special PIC prologues.  */
 
 void
-finalize_pic ()
+load_pic_register ()
 {
   /* Labels to get the PC in the prologue of this function.  */
   int orig_flag_pic = flag_pic;
   rtx insn;
 
-  if (current_function_uses_pic_offset_table == 0)
-    return;
-
   if (! flag_pic)
     abort ();
 
@@ -2882,16 +2862,8 @@ finalize_pic ()
   get_pc_symbol = gen_rtx_SYMBOL_REF (Pmode, get_pc_symbol_name);
   flag_pic = 0;
 
-  emit_insn_after (pic_setup_code (), get_insns ());
-
-  /* Insert the code in each nonlocal goto receiver.
-     If you make changes here or to the nonlocal_goto_receiver
-     pattern, make sure the unspec_volatile numbers still
-     match.  */
-  for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
-    if (GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE
-       && XINT (PATTERN (insn), 1) == 5)
-      emit_insn_after (pic_setup_code (), insn);
+  emit_insn (gen_get_pc (pic_offset_table_rtx, global_offset_table,
+                        get_pc_symbol));
 
   flag_pic = orig_flag_pic;
 
index aedccd1..93b8aac 100644 (file)
@@ -1252,8 +1252,6 @@ extern int sparc_mode_class[];
 
 #define PIC_OFFSET_TABLE_REGNUM 23
 
-#define FINALIZE_PIC finalize_pic ()
-
 /* Pick a default value we can notice from override_options:
    !v9: Default is on.
    v9: Default is off.  */
index 82386e5..21dda76 100644 (file)
@@ -50,7 +50,6 @@
 ;;                     2       goto_handler_and_restore
 ;;                     3       goto_handler_and_restore_v9*
 ;;                     4       flush
-;;                     5       nonlocal_goto_receiver
 ;;
 
 ;; The upper 32 fp regs on the v9 can't hold SFmode values.  To deal with this
    && in_same_eh_region (insn, operands[2])
    && in_same_eh_region (insn, ins1)"
   "call\\t%a0, %1\\n\\tadd\\t%%o7, (%l2-.-4), %%o7")
+\f
+(define_expand "prologue"
+  [(const_int 1)]
+  "flag_pic && current_function_uses_pic_offset_table"
+  "
+{
+  load_pic_register ();
+  DONE;
+}")
 
-;; After a nonlocal goto, we need to restore the PIC register, but only
-;; if we need it.  So do nothing much here, but we'll check for this in
-;; finalize_pic.
+;; We need to reload %l7 for -mflat -fpic,
+;; otherwise %l7 should be preserved simply
+;; by loading the function's register window
+(define_expand "exception_receiver"
+  [(const_int 0)]
+  "TARGET_FLAT && flag_pic"
+  "
+{
+  load_pic_register ();
+  DONE;
+}")
 
-;; Make sure this unspec_volatile number agrees with finalize_pic.
-(define_insn "nonlocal_goto_receiver"
-  [(unspec_volatile [(const_int 0)] 5)]
-  "flag_pic"
-  ""
-  [(set_attr "length" "0")])
+;; Likewise
+(define_expand "builtin_setjmp_receiver"
+  [(label_ref (match_operand 0 "" ""))]
+  "TARGET_FLAT && flag_pic"
+  "
+{
+  load_pic_register ();
+  DONE;
+}")
 \f
 (define_insn "trap"
   [(trap_if (const_int 1) (const_int 5))]
index 369e85c..0000b08 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20001012-1.c: New test.
+       * gcc.dg/20001012-2.c: New test.
+
 2000-10-12  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.dg/format-attr-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/20001012-1.c b/gcc/testsuite/gcc.dg/20001012-1.c
new file mode 100644 (file)
index 0000000..2fa7d76
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do run { target sparc*-*-* } } */
+/* { dg-options "-O2 -fpic" } */
+
+double
+foo (void)
+{
+  return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d);
+}
+
+main ()
+{
+  if (foo() != 1.0)
+    abort ();
+  exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/20001012-2.c b/gcc/testsuite/gcc.dg/20001012-2.c
new file mode 100644 (file)
index 0000000..b92c4a0
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run { target sparc*-*-* } } */
+/* { dg-options "-O2 -fpic" } */
+
+void foo (char *x, const char *y, ...)
+{
+}
+
+double bar (const char *x, long y)
+{
+  return 0.0;
+}
+
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen (const char *);
+
+double baz (const char *x)
+{
+  if (x[0] != '\0')
+    {
+      char y[6 + strlen (x)];
+      foo (y, "FOO", x);
+      return bar (y, 0);
+    }
+
+  return (__extension__ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) { __l: 0x3f800000UL }).__d);
+}
+
+main ()
+{
+  if (baz("") != 1.0)
+    abort ();
+  exit (0);
+}