Commit b069de3b by Stan Shebs Committed by Stan Shebs

config.gcc (i[34567]86-*-darwin*): New configuration.

        * config.gcc (i[34567]86-*-darwin*): New configuration.
        * config/darwin.h (TARGET_ENCODE_SECTION_INFO): Undefine before
        defining.
        (TARGET_ENCODE_SECTION_INFO): Ditto.
        (ASM_PREFERRED_EH_DATA_FORMAT): Ditto.
        * config/darwin.c (machopic_indirect_data_reference): Remove
        setting of RTX_UNCHANGING_P.
        (machopic_legitimize_pic_address): Move RTX_UNCHANGING_P up so as
        * config/i386/t-darwin: New file.
        * config/i386/darwin.h: New file.
        * config/i386/i386.h (TARGET_MACHO): Add default definition.
        * config/i386/i386.md (tablejump): Add TARGET_MACHO case.
        * config/i386/i386.c (output_set_got): For Mach-O, output Mach-O
        label and not the GOT add.
        (constant_address_p): For Mach-O, seeing a CONST is enough.
        (legitimate_pic_address_disp_p): Add a Mach-O case.
        (legitimate_address_p): Also test machopic_operand_p if Mach-O.
        (legitimize_pic_address): Use generic Mach-O code to legitimize.
        (output_pic_addr_const): Suppress @PLT if Mach-O, and parens
        if outputting a difference.
        (ix86_output_addr_diff_elt): Add Mach-O case.
        (ix86_expand_move): Similarly.
        (ix86_expand_call): Similarly.
        (current_machopic_label_num): New global.
        (machopic_output_stub): New function.
        (ix86_value_regno): New function.
        (ix86_function_value): Use it instead of VALUE_REGNO.
        (ix86_libcall_value): Ditto.
        * config/i386/unix.h (VALUE_REGNO): Remove.

