Commit 2a3a552c authored by andre's avatar andre
Browse files

[project @ 1997-05-26 20:49:19 by andre]

AIX/RS6000 patches
parent eaa66dba
......@@ -219,46 +219,33 @@ sub init_TARGET_STUFF {
$T_HDR_direct = "\t\.text\n\t\.align 2\n";
#--------------------------------------------------------#
} elsif ( $TargetPlatform =~ /^powerpc-.*/ ) {
} elsif ( $TargetPlatform =~ /^powerpc-.*|^rs6000-.*/ ) {
$T_STABBY = 0; # 1 iff .stab things (usually if a.out format)
$T_US = ''; # _ if symbols have an underscore on the front
$T_DO_GC = 'PerformGC_wrapper';
$T_DO_GC = '\.PerformGC_wrapper';
$T_PRE_APP = 'NOT APPLICABLE'; # regexp that says what comes before APP/NO_APP
$T_CONST_LBL = 'NOT APPLICABLE'; # regexp for what such a lbl looks like
# $T_CONST_LBL = '^LC\.\.(\d+):$'; # regexp for what such a lbl looks like
$T_POST_LBL = ':';
$T_MOVE_DIRVS = '^(\s*(\.toc|\.align \d+|\.csect \S+|\t\.?l?globl \S+)\n)';
# $T_MOVE_DIRVS = '^(\s*(\.toc|.csect \S+|\.l?globl \S+|\.align \d+)\n)';
$T_COPY_DIRVS = '\.(l?globl)';
$T_hsc_cc_PAT = '\.string.*\)(hsc|cc) (.*)\\\\t(.*)"';
$T_hsc_cc_PAT = '\.byte.*\)(hsc|cc) (.*)"\n\t\.byte \d+\n\t\.byte "(.*)"\n\t\.byte \d+';
$T_DOT_WORD = '\.long';
$T_DOT_GLOBAL = '\.globl';
$T_HDR_toc = "\.toc\n";
$T_HDR_literal = "# literal\n\.csect .data[RW]\n\t\.align 2\n"; #not RO!?
$T_HDR_literal = "\.csect .data[RW]\n\t\.align 2\n"; #not RO!?
$T_HDR_misc = "# misc\n\.csect \.text[PR]\n\t\.align 2\n";
$T_HDR_data = "# data\n\.csect \.data[RW]\n\t\.align 2\n";
$T_HDR_consist = "# consist\n\.csect \.data[RW]\n\t\.align 2\n";
$T_HDR_closure = "# closure\n\.csect \.data[RW]\n\t\.align 2\n";
$T_HDR_info = "# info\n\.csect \.data[RW]\n\t\.align 2\n"; #not RO!?
$T_HDR_entry = "# entry\n";
$T_HDR_entry = "# entry\n\.csect \.text[PR]\n\t\.align 2\n";
$T_HDR_fast = "# fast\n\.csect \.text[PR]\n\t\.align 2\n";
$T_HDR_vector = "# vector\n\.csect \.data[RW]\n\t\.align 2\n"; #not RO!?
$T_HDR_direct = "# direct\n";
# $T_HDR_literal = "\.section\t\.rodata\n";
# $T_HDR_misc = "\.text\n\t\.align 2\n";
# $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_info = "\.text\n\t\.align 2\n";
# $T_HDR_entry = "\.text\n";
# $T_HDR_fast = "\.text\n\t\.align 2\n";
# $T_HDR_vector = "\.text\n\t\.align 2\n";
# $T_HDR_direct = "\.text\n\t\.align 2\n";
#--------------------------------------------------------#
} elsif ( $TargetPlatform =~ /^sparc-.*-solaris2/ ) {
......@@ -405,9 +392,9 @@ sub mangle_asm {
next if /$TPREAPP(NO_)?APP/o;
next if /^;/ && $TargetPlatform =~ /^hppa/;
next if /(^$|^\t\.file\t|^ # )/ && $TargetPlatform =~ /^(mips|powerpc)-/;
next if /(^$|^\t\.file\t|^ # )/ && $TargetPlatform =~ /^(mips|powerpc|rs6000)-/;
last if /^_section_\.text:$/ && $TargetPlatform =~ /^powerpc-/;
last if /^_section_\.text:$/ && $TargetPlatform =~ /^powerpc-|^rs6000-/;
if ( $TargetPlatform =~ /^mips-/
&& /^\t\.(globl \S+ \.text|comm\t)/ ) {
......@@ -490,23 +477,19 @@ sub mangle_asm {
} elsif ( /^([A-Za-z0-9_]+)\s+\.comm/ && $TargetPlatform =~ /^hppa/ ) {
$chk[++$i] = $_;
$chkcat[$i] = 'bss';
$chksymb[$i] = $1; # useless, $1 is always '', since we end up using the second
# pattern /^hppa/. Change $1 to ''. Or reverse the pattern.
# Anyway, it is never used. - andre
$chksymb[$i] = $1;
$chksymb[$i] = '';
} elsif ( $TargetPlatform =~ /^powerpc-/ && /^LC\.\.([0-9]+)/ ) {
# } elsif ( /^LC\.\.([0-9]+)/ && $TargetPlatform =~ /^powerpc-/ ) {
} elsif ( $TargetPlatform =~ /^powerpc-|^rs6000-/ && /^LC\.\.([0-9]+)/ ) {
$chk[++$i] = $_;
$chkcat[$i] = 'toc';
$chksymb[$i] = $1;
} elsif ( /^$TUS[@]?(ret_|djn_)/o ) {
} elsif ( /^($TUS[@]?(ret_|djn_)[A-Za-z0-9_]+)/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
$chksymb[$i] = '';
$symbtmp = $1;
$chksymb[$i] = $symbtmp if ($TargetPlatform =~ /^powerpc-/) ;
$chksymb[$i] = $symbtmp if ($TargetPlatform =~ /^powerpc-|^rs6000-/) ; #rm andre
} elsif ( /^$TUS[@]?vtbl_([A-Za-z0-9_]+)$TPOSTLBL[@]?$/o ) {
$chk[++$i] = $_;
......@@ -525,9 +508,13 @@ sub mangle_asm {
} elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_upd$TPOSTLBL[@]?$/o ) {
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
if ($TargetPlatform =~ /^powerpc-/)
{ $chksymb[$i] = $symbtmp;}
else { $chksymb[$i] = ''; };
print STDERR "_upd!!!!! I guess this code is dead!!!!\n";
# I guess this is never entered, since all _upds are
# either vtbl_'s or ret_'s, caught above. - andre
$chksymb[$i] = '';
# if ($TargetPlatform =~ /^powerpc-/)
# { $chksymb[$i] = $symbtmp;}
# else { $chksymb[$i] = ''; };
} elsif ( $TargetPlatform =~ /^i386-.*-solaris2/
......@@ -548,7 +535,7 @@ sub mangle_asm {
} elsif ( /^$TUS[@]?[A-Za-z0-9_]/o
&& ( $TargetPlatform !~ /^hppa/ # need to avoid local labels in this case
|| ! /^L\$\d+$/ )
&& ( $TargetPlatform !~ /^powerpc/ # ditto
&& ( $TargetPlatform !~ /^powerpc|^rs6000/ # ditto
|| ! /^(L\.\.\d+|LT\.\..*):$/ ) ) {
local($thing);
chop($thing = $_);
......@@ -559,7 +546,7 @@ sub mangle_asm {
|| /^$TUS[@]?_reg.*$TPOSTLBL$/o; # PROF: __reg<module>
$chk[++$i] = $_;
$chkcat[$i] = 'misc';
if ($TargetPlatform =~ /^powerpc-/)
if ($TargetPlatform =~ /^powerpc-|^rs6000-/)
{ $chksymb[$i] = $thing; }
else { $chksymb[$i] = ''; };
......@@ -578,7 +565,7 @@ sub mangle_asm {
# about the whole module before we start spitting
# output.
local($FIRST_MANGLABLE) = ($TargetPlatform =~ /^(alpha-|hppa|mips-|power)/) ? 1 : 0;
local($FIRST_MANGLABLE) = ($TargetPlatform =~ /^(alpha-|hppa|mips-)/) ? 1 : 0;
# print STDERR "first chunk to mangle: $FIRST_MANGLABLE\n";
......@@ -591,10 +578,9 @@ sub mangle_asm {
# HPPAs, MIPSen: also start medding at chunk 1
# AIX hack for the moment, to join up multiple identical tocs
if ($TargetPlatform =~ /^powerpc/) {
print OUTASM ".toc\n.csect .text[PR]\ngcc2_compiled.:\n__gnu_compiled_c:\n";
# print OUTASM ".csect _ghc88142.rw_c[RW]\n\t.align 2\nghc_cc_ID:\n\t.byte \"@(#)cc prelude/Prelude.hc\"\n\t.byte 9\n\t.byte "35.0,,"\n\t.byte 0"
print OUTASM $T_HDR_toc;
if ($TargetPlatform =~ /^powerpc|^rs6000/) {
print OUTASM $T_HDR_toc; # yes, we have to put a .toc
# in the beginning of every file!
%tocequiv = (); # maps toc symbol number to toc symbol
%revtocequiv = (); # maps toc symbol to toc symbol number
for ($i = 1; $i < $numchks; $i++) {
......@@ -620,26 +606,11 @@ sub mangle_asm {
$tocsymb =~ s/^\t\.tc \S+,(\S+)\n/\1/;
$tocequiv{$tocnumber} = $tocsymb;
# limit is the limit of the scope of the current toc (either eof or find a new toc)
$limit = $i;
while ($chkcat[$limit] eq 'toc') {$limit++;};
while (($limit < $numchks) && ($chkcat[$limit] ne 'toc')) {$limit++;};
if ( $revtocequiv{$tocsymb} eq '') {
$revtocequiv{$tocsymb} = $tocnumber;
if ( $chk[$i] !~ /\.tc \S+_fast\d+\[TC\],\.\S+_fast\d+/ # no need to print these
|| $chk[$i] !~ /\.tc UpdatePAP\[TC\],\.UpdatePAP/
|| $chk[$i] !~ /\.tc \S+\[TC\],\.\S+_entry\n/ )
{ print OUTASM $chk[$i]; };
} else {
for ($j = $i; $j <= $limit; $j++) {
$chk[$j] =~ s/LC\.\.$tocnumber\(/LC\.\.${revtocequiv{$tocsymb}}\(/g;
};
};
$chkcat[$i] = 'DONE ALREADY';
}
}
};
} elsif ( $chkcat[$i] eq 'toc' && $chk[$i] =~ /\.byte/ ) {
$chkcat[$i] = 'literal';
}
}
};
for ($i = $FIRST_MANGLABLE; $i < $numchks; $i++) {
$c = $chk[$i]; # convenience copy
......@@ -683,11 +654,13 @@ sub mangle_asm {
$p =~ s/^\tsw\t\$fp,\d+\(\$sp\)\n//;
$p =~ s/^\tsw\t\$28,\d+\(\$sp\)\n//;
$p =~ s/__FRAME__/$FRAME/;
} elsif ($TargetPlatform =~ /^powerpc-/) {
} elsif ($TargetPlatform =~ /^powerpc-|^rs6000/) {
$p =~ s/^\tmflr 0\n//;
$p =~ s/^\tstm \d+,-\d+\(1\)\n//;
$p =~ s/^\tst 0,\d+\(1\)\n//;
$p =~ s/^\tstu 1,-\d+\(1\)\n//;
$p =~ s/^\tstw? 0,\d+\(1\)\n//;
$p =~ s/^\tstw?u 1,-\d+\(1\)\n//;
$p =~ s/^\tstw? \d+,-\d+\(1\)\n//g;
$p =~ s/^\tstfd \d+,-\d+\(1\)\n//;
} else {
print STDERR "$Pgm: unknown prologue mangling? $TargetPlatform\n";
}
......@@ -722,11 +695,12 @@ sub mangle_asm {
$e =~ s/^\tlw\t\$fp,\d+\(\$sp\)\n//;
$e =~ s/^\taddu\t\$sp,\$sp,\d+\n//;
$e =~ s/^\tj\t\$31\n//;
} elsif ($TargetPlatform =~ /^powerpc-/) {
$e =~ s/^\cal 1,\d+\(1\)\n//;
$e =~ s/^\tl \d+,\d+\(1\)\n//;
} elsif ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
$e =~ s/^\taddi 1,1,\d+\n//;
$e =~ s/^\tcal 1,\d+\(1\)\n//;
$e =~ s/^\tlw?z? \d+,\d+\(1\)\n//;
$e =~ s/^\tmtlr 0\n//;
$e =~ s/^\tbr\n//;
$e =~ s/^\tbl?r\n//;
} else {
print STDERR "$Pgm: unknown epilogue mangling? $TargetPlatform\n";
}
......@@ -869,19 +843,20 @@ sub mangle_asm {
if ( $chkcat[$i] eq 'misc' ) {
if ($chk[$i] ne '') {
print OUTASM $T_HDR_misc;
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000/) {
$chksymb[$i] =~ s/://;
if ($chksymb[$i] =~ /ret.*upd/ || $KNOWN_FUNNY_THING{$chksymb[$i]}
|| $chksymb[$i] =~ /^${T_US}_(PRIn|PRStart).*${T_POST_LBL}$/o )
{ print OUTASM "\t\.globl $chksymb[$i]\n\t\.globl \.$chksymb[$i]\n";
} else { print OUTASM "\t\.lglobl \.$chksymb[$i]\n"; };
#new if ($chksymb[$i] =~ /ret.*upd/ || $KNOWN_FUNNY_THING{$chksymb[$i]}
#new || $chksymb[$i] =~ /^$.{T_US}_(PRIn|PRStart).*${T_POST_LBL}$/o )
#new { print OUTASM "\t\.globl $chksymb[$i]\n"; }
if ($chksymb[$i] ne '')
{ print OUTASM "\t\.globl \.$chksymb[$i]\n"; };
if ($chk[$i] =~ /TOC\[tc0\], 0\n/)
{ ($p, $r) = split(/TOC\[tc0\], 0\n/, $chk[$i]); $printDS = 1;}
else { $r = $chk[$i]; $printDS = 0; };
$chk[$i] = &mangle_powerpc_tailjump($r);
};
&print_doctored($chk[$i], 0);
if ($TargetPlatform =~ /^powerpc-/ && $printDS) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/ && $printDS) {
print OUTASM "\.csect ${chksymb[$i]}[DS]\n";
print OUTASM "${p}TOC[tc0], 0\n";
}
......@@ -905,7 +880,7 @@ sub mangle_asm {
$consist =~ s/[^A-Za-z0-9_.]/ZZ/g; # ToDo: properly?
print OUTASM $T_HDR_consist, "${consist}${T_POST_LBL}\n";
} elsif ( $TargetPlatform !~ /^(mips|powerpc)-/ ) { # we just don't try in those case (ToDo)
} elsif ( $TargetPlatform !~ /^(mips)-/ ) { # we just don't try in those case (ToDo)
# on mips: consistency string is just a v
# horrible bunch of .bytes,
# which I am too lazy to sort out (WDP 95/05)
......@@ -936,7 +911,16 @@ sub mangle_asm {
if ( defined($infochk{$symb}) ) {
print OUTASM $T_HDR_info;
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
$chk[$infochk{$symb}] =~ s/\.long ([_A-Za-z]\S+_entry)/\.long \.\1/;
$chk[$infochk{$symb}] =~ s/\.long ([A-Za-z]\S+_upd)/\.long \.\1/;
$chk[$infochk{$symb}] =~ s/\.long (IndUpdRet\S+)/\.long \.\1/;
$chk[$infochk{$symb}] =~ s/\.long StdErrorCode/\.long \.StdErrorCode/;
$chk[$infochk{$symb}] =~ s/\.long UpdErr/\.long \.UpdErr/;
print OUTASM $chk[$infochk{$symb}];
} else {
print OUTASM &rev_tbl($symb, $chk[$infochk{$symb}], 1);
}
# entry code will be put here!
# paranoia
......@@ -954,17 +938,16 @@ sub mangle_asm {
# teach it to drop through to the fast entry point:
$c = $chk[$slowchk{$symb}];
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
($p, $r) = split(/TOC\[tc0\], 0\n/, $c);
if ($symb =~ /^[_A-Z]/)
{
print OUTASM "\t\.globl ${chksymb[$i]}_entry\n";
print OUTASM "\t\.globl \.${chksymb[$i]}_entry\n";
print OUTASM "\.csect ${symb}_entry[DS]\n";
print OUTASM "${p}TOC[tc0], 0\n";
}
else { print OUTASM "\t\.lglobl \.${symb}_entry\n"; };
$c = &mangle_powerpc_tailjump($r);
};
$r =~ s/\.csect \.text\[PR\]\n//; # todo: properly - andre
$c = &mangle_powerpc_tailjump($r);
};
if ( defined($fastchk{$symb}) ) {
......@@ -980,7 +963,7 @@ sub mangle_asm {
} elsif ( $TargetPlatform =~ /^m68k-/ ) {
$c =~ s/^\tjmp ${T_US}${symb}_fast\d+.*\n\tnop\n//;
$c =~ s/^\tjmp ${T_US}${symb}_fast\d+.*\n//;
} elsif ( $TargetPlatform =~ /^powerpc-/ ) {
} 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//;
......@@ -1015,14 +998,14 @@ sub mangle_asm {
) {
print OUTASM $T_HDR_fast;
}
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
local(@lbls) = split(/:/, $c);
$fullname = $lbls[0];
$fullname =~ s/$T_MOVE_DIRVS//g;
if ( $fullname =~ /^[A-Z]/)
{ print OUTASM "\t\.globl \.${fullname}\n";
} else {
print OUTASM "\t\.lglobl \.${fullname}\n";
print OUTASM "\t\.lglobl \.${fullname}\n"; #todo: rm - andre
};
$c =~ s/((.*\n)*)\t.long \S+, TOC\[tc0\], 0\n\.csect \.text\[PR\]\n((.*\n)*)/\1\3/;
$c = &mangle_powerpc_tailjump($c);
......@@ -1038,7 +1021,7 @@ sub mangle_asm {
# VECTOR TABLE
if ( defined($vectorchk{$symb}) ) {
print OUTASM $T_HDR_vector;
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
if ( $symb =~ /^[A-Z]/) {
print OUTASM "\t\.globl \.vtbl_${symb}\n";
print OUTASM "\t\.globl vtbl_${symb}\n";
......@@ -1056,7 +1039,7 @@ sub mangle_asm {
# DIRECT RETURN
if ( defined($directchk{$symb}) ) {
print OUTASM $T_HDR_direct;
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
($p, $r) = split(/TOC\[tc0\], 0\n/, $chk[$directchk{$symb}]);
&print_doctored($r, 0);
print OUTASM "\.csect ${symb}DirectReturn[DS]\n";
......@@ -1077,9 +1060,13 @@ sub mangle_asm {
}
} elsif ( $chkcat[$i] eq 'toc' ) {
if ($chk[$i] ne '') {
print OUTASM $T_HDR_literal;
print OUTASM $chk[$i];
# silly optimisation to print tocs, since they come in groups...
print OUTASM $T_HDR_toc;
local($j) = $i;
while ($chkcat[$j] eq 'toc')
{ print OUTASM $chk[$j];
$chkcat[$j] = 'DONE ALREADY';
$j++;
}
} else {
......@@ -1089,13 +1076,10 @@ sub mangle_asm {
print OUTASM $EXTERN_DECLS if $TargetPlatform =~ /^mips-/;
if ($TargetPlatform =~ /^powerpc-/) {
if ($TargetPlatform =~ /^powerpc-|^rs6000-/) {
print OUTASM ".csect .text[PR]\n_section_.text:\n.csect .data[RW]\n\t.long _section_.text\n"
};
# print OUTASM ".csect .text[PR]\n_section_.text:\n.csect .data[RW]\n\t.long _section_.text\n"
# if $TargetPlatform =~ /^powerpc-/;
# finished
close(OUTASM) || &tidy_up_and_die(1,"Failed writing to $out_asmf\n");
close(INASM) || &tidy_up_and_die(1,"Failed reading from $in_asmf\n");
......@@ -1552,18 +1536,18 @@ sub mini_mangle_asm_powerpc {
sub mangle_powerpc_tailjump {
local($c) = @_;
local($maybe_more) = 1;
while (($c =~ /\tl \d+,LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n/) && $maybe_more)
while (($c =~ /\tlw?z? \d+,LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n/) && $maybe_more)
{ $maybe_more = 0;
$lcsymb = $c;
$lcsymb =~ s/(.*\n)*\tl \d+,LC\.\.(\d+)\(2\)\n\tmtctr \d+\n\tbctr\n(.*\n)*/\2/;
$lcsymb =~ s/(.*\n)*\tlw?z? \d+,LC\.\.(\d+)\(2\)\n\tmtctr \d+\n\tbctr\n(.*\n)*/\2/;
# the checks for r1 and r2 are mostly paranoia...
$r1 = $c;
$r1 =~ s/(.*\n)*\tl (\d+),LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n(.*\n)*/\2/;
$r1 =~ s/(.*\n)*\tlw?z? (\d+),LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n(.*\n)*/\2/;
$r2 = $c;
$r2 =~ s/(.*\n)*\tl \d+,LC\.\.(\d+)\(2\)\n\tmtctr (\d+)\n\tbctr\n(.*\n)*/\3/;
if (r1 eq r2)
$r2 =~ s/(.*\n)*\tlw?z? \d+,LC\.\.(\d+)\(2\)\n\tmtctr (\d+)\n\tbctr\n(.*\n)*/\3/;
if (r1 == r2)
{ $maybe_more = 1;
$c =~ s/((.*\n)*)\tl \d+,LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n((.*\n)*)/\1\tb $tocequiv{$lcsymb}\n\3/;
$c =~ s/((.*\n)*)\tlw?z? \d+,LC\.\.\d+\(2\)\n\tmtctr \d+\n\tbctr\n((.*\n)*)/\1\tb $tocequiv{$lcsymb}\n\3/;
}
};
$c;
......
......@@ -179,6 +179,7 @@ sub process_asm_block {
return(&process_asm_block_alpha($str)) if $TargetPlatform =~ /^alpha-/;
return(&process_asm_block_hppa($str)) if $TargetPlatform =~ /^hppa/;
return(&process_asm_block_mips($str)) if $TargetPlatform =~ /^mips-/;
return(&process_asm_block_powerpc($str)) if $TargetPlatform =~ /^powerpc-|^rs6000-/;
# otherwise...
&tidy_up_and_die(1,"$Pgm: no process_asm_block for $TargetPlatform\n");
......@@ -432,6 +433,42 @@ sub process_asm_block_mips {
}
\end{code}
\begin{code}
sub process_asm_block_powerpc {
local($str) = @_;
# strip the marker
$str =~ s/___stg_split_marker.*\n//;
$str =~ s/___stg_split_marker.*\n//; # yes, twice.
# remove/record any literal constants defined here
while ( $str =~ /^(.csect .data[RW]\n\s+\.align.*\n(LC\.\.\d+):\n(\s\.byte .*\n)+)/ ) {
local($label) = $2;
local($body) = $1;
&tidy_up_and_die(1,"Local constant label $label already defined!\n")
if $LocalConstant{$label};
$LocalConstant{$label} = $body;
$str =~ s/^.csect .data[RW]\n\s+\.align.*\nLC\.\.\d+:\n(\s\.byte .*\n)+//;
}
# inject definitions for any local constants now used herein
foreach $k (keys %LocalConstant) {
if ( $str =~ /\b$k(\b|\[)/ ) {
$str = $LocalConstant{$k} . $str;
}
}
print STDERR "### STRIPPED BLOCK (powerpc/rs6000):\n$str" if $Dump_asm_splitting_info;
$str = ".toc\n" . $str;
$str;
}
\end{code}
\begin{code}
# make "require"r happy...
1;
......
......@@ -1216,14 +1216,14 @@ sub setupMachOpts {
unshift(@CcRegd_flags, ('-DSTACK_CHECK_BY_PAGE_FAULT=1')) if $StkChkByPageFaultOK;
unshift(@CcBoth_flags, ('-static'));
} elsif ($TargetPlatform =~ /^powerpc-/) {
} elsif ($TargetPlatform =~ /^powerpc-|^rs6000/) {
# we know how to *mangle* asm for PowerPC
# :-( unshift(@CcRegd_flags, ('-D__STG_REV_TBLS__'));
unshift(@CcRegd_flags, ('-DSTACK_CHECK_BY_PAGE_FAULT=1')) if $StkChkByPageFaultOK;
unshift(@CcBoth_flags, ('-static')); # always easier to start with
unshift(@CcRegd_flags, ('-finhibit-size-directive')); # avoids traceback tables
# unshift(@Ld_flags, ('-Xlinker -bbigtoc -Xlinker -bnoquiet')); # we have lots of toc entries..
unshift(@Ld_flags, ('-Xlinker -bbigtoc')); # we have lots of toc entries...
# unshift(@Ld_flags, ('-Xlinker -bbigtoc -Xlinker -bnoquiet')); # if we have lots of toc entries...
unshift(@Ld_flags, ('-Xlinker -bbigtoc')); # just in case we have lots of toc entries...
} elsif ($TargetPlatform =~ /^sparc-/) {
# we know how to *mangle* asm for SPARC
......@@ -1711,6 +1711,11 @@ Now the Haskell compiler, C compiler, and assembler
}
if ($do_cc) {
# # if we're going to split up object files, #delete! andre
# # we inject split markers into the .hc file now #delete! andre
# if ( $HscOut eq '-C=' && $SplitObjFiles ) { #delete! andre
# &inject_split_markers ( $hsc_out ); #delete! andre
# } #delete! andre
&runGcc ($is_hc_file, $hsc_out, $cc_as_o);
&runMangler($is_hc_file, $cc_as_o, $cc_as, $ifile_root);
}
......@@ -2040,7 +2045,7 @@ sub runGcc {
local($cc_help_s) = "ghc$$.s";
$cc = $CcRegd;
$s_output = ($is_hc_file || $TargetPlatform =~ /^(powerpc|hppa|i386)/) ? $cc_as_o : $cc_as;
$s_output = ($is_hc_file || $TargetPlatform =~ /^(powerpc|rs6000|hppa|i386)/) ? $cc_as_o : $cc_as;
$c_flags .= " @CcRegd_flags";
$c_flags .= ($is_hc_file) ? " @CcRegd_flags_hc" : " @CcRegd_flags_c";
......@@ -2121,8 +2126,8 @@ sub runMangler {
|| &tidy_up_and_die(1,"$Pgm: panic: can't load ghc-asm-hppa.prl!\n");
&mini_mangle_asm_hppa($cc_as_o, $cc_as);
} elsif ($TargetPlatform =~ /^powerpc/) {
# minor mangling of non-threaded files for hp-pa only
} elsif ($TargetPlatform =~ /^powerpc|^rs6000/) {
# minor mangling of non-threaded files for powerpcs and rs6000s
require('ghc-asm.prl')
|| &tidy_up_and_die(1,"$Pgm: panic: can't load ghc-asm-powerpc.prl!\n");
&mini_mangle_asm_powerpc($cc_as_o, $cc_as);
......@@ -2851,7 +2856,7 @@ arg: while($_ = $Args[0]) {
next arg; };
/^-split-objs/ && do {
if ( $TargetPlatform !~ /^(alpha|hppa1\.1|i386|m68k|mips|powerpc|sparc)-/ ) {
if ( $TargetPlatform !~ /^(alpha|hppa1\.1|i386|m68k|mips|powerpc|rs6000|sparc)-/ ) {
$SplitObjFiles = 0;
print STDERR "WARNING: don't know how to split objects on this platform: $TargetPlatform\n`-split-objs' option ignored\n";
} else {
......
......@@ -464,7 +464,7 @@ extern void __DISCARD__(STG_NO_ARGS);
%************************************************************************
\begin{code}
#if powerpc_TARGET_ARCH
#if powerpc_TARGET_ARCH || rs6000_TARGET_ARCH
/* do FUNBEGIN/END the easy way */
#define FUNBEGIN __asm__ volatile ("--- BEGIN ---");
......@@ -488,6 +488,12 @@ extern void __DISCARD__(STG_NO_ARGS);
#define MINI_INTERPRETER_SETUP \
StgChar space[RESERVED_C_STACK_BYTES+6*sizeof(double)+19*sizeof(long)]; \
__asm__ volatile ("stm 13,-176(1)\n" \
"\tstfd 14,-200(1)\n" \
"\tstfd 15,-208(1)\n" \
"\tstfd 16,-216(1)\n" \
"\tstfd 17,-224(1)\n" \
"\tstfd 18,-232(1)\n" \
"\tstfd 19,-240(1)\n" \
: : "I" (RESERVED_C_STACK_BYTES+16) : "1" );
/* the 16 bytes is for the argument-register save-area above $sp */
......@@ -496,6 +502,12 @@ extern void __DISCARD__(STG_NO_ARGS);
__asm__ volatile (".globl miniInterpretEnd\n" \
"miniInterpretEnd:\n" \
"\tlm 13,-176(1)\n" \
"\tlfd 14,-200(1)\n" \
"\tlfd 15,-208(1)\n" \
"\tlfd 16,-216(1)\n" \
"\tlfd 17,-224(1)\n" \
"\tlfd 18,-232(1)\n" \
"\tlfd 19,-240(1)\n" \
: : "I" (RESERVED_C_STACK_BYTES+16) : "1" );
#endif /* powerpc */
......
......@@ -557,7 +557,7 @@ gets whatever it's after.
%************************************************************************
\begin{code}
#if powerpc_TARGET_ARCH
#if powerpc_TARGET_ARCH || rs6000_TARGET_ARCH
/* shift 4 arg registers down one */
......@@ -565,6 +565,7 @@ gets whatever it's after.
register void (*f)() __asm__("$2"); \
__asm__ volatile ( \
"move $2,$4\n" \
"not used!!!????\n" \
"\tmove $4,$5\n" \
"\tmove $5,$6\n" \
"\tmove $6,$7\n" \
......@@ -577,11 +578,13 @@ gets whatever it's after.
__asm__ volatile ( \
"subu $sp,$sp,4\n" \
"\ts.d $f0, -8($sp)\n" \
"not used!!!????\n" \
"\tsw $2, -12($sp)");
#define MAGIC_RETURN \
__asm__ volatile ( \
"l.d $f0, -8($sp)\n" \
"not used!!!????\n" \
"\tlw $2, -12($sp)");
#define WRAPPER_NAME(f) /* nothing */
......
......@@ -720,38 +720,38 @@ f14-f31 (callee-save, non-volatile)
I think we can do the Whole Business with callee-save registers only!
\begin{code}
#if powerpc_TARGET_ARCH
#if powerpc_TARGET_ARCH || rs6000_TARGET_ARCH
#define REG(x) __asm__(#x)
#if defined(MARK_REG_MAP)
#define REG_Mark 22
#define REG_MStack 23
#define REG_MRoot 24
#define REG_BitArray 25
#define REG_HeapBase 26
#define REG_HeapLim 27
#define REG_Mark r22
#define REG_MStack r23
#define REG_MRoot r24
#define REG_BitArray r25
#define REG_HeapBase r26
#define REG_HeapLim r27
#else
#if defined(SCAN_REG_MAP)
#define REG_Scan 22
#define REG_New 23
#define REG_LinkLim 24
#define REG_Scan r22
#define REG_New r23
#define REG_LinkLim r24
#else
#if defined(SCAV_REG_MAP)
#define REG_Scav 22
#define REG_ToHp 23
#define REG_Scav r22
#define REG_ToHp r23
#if defined(GCap) || defined(GCgn)
#define REG_OldGen 24
#define REG_OldGen r24
#endif /* GCap || GCgn */
#else /* default: MAIN_REG_MAP */
/* callee saves */
/* #define CALLEE_SAVES_FltReg1 */
/* #define CALLEE_SAVES_FltReg2 */
/* #define CALLEE_SAVES_FltReg3 */
/* #define CALLEE_SAVES_FltReg4 */
/* #define CALLEE_SAVES_DblReg1 */
/* #define CALLEE_SAVES_DblReg2 */
#define CALLEE_SAVES_FltReg1
#define CALLEE_SAVES_FltReg2
#define CALLEE_SAVES_FltReg3
#define CALLEE_SAVES_FltReg4
#define CALLEE_SAVES_DblReg1
#define CALLEE_SAVES_DblReg2
#define CALLEE_SAVES_SpA
#define CALLEE_SAVES_SuA
#define CALLEE_SAVES_SpB
......@@ -770,34 +770,34 @@ I think we can do the Whole Business with callee-save registers only!
#define CALLEE_SAVES_R7
#define CALLEE_SAVES_R8
#define REG_R1 14
#define REG_R2 15
#define REG_R3 16
#define REG_R4 17
#define REG_R5 18
#define REG_R6 19
#define REG_R7 20
#define REG_R8 21
#define REG_R1 r14
#define REG_R2 r15
#define REG_R3 r16
#define REG_R4 r17
#define REG_R5 r18
#define REG_R6 r19
#define REG_R7 r20
#define REG_R8 r21
/* #define REG_Flt1 14 */
/* #define REG_Flt2 15 */
/* #define REG_Flt3 16 */
/* #define REG_Flt4 17 */
#define REG_Flt1 fr14
#define REG_Flt2 fr15
#define REG_Flt3 fr16
#define REG_Flt4 fr17
/* #define REG_Dbl1 18 */
/* #define REG_Dbl2 19 */
#define REG_Dbl1 fr18
#define REG_Dbl2 fr19
#define REG_SpA 22
#define REG_SuA 23
#define REG_SpB 24
#define REG_SuB 25
#define REG_SpA r22
#define REG_SuA r23
#define REG_SpB r24
#define REG_SuB r25