1. 23 Mar, 2000 2 commits
    • simonpj's avatar
      [project @ 2000-03-23 17:45:17 by simonpj] · 111cee3f
      simonpj authored
      This utterly gigantic commit is what I've been up to in background
      mode in the last couple of months.  Originally the main goal
      was to get rid of Con (staturated constant applications)
      in the CoreExpr type, but one thing led to another, and I kept
      postponing actually committing.   Sorry.
      
      	Simon, 23 March 2000
      
      
      I've tested it pretty thoroughly, but doubtless things will break.
      
      Here are the highlights
      
      * Con is gone; the CoreExpr type is simpler
      * NoRepLits have gone
      * Better usage info in interface files => less recompilation
      * Result type signatures work
      * CCall primop is tidied up
      * Constant folding now done by Rules
      * Lots of hackery in the simplifier
      * Improvements in CPR and strictness analysis
      
      Many bug fixes including
      
      * Sergey's DoCon compiles OK; no loop in the strictness analyser
      * Volker Wysk's programs don't crash the CPR analyser
      
      I have not done much on measuring compilation times and binary sizes;
      they could have got worse.  I think performance has got significantly
      better, though, in most cases.
      
      
      Removing the Con form of Core expressions
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The big thing is that
      
        For every constructor C there are now *two* Ids:
      
      	C is the constructor's *wrapper*. It evaluates and unboxes arguments
      	before calling $wC.  It has a perfectly ordinary top-level defn
      	in the module defining the data type.
      
      	$wC is the constructor's *worker*.  It is like a primop that simply
      	allocates and builds the constructor value.  Its arguments are the
      	actual representation arguments of the constructor.
      	Its type may be different to C, because:
      		- useless dict args are dropped
      		- strict args may be flattened
      
        For every primop P there is *one* Id, its (curried) Id
      
        Neither contructor worker Id nor the primop Id have a defminition anywhere.
        Instead they are saturated during the core-to-STG pass, and the code generator
        generates code for them directly. The STG language still has saturated
        primops and constructor applications.
      
      * The Const type disappears, along with Const.lhs.  The literal part
        of Const.lhs reappears as Literal.lhs.  Much tidying up in here,
        to bring all the range checking into this one module.
      
      * I got rid of NoRep literals entirely.  They just seem to be too much trouble.
      
      * Because Con's don't exist any more, the funny C { args } syntax
        disappears from inteface files.
      
      
      Parsing
      ~~~~~~~
      * Result type signatures now work
      	f :: Int -> Int = \x -> x
      	-- The Int->Int is the type of f
      
      	g x y :: Int = x+y
      	-- The Int is the type of the result of (g x y)
      
      
      Recompilation checking and make
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * The .hi file for a modules is not touched if it doesn't change.  (It used to
        be touched regardless, forcing a chain of recompilations.)  The penalty for this
        is that we record exported things just as if they were mentioned in the body of
        the module.  And the penalty for that is that we may recompile a module when
        the only things that have changed are the things it is passing on without using.
        But it seems like a good trade.
      
      * -recomp is on by default
      
      Foreign declarations
      ~~~~~~~~~~~~~~~~~~~~
      * If you say
      	foreign export zoo :: Int -> IO Int
        then you get a C produre called 'zoo', not 'zzoo' as before.
        I've also added a check that complains if you export (or import) a C
        procedure whose name isn't legal C.
      
      
      Code generation and labels
      ~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Now that constructor workers and wrappers have distinct names, there's
        no need to have a Foo_static_closure and a Foo_closure for constructor Foo.
        I nuked the entire StaticClosure story.  This has effects in some of
        the RTS headers (i.e. s/static_closure/closure/g)
      
      
      Rules, constant folding
      ~~~~~~~~~~~~~~~~~~~~~~~
      * Constant folding becomes just another rewrite rule, attached to the Id for the
        PrimOp.   To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs).
        The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone.
      
      * Appending of constant strings now works, using fold/build fusion, plus
        the rewrite rule
      	unpack "foo" c (unpack "baz" c n)  =  unpack "foobaz" c n
        Implemented in PrelRules.lhs
      
      * The CCall primop is tidied up quite a bit.  There is now a data type CCall,
        defined in PrimOp, that packages up the info needed for a particular CCall.
        There is a new Id for each new ccall, with an big "occurrence name"
      	{__ccall "foo" gc Int# -> Int#}
        In interface files, this is parsed as a single Id, which is what it is, really.
      
      Miscellaneous
      ~~~~~~~~~~~~~
      * There were numerous places where the host compiler's
        minInt/maxInt was being used as the target machine's minInt/maxInt.
        I nuked all of these; everything is localised to inIntRange and inWordRange,
        in Literal.lhs
      
      * Desugaring record updates was broken: it didn't generate correct matches when
        used withe records with fancy unboxing etc.  It now uses matchWrapper.
      
      * Significant tidying up in codeGen/SMRep.lhs
      
      * Add __word, __word64, __int64 terminals to signal the obvious types
        in interface files.  Add the ability to print word values in hex into
        C code.
      
      * PrimOp.lhs is no longer part of a loop.  Remove PrimOp.hi-boot*
      
      
      Types
      ~~~~~
      * isProductTyCon no longer returns False for recursive products, nor
        for unboxed products; you have to test for these separately.
        There's no reason not to do CPR for recursive product types, for example.
        Ditto splitProductType_maybe.
      
      Simplification
      ~~~~~~~~~~~~~~~
      * New -fno-case-of-case flag for the simplifier.  We use this in the first run
        of the simplifier, where it helps to stop messing up expressions that
        the (subsequent) full laziness pass would otherwise find float out.
        It's much more effective than previous half-baked hacks in inlining.
      
        Actually, it turned out that there were three places in Simplify.lhs that
        needed to know use this flag.
      
      * Make the float-in pass push duplicatable bindings into the branches of
        a case expression, in the hope that we never have to allocate them.
        (see FloatIn.sepBindsByDropPoint)
      
      * Arrange that top-level bottoming Ids get a NOINLINE pragma
        This reduced gratuitous inlining of error messages.
        But arrange that such things still get w/w'd.
      
      * Arrange that a strict argument position is regarded as an 'interesting'
        context, so that if we see
      	foldr k z (g x)
        then we'll be inclined to inline g; this can expose a build.
      
      * There was a missing case in CoreUtils.exprEtaExpandArity that meant
        we were missing some obvious cases for eta expansion
        Also improve the code when handling applications.
      
      * Make record selectors (identifiable by their IdFlavour) into "cheap" operations.
      	  [The change is a 2-liner in CoreUtils.exprIsCheap]
        This means that record selection may be inlined into function bodies, which
        greatly improves the arities of overloaded functions.
      
      * Make a cleaner job of inlining "lone variables".  There was some distributed
        cunning, but I've centralised it all now in SimplUtils.analyseCont, which
        analyses the context of a call to decide whether it is "interesting".
      
      * Don't specialise very small functions in Specialise.specDefn
        It's better to inline it.  Rather like the worker/wrapper case.
      
      * Be just a little more aggressive when floating out of let rhss.
        See comments with Simplify.wantToExpose
        A small change with an occasional big effect.
      
      * Make the inline-size computation think that
      	case x of I# x -> ...
        is *free*.
      
      
      CPR analysis
      ~~~~~~~~~~~~
      * Fix what was essentially a bug in CPR analysis.  Consider
      
      	letrec f x = let g y = let ... in f e1
      		     in
      		     if ... then (a,b) else g x
      
        g has the CPR property if f does; so when generating the final annotated
        RHS for f, we must use an envt in which f is bound to its final abstract
        value.  This wasn't happening.  Instead, f was given the CPR tag but g
        wasn't; but of course the w/w pass gives rotten results in that case!!
        (Because f's CPR-ness relied on g's.)
      
        On they way I tidied up the code in CprAnalyse.  It's quite a bit shorter.
      
        The fact that some data constructors return a constructed product shows
        up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs
      
      
      
      Strictness analysis and worker/wrapper
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * BIG THING: pass in the demand to StrictAnal.saExpr.  This affects situations
        like
      	f (let x = e1 in (x,x))
        where f turns out to have strictness u(SS), say.  In this case we can
        mark x as demanded, and use a case expression for it.
      
        The situation before is that we didn't "know" that there is the u(SS)
        demand on the argument, so we simply computed that the body of the let
        expression is lazy in x, and marked x as lazily-demanded.  Then even after
        f was w/w'd we got
      
      	let x = e1 in case (x,x) of (a,b) -> $wf a b
      
        and hence
      
      	let x = e1 in $wf a b
      
        I found a much more complicated situation in spectral/sphere/Main.shade,
        which improved quite a bit with this change.
      
      * Moved the StrictnessInfo type from IdInfo to Demand.  It's the logical
        place for it, and helps avoid module loops
      
      * Do worker/wrapper for coerces even if the arity is zero.  Thus:
      	stdout = coerce Handle (..blurg..)
        ==>
      	wibble = (...blurg...)
      	stdout = coerce Handle wibble
        This is good because I found places where we were saying
      	case coerce t stdout of { MVar a ->
      	...
      	case coerce t stdout of { MVar b ->
      	...
        and the redundant case wasn't getting eliminated because of the coerce.
      111cee3f
    • sewardj's avatar
      [project @ 2000-03-23 12:22:04 by sewardj] · 1e5271f1
      sewardj authored
      In interface files, don't forget to mention the names of modules imported
      via hi-boot files.  This is needed so that Hugs can use the import decls
      in interface files to safely overestimate the dependency sets which it will
      encounter when linking object code.
      1e5271f1
  2. 20 Mar, 2000 1 commit
  3. 19 Mar, 2000 1 commit
  4. 18 Mar, 2000 1 commit
  5. 17 Mar, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-03-17 12:40:03 by simonmar] · 8ae10d70
      simonmar authored
      Add the readBlahOffAddr suite of primitives.  The previous method of
      using indexStuffOffAddr didn't enforce proper ordering in the I/O
      monad.
      
      The indexBlahOffAddr primops may go away in the future if/when we
      figure out how to make unsafePerformIO into a no-op at the back end.
      8ae10d70
  6. 16 Mar, 2000 1 commit
  7. 15 Mar, 2000 2 commits
  8. 14 Mar, 2000 1 commit
  9. 13 Mar, 2000 2 commits
  10. 11 Mar, 2000 1 commit
  11. 09 Mar, 2000 3 commits
  12. 08 Mar, 2000 2 commits
    • simonmar's avatar
      [project @ 2000-03-08 17:48:24 by simonmar] · de896403
      simonmar authored
      - generalise the per-module initialisation stubs so that we use it
        in normal (non-profiled) code too.  The initialisation stubs are
        now called '__init_<module>' rather than '_reg<module>'.
      
      - Register foreign exported functions as stable pointers in the
        initialisation code for the module.  This fixes the foreign export
        problems reported by several people.
      
      - remove the concept of "module groups" from the profiling subsystem.
      
      - change the profiling semantics slightly; it should be unnecessary
        to use '-caf-all' to get reasonable profiles now.
      de896403
    • simonmar's avatar
      [project @ 2000-03-08 15:58:30 by simonmar] · 54e6a4e1
      simonmar authored
      okToUnfoldInHiFile: look at args of a Con for litlits.
      54e6a4e1
  13. 06 Mar, 2000 1 commit
  14. 02 Mar, 2000 4 commits
  15. 01 Mar, 2000 2 commits
    • lewie's avatar
      [project @ 2000-03-01 18:10:43 by lewie] · a61b7e6e
      lewie authored
      Filled in some missing support for importing defs w/ implicit params.
      Fixed bug in improvement w/ implicit params.
      a61b7e6e
    • sewardj's avatar
      [project @ 2000-03-01 12:31:22 by sewardj] · 9fa0c8cb
      sewardj authored
      Temporarily disable Stix inlining whilst we figure out how to fix
      obscure bugs in the register allocator.  With inlining off, everything
      seems to work, and the compiler can boot itself, but when enabled,
      inlining exposes a register allocation bug which causes
      ghc/compiler/utils/FastString.lhs to be miscompiled on Linux (the big
      arithmetic expressions for computing hash values).
      9fa0c8cb
  16. 29 Feb, 2000 1 commit
  17. 28 Feb, 2000 3 commits
    • lewie's avatar
      [project @ 2000-02-28 21:59:32 by lewie] · f8e67a2c
      lewie authored
      Fix signatures w/ implicit parameter types in them (in particular,
      correctly handle the case where there are no type variables).  Also
      made a few more things Outputable.  Nuke outdated comment in Parser.y.
      f8e67a2c
    • sewardj's avatar
      [project @ 2000-02-28 12:02:31 by sewardj] · 4070b105
      sewardj authored
      Many changes to improve the quality and correctness of generated code,
      both for x86 and all-platforms.  The intent is that the x86 NCG will
      now be good enough for general use.
      
      -- Add an almost-trivial Stix (generic) peephole optimiser, whose sole
         purpose is elide assignments to temporaries used only once, in the
         very next tree.  This generates substantially better code for
         conditionals on all platforms.  Enhance Stix constant folding to
         take advantage of the inlining.
      
         The inlining presents subsequent insn selection phases with more
         complex trees than would have previously been used to.  This has
         shown up several bugs in the x86 insn selectors, now fixed.
         (assumptions that data size is Word, when could be Byte,
          assumptions that an operand will always be in a temp reg, etc)
      
      -- x86: Use the FLDZ and FLD1 insns.
      
      -- x86: spill FP registers with 80-bit loads/stores so that
         Intel's extra 16 bits of accuracy are not lost.  If this isn't
         done, FP spills are not suitably transparent.  Increase the
         number of spill words available to 2048.
      
      -- x86: give the register allocator more flexibility in choosing
         spill temporaries.
      
      -- x86, RegAllocInfo.regUsage: fix error for GST, and rewrite to
         make it clearer.
      
      -- Correctly track movements in the C stack pointer, and generate
         correct spill code for archs which spill against the stack pointer
         even when the stack pointer moves.  Redo the x86 ccall mechanism
         to push args on the C stack in the normal way.  Rather than have
         the spiller have to analyse code sequences to determine the current
         stack offset, the insn selectors communicate the current offset
         whenever it changes by inserting a DELTA pseudo-insn.  Then the
         spiller only has to spot DELTAs.
      
         This means having a new native-code-generator monad (Stix.NatM)
         which carries both a UniqSupply and the current stack offset.
      
      -- Remove the asmPar/asmSeq ways of grouping insns together.
         In the presence of fixed registers, it is hard to demonstrate
         that insn selectors using asmPar always give correct code, and
         the extra complication doesn't help any.
      
         Also, directly construct code sequences using tree-based ordered
         lists (utils/OrdList.lhs) for linear-time appends, rather than
         the bizarrely complex method using fns and fn composition.
      
      -- Inline some hcats in printing of x86 address modes.
      
      -- Document more of the hidden assumptions which insn selection relies
         on, particular wrt addressing modes.
      4070b105
    • simonmar's avatar
      [project @ 2000-02-28 09:17:54 by simonmar] · c5535e01
      simonmar authored
      'IPVARID :: type' moved from btype to type, to reduce conflicts.
      c5535e01
  18. 25 Feb, 2000 3 commits
    • panne's avatar
      [project @ 2000-02-25 15:06:30 by panne] · 5e95eb49
      panne authored
      *ahem*  Re-enable -fwarn-unused-binds and -fwarn-unused-imports...  :-}
      5e95eb49
    • panne's avatar
      [project @ 2000-02-25 14:55:31 by panne] · f83a5a68
      panne authored
      Deprecations of variables now works, although the source location is
      not yet reported correctly and the code needs some cleanup. Added a
      new flag -fwarn-deprecations to the set of standard warnings. The
      syntax of deprecations has been extended to deprecate types, classes,
      or even constructors, although this does not work yet.
      f83a5a68
    • simonmar's avatar
      [project @ 2000-02-25 10:49:30 by simonmar] · f1b1d5f0
      simonmar authored
      Make the desugarer a little more liberal about the class of case
      expressions which get the special unboxed tuple treatment.
      f1b1d5f0
  19. 23 Feb, 2000 1 commit
    • lewie's avatar
      [project @ 2000-02-23 19:41:50 by lewie] · e87d56ce
      lewie authored
      Handle `with' more cleverly.  I was generating partially applied methods
      for the case where the `with' expression was also overloaded, but this
      was buggy, and completely unnecessary.  Instead, simply force the method
      binding at the point of the `with' expression (we reap no benefits from
      pushing the sharing further out anyway), and release the remainder of
      the method's context into the LIE.
      e87d56ce
  20. 22 Feb, 2000 2 commits
    • panne's avatar
      [project @ 2000-02-22 15:47:56 by panne] · b78eb7be
      panne authored
      Load deprecations from interface files into a deprecation environment
      which maps Names to RenamedDeprecations. This map is not used yet, but
      very soon it will...
      
      This commit fixes a bug related to implicit parameters, too:
      Previously, an interface file containing the name "with" could not be
      read by the interface parser. This broke Malcolm's HaXml 0.9 (released
      today). Remember Sven's glaexts-commandment (Jeffrey? :-) : Always
      keep Lex.lhs's ghcExtensionKeywordsFM and ParseIface.y's var_fs
      production in synch!
      b78eb7be
    • panne's avatar
      [project @ 2000-02-22 12:45:30 by panne] · c01dc71d
      panne authored
      Space leak paranoia: Don't keep whole InterfaceDetails alive
      throughout the middle part of the compiler
      c01dc71d
  21. 21 Feb, 2000 2 commits
  22. 20 Feb, 2000 1 commit
  23. 18 Feb, 2000 1 commit
    • panne's avatar
      [project @ 2000-02-18 15:36:48 by panne] · 770cf880
      panne authored
      Now deprecations can be read from interface files. To avoid a
      lookahead of 2, the syntax for interface files has been liberated
      slightly: They can end in as many freely mixed rule pragmas or
      deprecation pragmas as you like.
      
      Note: Parsing the deprecation pragma uses the same Lazy Technology (tm)
      as the one for rules. Don't know if this makes sense, but it is
      convenient here.
      770cf880
  24. 17 Feb, 2000 1 commit
    • panne's avatar
      [project @ 2000-02-17 14:47:21 by panne] · 48eec568
      panne authored
      Result of my daily DEPRECATED-hour: Now it's possible to use the
      pragma without harm, but nothing spectacular happens yet, only the
      usual renamer checks (duplication, var in scope).
      48eec568