diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-20 18:42:24 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-20 18:42:24 +0000 |
commit | 46e442c7941547741026fd7f706faf9837bd4939 (patch) | |
tree | 33fea21ac869569cab0b164a30d0095ceb5f9c3e /gcc | |
parent | fc3feebd5477e068604c2365fb3b652b78ce41b0 (diff) | |
download | gcc-46e442c7941547741026fd7f706faf9837bd4939.tar.gz |
* config/rs6000/rs6000.c (rs6000_emit_prologue): Update for change
to load_macho_picbase.
* config/rs6000/rs6000.md: Document Darwin-specific unspec IDs.
(load_macho_picbase): Take the symbol to use as a parameter.
(macho_correct_pic): New insn.
(builtin_setjmp_reciever): On Darwin, restore the PIC register.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57360 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.md | 47 |
3 files changed, 47 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 59da95618dd..7dfdfa0668a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2002-09-20 Geoffrey Keating <geoffk@apple.com> + * config/rs6000/rs6000.c (rs6000_emit_prologue): Update for change + to load_macho_picbase. + * config/rs6000/rs6000.md: Document Darwin-specific unspec IDs. + (load_macho_picbase): Take the symbol to use as a parameter. + (macho_correct_pic): New insn. + (builtin_setjmp_reciever): On Darwin, restore the PIC register. + * config/rs6000/rs6000.h (ELIMINABLE_REGS): Use RS6000_PIC_OFFSET_TABLE_REGNUM rather than hardcoding 30. (CAN_ELIMINATE): Likewise. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index ba0249cba7e..909dc6bd195 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -10458,8 +10458,12 @@ rs6000_emit_prologue () && flag_pic && current_function_uses_pic_offset_table) { rtx dest = gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM); +#if TARGET_MACHO + char *picbase = machopic_function_base_name (); + rtx src = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1)); - rs6000_maybe_dead (emit_insn (gen_load_macho_picbase (dest))); + rs6000_maybe_dead (emit_insn (gen_load_macho_picbase (dest, src))); +#endif rs6000_maybe_dead ( emit_move_insn (gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM), diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 8bfec08c4d5..e85dc53c0c5 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -1,6 +1,6 @@ ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, -;; 1999, 2000, 2001 Free Software Foundation, Inc. +;; 1999, 2000, 2001, 2002 Free Software Foundation, Inc. ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) ;; This file is part of GNU CC. @@ -32,6 +32,8 @@ ;; 8 movsi_got ;; 9/v eh_reg_restore ;; 10 fctiwz +;; 15 load_macho_picbase +;; 16 macho_correct_pic ;; 19 movesi_from_cr ;; 20 movesi_to_cr @@ -10220,30 +10222,51 @@ (define_insn "load_macho_picbase" [(set (match_operand:SI 0 "register_operand" "=l") - (unspec:SI [(const_int 0)] 15))] + (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")] 15))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" - "* -{ -#if TARGET_MACHO - char *picbase = machopic_function_base_name (); - operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1)); -#endif - return \"bcl 20,31,%1\\n%1:\"; -}" + "bcl 20,31,%1\\n%1:" [(set_attr "type" "branch") (set_attr "length" "4")]) +(define_insn "macho_correct_pic" + [(set (match_operand:SI 0 "gpc_reg_operand" "=r") + (plus:SI (match_operand:SI 1 "gpc_reg_operand" "=r") + (unspec:SI [(match_operand:SI 2 "immediate_operand" "s") + (match_operand:SI 3 "immediate_operand" "s")] + 16)))] + "DEFAULT_ABI == ABI_DARWIN" + "addis %0,%1,ha16(%2-%3)\n\taddi %1,%1,lo16(%2-%3)" + [(set_attr "length" "8")]) + ;; If the TOC is shared over a translation unit, as happens with all ;; the kinds of PIC that we support, we need to restore the TOC ;; pointer only when jumping over units of translation. +;; On Darwin, we need to reload the picbase. (define_expand "builtin_setjmp_receiver" [(use (label_ref (match_operand 0 "" "")))] "(DEFAULT_ABI == ABI_V4 && flag_pic == 1) - || (TARGET_TOC && TARGET_MINIMAL_TOC)" + || (TARGET_TOC && TARGET_MINIMAL_TOC) + || (DEFAULT_ABI == ABI_DARWIN && flag_pic)" " { - rs6000_emit_load_toc_table (FALSE); + if (DEFAULT_ABI == ABI_DARWIN) + { + char *picbase = machopic_function_base_name (); + rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1)); + rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM); + rtx tmplabrtx; + char tmplab[20]; + + ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\", + CODE_LABEL_NUMBER (operands[0])); + tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (tmplab, -1)); + + emit_insn (gen_load_macho_picbase (picreg, tmplabrtx)); + emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx)); + } + else + rs6000_emit_load_toc_table (FALSE); DONE; }") |