$T_COPY_DIRVS = '\.(globl)';
$T_hsc_cc_PAT = '\.byte.*\)(hsc|cc) (.*)"\n\t\.byte \d+\n\t\.byte "(.*)"\n\t\.byte \d+';
- $T_DOT_WORD = '\.(long|short|byte)';
+ $T_DOT_WORD = '\.(long|short|byte|fill|space)';
$T_DOT_GLOBAL = '\.globl';
$T_HDR_toc = "\.toc\n";
$T_HDR_literal = "\t\.const_data\n\t\.align 2\n";
$chkcat[$i] = 'misc';
$chksymb[$i] = '';
+ } elsif ( $TargetPlatform =~ /^powerpc-apple-.*/ && /^\.picsymbol_stub/ )
+ {
+ $chk[++$i] = $_;
+ $chkcat[$i] = 'dyld';
+ $chksymb[$i] = '';
+ } elsif ( $TargetPlatform =~ /^powerpc-apple-.*/ && /^\.lazy_symbol_pointer/ )
+ {
+ $chk[++$i] = $_;
+ $chkcat[$i] = 'dyld';
+ $chksymb[$i] = '';
+ } elsif ( $TargetPlatform =~ /^powerpc-apple-.*/ && /^\.non_lazy_symbol_pointer/ )
+ {
+ $chk[++$i] = $_;
+ $chkcat[$i] = 'dyld';
+ $chksymb[$i] = '';
+ } elsif ( $TargetPlatform =~ /^powerpc-apple-.*/ && /^\.data/ && $chkcat[$i] == 'dyld')
+ { # non_lazy_symbol_ptrs that point to local symbols
+ $chk[++$i] = $_;
+ $chkcat[$i] = 'dyld';
+ $chksymb[$i] = '';
} else { # simple line (duplicated at the top)
$chk[$i] .= $_;
}
$numchks = $#chk + 1;
- open CHUNKS, ">/tmp/chunks1" or die "Cannot open /tmp/chunks1: $!\n";
- for (my $i = 0; $i < @chk; ++$i) { print CHUNKS "======= $i =======\n", $chk[$i] }
- close CHUNKS;
-
- # ########
+ # open CHUNKS, ">/tmp/chunks1" or die "Cannot open /tmp/chunks1: $!\n";
+ # for (my $i = 0; $i < @chk; ++$i) { print CHUNKS "======= $i =======\n", $chk[$i] }
+ # close CHUNKS;
# the division into chunks is imperfect;
# we throw some things over the fence into the next
$p =~ s/^\tsw\t\$28,\d+\(\$sp\)\n//;
$p =~ s/__FRAME__/$FRAME/;
} elsif ($TargetPlatform =~ /^powerpc-apple-.*/) {
- $p =~ s/^\tmflr r0\n//;
+ $pcrel_label = $p;
+ $pcrel_label =~ s/(.|\n)*^(L\d+\$pb):\n(.|\n)*/$2/ or $pcrel_label = "";
+
+ $p =~ s/^\tmflr r0\n//;
$p =~ s/^\tbl saveFP # f\d+\n//;
+ $p =~ s/^\tbl saveFP ; save f\d+-f\d+\n//;
+ $p =~ s/^L\d+\$pb:\n//;
$p =~ s/^\tstmw r\d+,-\d+\(r1\)\n//;
$p =~ s/^\tstfd f\d+,-\d+\(r1\)\n//g;
$p =~ s/^\tstw r0,\d+\(r1\)\n//g;
$p =~ s/^\tstwu r1,-\d+\(r1\)\n//;
$p =~ s/^\tstw r\d+,-\d+\(r1\)\n//g;
+ $p =~ s/^\tbcl 20,31,L\d+\$pb\n//;
+ $p =~ s/^L\d+\$pb:\n//;
+ $p =~ s/^\tmflr r31\n//;
} else {
print STDERR "$Pgm: unknown prologue mangling? $TargetPlatform\n";
}
-
- if ($TargetPlatform =~ /^powerpc-apple-.*/) {
- # on PowerPC, we have to keep a part of the prologue
- # (which loads the current instruction pointer into register r31)
- $u_p = $p; # $u_p is for unexpected prologue
- $u_p =~ s/^\tbcl 20,31,L\d+\$pb\n//;
- $u_p =~ s/^L\d+\$pb:\n//;
- $u_p =~ s/^\tmflr r31\n//;
- die "Prologue junk?: $u_p\n" if $u_p =~ /^\t[^\.]/
- } else {
- # HWL HACK: dont die, just print a warning
- #print stderr "HWL: this should die! Prologue junk?: $p\n" if $p =~ /^\t[^\.]/;
- die "Prologue junk?: $p\n" if $p =~ /^\t[^\.]/;
+
+ # HWL HACK: dont die, just print a warning
+ #print stderr "HWL: this should die! Prologue junk?: $p\n" if $p =~ /^\t[^\.]/;
+ die "Prologue junk?: $p\n" if $p =~ /^\t[^\.]/;
+
+ if ($TargetPlatform =~ /^powerpc-apple-.*/ && $pcrel_label ne "") {
+ # on PowerPC, we have to keep a part of the prologue
+ # (which loads the current instruction pointer into register r31)
+ $p .= "bcl 20,31,$pcrel_label\n";
+ $p .= "$pcrel_label:\n";
+ $p .= "\tmflr r31";
}
+
# glue together what's left
$c = $p . $r;
$c =~ s/\n\t\n/\n/; # junk blank line
# toss all calls to __DISCARD__
$c =~ s/^\t(call|jbsr|jal)\s+${T_US}__DISCARD__\n//go;
-# ###WTT### $c =~ s/^\tbl\s+L___DISCARD__\$stub\n//go if $TargetPlatform =~ /^powerpc-apple-.*/;
+ $c =~ s/^\tbl\s+L___DISCARD__\$stub\n//go if $TargetPlatform =~ /^powerpc-apple-.*/;
# MIPS: that may leave some gratuitous asm macros around
# (no harm done; but we get rid of them to be tidier)
$j++;
}
+ } elsif ( $TargetPlatform =~ /^powerpc-apple-.*/ && $chkcat[$i] eq 'dyld' ) {
+ # powerpc-apple: dynamic linker stubs
+ if($chk[$i] !~ /\.indirect_symbol ___DISCARD__/)
+ { # print them out unchanged, but remove the stubs for __DISCARD__
+ print OUTASM $chk[$i];
+ }
} else {
&tidy_up_and_die(1,"$Pgm: unknown chkcat (ghc-asm: $TargetPlatform)\n$chkcat[$i]\n$chk[$i]\n");
}