1. 18 Mar, 2002 1 commit
  2. 14 Mar, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-03-14 15:27:15 by simonpj] · 1553c778
      simonpj authored
      ------------------------
      	Change
      		GlobalName --> ExternalName
      		LocalName  ->  InternalName
      	------------------------
      
      For a long time there's been terminological confusion between
      
      	GlobalName vs LocalName	 (property of a Name)
      	GlobalId vs LocalId	 (property of an Id)
      
      I've now changed the terminology for Name to be
      
      	ExternalName vs InternalName
      
      I've also added quite a bit of documentation in the Commentary.
      1553c778
  3. 04 Jan, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-01-04 11:39:00 by simonpj] · ce26c4b7
      simonpj authored
      -----------------------------
      	Fix a too-vigorous export bug
      	-----------------------------
      
      	MERGE TO STABLE
      
      	[this is the Ian Lynagh -O2 bug]
      
      
      CoreTidy didn't filter the rules that it exports, so it
      exported some that mentioned Ids on the *left* hand side
      that are not exported.  So an importing module fell over.
      
      The fix is simple: filter the exposed rules.   On the way
      I tidied up CoreFVs a little.
      ce26c4b7
  4. 06 Dec, 2001 1 commit
  5. 19 Nov, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-11-19 14:23:52 by simonpj] · d8af6b8c
      simonpj authored
      --------------------------------------
      	Yet another cut at the DmdAnal domains
      	--------------------------------------
      
      This version of the domain for demand analysis was developed
      in discussion with Peter Sestoft, so I think it might at last
      be more or less right!
      
      Our idea is mentally to separate
      	strictness analysis
      from
      	absence and boxity analysis
      
      Then we combine them back into a single domain.  The latter
      is all you see in the compiler (the Demand type, as before)
      but we understand it better now.
      d8af6b8c
  6. 24 Oct, 2001 3 commits
  7. 19 Oct, 2001 1 commit
  8. 18 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-18 16:29:12 by simonpj] · 685e04e4
      simonpj authored
      ----------------------------------------------
      	The CoreTidy/CorePrep/CoreToStg saga continues
      	[actually, this commit mostly completes the job]
      	----------------------------------------------
      
      			DO NOT MERGE!
      
      * CorePrep injects implicit bindings, not the type checker,
        nor CgConTbls.   (This way, all the code generators see
        them, so no need to fiddle with the byte code generator.)
      
        As a result, all bindings in the module are for LocalIds,
        at least until CoreTidy.   This is a Big Win.
      
        Hence remove nasty isImplicitId test in update_bndr in
        SimplCore and DmdAnal
      
      * hasNoBinding is no longer true of a dataConId (worker).
        There's an implicit curried binding for it.
      
      * Remove yukky test in exprIsTrivial that did not regard
        a hasNoBinding Id as trivial; similarly in SimplUtils.tryEtaReduce
      
      * In CoreTidy, get the names to avoid from the type env.
        That way it includes implicit bindings too.
      
      * CoreTidy set the Arity of a top-level Id permanently;
        it's up to the rest of the compiler to respect it.
        Notably, CorePrep uses etaExpand to make the manifest arity
        match the claimed arity.
      
      * As a result, nuke CgArity, so that CgInfo now contains only
        CafInfo.  The CafInfo is knot-tied as before.
      
      
      Other things
      
      * In Simplify.simplLazyBind, be a bit keener to float bindings
        out if it's a top-level binding.
      685e04e4
  9. 15 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-15 15:06:01 by simonpj] · 713b32a5
      simonpj authored
      --------------------------
      	Tidy up arity propagation
      	--------------------------
      
      Due to excessive complexity, correct arity information was getting
      lost on the way to interface files.  As a result, a function that had
      CPR info __S SLm (say), was getting arity 0, and this confused the (old)
      CPR analyser ("lub of function and HasCPR").
      
      I hope this fixes the above error (which showed up somewhere in
      compiling Edison), but I'm going to commit it right now anyway.
      Meanwhile I'll recompile Edison too.
      
      
      Details
      ~~~~~~~
      Digging out the rather obscure cause made me tidy up the CgInfo stuff.
      The story is now
      
      * The CgInfo field of an Id gets attached to the Id *only* in
        the TypeEnv of the ModuleDetails, during CoreTidy.
      
        This ModuleDetails stuff is used
      	a) to generate the interface file
      	b) to import into other modules in GHCi
      
      * No CgInfo field is in the CoreBindings which are passed
        downsteam to CorePrep and thence CodeGen.  Quite right too...
        it's the downstream stuff that *generates* the CgInfo.
      
      * But the Arity field *is* now passed on through CoreTidy
        (like strictness info) since it is usefully used by CorePrep.
      
      * On the way I simplified the ArityInfo field of an IdInfo
        to simply
      		Arity
        instead of
      		Maybe Arity
      713b32a5
  10. 04 Oct, 2001 1 commit
  11. 03 Oct, 2001 3 commits
    • simonpj's avatar
      [project @ 2001-10-03 16:20:57 by simonpj] · a1b59a18
      simonpj authored
      Add comments, and nuke strictness info in CoreTidy if totally boring
      a1b59a18
    • simonpj's avatar
      [project @ 2001-10-03 13:58:13 by simonpj] · 4a1e12a1
      simonpj authored
      ----------------------------------------------
      	Output curried functions for data constructors
      	----------------------------------------------
      			(incomplete)
      
      The idea here is to output code for the *curried* version of
      the worker of a data constructor, so that the worker can be
      treated as a first-class citizen elsewhere in the compiler.
      In particular, it doesn't need to be a "hasNoBinding" thing,
      which are the subject of a number of nasty hacks.
      
      These changes only do the business for the code gen route
      via AbstractC.  Remaining to do: the byte code generator.
      
      Idea: move the byte-code gen to STG code, and inject the
      curried data-constructor workers at the STG stage.
      
      
      	I hope the changes here won't make
      	anything stop working.  For now, constructor
      	workers remain "hasNoBinding" things.
      
      CgConTbls, CodeGen, CoreTidy, CoreToStg
      4a1e12a1
    • simonmar's avatar
      [project @ 2001-10-03 09:20:20 by simonmar] · 28274f6a
      simonmar authored
      minor wibble: use Maybe.isJust rather than maybeToBool
      28274f6a
  12. 26 Sep, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-09-26 15:12:33 by simonpj] · e0d750be
      simonpj authored
      ------------------
      		Simon's big commit
      		------------------
      
      This commit, which I don't think I can sensibly do piecemeal, consists
      of the things I've been doing recently, mainly directed at making
      Manuel, George, and Marcin happier with RULES.
      
      
      Reogranise the simplifier
      ~~~~~~~~~~~~~~~~~~~~~~~~~
      1. The simplifier's environment is now an explicit parameter.  This
      makes it a bit easier to figure out where it is going.
      
      2. Constructor arguments can now be arbitrary expressions, except
      when the application is the RHS of a let(rec).  This makes it much
      easier to match rules like
      
      	RULES
      	    "foo"  f (h x, g y) = f' x y
      
      In the simplifier, it's Simplify.mkAtomicArgs that ANF-ises a
      constructor application where necessary.  In the occurrence analyser,
      there's a new piece of context info (OccEncl) to say whether a
      constructor app is in a place where it should be in ANF.  (Unless
      it knows this it'll give occurrence info which will inline the
      argument back into the constructor app.)
      
      3. I'm experimenting with doing the "float-past big lambda" transformation
      in the full laziness pass, rather than mixed in with the simplifier (was
      tryRhsTyLam).
      
      4.  Arrange that
      	case (coerce (S,T) (x,y)) of ...
      will simplify.  Previous it didn't.
      A local change to CoreUtils.exprIsConApp_maybe.
      
      5. Do a better job in CoreUtils.exprEtaExpandArity when there's an
      error function in one branch.
      
      
      Phase numbers, RULES, and INLINE pragmas
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      1.  Phase numbers decrease from N towards zero (instead of increasing).
      This makes it easier to add new earlier phases, which is what users want
      to do.
      
      2.  RULES get their own phase number, N, and are disabled in phases before N.
      
      e.g. 	{-# RULES "foo" [2] forall x y.  f (x,y) = f' x y #-}
      
      Note the [2], which says "only active in phase 2 and later".
      
      3.  INLINE and NOINLINE pragmas have a phase number to.  This is now treated
      in just the same way as the phase number on RULE; that is, the Id is not inlined
      in phases earlier than N.  In phase N and later the Id *may* be inlined, and
      here is where INLINE and NOINLINE differ: INLNE makes the RHS look small, so
      as soon as it *may* be inlined it probably *will* be inlined.
      
      The syntax of the phase number on an INLINE/NOINLINE pragma has changed to be
      like the RULES case (i.e. in square brackets).  This should also make sure
      you examine all such phase numbers; many will need to change now the numbering
      is reversed.
      
      Inlining Ids is no longer affected at all by whether the Id appears on the
      LHS of a rule.  Now it's up to the programmer to put a suitable INLINE/NOINLINE
      pragma to stop it being inlined too early.
      
      
      Implementation notes:
      
      *  A new data type, BasicTypes.Activation says when a rule or inline pragma
      is active.   Functions isAlwaysActive, isNeverActive, isActive, do the
      obvious thing (all in BasicTypes).
      
      * Slight change in the SimplifierSwitch data type, which led to a lot of
      simplifier-specific code moving from CmdLineOpts to SimplMonad; a Good Thing.
      
      * The InlinePragma in the IdInfo of an Id is now simply an Activation saying
      when the Id can be inlined.  (It used to be a rather bizarre pair of a
      Bool and a (Maybe Phase), so this is much much easier to understand.)
      
      * The simplifier has a "mode" environment switch, replacing the old
      black list.  Unfortunately the data type decl has to be in
      CmdLineOpts, because it's an argument to the CoreDoSimplify switch
      
          data SimplifierMode = SimplGently | SimplPhase Int
      
      Here "gently" means "no rules, no inlining".   All the crucial
      inlining decisions are now collected together in SimplMonad
      (preInlineUnconditionally, postInlineUnconditionally, activeInline,
      activeRule).
      
      
      Specialisation
      ~~~~~~~~~~~~~~
      1.  Only dictionary *functions* are made INLINE, not dictionaries that
      have no parameters.  (This inline-dictionary-function thing is Marcin's
      idea and I'm still not sure whether it's a good idea.  But it's definitely
      a Bad Idea when there are no arguments.)
      
      2.  Be prepared to specialise an INLINE function: an easy fix in
      Specialise.lhs
      
      But there is still a problem, which is that the INLINE wins
      at the call site, so we don't use the specialised version anyway.
      I'm still unsure whether it makes sense to SPECIALISE something
      you want to INLINE.
      
      
      
      
      
      Random smaller things
      ~~~~~~~~~~~~~~~~~~~~~~
      
      * builtinRules (there was only one, but may be more) in PrelRules are now
        incorporated.   They were being ignored before...
      
      * OrdList.foldOL -->  OrdList.foldrOL, OrdList.foldlOL
      
      * Some tidying up of the tidyOpenTyVar, tidyTyVar functions.  I've
        forgotten exactly what!
      e0d750be
  13. 14 Sep, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-09-14 15:51:41 by simonpj] · 5ab261bb
      simonpj authored
      --------------------------
      	Add a rule-check pass
      	(special request by Manuel)
      	--------------------------
      
      	DO NOT merge with stable
      
      The flag
      
      	-frule-check foo
      
      will report all sites at which RULES whose name starts with "foo.."
      might apply, but in fact the arguments don't match so the rule
      doesn't apply.
      
      The pass is run right after all the core-to-core passes.  (Next thing
      to do: make the core-to-core script external, so you can fiddle with
      it.  Meanwhile, the core-to-core script is in
      	DriverState.builCoreToDo
      so you can move the CoreDoRuleCheck line around if you want.
      
      The format of the report is experimental: Manuel, feel free to fiddle
      with it.
      
      Most of the code is in specialise/Rules.lhs
      
      
      Incidental changes
      ~~~~~~~~~~~~~~~~~~
      Change BuiltinRule so that the rule name is accessible
      without actually successfully applying the rule.  This
      change affects quite a few files in a trivial way.
      5ab261bb
  14. 24 Aug, 2001 1 commit
  15. 25 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-25 09:19:41 by simonpj] · a47868d5
      simonpj authored
      ---------------------------------
      	Another long-standing infelicity!
      	---------------------------------
      
      CoreTidy was throwing away demand info on let-binders.
      This meant that CorePrep would build a let (thunk) instead of
      a case, even if the Id is sure to be demanded.
      
      Easily fixed by making CoreTidy retain the demand info.
      
      This demand-analysis stuff is having the excellent side effect
      of flushing out performance bugs!
      a47868d5
  16. 23 Jul, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-07-23 10:54:46 by simonpj] · f6cd95ff
      simonpj authored
      ---------------------------------
      	Switch to the new demand analyser
      	---------------------------------
      
      This commit makes the new demand analyser the main beast,
      with the old strictness analyser as a backup.  When
      DEBUG is on, the old strictness analyser is run too, and the
      results compared.
      
      WARNING: this isn't thorougly tested yet, so expect glitches.
      Delay updating for a few days if the HEAD is mission critical
      for you.
      
      But do try it out.  I'm away for 2.5 weeks from Thursday, so
      it would be good to shake out any glaring bugs before then.
      f6cd95ff
  17. 12 Jun, 2001 1 commit
  18. 14 May, 2001 2 commits
    • sewardj's avatar
      [project @ 2001-05-14 16:40:54 by sewardj] · 7e8d0a0b
      sewardj authored
      Record-selector unfolding fix #2
      7e8d0a0b
    • simonpj's avatar
      [project @ 2001-05-14 12:03:41 by simonpj] · ea8abf4c
      simonpj authored
      ****	MERGE WITH 5.00 BRANCH     ********
      
      	-----------------------------------------------
      	Expose record selectors with correct unfoldings
      	-----------------------------------------------
      
      The problem was that there was that with "ghc --make" we were
      passing on record selectors to importing modules in their un-tidied
      form.  The idea was that they have very stylised bindings so they
      don't need tidying.  But they do, because they may mention error
      messages that get floated out.
      
      Here's the comment from CoreTidy.lhs
      
      -- MINOR-HACK ALERT: we *do* tidy record selectors.  Reason: they mention error
      -- messages, which may be floated out:
      --	x_field pt = case pt of
      --			Rect x y -> y
      --			Pol _ _  -> error "buggle wuggle"
      -- The error message will be floated out so we'll get
      --	lvl5 = error "buggle wuggle"
      --	x_field pt = case pt of
      --			Rect x y -> y
      --			Pol _ _  -> lvl5
      --
      -- When this happens, it's vital that the Id exposed to importing modules
      -- (by ghci) mentions lvl5 in its unfolding, not the un-tidied version.
      --
      -- What about the Id in the TyCon?  It probably shouldn't be in the TyCon at
      -- all, but in any case it will have the error message inline so it won't matter.
      ea8abf4c
  19. 23 Mar, 2001 1 commit
  20. 19 Mar, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-03-19 16:13:22 by simonpj] · 17d765ce
      simonpj authored
      -------------------------------
      	Improve orphan-module resolution
      	-------------------------------
      
      Consider the following rule (and there are lots of these in
      the Prelude):
      
      	fromIntegral T = fromIntegral_T
      
      where T is defined in the module being compiled.
      
      is an orphan.  Of course it isn't, an declaring it an orphan would
      make the whole module an orphan module, which is bad.
      
      This commit arranges to determine orphan rules, and the orphan-hood
      of a module, much later than before.  (Before mi_orphan was set by
      the renamer, now it is set by MkIface.)
      17d765ce
  21. 13 Mar, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-03-13 12:50:29 by simonmar] · 10cbc75d
      simonmar authored
      Some rearrangements that Simon & I have been working on recently:
      
          - CoreSat is now CorePrep, and is a general "prepare-for-code-
            generation" pass.  It does cloning, saturation of constructors &
            primops, A-normal form, and a couple of other minor fiddlings.
      
          - CoreTidy no longer does cloning, and minor fiddlings.  It doesn't
            need the unique supply any more, so that's removed.
      
          - CoreToStg now collects CafInfo and the list of CafRefs for each
            binding.  The SRT pass is much simpler now.
      
          - IdInfo now has a CgInfo field for "code generator info".  It currently
            contains arity (the actual code gen arity which affects the calling
            convention as opposed to the ArityInfo which is a measure of how
            many arguments the Id can be applied to before it does any work), and
            CafInfo.
      
            Previously we overloaded the ArityInfo field to contain both
            codegen arity and simplifier arity.  Things are cleaner now.
      
          - CgInfo is collected by CoreToStg, and passed back into CoreTidy in
            a loop.  The compiler will complain rather than going into a black
            hole if the CgInfo is pulled on too early.
      
          - Worker info in an interface file now comes with arity info attached.
            Previously the main arity info was overloaded for this purpose, but
            it lead to a few hacks in the compiler, this tidies things up somewhat.
      
      Bottom line: we removed several fragilities, and tidied up a number of
      things.  Code size should be smaller, but we'll see...
      10cbc75d
  22. 08 Mar, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-03-08 12:07:38 by simonpj] · 51a571c0
      simonpj authored
      --------------------
      	A major hygiene pass
      	--------------------
      
      1. The main change here is to
      
      	Move what was the "IdFlavour" out of IdInfo,
      	and into the varDetails field of a Var
      
         It was a mess before, because the flavour was a permanent attribute
         of an Id, whereas the rest of the IdInfo was ephemeral.  It's
         all much tidier now.
      
         Main places to look:
      
      	   Var.lhs	Defn of VarDetails
      	   IdInfo.lhs	Defn of GlobalIdDetails
      
         The main remaining infelicity is that SpecPragmaIds are right down
         in Var.lhs, which seems unduly built-in for such an ephemeral thing.
         But that is no worse than before.
      
      
      2. Tidy up the HscMain story a little.  Move mkModDetails from MkIface
         into CoreTidy (where it belongs more nicely)
      
         This was partly forced by (1) above, because I didn't want to make
         DictFun Ids into a separate kind of Id (which is how it was before).
         Not having them separate means we have to keep a list of them right
         through, rather than pull them out of the bindings at the end.
      
      3. Add NameEnv as a separate module (to join NameSet).
      
      4. Remove unnecessary {-# SOURCE #-} imports from FieldLabel.
      51a571c0
  23. 27 Feb, 2001 1 commit
  24. 26 Feb, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-02-26 15:06:57 by simonmar] · 1c62b517
      simonmar authored
      Implement do-style bindings on the GHCi command line.
      
      The syntax for a command-line is exactly that of a do statement, with
      the following meanings:
      
        - `pat <- expr'
          performs expr, and binds each of the variables in pat.
      
        - `let pat = expr; ...'
          binds each of the variables in pat, doesn't do any evaluation
      
        - `expr'
          behaves as `it <- expr' if expr is IO-typed, or `let it = expr'
          followed by `print it' otherwise.
      1c62b517
  25. 29 Jan, 2001 1 commit
  26. 26 Jan, 2001 1 commit
  27. 25 Jan, 2001 1 commit
  28. 20 Dec, 2000 3 commits
  29. 08 Dec, 2000 5 commits