X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdriver%2Fmangler%2Fghc-asm.lprl;h=5850074ea99ac8eb6faf476f1f8c1479a24efad9;hb=a18ef0ff52adb393c353a45566113faf28a9f13a;hp=c8d15456938a30038da326a76bfee6a4779e6d0e;hpb=b7d9c3ac7200fe61f937275baed5d2baf781615e;p=ghc-hetmet.git diff --git a/ghc/driver/mangler/ghc-asm.lprl b/ghc/driver/mangler/ghc-asm.lprl index c8d1545..5850074 100644 --- a/ghc/driver/mangler/ghc-asm.lprl +++ b/ghc/driver/mangler/ghc-asm.lprl @@ -89,7 +89,7 @@ sub init_TARGET_STUFF { $T_COPY_DIRVS = '^\s+\.(IMPORT|EXPORT)'; $T_hsc_cc_PAT = '\.STRING.*\)(hsc|cc) (.*)\\\\x09(.*)\\\\x00"'; - $T_DOT_WORD = '\.word'; + $T_DOT_WORD = '\.(blockz|word|half|byte)'; $T_DOT_GLOBAL = '^\s+\.EXPORT'; $T_HDR_literal = "\t.SPACE \$TEXT\$\n\t.SUBSPA \$LIT\$\n"; $T_HDR_misc = "\t.SPACE \$TEXT\$\n\t.SUBSPA \$CODE\$\n\t\.align 4\n"; @@ -104,7 +104,7 @@ sub init_TARGET_STUFF { $T_HDR_direct = "\t.SPACE \$TEXT\$\n\t.SUBSPA \$CODE\$\n\t\.align 4\n"; #--------------------------------------------------------# - } elsif ( $TargetPlatform =~ /^i386-.*-(linuxaout|freebsd2|nextstep3|cygwin32)$/ ) { + } elsif ( $TargetPlatform =~ /^i386-.*-(linuxaout|freebsd2|nextstep3|cygwin32|mingw32)$/ ) { # NeXT added but not tested. CaS $T_STABBY = 1; # 1 iff .stab things (usually if a.out format) @@ -126,6 +126,7 @@ sub init_TARGET_STUFF { $T_HDR_data = "\.data\n\t\.align 2\n"; $T_HDR_consist = "\.text\n"; $T_HDR_closure = "\.data\n\t\.align 2\n"; + $T_HDR_closure = "\.data\n\t\.align 2\n\t.long 0\n" if ( $TargetPlatform =~ /.*-mingw32$/ ); $T_HDR_srt = "\.data\n\t\.align 2\n"; $T_HDR_info = "\.text\n\t\.align 2\n"; # NB: requires padding $T_HDR_entry = "\.text\n"; # no .align so we're right next to _info (arguably wrong...?) @@ -163,11 +164,11 @@ sub init_TARGET_STUFF { $T_HDR_consist = "\.text\n"; $T_HDR_closure = "\.data\n\t\.align 4\n"; # ToDo: change align? $T_HDR_srt = "\.data\n\t\.align 4\n"; # ToDo: change align? - $T_HDR_info = "\.text\n\t\.align 16\n"; # NB: requires padding + $T_HDR_info = "\.text\n\t\.align 4\n"; # NB: requires padding $T_HDR_entry = "\.text\n"; # no .align so we're right next to _info (arguably wrong...?) - $T_HDR_fast = "\.text\n\t\.align 16\n"; - $T_HDR_vector = "\.text\n\t\.align 16\n"; # NB: requires padding - $T_HDR_direct = "\.text\n\t\.align 16\n"; + $T_HDR_fast = "\.text\n\t\.align 4\n"; + $T_HDR_vector = "\.text\n\t\.align 4\n"; # NB: requires padding + $T_HDR_direct = "\.text\n\t\.align 4\n"; #--------------------------------------------------------# } elsif ( $TargetPlatform =~ /^m68k-.*-sunos4/ ) { @@ -264,7 +265,7 @@ sub init_TARGET_STUFF { $T_COPY_DIRVS = '\.(global|proc|stab)'; $T_hsc_cc_PAT = '\.asciz.*\)(hsc|cc) (.*)\\\\t(.*)"'; - $T_DOT_WORD = '\.(word|byte|half|skip)'; + $T_DOT_WORD = '\.(word|byte|half|skip|uahalf|uaword)'; $T_DOT_GLOBAL = '^\t\.global'; $T_HDR_literal = "\.text\n\t\.align 8\n"; $T_HDR_misc = "\.text\n\t\.align 4\n"; @@ -393,6 +394,7 @@ sub mangle_asm { while () { next if $T_STABBY && /^\.stab.*$TUS[@]?__stg_split_marker/o; next if $T_STABBY && /^\.stab.*ghc.*c_ID/; + next if /^\t\.def.*endef$/; next if /$TPREAPP(NO_)?APP/o; next if /^;/ && $TargetPlatform =~ /^hppa/; @@ -642,6 +644,7 @@ sub mangle_asm { if ($TargetPlatform =~ /^i386-/) { $p =~ s/^\tpushl \%edi\n//; $p =~ s/^\tpushl \%esi\n//; + $p =~ s/^\tpushl \%ebx\n//; $p =~ s/^\tsubl \$\d+,\%esp\n//; $p =~ s/^\tmovl \$\d+,\%eax\n\tcall __alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/); } elsif ($TargetPlatform =~ /^m68k-/) { @@ -701,6 +704,7 @@ sub mangle_asm { $e =~ s/^\tret\n//; $e =~ s/^\tpopl \%edi\n//; $e =~ s/^\tpopl \%esi\n//; + $e =~ s/^\tpopl \%ecx\n//; $e =~ s/^\taddl \$\d+,\%esp\n//; } elsif ($TargetPlatform =~ /^m68k-/) { $e =~ s/^\tunlk a6\n//; @@ -732,7 +736,7 @@ sub mangle_asm { # toss the register-windowing save/restore/ret* instructions # directly: if ( $TargetPlatform =~ /^sparc-/ ) { - $c =~ s/^\t(save .*|restore|ret|retl)\n//g; + $c =~ s/^\t(save.*|restore|ret|retl)\n//g; # throw away PROLOGUE comments $c =~ s/^\t!#PROLOGUE# 0\n\t!#PROLOGUE# 1\n//; } @@ -966,7 +970,7 @@ sub mangle_asm { $chk[$infochk{$symb}] =~ s/\.long ([A-Za-z]\S+_upd)/\.long \.\1/; print OUTASM $chk[$infochk{$symb}]; } else { - print OUTASM &rev_tbl($symb, $chk[$infochk{$symb}], 1); + print OUTASM &rev_tbl($symb, $chk[$infochk{$symb}], 1); } # entry code will be put here! @@ -1013,8 +1017,8 @@ sub mangle_asm { } elsif ( $TargetPlatform =~ /^powerpc-|^rs6000-/ ) { $c =~ s/^\tb \.${T_US}${symb}_fast\d+\n//; } elsif ( $TargetPlatform =~ /^sparc-/ ) { - $c =~ s/^\tcall ${T_US}${symb}_fast\d+,.*\n\tnop\n//; - $c =~ s/^\tcall ${T_US}${symb}_fast\d+,.*\n(\t[a-z].*\n)/$1/; + $c =~ s/^\tcall\s+${T_US}${symb}_fast\d+,.*\n\t\s*nop\n//; + $c =~ s/^\tcall\s+${T_US}${symb}_fast\d+,.*\n(\t\s*[a-z].*\n)/$1/; } else { print STDERR "$Pgm: mystery slow-fast dropthrough: $TargetPlatform\n"; } @@ -1153,7 +1157,8 @@ sub print_doctored { local($_, $need_fallthru_patch) = @_; if ( $TargetPlatform !~ /^i386-/ - || ! /^\t[a-z]/ ) { # no instructions in here, apparently + || ! /^\t[a-z]/ # no instructions in here, apparently + || /^${T_US}_reg[A-Za-z0-9_]+${T_POST_LBL}/) { print OUTASM $_; return; } @@ -1212,7 +1217,7 @@ sub print_doctored { } if ($StolenX86Regs <= 3 ) { # spurious uses of edi? s/^\tmovl (.*),\%edi\n\tjmp \*%edi\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g; - s/^\tjmp \*(-?\d*)\((.*\%edi.*)\)\n/\tmovl $2,\%eax\n\tjmp \*$1\(\%eax\)\n/g; + s/^\tjmp \*(-?\d*\(.*\%edi.*\))\n/\tmovl $1,\%eax\n\tjmp \*\%eax\n/g; s/^\tjmp \*\%edi\n/\tmovl \%edi,\%eax\n\tjmp \*\%eax\n/g; die "$Pgm: (mangler) still have jump involving \%edi!\n$_" if /(jmp|call) .*\%edi/; @@ -1331,7 +1336,7 @@ sub rev_tbl { push(@words, $lines[$i]); } } else { # hppa weirdness - for ( ; $i <= $#lines && $lines[$i] =~ /^\s+\.(word|IMPORT)/; $i++) { + for ( ; $i <= $#lines && $lines[$i] =~ /^\s+($TDOTWORD|\.IMPORT)/; $i++) { if ($lines[$i] =~ /^\s+\.IMPORT/) { push(@imports, $lines[$i]); } else { @@ -1346,7 +1351,8 @@ sub rev_tbl { # now throw away the first word (SRT) iff it is empty. # The .zero business is for Linux/ELF. # The .skip business is for Sparc/Solaris/ELF. - if ($discard1 && $words[0] =~ /^\t?($TDOTWORD\s+0|\.zero\s+4|\.skip\s+4)/) { + # The .blockz business is for HPPA. + if ($discard1 && $words[0] =~ /^\t?($TDOTWORD\s+0|\.zero\s+4|\.skip\s+4|\.blockz\s+4)/) { shift(@words) }