From-SVN: r55916
parent b3a646eb
2002-07-31 Stan Shebs <shebs@apple.com>
* config.gcc (i[34567]86-*-darwin*): New configuration.
* config/darwin.h (TARGET_ENCODE_SECTION_INFO): Undefine before
defining.
(TARGET_ENCODE_SECTION_INFO): Ditto.
(ASM_PREFERRED_EH_DATA_FORMAT): Ditto.
* config/darwin.c (machopic_indirect_data_reference): Remove
setting of RTX_UNCHANGING_P.
(machopic_legitimize_pic_address): Move RTX_UNCHANGING_P up so as
not to be applied to sums.
* config/i386/t-darwin: New file.
* config/i386/darwin.h: New file.
* config/i386/i386.h (TARGET_MACHO): Add default definition.
* config/i386/i386.md (tablejump): Add TARGET_MACHO case.
* config/i386/i386.c (output_set_got): For Mach-O, output Mach-O
label and not the GOT add.
(constant_address_p): For Mach-O, seeing a CONST is enough.
(legitimate_pic_address_disp_p): Add a Mach-O case.
(legitimate_address_p): Also test machopic_operand_p if Mach-O.
(legitimize_pic_address): Use generic Mach-O code to legitimize.
(output_pic_addr_const): Suppress @PLT if Mach-O, and parens
if outputting a difference.
(ix86_output_addr_diff_elt): Add Mach-O case.
(ix86_expand_move): Similarly.
(ix86_expand_call): Similarly.
(current_machopic_label_num): New global.
(machopic_output_stub): New function.
(ix86_value_regno): New function.
(ix86_function_value): Use it instead of VALUE_REGNO.
(ix86_libcall_value): Ditto.
* config/i386/unix.h (VALUE_REGNO): Remove.
2002-07-31 Graham Stott <grahas@btinternet.com> 2002-07-31 Graham Stott <grahas@btinternet.com>
* config/rs6000/rs6000.c(rs6000_hash_constant): Fix * config/rs6000/rs6000.c(rs6000_hash_constant): Fix
......
...@@ -998,6 +998,18 @@ i370-*-linux*) ...@@ -998,6 +998,18 @@ i370-*-linux*)
thread_file='posix' thread_file='posix'
fi fi
;; ;;
i[34567]86-*-darwin*)
tm_file="${tm_file} darwin.h i386/darwin.h"
tm_p_file="${tm_p_file} darwin-protos.h"
tmake_file=i386/t-darwin
extra_objs="darwin.o"
target_gtfiles="\$(srcdir)/config/darwin.c"
c_target_objs="darwin-c.o"
cxx_target_objs="darwin-c.o"
# Darwin linker does collect2 functionality
use_collect2=no
float_format=i386
;;
i[34567]86-*-elf*) i[34567]86-*-elf*)
xm_defines=POSIX xm_defines=POSIX
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h" tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h"
......
...@@ -491,9 +491,6 @@ machopic_indirect_data_reference (orig, reg) ...@@ -491,9 +491,6 @@ machopic_indirect_data_reference (orig, reg)
else else
result = gen_rtx (PLUS, Pmode, base, orig); result = gen_rtx (PLUS, Pmode, base, orig);
if (RTX_UNCHANGING_P (base) && RTX_UNCHANGING_P (orig))
RTX_UNCHANGING_P (result) = 1;
if (MACHOPIC_JUST_INDIRECT && GET_CODE (base) == MEM) if (MACHOPIC_JUST_INDIRECT && GET_CODE (base) == MEM)
{ {
if (reg) if (reg)
...@@ -665,10 +662,10 @@ machopic_legitimize_pic_address (orig, mode, reg) ...@@ -665,10 +662,10 @@ machopic_legitimize_pic_address (orig, mode, reg)
} }
#if !defined (TARGET_TOC) #if !defined (TARGET_TOC)
RTX_UNCHANGING_P (pic_ref) = 1;
emit_move_insn (reg, pic_ref); emit_move_insn (reg, pic_ref);
pic_ref = gen_rtx (MEM, GET_MODE (orig), reg); pic_ref = gen_rtx (MEM, GET_MODE (orig), reg);
#endif #endif
RTX_UNCHANGING_P (pic_ref) = 1;
} }
else else
{ {
...@@ -700,6 +697,7 @@ machopic_legitimize_pic_address (orig, mode, reg) ...@@ -700,6 +697,7 @@ machopic_legitimize_pic_address (orig, mode, reg)
gen_rtx (LO_SUM, Pmode, gen_rtx (LO_SUM, Pmode,
hi_sum_reg, offset))); hi_sum_reg, offset)));
pic_ref = reg; pic_ref = reg;
RTX_UNCHANGING_P (pic_ref) = 1;
#else #else
emit_insn (gen_rtx (SET, VOIDmode, reg, emit_insn (gen_rtx (SET, VOIDmode, reg,
gen_rtx (HIGH, Pmode, offset))); gen_rtx (HIGH, Pmode, offset)));
...@@ -707,6 +705,7 @@ machopic_legitimize_pic_address (orig, mode, reg) ...@@ -707,6 +705,7 @@ machopic_legitimize_pic_address (orig, mode, reg)
gen_rtx (LO_SUM, Pmode, reg, offset))); gen_rtx (LO_SUM, Pmode, reg, offset)));
pic_ref = gen_rtx (PLUS, Pmode, pic_ref = gen_rtx (PLUS, Pmode,
pic_offset_table_rtx, reg); pic_offset_table_rtx, reg);
RTX_UNCHANGING_P (pic_ref) = 1;
#endif #endif
} }
else else
...@@ -737,8 +736,6 @@ machopic_legitimize_pic_address (orig, mode, reg) ...@@ -737,8 +736,6 @@ machopic_legitimize_pic_address (orig, mode, reg)
} }
} }
RTX_UNCHANGING_P (pic_ref) = 1;
if (GET_CODE (pic_ref) != REG) if (GET_CODE (pic_ref) != REG)
{ {
if (reg != 0) if (reg != 0)
......
...@@ -548,7 +548,9 @@ enum machopic_addr_class { ...@@ -548,7 +548,9 @@ enum machopic_addr_class {
#define MACHOPIC_JUST_INDIRECT (flag_pic == 1) #define MACHOPIC_JUST_INDIRECT (flag_pic == 1)
#define MACHOPIC_PURE (flag_pic == 2) #define MACHOPIC_PURE (flag_pic == 2)
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info
#undef TARGET_STRIP_NAME_ENCODING
#define TARGET_STRIP_NAME_ENCODING darwin_strip_name_encoding #define TARGET_STRIP_NAME_ENCODING darwin_strip_name_encoding
#define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \ #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \
...@@ -611,6 +613,7 @@ enum machopic_addr_class { ...@@ -611,6 +613,7 @@ enum machopic_addr_class {
#define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
#undef ASM_PREFERRED_EH_DATA_FORMAT
#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
(((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr) (((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
......
/* Target definitions for x86 running Darwin.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Enable Mach-O bits in generic x86 code. */
#undef TARGET_MACHO
#define TARGET_MACHO 1
#define TARGET_VERSION fprintf (stderr, " (i386 Darwin)");
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("__i386__"); \
builtin_define ("__LITTLE_ENDIAN__"); \
builtin_define ("__MACH__"); \
builtin_define ("__APPLE__"); \
} \
while (0)
/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. */
#undef CC1_SPEC
#define CC1_SPEC "%{!static:-fPIC}"
/* The Darwin assembler mostly follows AT&T syntax. */
#undef ASSEMBLER_DIALECT
#define ASSEMBLER_DIALECT ASM_ATT
/* Define macro used to output shift-double opcodes when the shift
count is in %cl. Some assemblers require %cl as an argument;
some don't. This macro controls what to do: by default, don't
print %cl. */
#define SHIFT_DOUBLE_OMITS_COUNT 0
/* Define the syntax of pseudo-ops, labels and comments. */
/* String containing the assembler's comment-starter. */
#define ASM_COMMENT_START "#"
/* By default, target has a 80387, uses IEEE compatible arithmetic,
and returns float values in the 387. */
#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS)
/* TARGET_DEEP_BRANCH_PREDICTION is incompatible with Mach-O PIC. */
#undef TARGET_DEEP_BRANCH_PREDICTION
#define TARGET_DEEP_BRANCH_PREDICTION 0
/* Define the syntax of pseudo-ops, labels and comments. */
#define LPREFIX "L"
/* This definition is unlikely to be used, but provide it just in
case. */
#define USER_LABEL_PREFIX "_"
/* Assembler pseudos to introduce constants of various size. */
#define ASM_BYTE_OP "\t.byte\t"
#define ASM_SHORT "\t.word\t"
#define ASM_LONG "\t.long\t"
/* Darwin as doesn't do ".quad". */
#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
do { if ((LOG) != 0) \
if (in_text_section () \
) \
fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
else \
fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
} while (0)
/* This says how to output an assembler line
to define a global common symbol. */
#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
( fputs (".comm ", (FILE)), \
assemble_name ((FILE), (NAME)), \
fprintf ((FILE), ",%u\n", (ROUNDED)))
/* This says how to output an assembler line
to define a local common symbol. */
#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
( fputs (".lcomm ", (FILE)), \
assemble_name ((FILE), (NAME)), \
fprintf ((FILE), ",%u\n", (ROUNDED)))
/* Darwin profiling -- call mcount. */
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO) \
do { \
if (MACHOPIC_INDIRECT) \
{ \
const char *name = machopic_stub_name ("*mcount"); \
fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \
machopic_validate_stub_or_non_lazy_ptr (name, /*stub:*/1); \
} \
else fprintf (FILE, "\tcall mcount\n"); \
} while (0)
...@@ -744,6 +744,7 @@ static int ix86_comp_type_attributes PARAMS ((tree, tree)); ...@@ -744,6 +744,7 @@ static int ix86_comp_type_attributes PARAMS ((tree, tree));
const struct attribute_spec ix86_attribute_table[]; const struct attribute_spec ix86_attribute_table[];
static tree ix86_handle_cdecl_attribute PARAMS ((tree *, tree, tree, int, bool *)); static tree ix86_handle_cdecl_attribute PARAMS ((tree *, tree, tree, int, bool *));
static tree ix86_handle_regparm_attribute PARAMS ((tree *, tree, tree, int, bool *)); static tree ix86_handle_regparm_attribute PARAMS ((tree *, tree, tree, int, bool *));
static int ix86_value_regno PARAMS ((enum machine_mode));
#if defined (DO_GLOBAL_CTORS_BODY) && defined (HAS_INIT_SECTION) #if defined (DO_GLOBAL_CTORS_BODY) && defined (HAS_INIT_SECTION)
static void ix86_svr3_asm_out_constructor PARAMS ((rtx, int)); static void ix86_svr3_asm_out_constructor PARAMS ((rtx, int));
...@@ -2235,7 +2236,8 @@ ix86_function_value (valtype) ...@@ -2235,7 +2236,8 @@ ix86_function_value (valtype)
return ret; return ret;
} }
else else
return gen_rtx_REG (TYPE_MODE (valtype), VALUE_REGNO (TYPE_MODE (valtype))); return gen_rtx_REG (TYPE_MODE (valtype),
ix86_value_regno (TYPE_MODE (valtype)));
} }
/* Return false iff type is returned in memory. */ /* Return false iff type is returned in memory. */
...@@ -2285,7 +2287,20 @@ ix86_libcall_value (mode) ...@@ -2285,7 +2287,20 @@ ix86_libcall_value (mode)
} }
} }
else else
return gen_rtx_REG (mode, VALUE_REGNO (mode)); return gen_rtx_REG (mode, ix86_value_regno (mode));
}
/* Given a mode, return the register to use for a return value. */
static int
ix86_value_regno (mode)
enum machine_mode mode;
{
if (GET_MODE_CLASS (mode) == MODE_FLOAT && TARGET_FLOAT_RETURNS_IN_80387)
return FIRST_FLOAT_REG;
if (mode == TImode || VECTOR_MODE_P (mode))
return FIRST_SSE_REG;
return 0;
} }
/* Create the va_list data type. */ /* Create the va_list data type. */
...@@ -3950,6 +3965,11 @@ output_set_got (dest) ...@@ -3950,6 +3965,11 @@ output_set_got (dest)
else else
output_asm_insn ("call\t%a2", xops); output_asm_insn ("call\t%a2", xops);
#if TARGET_MACHO
/* Output the "canonical" label name ("Lxx$pb") here too. This
is what will be referred to by the Mach-O PIC subsystem. */
ASM_OUTPUT_LABEL (asm_out_file, machopic_function_base_name ());
#endif
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
CODE_LABEL_NUMBER (XEXP (xops[2], 0))); CODE_LABEL_NUMBER (XEXP (xops[2], 0)));
...@@ -3969,7 +3989,7 @@ output_set_got (dest) ...@@ -3969,7 +3989,7 @@ output_set_got (dest)
if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION) if (!flag_pic || TARGET_DEEP_BRANCH_PREDICTION)
output_asm_insn ("add{l}\t{%1, %0|%0, %1}", xops); output_asm_insn ("add{l}\t{%1, %0|%0, %1}", xops);
else else if (!TARGET_MACHO)
output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %a1+(.-%a2)}", xops); output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %a1+(.-%a2)}", xops);
return ""; return "";
...@@ -4861,6 +4881,10 @@ constant_address_p (x) ...@@ -4861,6 +4881,10 @@ constant_address_p (x)
return TARGET_64BIT; return TARGET_64BIT;
case CONST: case CONST:
/* For Mach-O, really believe the CONST. */
if (TARGET_MACHO)
return true;
/* Otherwise fall through. */
case SYMBOL_REF: case SYMBOL_REF:
return !flag_pic && legitimate_constant_p (x); return !flag_pic && legitimate_constant_p (x);
...@@ -4959,6 +4983,19 @@ legitimate_pic_address_disp_p (disp) ...@@ -4959,6 +4983,19 @@ legitimate_pic_address_disp_p (disp)
saw_plus = true; saw_plus = true;
} }
/* Allow {LABEL | SYMBOL}_REF - SYMBOL_REF-FOR-PICBASE for Mach-O. */
if (TARGET_MACHO && GET_CODE (disp) == MINUS)
{
if (GET_CODE (XEXP (disp, 0)) == LABEL_REF
|| GET_CODE (XEXP (disp, 0)) == SYMBOL_REF)
if (GET_CODE (XEXP (disp, 1)) == SYMBOL_REF)
{
const char *sym_name = XSTR (XEXP (disp, 1), 0);
if (strstr (sym_name, "$pb") != 0)
return 1;
}
}
if (GET_CODE (disp) != UNSPEC) if (GET_CODE (disp) != UNSPEC)
return 0; return 0;
...@@ -5160,7 +5197,11 @@ legitimate_address_p (mode, addr, strict) ...@@ -5160,7 +5197,11 @@ legitimate_address_p (mode, addr, strict)
goto report_error; goto report_error;
} }
else if (flag_pic && SYMBOLIC_CONST (disp)) else if (flag_pic && (SYMBOLIC_CONST (disp)
#if TARGET_MACHO
&& !machopic_operand_p (disp)
#endif
))
{ {
is_legitimate_pic: is_legitimate_pic:
if (TARGET_64BIT && (index || base)) if (TARGET_64BIT && (index || base))
...@@ -5255,6 +5296,13 @@ legitimize_pic_address (orig, reg) ...@@ -5255,6 +5296,13 @@ legitimize_pic_address (orig, reg)
rtx new = orig; rtx new = orig;
rtx base; rtx base;
#if TARGET_MACHO
if (reg == 0)
reg = gen_reg_rtx (Pmode);
/* Use the generic Mach-O PIC machinery. */
return machopic_legitimize_pic_address (orig, GET_MODE (orig), reg);
#endif
if (local_symbolic_operand (addr, Pmode)) if (local_symbolic_operand (addr, Pmode))
{ {
/* In 64bit mode we can address such objects directly. */ /* In 64bit mode we can address such objects directly. */
...@@ -5767,7 +5815,7 @@ output_pic_addr_const (file, x, code) ...@@ -5767,7 +5815,7 @@ output_pic_addr_const (file, x, code)
case SYMBOL_REF: case SYMBOL_REF:
assemble_name (file, XSTR (x, 0)); assemble_name (file, XSTR (x, 0));
if (code == 'P' && ! SYMBOL_REF_FLAG (x)) if (!TARGET_MACHO && code == 'P' && ! SYMBOL_REF_FLAG (x))
fputs ("@PLT", file); fputs ("@PLT", file);
break; break;
...@@ -5825,11 +5873,13 @@ output_pic_addr_const (file, x, code) ...@@ -5825,11 +5873,13 @@ output_pic_addr_const (file, x, code)
break; break;
case MINUS: case MINUS:
putc (ASSEMBLER_DIALECT == ASM_INTEL ? '(' : '[', file); if (!TARGET_MACHO)
putc (ASSEMBLER_DIALECT == ASM_INTEL ? '(' : '[', file);
output_pic_addr_const (file, XEXP (x, 0), code); output_pic_addr_const (file, XEXP (x, 0), code);
putc ('-', file); putc ('-', file);
output_pic_addr_const (file, XEXP (x, 1), code); output_pic_addr_const (file, XEXP (x, 1), code);
putc (ASSEMBLER_DIALECT == ASM_INTEL ? ')' : ']', file); if (!TARGET_MACHO)
putc (ASSEMBLER_DIALECT == ASM_INTEL ? ')' : ']', file);
break; break;
case UNSPEC: case UNSPEC:
...@@ -7266,6 +7316,11 @@ ix86_output_addr_diff_elt (file, value, rel) ...@@ -7266,6 +7316,11 @@ ix86_output_addr_diff_elt (file, value, rel)
ASM_LONG, LPREFIX, value, LPREFIX, rel); ASM_LONG, LPREFIX, value, LPREFIX, rel);
else if (HAVE_AS_GOTOFF_IN_DATA) else if (HAVE_AS_GOTOFF_IN_DATA)
fprintf (file, "%s%s%d@GOTOFF\n", ASM_LONG, LPREFIX, value); fprintf (file, "%s%s%d@GOTOFF\n", ASM_LONG, LPREFIX, value);
#if TARGET_MACHO
else if (TARGET_MACHO)
fprintf (file, "%s%s%d-%s\n", ASM_LONG, LPREFIX, value,
machopic_function_base_name () + 1);
#endif
else else
asm_fprintf (file, "%s%U_GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", asm_fprintf (file, "%s%U_GLOBAL_OFFSET_TABLE_+[.-%s%d]\n",
ASM_LONG, LPREFIX, value); ASM_LONG, LPREFIX, value);
...@@ -7378,6 +7433,29 @@ ix86_expand_move (mode, operands) ...@@ -7378,6 +7433,29 @@ ix86_expand_move (mode, operands)
} }
else if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode)) else if (flag_pic && mode == Pmode && symbolic_operand (op1, Pmode))
{ {
#if TARGET_MACHO
if (MACHOPIC_PURE)
{
rtx temp = ((reload_in_progress
|| ((op0 && GET_CODE (op0) == REG)
&& mode == Pmode))
? op0 : gen_reg_rtx (Pmode));
op1 = machopic_indirect_data_reference (op1, temp);
op1 = machopic_legitimize_pic_address (op1, mode,
temp == op1 ? 0 : temp);
}
else
{
if (MACHOPIC_INDIRECT)
op1 = machopic_indirect_data_reference (op1, 0);
}
if (op0 != op1)
{
insn = gen_rtx_SET (VOIDmode, op0, op1);
emit_insn (insn);
}
return;
#endif /* TARGET_MACHO */
if (GET_CODE (op0) == MEM) if (GET_CODE (op0) == MEM)
op1 = force_reg (Pmode, op1); op1 = force_reg (Pmode, op1);
else else
...@@ -10495,6 +10573,10 @@ ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop) ...@@ -10495,6 +10573,10 @@ ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop)
if (TARGET_64BIT && pop) if (TARGET_64BIT && pop)
abort (); abort ();
#if TARGET_MACHO
if (flag_pic && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF)
fnaddr = machopic_indirect_call_target (fnaddr);
#else
/* Static functions and indirect calls don't need the pic register. */ /* Static functions and indirect calls don't need the pic register. */
if (! TARGET_64BIT && flag_pic if (! TARGET_64BIT && flag_pic
&& GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF
...@@ -10507,6 +10589,7 @@ ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop) ...@@ -10507,6 +10589,7 @@ ix86_expand_call (retval, fnaddr, callarg1, callarg2, pop)
emit_move_insn (al, callarg2); emit_move_insn (al, callarg2);
use_reg (&use, al); use_reg (&use, al);
} }
#endif /* TARGET_MACHO */
if (! call_insn_operand (XEXP (fnaddr, 0), Pmode)) if (! call_insn_operand (XEXP (fnaddr, 0), Pmode))
{ {
...@@ -13545,6 +13628,71 @@ ix86_svr3_asm_out_constructor (symbol, priority) ...@@ -13545,6 +13628,71 @@ ix86_svr3_asm_out_constructor (symbol, priority)
} }
#endif #endif
#if TARGET_MACHO
static int current_machopic_label_num;
/* Given a symbol name and its associated stub, write out the
definition of the stub. */
void
machopic_output_stub (file, symb, stub)
FILE *file;
const char *symb, *stub;
{
unsigned int length;
char *binder_name, *symbol_name, lazy_ptr_name[32];
int label = ++current_machopic_label_num;
/* Lose our funky encoding stuff so it doesn't contaminate the stub. */
symb = (*targetm.strip_name_encoding) (symb);
length = strlen (stub);
binder_name = alloca (length + 32);
GEN_BINDER_NAME_FOR_STUB (binder_name, stub, length);
length = strlen (symb);
symbol_name = alloca (length + 32);
GEN_SYMBOL_NAME_FOR_SYMBOL (symbol_name, symb, length);
sprintf (lazy_ptr_name, "L%d$lz", label);
if (MACHOPIC_PURE)
machopic_picsymbol_stub_section ();
else
machopic_symbol_stub_section ();
fprintf (file, "%s:\n", stub);
fprintf (file, "\t.indirect_symbol %s\n", symbol_name);
if (MACHOPIC_PURE)
{
fprintf (file, "\tcall LPC$%d\nLPC$%d:\tpopl %%eax\n", label, label);
fprintf (file, "\tmovl %s-LPC$%d(%%eax),%%edx\n", lazy_ptr_name, label);
fprintf (file, "\tjmp %%edx\n");
}
else
fprintf (file, "\tjmp *%s\n", lazy_ptr_name);
fprintf (file, "%s:\n", binder_name);
if (MACHOPIC_PURE)
{
fprintf (file, "\tlea %s-LPC$%d(%%eax),%%eax\n", lazy_ptr_name, label);
fprintf (file, "\tpushl %%eax\n");
}
else
fprintf (file, "\t pushl $%s\n", lazy_ptr_name);
fprintf (file, "\tjmp dyld_stub_binding_helper\n");
machopic_lazy_symbol_ptr_section ();
fprintf (file, "%s:\n", lazy_ptr_name);
fprintf (file, "\t.indirect_symbol %s\n", symbol_name);
fprintf (file, "\t.long %s\n", binder_name);
}
#endif /* TARGET_MACHO */
/* Order the registers for register allocator. */ /* Order the registers for register allocator. */
void void
......
...@@ -383,6 +383,11 @@ extern int x86_prefetch_sse; ...@@ -383,6 +383,11 @@ extern int x86_prefetch_sse;
the frame pointer in leaf functions. */ the frame pointer in leaf functions. */
#define TARGET_DEFAULT 0 #define TARGET_DEFAULT 0
/* This is not really a target flag, but is done this way so that
it's analogous to similar code for Mach-O on PowerPC. darwin.h
redefines this to 1. */
#define TARGET_MACHO 0
/* This macro is similar to `TARGET_SWITCHES' but defines names of /* This macro is similar to `TARGET_SWITCHES' but defines names of
command options that have values. Its definition is an command options that have values. Its definition is an
initializer with a subgrouping for each command option. initializer with a subgrouping for each command option.
......
...@@ -13141,7 +13141,7 @@ ...@@ -13141,7 +13141,7 @@
op0 = operands[0]; op0 = operands[0];
op1 = gen_rtx_LABEL_REF (Pmode, operands[1]); op1 = gen_rtx_LABEL_REF (Pmode, operands[1]);
} }
else if (HAVE_AS_GOTOFF_IN_DATA) else if (TARGET_MACHO || HAVE_AS_GOTOFF_IN_DATA)
{ {
code = PLUS; code = PLUS;
op0 = operands[0]; op0 = operands[0];
......
darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) $(RTL_BASE_H) \
$(REGS_H) hard-reg-set.h insn-config.h conditions.h output.h \
insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h \
function.h $(GGC_H) $(TM_P_H) gt-darwin.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(C_TREE_H) c-pragma.h toplev.h cpplib.h $(TM_P_H)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
gt-darwin.h : s-gtype ; @true
...@@ -66,14 +66,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -66,14 +66,6 @@ Boston, MA 02111-1307, USA. */
#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS) #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS)
/* Floating-point return values come in the FP register. */
#define VALUE_REGNO(MODE) \
(GET_MODE_CLASS (MODE) == MODE_FLOAT \
&& TARGET_FLOAT_RETURNS_IN_80387 ? FIRST_FLOAT_REG \
: (MODE) == TImode || VECTOR_MODE_P (MODE) ? FIRST_SSE_REG \
: 0)
/* Output code to add DELTA to the first argument, and then jump to FUNCTION. /* Output code to add DELTA to the first argument, and then jump to FUNCTION.
Used for C++ multiple inheritance. */ Used for C++ multiple inheritance. */
#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \ #define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment