X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdriver%2Fmangler%2Fghc-asm.lprl;h=29cbfb10780150550a1a488041dd2905ec22ae0d;hb=5ecfa1f1d48111f5c95ec2fdae895fa24f8e321a;hp=b1a97b6177071b05ab1239609d49ae42342c0282;hpb=9fe16c3bde51ddc6aec09bed7b819377d2a108e8;p=ghc-hetmet.git diff --git a/ghc/driver/mangler/ghc-asm.lprl b/ghc/driver/mangler/ghc-asm.lprl index b1a97b6..29cbfb1 100644 --- a/ghc/driver/mangler/ghc-asm.lprl +++ b/ghc/driver/mangler/ghc-asm.lprl @@ -184,8 +184,8 @@ sub init_TARGET_STUFF { $T_X86_PRE_LLBL = '.L'; $T_X86_BADJMP = '^\tjmp\s+[^\.\*]'; - $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,\s*0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.size\s+\S+,\d+|\.ident.*)\n)'; - $T_COPY_DIRVS = '^\s*\.(globl|type|size)'; + $T_MOVE_DIRVS = '^(\s*(\.(p2)?align\s+\d+(,\s*0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.size\s+\S+\s*,\s*\d+|\.ident.*|\.local.*)\n)'; + $T_COPY_DIRVS = '^\s*\.(globl|type|size|local)'; if ( $TargetPlatform =~ /freebsd|netbsd/ ) { $T_hsc_cc_PAT = '\.ascii.*\)(hsc|cc) (.*)\\\\11"\n\t\.ascii\s+"(.*)\\\\0"'; @@ -457,12 +457,17 @@ sub mangle_asm { if ( $TargetPlatform =~ /^mips-/ && /^\t\.(globl\S+\.text|comm\t)/ ) { $EXTERN_DECLS .= $_ unless /(__DISCARD__|\b(PK_|ASSIGN_)(FLT|DBL)\b)/; - - # As a temporary solution for compiling "foreign export" declarations, - # we use global variables to pass arguments from C to STG land. - # These declarations live in the .hc file and not in the generated C - # stub file, so we let them pass through here. - } elsif ( /^\t\.comm\t__fexp_.*$/ ) { + # Treat .comm variables as data. These show up in two (known) places: + # + # - the module_registered variable used in the __stginit fragment. + # even though these are declared static and initialised, gcc 3.3 + # likes to make them .comm, presumably to save space in the + # object file. + # + # - global variables used to pass arguments from C to STG in + # a foreign export. (is this still true? --SDM) + # + } elsif ( /^\t\.comm.*$/ ) { $chk[++$i] = $_; $chkcat[$i] = 'data'; $chksymb[$i] = ''; @@ -562,15 +567,6 @@ sub mangle_asm { $vectorchk{$1} = $i; - # As a temporary solution for compiling "foreign export" declarations, - # we use global variables to pass arguments from C to STG land. - # These declarations live in the .hc file and not in the generated C - # stub file, so we let them pass through here. - } elsif ( /^[\t ]+\.comm[\t ]+__fexp_.*$/ ) { - $chk[++$i] = $_; - $chkcat[$i] = 'data'; - $chksymb[$i] = ''; - } elsif ( $TargetPlatform =~ /^i386-.*-solaris2/ && /^[A-Za-z0-9][A-Za-z0-9_]*:/ ) { # Some Solaris system headers contain function definitions (as @@ -598,6 +594,7 @@ sub mangle_asm { || /^${T_US}.*_slow${T_POST_LBL}$/o # slow entry || /^${T_US}__stginit.*${T_POST_LBL}$/o # __stginit || /^${T_US}.*_btm${T_POST_LBL}$/o # large bitmaps + || /^${T_US}.*_srtd${T_POST_LBL}$/o # large bitmaps || /^${T_US}.*_fast${T_POST_LBL}$/o # primops || /^${T_US}.*_closure_tbl${T_POST_LBL}$/o # closure tables || /^_uname:/o; # x86/Solaris2 @@ -700,12 +697,18 @@ sub mangle_asm { } elsif ($TargetPlatform =~ /^ia64-/) { $p =~ s/^\t\.prologue .*\n//; - $p =~ s/^\t\.save ar\.pfs, r\d+\n\talloc r\d+ = ar\.pfs, 0, 31, \d+, 0\n//; + $p =~ s/^\t\.save ar\.pfs, r\d+\n\talloc r\d+ = ar\.pfs, 0, 3[12], \d+, 0\n//; $p =~ s/^\t\.fframe \d+\n\tadds r12 = -\d+, r12\n//; $p =~ s/^\t\.save rp, r\d+\n\tmov r\d+ = b0\n//; - $p =~ s/^\t\.(mii|mmi)\n//; # bundling is no longer sensible + $p =~ s/^\t\.(mii|mmi)\n//g; # bundling is no longer sensible $p =~ s/^\t;;\n//g; # discard stops $p =~ s/^\t\/\/.*\n//g; # gcc inserts timings in // comments + + # GCC 3.3 saves r1 in the prologue, move this to the body + if ($p =~ /^\tmov r\d+ = r1\n/) { + $p = $` . $'; + $r = $& . $r; + } } elsif ($TargetPlatform =~ /^m68k-/) { $p =~ s/^\tlink a6,#-?\d.*\n//; $p =~ s/^\tpea a6@\n\tmovel sp,a6\n//; @@ -839,8 +842,13 @@ sub mangle_asm { $c =~ s/^\tbl\s+L___DISCARD__\$stub\n//go if $TargetPlatform =~ /^powerpc-apple-.*/; # IA64: mangle tailcalls into jumps here - $c =~ s/^\tbr\.call\.sptk\.many b0 = (.*)\n\t;;\n(\tmov r1 = r\d+\n)?\t;;\n\t--- TAILCALL ---\n/\tbr\.few $1\n/g - if $TargetPlatform =~ /^ia64-/; + if ($TargetPlatform =~ /^ia64-/) { + while ($c =~ s/^\tbr\.call\.sptk\.many b0 = (.*)\n(?:^\.L([0-9]*):\n)?(?:\t;;\n)?(?:\tmov r1 = r\d+\n)?(?:\t;;\n)?\t--- TAILCALL ---\n(?:\t;;\n\tbr \.L\d+\n)?/\tbr\.few $1\n/) { + # Eek, the gcc optimiser is getting smarter... if we see a jump to the --- TAILCALL --- + # marker then we reapply the substitution at the source sites + $c =~ s/^\tbr \.L$2\n/\t--- TAILCALL ---\n/g if ($2); + } + } # MIPS: that may leave some gratuitous asm macros around # (no harm done; but we get rid of them to be tidier)