aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/darwin.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2008-10-06 19:07:33 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2008-10-06 19:07:33 +0000
commit08a6a74b917d3a7b0070c264374cd076edfacc9e (patch)
treedd906add3e83a4a7cf219604bf1100b0f5173d20 /gcc/config/darwin.c
parent2e4316da802a3049f67686001f9dbca5711dcace (diff)
downloadgcc-08a6a74b917d3a7b0070c264374cd076edfacc9e.zip
gcc-08a6a74b917d3a7b0070c264374cd076edfacc9e.tar.gz
gcc-08a6a74b917d3a7b0070c264374cd076edfacc9e.tar.bz2
darwin-protos.h (machopic_function_base_name): Delete.
gcc/ * config/darwin-protos.h (machopic_function_base_name): Delete. (machopic_function_base_sym): Likewise. (machopic_gen_offset): Declare. * config/darwin.h (MACHOPIC_FUNCTION_BASE_NAME): New macro. (ASM_OUTPUT_LABELREF): Use it instead of a hard-coded string constant. * config/darwin.c (machopic_function_base_name): Delete. (machopic_function_base_sym): Likewise. (gen_pic_offset): Rename to... (machopic_gen_offset): ...this and remove the pic_base argument. Instead use MACHO_DYNAMIC_NO_PIC_P to decide whether a PIC offset is needed. Create an UNSPEC_MACHOPIC_OFFSET if so, and set crtl->uses_pic_offset_table. (machopic_indirect_data_reference): Use new machopic_gen_offset interface. (machopic_legitimize_pic_address): Likewise. (machopic_operand_p): Check for UNSPEC_MACHOPIC_OFFSET. * config/i386/darwin.h (GOT_SYMBOL_NAME): Use MACHOPIC_FUNCTION_BASE_NAME instead of machopic_function_base_name. * config/i386/i386.c (output_set_got): Likewise. (darwin_local_data_pic): Check for an UNSPEC_MACHOPIC_OFFSET instead of a MINUS. (legitimate_pic_operand_p): Handle UNSPEC_MACHOPIC_OFFSET. (legitimate_address_p): Likewise. (output_pic_addr_const): Likewise. (output_addr_const_extra): Likewise. (ix86_delegitimize_address): Expect darwin_local_data_pic to match an UNSPEC rather than a MINUS. * config/i386/i386.md (UNSPEC_MACHOPIC_OFFSET): Define. (builtin_setjmp_receiver): Use machopic_gen_offset. * config/i386/predicates.md (pic_symbolic_operand): Handle UNSPEC_MACHOPIC_OFFSET. * config/rs6000/rs6000.c (rs6000_legitimize_reload_address): Use machopic_gen_offset and machopic_operand_p. (rs6000_output_addr_const_extra): Handle UNSPEC_MACHOPIC_OFFSET. (rs6000_emit_prologue): Use MACHOPIC_FUNCTION_BASE_NAME. * config/rs6000/rs6000.md (UNSPEC_MACHOPIC_OFFSET): Define. (builtin_setjmp_receiver): Use MACHOPIC_FUNCTION_BASE_NAME. Set crtl->uses_pic_offset_table. From-SVN: r140911
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r--gcc/config/darwin.c93
1 files changed, 25 insertions, 68 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index fe33273..3a4fc99 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -267,44 +267,26 @@ machopic_define_symbol (rtx mem)
SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_DEFINED;
}
-static GTY(()) const char * function_base;
+/* Return either ORIG or:
-const char *
-machopic_function_base_name (void)
-{
- /* if dynamic-no-pic is on, we should not get here */
- gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
-
- if (function_base == NULL)
- function_base = ggc_alloc_string ("<pic base>", sizeof ("<pic base>"));
-
- crtl->uses_pic_offset_table = 1;
-
- return function_base;
-}
-
-/* Return a SYMBOL_REF for the PIC function base. */
+ (const:P (unspec:P [ORIG] UNSPEC_MACHOPIC_OFFSET))
+ depending on MACHO_DYNAMIC_NO_PIC_P. */
rtx
-machopic_function_base_sym (void)
+machopic_gen_offset (rtx orig)
{
- rtx sym_ref;
-
- sym_ref = gen_rtx_SYMBOL_REF (Pmode, machopic_function_base_name ());
- SYMBOL_REF_FLAGS (sym_ref)
- |= (MACHO_SYMBOL_FLAG_VARIABLE | MACHO_SYMBOL_FLAG_DEFINED);
- return sym_ref;
-}
-
-/* Return either ORIG or (const:P (minus:P ORIG PIC_BASE)), depending
- on whether pic_base is NULL or not. */
-static inline rtx
-gen_pic_offset (rtx orig, rtx pic_base)
-{
- if (!pic_base)
+ if (MACHO_DYNAMIC_NO_PIC_P)
return orig;
else
- return gen_rtx_CONST (Pmode, gen_rtx_MINUS (Pmode, orig, pic_base));
+ {
+ /* Play games to avoid marking the function as needing pic if we
+ are being called as part of the cost-estimation process. */
+ if (current_ir_type () != IR_GIMPLE)
+ crtl->uses_pic_offset_table = 1;
+ orig = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, orig),
+ UNSPEC_MACHOPIC_OFFSET);
+ return gen_rtx_CONST (Pmode, orig);
+ }
}
static GTY(()) const char * function_base_func_name;
@@ -528,8 +510,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
else if (defined)
{
#if defined (TARGET_TOC) || defined (HAVE_lo_sum)
- rtx pic_base = machopic_function_base_sym ();
- rtx offset = gen_pic_offset (orig, pic_base);
+ rtx offset = machopic_gen_offset (orig);
#endif
#if defined (TARGET_TOC) /* i.e., PowerPC */
@@ -675,8 +656,6 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
))
{
/* addr(foo) = &func+(foo-func) */
- rtx pic_base;
-
orig = machopic_indirect_data_reference (orig, reg);
if (GET_CODE (orig) == PLUS
@@ -689,12 +668,6 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
return reg;
}
- /* if dynamic-no-pic we don't have a pic base */
- if (MACHO_DYNAMIC_NO_PIC_P)
- pic_base = NULL;
- else
- pic_base = machopic_function_base_sym ();
-
if (GET_CODE (orig) == MEM)
{
if (reg == 0)
@@ -731,7 +704,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
if (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
|| GET_CODE (XEXP (orig, 0)) == LABEL_REF)
{
- rtx offset = gen_pic_offset (XEXP (orig, 0), pic_base);
+ rtx offset = machopic_gen_offset (XEXP (orig, 0));
#if defined (TARGET_TOC) /* i.e., PowerPC */
/* Generating a new reg may expose opportunities for
common subexpression elimination. */
@@ -787,8 +760,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
if (reload_in_progress)
df_set_regs_ever_live (REGNO (pic), true);
pic_ref = gen_rtx_PLUS (Pmode, pic,
- gen_pic_offset (XEXP (orig, 0),
- pic_base));
+ machopic_gen_offset (XEXP (orig, 0)));
}
#if !defined (TARGET_TOC)
@@ -803,7 +775,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
if (GET_CODE (orig) == SYMBOL_REF
|| GET_CODE (orig) == LABEL_REF)
{
- rtx offset = gen_pic_offset (orig, pic_base);
+ rtx offset = machopic_gen_offset (orig);
#if defined (TARGET_TOC) /* i.e., PowerPC */
rtx hi_sum_reg;
@@ -860,7 +832,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
df_set_regs_ever_live (REGNO (pic), true);
pic_ref = gen_rtx_PLUS (Pmode,
pic,
- gen_pic_offset (orig, pic_base));
+ machopic_gen_offset (orig));
}
}
}
@@ -1064,27 +1036,12 @@ int
machopic_operand_p (rtx op)
{
if (MACHOPIC_JUST_INDIRECT)
- {
- while (GET_CODE (op) == CONST)
- op = XEXP (op, 0);
-
- if (GET_CODE (op) == SYMBOL_REF)
- return machopic_symbol_defined_p (op);
- else
- return 0;
- }
-
- while (GET_CODE (op) == CONST)
- op = XEXP (op, 0);
-
- if (GET_CODE (op) == MINUS
- && GET_CODE (XEXP (op, 0)) == SYMBOL_REF
- && GET_CODE (XEXP (op, 1)) == SYMBOL_REF
- && machopic_symbol_defined_p (XEXP (op, 0))
- && machopic_symbol_defined_p (XEXP (op, 1)))
- return 1;
-
- return 0;
+ return (GET_CODE (op) == SYMBOL_REF
+ && machopic_symbol_defined_p (op));
+ else
+ return (GET_CODE (op) == CONST
+ && GET_CODE (XEXP (op, 0)) == UNSPEC
+ && XINT (XEXP (op, 0), 1) == UNSPEC_MACHOPIC_OFFSET);
}
/* This function records whether a given name corresponds to a defined