From c9dfd084e476b18290e964e5e5d66adf0771b9e6 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 18 May 1999 15:03:53 +0000 Subject: [PATCH] [project @ 1999-05-18 15:03:53 by simonpj] Driver updates for Simons main commit; rewrite rules and flaggery --- ghc/driver/ghc-iface.lprl | 30 +++--- ghc/driver/ghc.lprl | 239 ++++++++------------------------------------- 2 files changed, 61 insertions(+), 208 deletions(-) diff --git a/ghc/driver/ghc-iface.lprl b/ghc/driver/ghc-iface.lprl index e9f2df0..7150536 100644 --- a/ghc/driver/ghc-iface.lprl +++ b/ghc/driver/ghc-iface.lprl @@ -153,17 +153,16 @@ sub constructNewHiFile { } local($new_module_version) = &calcNewModuleVersion(@decl_names); - print NEWHI "__interface ", $ModuleName{'new'}, " $new_module_version $ProjectVersionInt where\n"; - - print NEWHI $Stuff{'new:usages'} unless $Stuff{'new:usages'} eq ''; - print NEWHI $Stuff{'new:instance_modules'} unless $Stuff{'new:instance_modules'} eq ''; + print NEWHI "__interface ", $ModuleName{'new'}, " $new_module_version $Orphan{'new'} $ProjectVersionInt where\n"; print NEWHI $Stuff{'new:exports'}; + print NEWHI $Stuff{'new:usages'} unless $Stuff{'new:usages'} eq ''; print NEWHI $Stuff{'new:instances'} unless $Stuff{'new:instances'} eq ''; foreach $v (@decl_names) { &printNewItemVersion(NEWHI, $v, $new_module_version, $show_hi_diffs); # Print new version number print NEWHI $Decl{"new:$v"}; # Print the new decl itself } + print NEWHI $Stuff{'new:rules'} unless $Stuff{'new:rules'} eq ''; close(NEWHI) || &tidy_up_and_die(1,"Failed writing to $new_hi\n"); } @@ -194,11 +193,11 @@ sub readHiFile { $HiExists{$mod} = -1; # 1 <=> definitely exists; 0 <=> doesn't $HiHasBeenRead{$mod} = 0; $ModuleVersion{$mod} = 0; - $Stuff{"$mod:instance_modules"} = ''; $Stuff{"$mod:usages"} = ''; # stuff glommed together $Stuff{"$mod:exports"} = ''; $Stuff{"$mod:instances"} = ''; $Stuff{"$mod:declarations"} = ''; + $Stuff{"$mod:rules"} = ''; if (! -f $hifile) { # no pre-existing .hi file $HiExists{$mod} = 0; @@ -210,24 +209,29 @@ sub readHiFile { hi_line: while () { next if /^ *$/; # blank line - if ( /^__interface ([A-Z]\S*) (\d+)/ ) { + if ( /^__interface ([A-Z]\S*) (\d+)( \!)?/ ) { if ( $mod ne 'new' ) { + # Reading old .hi file $ModuleVersion{$mod} = $2; } - $ModuleName{$mod} = $1; # used to decide name of iface file. + + $ModuleName{$mod} = $1; # used to decide name of iface file. + $Orphan{$mod} = $3; + # optional "!" indicates that the + # module contains orphan rules or instance decls } elsif ( /^import / ) { $Stuff{"$mod:usages"} .= $_; # save the whole thing - } elsif ( /^__instimport/ ) { - $Stuff{"$mod:instance_modules"} .= $_; - } elsif ( /^__export/ ) { $Stuff{"$mod:exports"} .= $_; } elsif ( /^instance / ) { $Stuff{"$mod:instances"} .= $_; + } elsif ( /^{-## __R / ) { + $Stuff{"$mod:rules"} .= $_; + } elsif ( /^-[-]+ .*/ ) { # silently ignore comment lines. ; } else { # We're in a declaration @@ -303,7 +307,11 @@ sub calcNewModuleVersion { local($unchanged_version) = $ModuleVersion{'old'}; # will return one of these two local($changed_version) = $unchanged_version + 1; - foreach $t ( 'usages' , 'exports', 'instance_modules', 'instances', 'fixities' ) { + if ($Orphan{'old'} ne $Orphan{'new'}) { + return(&mv_change($changed_version, "orphan-hood changed")); + } + + foreach $t ( 'usages' , 'exports', 'instances', 'fixities', 'rules' ) { return(&mv_change($changed_version,"$t changed")) if $Stuff{"old:$t"} ne $Stuff{"new:$t"}; } diff --git a/ghc/driver/ghc.lprl b/ghc/driver/ghc.lprl index bef7b15..eaca19f 100644 --- a/ghc/driver/ghc.lprl +++ b/ghc/driver/ghc.lprl @@ -223,16 +223,11 @@ These are the default values, which may be changed by user flags. sub setupOptFlags { $Oopt_MaxSimplifierIterations = '-fmax-simplifier-iterations4'; $Oopt_PedanticBottoms = '-fpedantic-bottoms'; # ON by default - $Oopt_MonadEtaExpansion = ''; $Oopt_FinalStgProfilingMassage = ''; $Oopt_StgStats = ''; $Oopt_DoSpecialise = '-fspecialise'; $Oopt_FoldrBuild = 0; # *Off* by default! - $Oopt_FB_Support = ''; # was '-fdo-arity-expand'; -# $Oopt_FoldrBuildWW = 0; # Off by default - $Oopt_FoldrBuildInline = ''; # was '-fdo-inline-foldr-build'; $Oopt_UsageSPInf = ''; # Off by default - $Oopt_ShowSimplifierProgress = ''; } # end of setupOptFlags # Assign defaults to these right away. @@ -696,60 +691,42 @@ It really really wants to be the last STG-to-STG pass that is run. sub setupOptimiseFlags { - @HsC_minusNoO_flags - = ( '-fsimplify', - '[', - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', -# '-fdo-lambda-eta-expansion', # too complicated - '-freuse-con', -# '-flet-to-case', # no strictness analysis, so... - $Oopt_PedanticBottoms, -# $Oopt_MonadEtaExpansion, # no thanks - -# These two work fine, if you really want no simplification at all, -# for bizarre test reasons. But you get really terrible code if you use them, -# for example: let x = e in x -# with dozens of redundant thunks etc. So I'm leaving them out. -# -# '-fsimpl-uf-use-threshold0', -# '-fessential-unfoldings-only', + # this pass-ordering sequence was agreed by Simon and Andr\'e + # (WDP 94/07, 94/11). - # - # The presence of -fclone-binds is *temporary* to work around - # the fact that the desugarer in 3.0{2.3} does generate - # bindings with identical ids, and the type checker doesn't perform - # properly cloned type substitutions. Instead, we make sure that all - # binders are cloned first time through the simplifier. - # - # Will be properly fixed in the `new compiler` I hear, at which point - # the cloning can be turned off here. - # - # Let's find out.. - #'-fclone-binds', - - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, + @HsC_minusNoO_flags + = ( + '-fsimplify', + '[', + '-finline-phase2', + $Oopt_MaxSimplifierIterations, ']', - $Oopt_AddAutoSccs, -# '-ffull-laziness', # removed 95/04 WDP following Andr\'e's lead + $Oopt_AddAutoSccs, $Oopt_FinalStgProfilingMassage ); @HsC_minusO_flags # NOTE: used for *both* -O and -O2 (some conditional bits) = ( + '-ffoldr-build-on', + '-fdo-eta-reduction', + '-fdo-case-elim', + '-fdo-lambda-eta-expansion', + '-fcase-of-case', + '-fcase-merge', + '-flet-to-case', + $Oopt_PedanticBottoms, # initial simplify: mk specialiser happy: minimum effort please + '-fsimplify', '[', - $Oopt_FB_Support, - '-fkeep-spec-pragma-ids', # required before specialisation + '-finline-phase1', # Don't inline rule Ids till specialisation has bitten +# APR 99: the stuff in this comment is now +# handled by -finline-phase1 +# # I don't understand why we want -fessential-unfoldings-only here # If we have it, the following nasty thing happens: # f = E @@ -772,141 +749,44 @@ sub setupOptimiseFlags { # This shows up in PrelArr.lhs - the specialised instance for newArray # calls the generic rangeSize, because rangeSize is strict and is # replaced by its wrapper by the simplifier. +# '-fessential-unfoldings-only', +# '-fsimpl-uf-use-threshold0', - '-fessential-unfoldings-only', - '-fsimpl-uf-use-threshold0', - - # See remark re: cloning in defn of minusnotO - '-fclone-binds', - - '-fdo-case-elim', - '-fmax-simplifier-iterations1', - $Oopt_PedanticBottoms, + '-fmax-simplifier-iterations2', ']', - ($Oopt_DoSpecialise) ? ( - $Oopt_DoSpecialise, - ) : (), + ($Oopt_DoSpecialise) ? ( $Oopt_DoSpecialise, ) : (), $Oopt_UsageSPInf, # infer usage information here in case we need it later. # (add more of these where you need them --KSW 1999-04) - '-fsimplify', # need dependency anal after specialiser ... - '[', # need tossing before calc-inlinings ... - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', - '-fcase-merge', -# '-fdo-eta-reduction', - '-fdo-lambda-eta-expansion', - '-freuse-con', - $Oopt_PedanticBottoms, - $Oopt_MonadEtaExpansion, - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, - # - # The presence of -fclone-binds is *crucial* here as - # -ffull-laziness (which we're about to do next) floats - # bindings outwards, so we better make sure that this - # doesn't result in the floating out of bindings - # with identical uniques, i.e., -ffull-laziness needs - # to be preceeded by a simplifier pass with -fclone-binds - # set. - '-fclone-binds', - ']', + '-fsimplify', + '[', + $Oopt_MaxSimplifierIterations, -# ($Oopt_FoldrBuildWW) ? ( -# '-ffoldr-build-ww-anal', -# '-ffoldr-build-worker-wrapper', -# '-fsimplify', -# '[', -# $Oopt_FB_Support, -# '-ffloat-lets-exposing-whnf', -# '-ffloat-primops-ok', -# '-fcase-of-case', -# '-fdo-case-elim', -# '-fcase-merge', -# '-fdo-eta-reduction', -# '-fdo-lambda-eta-expansion', -# '-freuse-con', -# $Oopt_PedanticBottoms, -# $Oopt_MonadEtaExpansion, -# $Oopt_MaxSimplifierIterations, -# $Oopt_ShowSimplifierProgress, -# ']', -# ) : (), + # Still don't inline transformation rule Ids, to give the + # rules a good chance to fire + '-finline-phase1', + ']', - # this pass-ordering sequence was agreed by Simon and Andr\'e - # (WDP 94/07, 94/11). '-ffull-laziness', - ($Oopt_FoldrBuild) ? ( - '-ffoldr-build-on', # desugar list comprehensions for foldr/build - - '-fsimplify', - '[', - '-fignore-inline-pragma', # **** NB! - '-fdo-foldr-build', # NB - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', - '-fcase-merge', -# '-fdo-eta-reduction', - '-fdo-lambda-eta-expansion', # After full laziness - '-freuse-con', - $Oopt_PedanticBottoms, - $Oopt_MonadEtaExpansion, - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, - ']', - ) : (), - '-ffloat-inwards', '-fsimplify', '[', - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', - '-fcase-merge', - '-fdo-eta-reduction', - '-fdo-lambda-eta-expansion', - '-freuse-con', - ($Oopt_FoldrBuildInline), - # you need to inline foldr and build - ($Oopt_FoldrBuild) ? ('-fdo-foldr-build') : (), - # but do reductions if you see them! - $Oopt_PedanticBottoms, - $Oopt_MonadEtaExpansion, - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, + '-finline-phase2', + $Oopt_MaxSimplifierIterations, ']', '-fstrictness', + '-fcpr-analyse', '-fworker-wrapper', '-fsimplify', '[', - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', - '-fcase-merge', -# '-fdo-eta-reduction', - '-fdo-lambda-eta-expansion', - '-freuse-con', - '-flet-to-case', # Aha! Only done after strictness analysis - $Oopt_PedanticBottoms, - $Oopt_MonadEtaExpansion, - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, + $Oopt_MaxSimplifierIterations, + # No -finline-phase: allow all Ids to be inlined now ']', '-ffloat-inwards', @@ -916,38 +796,19 @@ sub setupOptimiseFlags { # ( ($OptLevel != 2) # ? '' -# : "-fliberate-case -fsimplify [ $Oopt_FB_Support -ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -fdo-case-elim -fcase-merge -fdo-eta-reduction -fdo-lambda-eta-expansion -freuse-con -flet-to-case $Oopt_PedanticBottoms $Oopt_MonadEtaExpansion $Oopt_MaxSimplifierIterations $Oopt_ShowSimplifierProgress ]" ), +# : "-fliberate-case -fsimplify [ $Oopt_FB_Support -ffloat-lets-exposing-whnf -ffloat-primops-ok -fcase-of-case -fdo-case-elim -fcase-merge -fdo-lambda-eta-expansion -freuse-con -flet-to-case $Oopt_PedanticBottoms $Oopt_MaxSimplifierIterations $Oopt_ShowSimplifierProgress ]" ), # Final clean-up simplification: '-fsimplify', '[', - $Oopt_FB_Support, - '-ffloat-lets-exposing-whnf', - '-ffloat-primops-ok', - '-fcase-of-case', - '-fdo-case-elim', - '-fcase-merge', -# '-fdo-eta-reduction', - '-fdo-lambda-eta-expansion', - '-freuse-con', - '-flet-to-case', - '-fignore-inline-pragma', # **** NB! - $Oopt_FoldrBuildInline, - ($Oopt_FoldrBuild) ? ('-fdo-foldr-build') : (), - # but still do reductions if you see them! - $Oopt_PedanticBottoms, - $Oopt_MonadEtaExpansion, - $Oopt_MaxSimplifierIterations, - $Oopt_ShowSimplifierProgress, + $Oopt_MaxSimplifierIterations, ']', # '-fstatic-args', -#LATER: '-fcalc-inlinings2', -- pointless for 2.01 - # stg2stg passes - '-flambda-lift', +# '-flambda-lift', $Oopt_FinalStgProfilingMassage, $Oopt_StgStats, @@ -3213,6 +3074,7 @@ arg: while($_ = $Args[0]) { /^-fallow-overlapping-instances$/ && do { push(@HsC_flags, $_); next arg; }; /^-fallow-undecidable-instances$/ && do { push(@HsC_flags, $_); next arg; }; + /^-fhistory-size.*$/ && do { push(@HsC_flags, $_); next arg; }; /^-fglasgow-exts$/ && do { push(@HsC_flags, $_); push(@HsP_flags, '-N'); @@ -3237,25 +3099,11 @@ arg: while($_ = $Args[0]) { /^-ffoldr-build$/ && do { $Oopt_FoldrBuild = 1; - $Oopt_FB_Support = '-fdo-arity-expand'; #print "Yes F/B\n"; next arg; }; /^-fno-foldr-build$/ && do { $Oopt_FoldrBuild = 0; - $Oopt_FB_Support = ''; - next arg; }; - - /^-fno-foldr-build-rule$/ - && do { $Oopt_FoldrBuild = 0; - next arg; }; - - /^-fno-enable-tech$/ - && do { $Oopt_FB_Support = ''; - next arg; }; - - /^-fno-snapback-to-append$/ - && do { $Oopt_FoldrBuildInline .= ' -fdo-not-fold-back-append '; next arg; }; # --------------- Renamer ------------- @@ -3287,9 +3135,6 @@ arg: while($_ = $Args[0]) { /^-fno-pre-inlining$/ && do { push(@HsC_flags, $_); next arg }; - /^-fdo-monad-eta-expansion$/ - && do { $Oopt_MonadEtaExpansion = $_; next arg; }; - /^-fno-let-from-(case|app|strict-let)$/ # experimental, really (WDP 95/10) && do { push(@HsC_flags, $_); next arg; }; -- 1.7.10.4