From 95ef475e663fcb26453a534fea2ac5f021471838 Mon Sep 17 00:00:00 2001 From: simonm Date: Tue, 13 Jun 2000 15:35:29 +0000 Subject: [PATCH] [project @ 2000-06-13 15:35:29 by simonm] Fix splitting on i386-unknwon-linux: string constants were being duplicated in each object, leading to large increases in binary sizes. --- ghc/driver/split/ghc-split.lprl | 41 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/ghc/driver/split/ghc-split.lprl b/ghc/driver/split/ghc-split.lprl index 3a4dadb..57729f2 100644 --- a/ghc/driver/split/ghc-split.lprl +++ b/ghc/driver/split/ghc-split.lprl @@ -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"); @@ -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} -- 1.7.10.4