Initial support for x86_64-darwin

Basic -fvia-C code generation is there, not much testing.
parent 08560cf0
......@@ -168,6 +168,10 @@ case $HostPlatform in
alpha-dec-osf*) fptools_cv_leading_underscore=no;;
*cygwin32) fptools_cv_leading_underscore=yes;;
*mingw32) fptools_cv_leading_underscore=yes;;
# HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries
x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;;
*) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
#include <nlist.h>
struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
......
......@@ -317,6 +317,15 @@ x86_64-*-linux*)
HostVendor_CPP='unknown'
HostOS_CPP='linux'
;;
x86_64-apple-darwin*)
HostPlatform=x86_64-apple-darwin
TargetPlatform=x86_64-apple-darwin
BuildPlatform=x86_64-apple-darwin
HostPlatform_CPP='x86_64_apple_darwin'
HostArch_CPP='x86_64'
HostVendor_CPP='apple'
HostOS_CPP='darwin'
;;
m68k-*-linux*)
HostPlatform=m68k-unknown-linux # hack again
TargetPlatform=m68k-unknown-linux
......
......@@ -96,6 +96,8 @@ x86_64-*-openbsd*)
TargetPlatform=x86_64-unknown-openbsd;;
x86_64-*-netbsd*)
TargetPlatform=x86_64-unknown-netbsd;;
x86_64-apple-darwin*)
TargetPlatform=x86_64-apple-darwin;;
*)
echo "Unrecognised platform: $TargetPlatform"
exit 1
......
......@@ -343,6 +343,32 @@ sub init_TARGET_STUFF {
$T_HDR_entry = "\t\.text\n\t\.align 2\n";
$T_HDR_vector = "\t\.text\n\t\.align 2\n";
#--------------------------------------------------------#
} elsif ( $TargetPlatform =~ /^x86_64-apple-darwin.*/ ) {
# Apple PowerPC Darwin/MacOS X.
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
$T_US = '_'; # _ if symbols have an underscore on the front
$T_PRE_APP = 'DOESNT APPLY'; # regexp that says what comes before APP/NO_APP
$T_CONST_LBL = '^\LC\d+:'; # regexp for what such a lbl looks like
$T_POST_LBL = ':';
$T_MOVE_DIRVS = '^(\s*(\.align \d+|\.text|\.data|\.const_data|\.cstring|\.non_lazy_symbol_pointer|\.const|\.static_const|\.literal4|\.literal8|\.static_data|\.globl \S+|\.section .*|\.lcomm.*)\n)';
$T_COPY_DIRVS = '\.(globl|lcomm)';
$T_DOT_WORD = '\.(quad|long|short|byte|fill|space)';
$T_DOT_GLOBAL = '\.globl';
$T_HDR_toc = "\.toc\n";
$T_HDR_literal16= "\t\.literal8\n\t\.align 4\n";
$T_HDR_literal = "\t\.const\n\t\.align 4\n";
$T_HDR_misc = "\t\.text\n\t\.align 2\n";
$T_HDR_data = "\t\.data\n\t\.align 2\n";
$T_HDR_rodata = "\t\.const\n\t\.align 2\n";
$T_HDR_relrodata= "\t\.const_data\n\t\.align 2\n";
$T_HDR_closure = "\t\.data\n\t\.align 2\n";
$T_HDR_info = "\t\.text\n\t\.align 2\n";
$T_HDR_entry = "\t\.text\n\t\.align 2\n";
$T_HDR_vector = "\t\.text\n\t\.align 2\n";
#--------------------------------------------------------#
} elsif ( $TargetPlatform =~ /^powerpc-.*-linux/ ) {
# PowerPC Linux
......@@ -1730,6 +1756,20 @@ sub rev_tbl {
}
}
if ( $TargetPlatform =~ /x86_64-apple-darwin/ ) {
# Tack a label to the front of the info table, too.
# For now, this just serves to work around a crash in Apple's new
# 64-bit linker (it seems to assume that there is no data before the
# first label in a section).
# The plan for the future is to do this on all Darwin platforms, and
# to add a reference to this label after the entry code, just as the
# NCG does, so we can enable dead-code-stripping in the linker without
# losing our info tables. (Hence the name _dsp, for dead-strip preventer)
$before .= "\n${infoname}_dsp:\n";
}
$tbl = $before
. (($TargetPlatform !~ /^hppa/) ? '' : join("\n", @imports) . "\n")
. join("\n", @words) . "\n"
......
......@@ -106,6 +106,12 @@ StgFunPtr StgReturn(void)
#else /* !USE_MINIINTERPRETER */
#ifdef LEADING_UNDERSCORE
#define STG_RUN "_StgRun"
#else
#define STG_RUN "StgRun"
#endif
#ifdef LEADING_UNDERSCORE
#define STG_RETURN "_StgReturn"
#else
......@@ -207,8 +213,8 @@ StgRunIsImplementedInAssembler(void)
/*
* save callee-saves registers on behalf of the STG code.
*/
".globl StgRun\n"
"StgRun:\n\t"
".globl " STG_RUN "\n"
STG_RUN ":\n\t"
"subq %0, %%rsp\n\t"
"movq %%rsp, %%rax\n\t"
"addq %0-48, %%rax\n\t"
......@@ -228,7 +234,7 @@ StgRunIsImplementedInAssembler(void)
"movq %%rdi,%%rax\n\t"
"jmp *%%rax\n\t"
".global " STG_RETURN "\n"
".globl " STG_RETURN "\n"
STG_RETURN ":\n\t"
"movq %%rbx, %%rax\n\t" /* Return value in R1 */
......
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