diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-11 01:41:11 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-11 01:41:11 +0000 |
commit | 8f74ae7bda1d0bece4773572f4d9d11a815c17f4 (patch) | |
tree | 0f526257c8b54faa7d71bb0a217a93ddc14bd8e0 /gcc/config/darwin.c | |
parent | bd58d49150ea48127a07d6f3b50d4c370c03d982 (diff) | |
download | gcc-8f74ae7bda1d0bece4773572f4d9d11a815c17f4.tar.gz |
2003-03-10 Andrew Pinski <apinski@apple.com>
* config/darwin.c (machopic_function_base_name): If dynamic-no-pic
is on should not get here.
(machopic_indirect_data_reference): If dynamic-no-pic is on just
generate high/low parts of the address.
(machopic_legitimize_pic_address): Change MACHOPIC_PURE to
MACHOPIC_INDIRECT. Dynamic-no-pic uses 0 as the pic base. Generate
symbol and labels with a new reg. Dynamic-no-pic does not have a
pic_offset_table_rtx.
(machopic_select_section): Change references of flag_pic to
MACHOPIC_INDIRECT.
(machopic_asm_out_destructor): Likewise.
* config/darwin.h (ASM_DECLARE_UNRESOLVED_REFERENCE): Change
reference of flag_pic to MACHOPIC_INDIRECT.
(MACHO_DYNAMIC_NO_PIC_P): Define as TARGET_DYNAMIC_NO_PIC.
(MACHOPIC_INDIRECT): Is also true when dynamic-no-pic is on.
(MACHOPIC_JUST_INDIRECT): Is also true when dynamic-no-pic is on.
(MACHOPIC_PURE): Is not pure when dynamic-no-pic is on.
* config/i386/darwin.h (MASK_MACHO_DYNAMIC_NO_PIC): Define as
0 for right now as dynamic-no-pic is not implemented on Darwin/ia32.
* config/rs6000/darwin.h (MASK_MACHO_DYNAMIC_NO_PIC): Define.
(TARGET_DYNAMIC_NO_PIC): Define.
(SUBTARGET_SWITCHES): Define, have sub-target switches for
dynamic-no-pic.
(SUBTARGET_OVERRIDE_OPTIONS): Move check for -fpic from
rs6000_override_options to here. Dynamic-no-pic overrides
pic.
(CC1_SPEC): Change from not static then pic to not static and not
dynamic-no-pic then pic.
* config/rs6000/rs6000.c (rs6000_override_options): Move the
check for -fpic and DARWIN_ABI to config/rs6000/darwin.h
(rs6000_legitimize_reload_address): Add case for loading floating in
dynamic-no-pic.
(rs6000_emit_move): Add case for dynamic-no-pic. Change reference
of flag_pic to MACHOPIC_INDIRECT.
(secondary_reload_class): Conditional change the reference of
flag_pic to MACHOPIC_INDIRECT.
(rs6000_output_mi_thunk): Change reference of flag_pic to
MACHOPIC_INDIRECT.
(output_profile_hook): Likewise.
(machopic_output_stub): Non-pure (dynamic-no-pic) is now supported.
* config/rs6000/rs6000.md (movdf_low): Add the case for
MACHO_DYNAMIC_NO_PIC_P.
(call): Change references for flag_pic in TARGET_MACHO to
MACHOPIC_INDIRECT.
(SUBTARGET_OVERRIDE_OPTIONS): Add case where -fpic is on and
-mdynamic-no-pic is on. Also move case for -fpic from rs6000.c.
* doc/invoke.texi (-mdynamic-no-pic): Document.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64157 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/darwin.c')
-rw-r--r-- | gcc/config/darwin.c | 69 |
1 files changed, 59 insertions, 10 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 376f1fb0fe0..86b3425545a 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -231,6 +231,9 @@ machopic_function_base_name () static const char *name = NULL; static const char *current_name; + /* if dynamic-no-pic is on, we should not get here */ + if (MACHO_DYNAMIC_NO_PIC_P) + abort (); current_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); if (name != current_name) @@ -426,7 +429,20 @@ machopic_indirect_data_reference (orig, reg) { const char *name = XSTR (orig, 0); - if (machopic_data_defined_p (name)) + int defined = machopic_data_defined_p (name); + + if (defined && MACHO_DYNAMIC_NO_PIC_P) + { +#if defined (TARGET_TOC) + emit_insn (gen_macho_high (reg, orig)); + emit_insn (gen_macho_low (reg, reg, orig)); +#else + /* some other cpu -- writeme! */ + abort (); +#endif + return reg; + } + else if (defined) { #if defined (TARGET_TOC) || defined (HAVE_lo_sum) rtx pic_base = gen_rtx (SYMBOL_REF, Pmode, @@ -569,7 +585,7 @@ machopic_legitimize_pic_address (orig, mode, reg) { rtx pic_ref = orig; - if (! MACHOPIC_PURE) + if (! MACHOPIC_INDIRECT) return orig; /* First handle a simple SYMBOL_REF or LABEL_REF */ @@ -592,6 +608,10 @@ machopic_legitimize_pic_address (orig, mode, reg) return reg; } + /* if dynamic-no-pic then use 0 as the pic base */ + if (MACHO_DYNAMIC_NO_PIC_P) + pic_base = CONST0_RTX (Pmode); + else pic_base = gen_rtx (SYMBOL_REF, Pmode, machopic_function_base_name ()); if (GET_CODE (orig) == MEM) @@ -605,6 +625,27 @@ machopic_legitimize_pic_address (orig, mode, reg) } #ifdef HAVE_lo_sum + if (MACHO_DYNAMIC_NO_PIC_P + && (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF + || GET_CODE (XEXP (orig, 0)) == LABEL_REF)) + { +#if defined (TARGET_TOC) /* ppc */ + rtx temp_reg = (no_new_pseudos) ? reg : gen_reg_rtx (Pmode); + rtx asym = XEXP (orig, 0); + rtx mem; + + emit_insn (gen_macho_high (temp_reg, asym)); + mem = gen_rtx_MEM (GET_MODE (orig), + gen_rtx (LO_SUM, Pmode, temp_reg, asym)); + RTX_UNCHANGING_P (mem) = 1; + emit_insn (gen_rtx (SET, VOIDmode, reg, mem)); +#else + /* Some other CPU -- WriteMe! but right now there are no other platform that can use dynamic-no-pic */ + abort (); +#endif + pic_ref = reg; + } + else if (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF || GET_CODE (XEXP (orig, 0)) == LABEL_REF) { @@ -692,7 +733,9 @@ machopic_legitimize_pic_address (orig, mode, reg) hi_sum_reg = reg; emit_insn (gen_rtx (SET, Pmode, hi_sum_reg, - gen_rtx (PLUS, Pmode, + (MACHO_DYNAMIC_NO_PIC_P) + ? gen_rtx (HIGH, Pmode, offset) + : gen_rtx (PLUS, Pmode, pic_offset_table_rtx, gen_rtx (HIGH, Pmode, offset)))); emit_insn (gen_rtx (SET, VOIDmode, reg, @@ -1137,7 +1180,8 @@ machopic_select_section (exp, reloc, align) objc_string_object_section (); else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) { - if (TREE_SIDE_EFFECTS (exp) || (flag_pic && reloc)) + + if (TREE_SIDE_EFFECTS (exp) || (MACHOPIC_INDIRECT && reloc)) const_data_section (); else readonly_data_section (); @@ -1200,7 +1244,8 @@ machopic_select_section (exp, reloc, align) else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) && !TREE_SIDE_EFFECTS (exp)) { - if (flag_pic && reloc) + + if (MACHOPIC_INDIRECT && reloc) const_data_section (); else readonly_data_section (); @@ -1210,7 +1255,8 @@ machopic_select_section (exp, reloc, align) } else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) { - if (TREE_SIDE_EFFECTS (exp) || (flag_pic && reloc)) + + if (TREE_SIDE_EFFECTS (exp) || (MACHOPIC_INDIRECT && reloc)) const_data_section (); else readonly_data_section (); @@ -1243,14 +1289,16 @@ machopic_asm_out_constructor (symbol, priority) rtx symbol; int priority ATTRIBUTE_UNUSED; { - if (flag_pic) + + if (MACHOPIC_INDIRECT) mod_init_section (); else constructor_section (); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); - if (!flag_pic) + + if (! MACHOPIC_INDIRECT) fprintf (asm_out_file, ".reference .constructors_used\n"); } @@ -1259,14 +1307,15 @@ machopic_asm_out_destructor (symbol, priority) rtx symbol; int priority ATTRIBUTE_UNUSED; { - if (flag_pic) + + if (MACHOPIC_INDIRECT) mod_term_section (); else destructor_section (); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); - if (!flag_pic) + if (! MACHOPIC_INDIRECT) fprintf (asm_out_file, ".reference .destructors_used\n"); } |