1. 20 Feb, 2011 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Added a VECTORISE pragma · f2aaae97
      chak@cse.unsw.edu.au. authored
      - Added a pragma {-# VECTORISE var = exp #-} that prevents
        the vectoriser from vectorising the definition of 'var'.
        Instead it uses the binding '$v_var = exp' to vectorise
        'var'.  The vectoriser checks that the Core type of 'exp'
        matches the vectorised Core type of 'var'.  (It would be
        quite complicated to perform that check in the type checker
        as the vectorisation of a type needs the state of the VM
      - Added parts of a related VECTORISE SCALAR pragma
      - Documented -ddump-vect
      - Added -ddump-vt-trace
      - Some clean up
  2. 21 Oct, 2010 1 commit
  3. 13 Sep, 2010 1 commit
  4. 28 Oct, 2009 1 commit
  5. 02 Oct, 2009 1 commit
  6. 08 Sep, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3403: interaction of CPR and pattern-match failure · 8a25c54e
      simonpj@microsoft.com authored
      A fine bug report (#3403) demonstrated that we were losing the tail
      call property when a complicated pattern match was involved.  After
      a bit of investigation I discovered that the culprit was the failure
      join-point introduced by the pattern matcher.  It was a zero-argument
      thunk, which is not very CPR-friendly, and that interacted badly with
      CPR worker/wrapper.
      It's easy to fix, the same way that we fix other join points, by supplying
      a dummy argument (that is not really passed at runtime.
  7. 23 Jul, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add tuple sections as a new feature · 58521c72
      simonpj@microsoft.com authored
      This patch adds tuple sections, so that
      	(x,,z)  means   \y -> (x,y,z)
      Thanks for Max Bolinbroke for doing the hard work.
      In the end, instead of using two constructors in HsSyn, I used
      just one (still called ExplicitTuple) whose arguments can be
      	Present (LHsExpr id)
      or	Missing PostTcType
      While I was at it, I did a bit of refactoring too.
  8. 03 Jun, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Allow RULES for seq, and exploit them · 90ce88a0
      simonpj@microsoft.com authored
      Roman found situations where he had
            case (f n) of _ -> e
      where he knew that f (which was strict in n) would terminate if n did.
      Notice that the result of (f n) is discarded. So it makes sense to
      transform to
            case n of _ -> e
      Rather than attempt some general analysis to support this, I've added
      enough support that you can do this using a rewrite rule:
        RULE "f/seq" forall n.  seq (f n) e = seq n e
      You write that rule.  When GHC sees a case expression that discards
      its result, it mentally transforms it to a call to 'seq' and looks for
      a RULE.  (This is done in Simplify.rebuildCase.)  As usual, the
      correctness of the rule is up to you.
      This patch implements the extra stuff.  I have not documented it explicitly
      in the user manual yet... let's see how useful it is first.
      The patch looks bigger than it is, because
        a) Comments; see esp MkId Note [seqId magic]
        b) Some refactoring.  Notably, I moved the special desugaring for
           seq from MkCore back into DsUtils where it properly belongs.
           (It's really a desugaring thing, not a CoreSyn invariant.)
        c) Annoyingly, in a RULE left-hand side we need to be careful that
           the magical desugaring done in MkId Note [seqId magic] item (c) 
           is *not* done on the LHS of a rule. Or rather, we arrange to 
           un-do it, in DsBinds.decomposeRuleLhs.
  9. 31 Mar, 2009 1 commit
  10. 30 Mar, 2009 1 commit
  11. 20 Sep, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Tidy up the treatment of dead binders · 7e8cba32
      simonpj@microsoft.com authored
      This patch does a lot of tidying up of the way that dead variables are
      handled in Core.  Just the sort of thing to do on an aeroplane.
      * The tricky "binder-swap" optimisation is moved from the Simplifier
        to the Occurrence Analyser.  See Note [Binder swap] in OccurAnal.
        This is really a nice change.  It should reduce the number of
        simplifier iteratoins (slightly perhaps).  And it means that
        we can be much less pessimistic about zapping occurrence info
        on binders in a case expression.  
      * For example:
      	case x of y { (a,b) -> e }
        Previously, each time around, even if y,a,b were all dead, the
        Simplifier would pessimistically zap their OccInfo, so that we
        can't see they are dead any more.  As a result virtually no 
        case expression ended up with dead binders.  This wasn't Bad
        in itself, but it always felt wrong.
      * I added a check to CoreLint to check that a dead binder really
        isn't used.  That showed up a couple of bugs in CSE. (Only in
        this sense -- they didn't really matter.)
      * I've changed the PprCore printer to print "_" for a dead variable.
        (Use -dppr-debug to see it again.)  This reduces clutter quite a
        bit, and of course it's much more useful with the above change.
      * Another benefit of the binder-swap change is that I could get rid of
        the Simplifier hack (working, but hacky) in which the InScopeSet was
        used to map a variable to a *different* variable. That allowed me
        to remove VarEnv.modifyInScopeSet, and to simplify lookupInScopeSet
        so that it doesn't look for a fixpoint.  This fixes no bugs, but 
        is a useful cleanup.
      * Roman pointed out that Id.mkWildId is jolly dangerous, because
        of its fixed unique.  So I've 
           - localied it to MkCore, where it is private (not exported)
           - renamed it to 'mkWildBinder' to stress that you should only
             use it at binding sites, unless you really know what you are
           - provided a function MkCore.mkWildCase that emodies the most
             common use of mkWildId, and use that elsewhere
         So things are much better
      * A knock-on change is that I found a common pattern of localising
        a potentially global Id, and made a function for it: Id.localiseId
  12. 15 Sep, 2008 1 commit
  13. 31 Jul, 2008 1 commit
  14. 20 Jul, 2008 1 commit
  15. 01 Jul, 2008 1 commit
  16. 05 Jun, 2008 2 commits
    • simonpj@microsoft.com's avatar
    • simonpj@microsoft.com's avatar
      Add non-recursive let-bindings for types · 1b1190e0
      simonpj@microsoft.com authored
      This patch adds to Core the ability to say
      	let a = Int in <body>
      where 'a' is a type variable.  That is: a type-let.
      See Note [Type let] in CoreSyn.
      * The binding is always non-recursive
      * The simplifier immediately eliminates it by substitution 
      So in effect a type-let is just a delayed substitution.  This is convenient
      in a couple of places in the desugarer, one existing (see the call to
      CoreTyn.mkTyBind in DsUtils), and one that's in the next upcoming patch.
      The first use in the desugarer was previously encoded as
      	(/\a. <body>) Int
      rather that eagerly substituting, but that was horrid because Core Lint
      had do "know" that a=Int inside <body> else it would bleat.  Expressing
      it directly as a 'let' seems much nicer.
  17. 16 May, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Improve the treatment of 'seq' (Trac #2273) · 4e36a8b1
      simonpj@microsoft.com authored
      Trac #2273 showed a case in which 'seq' didn't cure the space leak
      it was supposed to.  This patch does two things to help
      a) It removes a now-redundant special case in Simplify, which
         switched off the case-binder-swap in the early stages.  This
         isn't necessary any more because FloatOut has improved since
         the Simplify code was written.  And switching off the binder-swap
         is harmful for seq.
      However fix (a) is a bit fragile, so I did (b) too:
      b) Desugar 'seq' specially.  See Note [Desugaring seq (2)] in DsUtils
         This isn't very robust either, since it's defeated by abstraction, 
         but that's not something GHC can fix; the programmer should use
         a let! instead.
  18. 12 Apr, 2008 1 commit
  19. 23 Mar, 2008 1 commit
  20. 28 Feb, 2008 1 commit
  21. 17 Jan, 2008 1 commit
  22. 20 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Implement generalised list comprehensions · 67cb4091
      simonpj@microsoft.com authored
        This patch implements generalised list comprehensions, as described in 
        the paper "Comprehensive comprehensions" (Peyton Jones & Wadler, Haskell
        Workshop 2007).  If you don't use the new comprehensions, nothing
        should change.
        The syntax is not exactly as in the paper; see the user manual entry 
        for details.
        You need an accompanying patch to the base library for this stuff 
        to work.
        The patch is the work of Max Bolingbroke [batterseapower@hotmail.com], 
        with some advice from Simon PJ.
        The related GHC Wiki page is 
  23. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      Implementation notes: 
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
  24. 04 Sep, 2007 1 commit
  25. 03 Sep, 2007 1 commit
  26. 01 Sep, 2007 1 commit
  27. 21 Jun, 2007 1 commit
    • David Himmelstrup's avatar
      Add several new record features · 2eb04ca0
      David Himmelstrup authored
      1. Record disambiguation (-fdisambiguate-record-fields)
      In record construction and pattern matching (although not
      in record updates) it is clear which field name is intended
      even if there are several in scope.  This extension uses
      the constructor to disambiguate.  Thus
      	C { x=3 }
      uses the 'x' field from constructor C (assuming there is one)
      even if there are many x's in scope.
      2. Record punning (-frecord-puns)
      In a record construction or pattern match or update you can 
      omit the "=" part, thus
      	C { x, y }
      This is just syntactic sugar for
      	C { x=x, y=y }
      3.  Dot-dot notation for records (-frecord-dot-dot)
      In record construction or pattern match (but not update) 
      you can use ".." to mean "all the remaining fields".  So
      	C { x=v, .. }
      means to fill in the remaining fields to give
      	C { x=v, y=y }
      (assuming C has fields x and y).  This might reasonably
      considered very dodgy stuff.  For pattern-matching it brings
      into scope a bunch of things that are not explictly mentioned;
      and in record construction it just picks whatver 'y' is in
      scope for the 'y' field.   Still, Lennart Augustsson really
      wants it, and it's a feature that is extremely easy to explain.
      I thought of using the "parent" field in the GlobalRdrEnv, but
      that's really used for import/export and just isn't right for this.
      For example, for import/export a field is a subordinate of the *type
      constructor* whereas here we need to know what fields belong to a
      particular *data* constructor.
      The main thing is that we need to map a data constructor to its
      fields, and we need to do so in the renamer.   For imported modules
      it's easy: just look in the imported TypeEnv.  For the module being
      compiled, we make a new field tcg_field_env in the TcGblEnv.
      The important functions are
      There is still a significant infelicity in the way the renamer
      works on patterns, which I'll tackle next.
      I also did quite a bit of refactoring in the representation of
      record fields (mainly in HsPat).***END OF DESCRIPTION***
      Place the long patch description above the ***END OF DESCRIPTION*** marker.
      The first line of this file will be the patch name.
      This patch contains the following changes:
      M ./compiler/deSugar/Check.lhs -3 +5
      M ./compiler/deSugar/Coverage.lhs -6 +7
      M ./compiler/deSugar/DsExpr.lhs -6 +13
      M ./compiler/deSugar/DsMeta.hs -8 +8
      M ./compiler/deSugar/DsUtils.lhs -1 +1
      M ./compiler/deSugar/MatchCon.lhs -2 +2
      M ./compiler/hsSyn/Convert.lhs -3 +3
      M ./compiler/hsSyn/HsDecls.lhs -9 +25
      M ./compiler/hsSyn/HsExpr.lhs -13 +3
      M ./compiler/hsSyn/HsPat.lhs -25 +63
      M ./compiler/hsSyn/HsUtils.lhs -3 +3
      M ./compiler/main/DynFlags.hs +6
      M ./compiler/parser/Parser.y.pp -13 +17
      M ./compiler/parser/RdrHsSyn.lhs -16 +18
      M ./compiler/rename/RnBinds.lhs -2 +2
      M ./compiler/rename/RnEnv.lhs -22 +82
      M ./compiler/rename/RnExpr.lhs -34 +12
      M ./compiler/rename/RnHsSyn.lhs -3 +2
      M ./compiler/rename/RnSource.lhs -50 +78
      M ./compiler/rename/RnTypes.lhs -50 +84
      M ./compiler/typecheck/TcExpr.lhs -18 +18
      M ./compiler/typecheck/TcHsSyn.lhs -20 +21
      M ./compiler/typecheck/TcPat.lhs -8 +6
      M ./compiler/typecheck/TcRnMonad.lhs -6 +15
      M ./compiler/typecheck/TcRnTypes.lhs -2 +11
      M ./compiler/typecheck/TcTyClsDecls.lhs -3 +4
      M ./docs/users_guide/flags.xml +7
      M ./docs/users_guide/glasgow_exts.xml +42
  28. 11 May, 2007 1 commit
  29. 02 May, 2007 1 commit
  30. 24 Apr, 2007 1 commit
    • Simon Marlow's avatar
      Breakpoints: get the names of the free variables right · 367b0590
      Simon Marlow authored
      Previously we relied on the names of the Ids attached to a tick being
      the same as the names of the original variables in the source code.
      Sometimes this worked, sometimes it didn't because the simplifier
      would inline away the Id.  So now we do this properly and retain the
      original OccNames from the source code for each breakpoint, and use
      these to construct the new Ids when we stop.
      Doing this involved moving the tracking of in-scope variables from the
      desugarer to the coverage pass.
  31. 17 Apr, 2007 1 commit
    • Simon Marlow's avatar
      Re-working of the breakpoint support · cdce6477
      Simon Marlow authored
      This is the result of Bernie Pope's internship work at MSR Cambridge,
      with some subsequent improvements by me.  The main plan was to
       (a) Reduce the overhead for breakpoints, so we could enable 
           the feature by default without incurrent a significant penalty
       (b) Scatter more breakpoint sites throughout the code
      Currently we can set a breakpoint on almost any subexpression, and the
      overhead is around 1.5x slower than normal GHCi.  I hope to be able to
      get this down further and/or allow breakpoints to be turned off.
      This patch also fixes up :print following the recent changes to
      constructor info tables.  (most of the :print tests now pass)
      We now support single-stepping, which just enables all breakpoints.
        :step <expr>     executes <expr> with single-stepping turned on
        :step            single-steps from the current breakpoint
      The mechanism is quite different to the previous implementation.  We
      share code with the HPC (haskell program coverage) implementation now.
      The coverage pass annotates source code with "tick" locations which
      are tracked by the coverage tool.  In GHCi, each "tick" becomes a
      potential breakpoint location.
      Previously breakpoints were compiled into code that magically invoked
      a nested instance of GHCi.  Now, a breakpoint causes the current
      thread to block and control is returned to GHCi.
      See the wiki page for more details and the current ToDo list:
  32. 16 Mar, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Desugar applications of 'seq' specially; fix Trac #1031 · 3bdbcf16
      simonpj@microsoft.com authored
      Merge to 6.6 branch.  Test case is dsrun014.
      Note [Desugaring seq]  cf Trac #1031
         f x y = x `seq` (y `seq` (# x,y #))
      The [CoreSyn let/app invariant] means that, other things being equal, because 
      the argument to the outer 'seq' has an unlifted type, we'll use call-by-value thus:
         f x y = case (y `seq` (# x,y #)) of v -> x `seq` v
      But that is bad for two reasons: 
        (a) we now evaluate y before x, and 
        (b) we can't bind v to an unboxed pair
      Seq is very, very special!  So we recognise it right here, and desugar to
      	case x of _ -> case y of _ -> (# x,y #)
      The special case would be valid for all calls to 'seq', but it's only *necessary*
      for ones whose second argument has an unlifted type. So we only catch the latter
      case here, to avoid unnecessary tests.
  33. 05 Feb, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Establish the CoreSyn let/app invariant · 7b01315d
      simonpj@microsoft.com authored
      This patch clears up a long-standing wart.   For some time it's been the
      case that 
      	the RHS of a non-recursive let can be unlifed iff 
      	the RHS is ok-for-speculation
      This patch extends the invariant to the argument of an App, and 
      establishes it by the smart constructors mkDsApp, mkDsApps in the desugarer.
      Once established, it should be maintained by the optimiser.
      This tides up some awkward cases, notably in exprIsHNF, and I think it
      fixes a outright strictness bug in Simplify.prepareRhs.
  34. 13 Dec, 2006 1 commit
  35. 29 Nov, 2006 1 commit
    • andy@galois.com's avatar
      TickBox representation change · 8100cd43
      andy@galois.com authored
      This changes the internal representation of TickBoxes,
              Note (TickBox "module" n)  <expr>
              case tick<module,n> of
                _ -> <expr>
      tick has type :: #State #World, when the module and tick numbe
      are stored inside IdInfo.
      Binary tick boxes change from
               Note (BinaryTickBox "module" t f) <expr>
                btick<module,t,f> <expr>
      btick has type :: Bool -> Bool, with the module and tick number
      stored inside IdInfo.
  36. 24 Oct, 2006 1 commit
    • andy@galois.com's avatar
      Haskell Program Coverage · d5934bbb
      andy@galois.com authored
      This large checkin is the new ghc version of Haskell
      Program Coverage, an expression-level coverage tool for Haskell.
       - Hpc.[ch] - small runtime support for Hpc; reading/writing *.tix files.
       - Coverage.lhs - Annotates the HsSyn with coverage tickboxes.
        - New Note's in Core,
            - TickBox      -- ticked on entry to sub-expression
            - BinaryTickBox  -- ticked on exit to sub-expression, depending
      	       	     -- on the boolean result.
        - New Stg level TickBox (no BinaryTickBoxes, though) 
      You can run the coverage tool with -fhpc at compile time. 
      Main must be compiled with -fhpc. 
  37. 11 Oct, 2006 1 commit
    • Simon Marlow's avatar
      Module header tidyup, phase 1 · 49c98d14
      Simon Marlow authored
      This patch is a start on removing import lists and generally tidying
      up the top of each module.  In addition to removing import lists:
         - Change DATA.IOREF -> Data.IORef etc.
         - Change List -> Data.List etc.
         - Remove $Id$
         - Update copyrights
         - Re-order imports to put non-GHC imports last
         - Remove some unused and duplicate imports
  38. 03 Oct, 2006 1 commit
  39. 20 Sep, 2006 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Indexed newtypes · 27897431
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 19:24:27 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Indexed newtypes
        Thu Aug 31 22:09:21 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
          * Indexed newtypes
          - This patch makes indexed newtypes work
          - Only lightly tested
          - We need to distinguish between open and closed newtypes in a number of 
            places, because looking through newtypes doesn't work easily for open ones.