From fccf9848508741311fc9d64abc69a799e8162ee8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 13 Oct 2000 16:55:19 +0200 Subject: [PATCH] sparc.md (nonlocal_goto_receiver): Remove. * 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. * gcc.dg/20001012-1.c: New test. * gcc.dg/20001012-2.c: New test. From-SVN: r36859 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/config/sparc/sparc-protos.h | 2 +- gcc/config/sparc/sparc.c | 36 ++++-------------------------------- gcc/config/sparc/sparc.h | 2 -- gcc/config/sparc/sparc.md | 39 +++++++++++++++++++++++++++++---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/20001012-1.c | 15 +++++++++++++++ gcc/testsuite/gcc.dg/20001012-2.c | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 101 insertions(+), 45 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/20001012-1.c create mode 100644 gcc/testsuite/gcc.dg/20001012-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8fdca97..0bd5e1e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2000-10-13 Jakub Jelinek + + * 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 * tree.h (struct obstack): Declare. diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h index 52d95f8..fe7f678 100644 --- a/gcc/config/sparc/sparc-protos.h +++ b/gcc/config/sparc/sparc-protos.h @@ -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)); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index ec3329b..a6364ab 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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; diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index aedccd1..93b8aac 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -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. */ diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 82386e5..21dda76 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -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 @@ -9439,17 +9438,37 @@ && in_same_eh_region (insn, operands[2]) && in_same_eh_region (insn, ins1)" "call\\t%a0, %1\\n\\tadd\\t%%o7, (%l2-.-4), %%o7") + +(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; +}") (define_insn "trap" [(trap_if (const_int 1) (const_int 5))] diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 369e85c..0000b08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2000-10-13 Jakub Jelinek + + * gcc.dg/20001012-1.c: New test. + * gcc.dg/20001012-2.c: New test. + 2000-10-12 Joseph S. Myers * 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 index 0000000..2fa7d76 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20001012-1.c @@ -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 index 0000000..b92c4a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20001012-2.c @@ -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); +} -- 2.7.4