local($hc_file) = @_;
unlink("$Tmp_prefix.unmkd");
- local($to_do) = "$Cp $hc_file $Tmp_prefix.unmkd";
+ local($to_do) = "cp $hc_file $Tmp_prefix.unmkd";
&run_something($to_do, 'Prepare to number split markers');
open(TMPI, "< $Tmp_prefix.unmkd") || &tidy_up_and_die(1,"$Pgm: failed to open `$Tmp_prefix.unmkd' (to read)\n");
$_ = <TMPI>;
}
print TMPO "__STG_SPLIT_MARKER(1)\n";
- print TMPO $_ if ! /^\s*\/\* SPLIT \*\/\s*$/;
-
- # Have to be a bit careful detecting /* SPLIT */ comments
- # since a progam may use a string containing "/* SPLIT */"
- # We check that there is nothing else on the line
+ print TMPO $_ if ! /\/\* SPLIT \*\//;
while (<TMPI>) {
- if (/^\s*\/\* SPLIT \*\/\s*$/) {
+ if (/\/\* SPLIT \*\//) {
$marker_no++;
print TMPO "__STG_SPLIT_MARKER($marker_no)\n";
next;
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");
if ( $OptimiseC ) {
$str =~ s/_?__stg_split_marker.*:\n//;
} else {
- $str =~ s/(\.text\n\t\.align .\n)\t\.global\s+.*_?__stg_split_marker.*\n\t\.proc.*\n/$1/;
- $str =~ s/(\t\.align .\n)\t\.global\s+.*_?__stg_split_marker.*\n\t\.proc.*\n/$1/;
+ $str =~ s/(\.text\n\t\.align .\n)\t\.global\s+.*_?__stg_split_marker.*\n\t\.proc.*\n/\1/;
+ $str =~ s/(\t\.align .\n)\t\.global\s+.*_?__stg_split_marker.*\n\t\.proc.*\n/\1/;
}
# make sure the *.hc filename gets saved; not just ghc*.c (temp name)
$str =~ s/^\.stabs "(ghc\d+\.c)"/.stabs "$ifile_root.hc"/g; # HACK HACK
# remove/record any literal constants defined here
- while ( $str =~ /(\t\.align .\n(LC\d+):\n(\t\.ascii.*\n)+)/ ) {
+ while ( $str =~ /(\t\.align .\n(LC\d+):\n\t\.ascii.*\n)/ ) {
local($label) = $2;
local($body) = $1;
$LocalConstant{$label} = $body;
- $str =~ s/\t\.align .\nLC\d+:\n(\t\.ascii.*\n)+//;
+ $str =~ s/\t\.align .\nLC\d+:\n\t\.ascii.*\n//;
}
# inject definitions for any local constants now used herein
sub process_asm_block_m68k {
local($str) = @_;
- # strip the marker
+ # strip the marker (ToDo: something special for unregisterized???)
- $str =~ s/(\.text\n\t\.even\n)\t\.globl\s+.*_?__stg_split_marker.*\n/$1/;
- $str =~ s/(\t\.even\n)\t\.globl\s+.*_?__stg_split_marker.*\n/$1/;
+ $str =~ s/(\.text\n\t\.even\n)\t\.globl\s+.*_?__stg_split_marker.*\n/\1/;
+ $str =~ s/(\t\.even\n)\t\.globl\s+.*_?__stg_split_marker.*\n/\1/;
# it seems prudent to stick on one of these:
$str = "\.text\n\t.even\n" . $str;
if ( $OptimiseC ) {
$str =~ s/_?__stg_split_marker.*:\n//;
} else {
- $str =~ s/(\t\.align .\n)\t\.globl\s+.*_?__stg_split_marker.*\n\t\.ent.*\n/$1/;
+ $str =~ s/(\t\.align .\n)\t\.globl\s+.*_?__stg_split_marker.*\n\t\.ent.*\n/\1/;
}
# remove/record any literal constants defined here
# Slide the dummy direct return code into the vtbl .ent/.end block,
# to keep the label fixed if it's the last thing in a module, and
# to avoid having any anonymous text that the linker will complain about
- $str =~ s/(\t\.end [A-Za-z0-9_]+)\n\t# nop/\tnop\n$1/g;
+ $str =~ s/(\t\.end [A-Za-z0-9_]+)\n\t# nop/\tnop\n\1/g;
print STDERR "### STRIPPED BLOCK (alpha):\n$str" if $Dump_asm_splitting_info;
sub process_asm_block_iX86 {
local($str) = @_;
- # strip the marker
+ # strip the marker (ToDo: something special for unregisterized???)
- $str =~ s/(\.text\n\t\.align .(,0x90)?\n)\.globl\s+.*_?__stg_split_marker.*\n/$1/;
- $str =~ s/(\t\.align .(,0x90)?\n)\.globl\s+.*_?__stg_split_marker.*\n/$1/;
+ $str =~ s/(\.text\n\t\.align .(,0x90)?\n)\.globl\s+.*_?__stg_split_marker.*\n/\1/;
+ $str =~ s/(\t\.align .(,0x90)?\n)\.globl\s+.*_?__stg_split_marker.*\n/\1/;
# it seems prudent to stick on one of these:
$str = "\.text\n\t.align 4\n" . $str;
if ( $OptimiseC ) {
$str =~ s/_?__stg_split_marker.*:\n//;
} else {
- $str =~ s/(\t\.align .\n)\t\.globl\s+.*_?__stg_split_marker.*\n\t\.ent.*\n/$1/;
+ $str =~ s/(\t\.align .\n)\t\.globl\s+.*_?__stg_split_marker.*\n\t\.ent.*\n/\1/;
}
# remove/record any literal constants defined here
# Slide the dummy direct return code into the vtbl .ent/.end block,
# to keep the label fixed if it's the last thing in a module, and
# to avoid having any anonymous text that the linker will complain about
- $str =~ s/(\t\.end [A-Za-z0-9_]+)\n\t# nop/\tnop\n$1/g;
+ $str =~ s/(\t\.end [A-Za-z0-9_]+)\n\t# nop/\tnop\n\1/g;
$str .= $UNDEFINED_FUNS; # pin on gratuitiously-large amount of info
\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;
\end{code}