+ # remove junk whitespace around the split point
+ $p =~ s/\t+$//;
+ $r =~ s/^\s*\n//;
+
+ if ($TargetPlatform =~ /^i386-/) {
+ $p =~ s/^\tpushl\s+\%edi\n//;
+ $p =~ s/^\tpushl\s+\%esi\n//;
+ $p =~ s/^\tpushl\s+\%ebx\n//;
+ $p =~ s/^\tmovl\s+\%esi,\s*\d*\(\%esp\)\n//;
+ $p =~ s/^\tmovl\s+\%edi,\s*\d*\(\%esp\)\n//;
+ $p =~ s/^\tsubl\s+\$\d+,\s*\%esp\n//;
+ $p =~ s/^\tmovl\s+\$\d+,\s*\%eax\n\tcall\s+__alloca\n// if ($TargetPlatform =~ /^.*-cygwin32/);
+
+ # GCC 3.1 is in the habit of adding spurious writes to the
+ # stack in the prologue. Just to be on the safe side,
+ # chuck these over the fence into the main code.
+ while ($p =~ /^\tmovl\s+\$\d+,\s*\d*\(\%esp\)\n/) {
+ # print "Spurious instruction: $&";
+ $p = $` . $';
+ $r = $& . $r;
+ }
+
+ } elsif ($TargetPlatform =~ /^ia64-/) {
+ $p =~ s/^\t\.prologue .*\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//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//;
+ # The above showed up in the asm code,
+ # so I added it here.
+ # I hope it's correct.
+ # CaS
+ $p =~ s/^\tmovel d2,sp\@-\n//;
+ $p =~ s/^\tmovel d5,sp\@-\n//; # SMmark.* only?
+ $p =~ s/^\tmoveml \#0x[0-9a-f]+,sp\@-\n//; # SMmark.* only?
+ } elsif ($TargetPlatform =~ /^mips-/) {
+ # the .frame/.mask/.fmask that we use is the same
+ # as that produced by GCC for miniInterpret; this
+ # gives GDB some chance of figuring out what happened
+ $FRAME = "\t.frame\t\$sp,2168,\$31\n\t.mask\t0x90000000,-4\n\t.fmask\t0x00000000,0\n";
+ $p =~ s/^\t\.(frame).*\n/__FRAME__/g;
+ $p =~ s/^\t\.(mask|fmask).*\n//g;
+ $p =~ s/^\t\.cprestore.*\n/\t\.cprestore 416\n/; # 16 + 100 4-byte args
+ $p =~ s/^\tsubu\t\$sp,\$sp,\d+\n//;
+ $p =~ s/^\tsw\t\$31,\d+\(\$sp\)\n//;
+ $p =~ s/^\tsw\t\$fp,\d+\(\$sp\)\n//;
+ $p =~ s/^\tsw\t\$28,\d+\(\$sp\)\n//;
+ $p =~ s/__FRAME__/$FRAME/;
+ } elsif ($TargetPlatform =~ /^powerpc-apple-.*/) {
+ $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//;
+
+ # This is bad: GCC 3 seems to zero-fill some local variables in the prologue
+ # under some circumstances, only when generating position dependent code.
+ # I have no idea why, and I don't think it is necessary, so let's toss it.
+ $p =~ s/^\tli r\d+,0\n//g;
+ $p =~ s/^\tstw r\d+,\d+\(r1\)\n//g;
+ } else {
+ print STDERR "$Pgm: unknown prologue mangling? $TargetPlatform\n";
+ }
+
+ # 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 =~ /^\s+[^\s\.]/;
+
+ 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\n";
+ }
+