+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.
2003-03-10 Devang Patel <dpatel@apple.com>
check_function_return_warnings up to just after
delete_unreachable_blocks.
-
2003-03-10 Stephane Carrez <stcarrez@nerim.fr>
* config/m68hc11/m68hc11.h (HARD_REGNO_RENAME_OK): Define.
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)
{
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,
{
rtx pic_ref = orig;
- if (! MACHOPIC_PURE)
+ if (! MACHOPIC_INDIRECT)
return orig;
/* First handle a simple SYMBOL_REF or LABEL_REF */
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)
}
#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)
{
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,
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 ();
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 ();
}
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 ();
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");
}
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");
}
#define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
do { \
if (FILE) { \
- if (flag_pic) \
+ if (MACHOPIC_INDIRECT) \
fprintf (FILE, "\t.lazy_reference "); \
else \
fprintf (FILE, "\t.reference "); \
/* Macros defining the various PIC cases. */
-#define MACHOPIC_INDIRECT (flag_pic)
-#define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
-#define MACHOPIC_PURE (flag_pic == 2)
+#define MACHO_DYNAMIC_NO_PIC_P (TARGET_DYNAMIC_NO_PIC)
+#define MACHOPIC_INDIRECT (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
+#define MACHOPIC_JUST_INDIRECT (flag_pic == 1 || MACHO_DYNAMIC_NO_PIC_P)
+#define MACHOPIC_PURE (flag_pic == 2 && ! MACHO_DYNAMIC_NO_PIC_P)
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info
#undef TARGET_DEEP_BRANCH_PREDICTION
#define TARGET_DEEP_BRANCH_PREDICTION 0
+/* For now, disable dynamic-no-pic. We'll need to go through i386.c
+ with a fine-tooth comb looking for refs to flag_pic! */
+#define MASK_MACHO_DYNAMIC_NO_PIC 0
+#define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
+
/* Define the syntax of pseudo-ops, labels and comments. */
#define LPREFIX "L"
#define TARGET_TOC 0
#define TARGET_NO_TOC 1
+/* Darwin switches. */
+/* Use dynamic-no-pic codegen (no picbase reg; not suitable for shlibs.) */
+#define MASK_MACHO_DYNAMIC_NO_PIC 0x00800000
+
+#define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
+
/* Handle #pragma weak and #pragma pack. */
#define HANDLE_SYSV_PRAGMA 1
-/* The Darwin ABI always includes AltiVec, can't be (validly) turned
- off. */
-
-#define SUBTARGET_OVERRIDE_OPTIONS \
- rs6000_altivec_abi = 1;
#define TARGET_OS_CPP_BUILTINS() \
do \
} \
while (0)
+
+/* */
+#undef SUBTARGET_SWITCHES
+#define SUBTARGET_SWITCHES \
+ {"dynamic-no-pic", MASK_MACHO_DYNAMIC_NO_PIC, \
+ N_("Generate code suitable for executables (NOT shared libs)")}, \
+ {"no-dynamic-no-pic", -MASK_MACHO_DYNAMIC_NO_PIC, ""},
+
+
+/* The Darwin ABI always includes AltiVec, can't be (validly) turned
+ off. */
+
+#define SUBTARGET_OVERRIDE_OPTIONS \
+do { \
+ rs6000_altivec_abi = 1; \
+ if (DEFAULT_ABI == ABI_DARWIN) \
+ { \
+ if (MACHO_DYNAMIC_NO_PIC_P) \
+ { \
+ if (flag_pic) \
+ warning ("-mdynamic-no-pic overrides -fpic or -fPIC"); \
+ flag_pic = 0; \
+ } \
+ else if (flag_pic == 1) \
+ { \
+ /* Darwin doesn't support -fpic. */ \
+ warning ("-fpic is not supported; -fPIC assumed"); \
+ flag_pic = 2; \
+ } \
+ } \
+}while(0)
+
/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. */
+
#define CC1_SPEC "\
%{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
-%{!static:-fPIC}"
+%{!static:%{!mdynamic-no-pic:-fPIC}}"
/* Make both r2 and r3 available for allocation. */
#define FIXED_R2 0
flag_pic = 0;
}
- /* For Darwin, always silently make -fpic and -fPIC identical. */
- if (flag_pic == 1 && DEFAULT_ABI == ABI_DARWIN)
- flag_pic = 2;
-
/* Set debug flags */
if (rs6000_debug_name)
{
}
else if (TARGET_MACHO && TARGET_32BIT && TARGET_NO_TOC
&& ! flag_pic
+#if TARGET_MACHO
+ && ! MACHO_DYNAMIC_NO_PIC_P
+#endif
&& GET_CODE (x) != CONST_INT
&& GET_CODE (x) != CONST_DOUBLE
&& CONSTANT_P (x)
*win = 1;
return x;
}
+ if (GET_CODE (x) == SYMBOL_REF
+ && DEFAULT_ABI == ABI_DARWIN
+ && !ALTIVEC_VECTOR_MODE (mode)
+ && MACHO_DYNAMIC_NO_PIC_P)
+ {
+ /* Darwin load of floating point constant. */
+ x = gen_rtx (LO_SUM, GET_MODE (x),
+ gen_rtx (HIGH, Pmode, x), x);
+ push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
+ BASE_REG_CLASS, Pmode, VOIDmode, 0, 0,
+ opnum, (enum reload_type)type);
+ *win = 1;
+ return x;
+ }
#endif
if (TARGET_TOC
&& CONSTANT_POOL_EXPR_P (x)
if (DEFAULT_ABI == ABI_DARWIN)
{
+#if TARGET_MACHO
+ if (MACHO_DYNAMIC_NO_PIC_P)
+ {
+ /* Take care of any required data indirection. */
+ operands[1] = rs6000_machopic_legitimize_pic_address (
+ operands[1], mode, operands[0]);
+ if (operands[0] != operands[1])
+ emit_insn (gen_rtx_SET (VOIDmode,
+ operands[0], operands[1]));
+ return;
+ }
+#endif
emit_insn (gen_macho_high (target, operands[1]));
emit_insn (gen_macho_low (operands[0], target, operands[1]));
return;
#if TARGET_MACHO
/* Darwin uses a special PIC legitimizer. */
- if (DEFAULT_ABI == ABI_DARWIN && flag_pic)
+ if (DEFAULT_ABI == ABI_DARWIN && MACHOPIC_INDIRECT)
{
operands[1] =
rs6000_machopic_legitimize_pic_address (operands[1], mode,
{
int regno;
- if (TARGET_ELF || (DEFAULT_ABI == ABI_DARWIN && flag_pic))
+ if (TARGET_ELF || (DEFAULT_ABI == ABI_DARWIN
+#if TARGET_MACHO
+ && MACHOPIC_INDIRECT
+#endif
+ ))
{
/* We cannot copy a symbolic operand directly into anything
other than BASE_REGS for TARGET_ELF. So indicate that a
funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
#if TARGET_MACHO
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
funexp = machopic_indirect_call_target (funexp);
#endif
#if TARGET_MACHO
/* For PIC code, set up a stub and collect the caller's address
from r0, which is where the prologue puts it. */
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
{
mcount_name = machopic_stub_name (mcount_name);
if (current_function_uses_pic_offset_table)
fprintf (file, "\tbctr\n");
}
else
- fprintf (file, "non-pure not supported\n");
+ {
+ fprintf (file, "\tlis r11,ha16(%s)\n", lazy_ptr_name);
+ fprintf (file, "\tlwzu r12,lo16(%s)(r11)\n", lazy_ptr_name);
+ fprintf (file, "\tmtctr r12\n");
+ fprintf (file, "\tbctr\n");
+ }
machopic_lazy_symbol_ptr_section ();
fprintf (file, "%s:\n", lazy_ptr_name);
operands2[2] = operands[2];
operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
+#if TARGET_MACHO
+ if (MACHO_DYNAMIC_NO_PIC_P)
+ output_asm_insn (\"{liu|lis} %L0,ha16(%2+4)\", operands);
+ else
/* We cannot rely on ha16(low half)==ha16(high half), alas,
although in practice it almost always is. */
output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
+#endif
return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
}
default:
"
{
#if TARGET_MACHO
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
operands[0] = machopic_indirect_call_target (operands[0]);
#endif
"
{
#if TARGET_MACHO
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
operands[1] = machopic_indirect_call_target (operands[1]);
#endif
"
{
#if TARGET_MACHO
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
operands[0] = machopic_indirect_call_target (operands[0]);
#endif
"
{
#if TARGET_MACHO
- if (flag_pic)
+ if (MACHOPIC_INDIRECT)
operands[1] = machopic_indirect_call_target (operands[1]);
#endif
-mstrict-align -mno-strict-align -mrelocatable @gol
-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
+-mdynamic-no-pic @gol
-mcall-aix -mcall-sysv -mcall-netbsd @gol
-maix-struct-return -msvr4-struct-return @gol
-mabi=altivec -mabi=no-altivec @gol
processor in big endian mode. The @option{-mbig-endian} option is
the same as @option{-mbig}.
+@item -mdynamic-no-pic
+@opindex mdynamic-no-pic
+On Darwin and Mac OS X systems, compile code so that it is not
+relocatable, but that its external references are relocatable. The
+resulting code is suitable for applications, but not shared
+libraries.
+
@item -mcall-sysv
@opindex mcall-sysv
On System V.4 and embedded PowerPC systems compile code using calling