[project @ 1999-12-20 10:12:50 by simonpj]
[ghc-hetmet.git] / ghc / driver / ghc-split.lprl
index 3a4dadb..91a34d2 100644 (file)
@@ -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");
@@ -199,7 +200,7 @@ sub process_asm_block_sparc {
     $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\.?(L?LC\d+):\n(\t\.asci[iz].*\n)+)/ ) {
        local($label) = $2;
        local($body)  = $1;
 
@@ -208,7 +209,7 @@ sub process_asm_block_sparc {
 
        $LocalConstant{$label} = $body;
        
-       $str =~ s/\t\.align .\nLC\d+:\n(\t\.ascii.*\n)+//;
+       $str =~ s/\t\.align .\n\.?LL?C\d+:\n(\t\.asci[iz].*\n)+//;
     }
 
     # inject definitions for any local constants now used herein
@@ -311,7 +312,7 @@ sub process_asm_block_iX86 {
     $str = "\.text\n\t.align 4\n" . $str;
 
     # remove/record any literal constants defined here
-    while ( ($str =~ /((LC\d+):\n\t\.ascii.*\n)/ )) {
+    while ( ($str =~ /(\.?(LC\d+):\n\t\.(ascii|string).*\n)/ )) {
        local($label) = $2;
        local($body)  = $1;
 
@@ -320,7 +321,7 @@ sub process_asm_block_iX86 {
 
        $LocalConstant{$label} = $body;
        
-       $str =~ s/LC\d+:\n\t\.ascii.*\n//;
+       $str =~ s/\.?LC\d+:\n\t\.(ascii|string).*\n//;
     }
 
     # inject definitions for any local constants now used herein
@@ -433,6 +434,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;
 \end{code}