1. 20 Feb, 2003 2 commits
    • simonpj's avatar
      [project @ 2003-02-20 18:33:50 by simonpj] · 56b5a8b8
      simonpj authored
      -------------------------------------
            Add Core Notes and the {-# CORE #-} pragma
      	-------------------------------------
      
      This is an idea of Hal Daume's. The key point is that Notes in Core
      are augmented thus:
      
        data Note
          = SCC CostCentre
          | ...
          | CoreNote String     -- NEW
      
      These notes can be injected via a Haskell-source pragma:
      
         f x = ({-# CORE "foo" #-} show) ({-# CORE "bar" #-} x)
      
      This wraps a (Note (CoreNote "foo")) around the 'show' variable,
      and a similar note around the argument to 'show'.
      
      These notes are basically ignored by GHC, but are emitted into
      External Core, where they may convey useful information.
      
      Exactly how code involving these notes is munged by the simplifier
      isn't very well defined.  We'll see how it pans out.  Meanwhile
      the impact on the rest of the compiler is minimal.
      56b5a8b8
    • simonpj's avatar
      [project @ 2003-02-20 13:00:24 by simonpj] · 5b7c931a
      simonpj authored
      Eliminate bogus string-literal duplication
      5b7c931a
  2. 19 Feb, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-02-19 15:54:05 by simonpj] · 3355c9d5
      simonpj authored
      -------------------------------------
      	 	Two minor wibbles
      	-------------------------------------
      
      
      1.  Make the generic toT/fromT Ids for "generic derived classes" into
          proper ImplicitIds, with their own GlobalIdDetails. This makes it
          easier to identify them.  (The lack of this showed up as a bug
          when I made an apparently-innocuous other change.)
      
      2.  Distinguish ClassOpIds from RecordSelIds in their GlobalIdDetails.
          They are treated differently here and there, so I made this change
          as part of (1)
      
      3.  Ensure that a declaration quotation [d| ... |] does not have a
          permanent effect on the instance environment. (A TH fix.)
      3355c9d5
  3. 12 Feb, 2003 1 commit
    • simonpj's avatar
      [project @ 2003-02-12 15:01:31 by simonpj] · 42b63073
      simonpj authored
      -------------------------------------
        Big upheaval to the way that constructors are named
      	-------------------------------------
      
      This commit enshrines the new story for constructor names.  We could never
      really get External Core to work nicely before, but now it does.
      
      The story is laid out in detail in the Commentary
      	ghc/docs/comm/the-beast/data-types.html
      so I will not repeat it here.
      
      	[Manuel: the commentary isn't being updated, apparently.]
      
      However, the net effect is that in Core and in External Core, contructors look
      like constructors, and the way things are printed is all consistent.
      
      It is a fairly pervasive change (which is why it has been so long postponed),
      but I hope the question is now finally closed.
      
      All the libraries compile etc, and I've run many tests, but doubtless there will
      be some dark corners.
      42b63073
  4. 21 Nov, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-11-21 14:59:51 by simonpj] · c9c01697
      simonpj authored
      -------------------------------
      	Better notion of what a 'value' is
      	Slightly better eta reduction
      	-------------------------------
      
      1.  At various places we watch out for "values"; the predicate exprIsValue
      detects them. It was stupidly treating nullary constructors as non-values
      which is exceptionally stupid.  This (performance) bug has been there
      for ages.
      
      There's an exactly similar bug in SimplUtils.interestingArg, which looks
      for an interesting argument to trigger an inlining.
      
      
      2.  The eta reduction in SimplUtils.tryEtaReduce would only eta reduce if
      that left us with a variable.  That led to slightly tiresome thing like
      	:DMonad (/\a b -> foo @ s @ a @ b) ...
      where this would be neater
      	:DMonad (foo @ s)
      The fix is easy, and there's a little less code too.
      c9c01697
  5. 19 Nov, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-11-19 14:16:43 by simonmar] · de7a4a03
      simonmar authored
      - Fix a bug in eta-expansion of an application; it probably never bit
        us in practice.
      
      - Change the behaviour of State#-lambdas: previously a State# lambda
        was considered to be one-shot for the purposes of inlining and
        eta-expansion.  Both can lead to unbounded extra work, but inlining
        is more likely to kill us, and eta-expansion is the case we mostly
        care about (getting the State# lambda to the outside of the function
        is often very important).  So now we only consider a State# lambda to be
        one-shot in eta expansion, not for inlining.
      de7a4a03
  6. 03 Sep, 2002 1 commit
  7. 29 Aug, 2002 1 commit
  8. 11 Apr, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-04-11 12:03:29 by simonpj] · a7b95beb
      simonpj authored
      -------------------
      	Mainly derived Read
      	-------------------
      
      This commit is a tangle of several things that somehow got wound up
      together, I'm afraid.
      
      
      The main course
      ~~~~~~~~~~~~~~~
      Replace the derived-Read machinery with Koen's cunning new parser
      combinator library.   The result should be
      	* much smaller code sizes from derived Read
      	* faster execution of derived Read
      
      WARNING: I have not thoroughly tested this stuff; I'd be glad if you did!
      	 All the hard work is done, but there may be a few nits.
      
      The Read class gets two new methods, not exposed
      in the H98 inteface of course:
        class Read a where
          readsPrec    :: Int -> ReadS a
          readList     :: ReadS [a]
          readPrec     :: ReadPrec a		-- NEW
          readListPrec :: ReadPrec [a]	-- NEW
      
      There are the following new libraries:
      
        Text.ParserCombinators.ReadP		Koens combinator parser
        Text.ParserCombinators.ReadPrec	Ditto, but with precedences
      
        Text.Read.Lex				An emasculated lexical analyser
      					that provides the functionality
      					of H98 'lex'
      
      TcGenDeriv is changed to generate code that uses the new libraries.
      The built-in instances of Read (List, Maybe, tuples, etc) use the new
      libraries.
      
      
      Other stuff
      ~~~~~~~~~~~
      1. Some fixes the the plumbing of external-core generation. Sigbjorn
      did most of the work earlier, but this commit completes the renaming and
      typechecking plumbing.
      
      2. Runtime error-generation functions, such as GHC.Err.recSelErr,
      GHC.Err.recUpdErr, etc, now take an Addr#, pointing to a UTF8-encoded
      C string, instead of a Haskell string.  This makes the *calls* to these
      functions easier to generate, and smaller too, which is a good thing.
      
      In particular, it means that MkId.mkRecordSelectorId doesn't need to
      be passed "unpackCStringId", which was GRUESOME; and that in turn means
      that tcTypeAndClassDecls doesn't need to be passed unf_env, which is
      a very worthwhile cleanup.   Win/win situation.
      
      3.  GHC now faithfully translates do-notation using ">>" for statements
      with no binding, just as the report says.  While I was there I tidied
      up HsDo to take a list of Ids instead of 3 (but now 4) separate Ids.
      Saves a bit of code here and there.  Also introduced Inst.newMethodFromName
      to package a common idiom.
      a7b95beb
  9. 04 Mar, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-03-04 17:01:26 by simonmar] · 0171936c
      simonmar authored
      Binary Interface Files - stage 1
      --------------------------------
      
      This commit changes the default interface file format from text to
      binary, in order to improve compilation performace.
      
      To view an interface file, use 'ghc --show-iface Foo.hi'.
      
      utils/Binary.hs is the basic Binary I/O library, based on the nhc98
      binary I/O library but much stripped-down and working in terms of
      bytes rather than bits, and with some special features for GHC: it
      remembers which Module is being emitted to avoid dumping too many
      qualified names, and it keeps track of a "dictionary" of FastStrings
      so that we don't dump the same FastString more than once into the
      binary file.  I'll make a generic version of this for the libraries at
      some point.
      
      main/BinIface.hs contains most of the Binary instances.  Some
      instances are in the same module as the data type (RdrName, Name,
      OccName in particular).  Most instances were generated using a
      modified version of DrIFT, which I'll commit later.  However, editing
      them by hand isn't hard (certainly easier than modifying
      ParseIface.y).
      
      The first thing in a binary interface is the interface version, so
      nice error messages will be generated if the binary format changes and
      you still have old interfaces lying around.  The version also now
      includes the "way" as an extra sanity check.
      
      Other changes
      -------------
      
      I don't like the way FastStrings contain both hashed strings (with
      O(1) comparison) and literal C strings (with O(n) comparison).  So as
      a first step to separating these I made serveral "literal" type
      strings into hashed strings.  SLIT() still generates a literal, and
      now FSLIT() generates a hashed string.  With DEBUG on, you'll get a
      warning if you try to compare any SLIT()s with anything, and the
      compiler will fall over if you try to dump any literal C strings into
      an interface file (usually indicating a use of SLIT() which should be
      FSLIT()).
      
      mkSysLocal no longer re-encodes its FastString argument each time it
      is called.
      
      I also fixed the -pgm options so that the argument can now optionally
      be separted from the option.
      
      Bugfix: PrelNames declared Names for several comparison primops, eg.
      eqCharName, eqIntName etc. but these had different uniques from the
      real primop names.  I've moved these to PrimOps and defined them using
      mkPrimOpIdName instead, and deleted some for which we don't have real
      primops (Manuel: please check that things still work for you after
      this change).
      0171936c
  10. 14 Feb, 2002 1 commit
  11. 06 Feb, 2002 1 commit
    • simonpj's avatar
      [project @ 2002-02-06 15:54:23 by simonpj] · 979947f5
      simonpj authored
      Eliminate all vestiages of UsageTy, in preparation for
      	Keith's new version.  Hurrah!
      
      	Keith: LBVarInfo and usOnce,usMany are still there,
      	because I know you have eliminated LBVarInfo, and I didn't
      	want to cause unnecessary conflicts.
      979947f5
  12. 10 Dec, 2001 1 commit
  13. 01 Nov, 2001 2 commits
    • simonpj's avatar
      [project @ 2001-11-01 13:20:05 by simonpj] · 51666a19
      simonpj authored
      ---------------------------------------
      	Fix a unboxed-binding bug in SpecConstr
      	---------------------------------------
      
      	[HEAD only]
      
      This fixes a rather obscure bug in the constructor
      specialiser discovered by Ralf Hinze.  It was
      generating a specialised version of the function
      with no arguments --- and the function returned an
      unboxed type.
      
      Solution: same as for worker-wrapper; add a dummy
      argument.
      
      Several files are affected because I added
      CoreUtils.mkPiTypes, as a useful helper function.
      51666a19
    • simonpj's avatar
      [project @ 2001-11-01 10:33:58 by simonpj] · 883d5ca9
      simonpj authored
      ----------------------------------
      	Fix a bug in Simplify.mkDupableAlt
      	----------------------------------
      
      	[This is the HEAD commit; I've fixed
      	 the branch separately.]
      
      This fixes a funResultTy panic that Koen encountered.
      
      The reason was that the simplifier was doing a
      case-of-case where the result had a polymorphic type.
      This in turn showed up because of a newtype (now
      transparent) with a forall inside it.
      
      The fix is very easy; can't think how I got it wrong
      in the first place.
      883d5ca9
  14. 25 Oct, 2001 1 commit
    • sof's avatar
      [project @ 2001-10-25 02:13:10 by sof] · 9e933350
      sof authored
      - Pet peeve removal / code tidyup, replaced various sub-optimal
        uses of 'length' with something a bit better, i.e., replaced
        the following patterns
      
         *  length as `cmpOp` length bs
         *  length as `cmpOp` val   -- incl. uses where val == 1 and val == 0
         *  {take,drop,splitAt} (length as) bs
         *  length [ () | pat <- as ]
      
        with uses of misc Util functions.
      
        I'd be surprised if there's a noticeable reduction in running
        times as a result of these changes, but every little bit helps.
      
        [ The changes have been tested wrt testsuite/ - I'm seeing a couple
          of unexpected breakages coming from CorePrep, but I'm currently
          assuming that these are due to other recent changes. ]
      
      - compMan/CompManager.lhs: restored 4.08 compilability + some code
        cleanup.
      
      None of these changes are HEADworthy.
      9e933350
  15. 24 Oct, 2001 2 commits
  16. 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
  17. 17 Oct, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-10-17 13:12:56 by simonmar] · 93436263
      simonmar authored
      Use the smart constructor mkNote instead of the dumb constructor
      (Note) when rebuilding the expression after eta expansion.  This is
      necessary to avoid invalidating some assumptions we make about the
      output of etaExpand in CorePrep, in particular that there aren't any
      lambda expressions inside an SCC note.
      93436263
  18. 03 Oct, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-10-03 13:58:50 by simonpj] · f659cb97
      simonpj authored
      ---------------------
      	Clear up infelicities
      	---------------------
      	CorePrep, CoreUtils, SimplUtils
      	LiberateCase (wibbles only)
      
      * Previously CorePrep was floating LocalIds to top level, which
        breaks the invariant that after CorePrep all top level Ids are
        GlobalIds.  But it didn't really need to, and this pass makes it
        so.  It's much tidier now.
      
      * Make CorePrep do eta expansion on partial applications
      	x = foldr f y  ==>   x = \ys -> foldr f y ys
        (This used to be done in the simplifier, but now the
        simplifier only eta expands where there is at least one
        lambda already.)
      
      * Omit CoreUtils.etaReduce.  (Never called.)
      
      * Improve CoreUtils.etaExpand, so that it doesn't add gratuitous
        beta redexes.
      f659cb97
  19. 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
  20. 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
  21. 20 Jul, 2001 2 commits
    • simonpj's avatar
      [project @ 2001-07-20 16:47:55 by simonpj] · e3defabc
      simonpj authored
      ------------------------
      	More newtype squashing
      	------------------------
      
      Recursive newtypes were confusing the worker/wrapper generator.
      This is because I originally got rid of opaque newtypes altogether,
      then put them back for recursive ones only, and forgot to reinstate
      the cunning stuff in the w/w stuff.
      
      (Discovered by Sigbjorn; thanks!)
      e3defabc
    • simonpj's avatar
      [project @ 2001-07-20 10:05:37 by simonpj] · 98a74c9d
      simonpj authored
      --------------------------
      	Correct a bug in exprArity
      	--------------------------
      
      This long-standing bug meant that exprArity gave over-pessimistic
      answers.  e.g.
      
      	\x -> f x
      
      where nothing is known about f.  We were getting
      
      	0 (for f)
      	-1 (for the argument)
      	+1 (for the lambda)
      	-----
      	0
      
      The right answer is of course 1.
      98a74c9d
  22. 28 Jun, 2001 1 commit
  23. 25 Jun, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-06-25 08:08:32 by simonpj] · 3622a7de
      simonpj authored
      ---------------------------
      	Add a new case optimisation
      	---------------------------
      
      I found that lib/std/PrelCError had a case-expression that was
      generating terrible code.   Something like this
      
      	x | p `is` 1 -> e1
      	  | p `is` 2 -> e2
      	...etc...
      
      where @is@ was something like
      
      	p `is` n = p /= (-1) && p == n
      
      This gave rise to a horrible sequence of cases
      
      	case p of
      	  (-1) -> $j p
      	  1    -> e1
      	  DEFAULT -> $j p
      
      and similarly in cascade for all the join points!
      
      
      Solution: add the following transformation:
      
      	case e of		=====>     case e of
      	  C _ -> <expr>			     D v -> ....v....
      	  D v -> ....v....		     DEFAULT -> <expr>
      	  DEFAULT -> <expr>
      
      The point is that we merge common RHSs, at least for the DEFAULT case.
      [One could do something more elaborate but I've never seen it needed.]
      
      This transformation is implemented in SimplUtils.mkCase
      
      
      *** WARNING ***
      	To make this transformation easy, I have switched the convention
      	for DEFAULT clauses.  They must now occur FIRST in the list of
      	alternatives for a Core case expression.  (The semantics is
      	unchanged: they still are a catch-all case.)
      
      	The reason is that DEFAULT clauses sometimes need special treatment,
      	and it's a lot easier to find them at the front.
      
      	The easiest way to be insensitive to this change is to use
      	CoreUtils.findDefault to pull the default clause out.
      
      I've made the (surprisingly few) changes consequent on this changed
      of convention, but they aren't in this commit.  Instead they are part
      of the big commit on newtypes I'm doing at the same time.
      3622a7de
  24. 04 Jun, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-06-04 16:49:15 by simonpj] · f08a180a
      simonpj authored
      ----------------------------------
      	Make exprArity give the right answer
      	----------------------------------
      
      		MERGE INTO 5.00.2
      
      This fixes a fairly long-standing bug in exprArity, dating from
      the time we allowed arguments to be non-atoms. If f had arity
      2, it was saying that
      
      	f (factorial x)
      
      had arity 2, as well, which is plain wrong.
      f08a180a
  25. 25 May, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-05-25 08:55:03 by simonpj] · 3af411e9
      simonpj authored
      -------------------------------------
      	Wibbles to Don's runtime-types commit
      	-------------------------------------
      
      There was an upside down predicate which utterly broke the compiler.
      
      While I was about it
      
      * I changed the global flag to
      	opt_RuntimeTypes
        with command line option
      	-fruntime-types (was -fkeep-stg-types)
      
      * I moved isRuntimeArg, isRuntimeVar to CoreSyn
      3af411e9
  26. 24 May, 2001 1 commit
  27. 22 May, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-05-22 13:43:14 by simonpj] · f16228e4
      simonpj authored
      -------------------------------------------
      	Towards generalising 'foreign' declarations
      	-------------------------------------------
      
      This is a first step towards generalising 'foreign' declarations to
      handle langauges other than C.  Quite a lot of files are touched,
      but nothing has really changed.  Everything should work exactly as
      before.
      
      	But please be on your guard for ccall-related bugs.
      
      Main things
      
      Basic data types: ForeignCall.lhs
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Remove absCSyn/CallConv.lhs
      
      * Add prelude/ForeignCall.lhs.  This defines the ForeignCall
        type and its variants
      
      * Define ForeignCall.Safety to say whether a call is unsafe
        or not (was just a boolean).  Lots of consequential chuffing.
      
      * Remove all CCall stuff from PrimOp, and put it in ForeignCall
      
      
      Take CCallOp out of the PrimOp type (where it was always a glitch)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      * Add IdInfo.FCallId variant to the type IdInfo.GlobalIdDetails,
      	along with predicates Id.isFCallId, Id.isFCallId_maybe
      
      * Add StgSyn.StgOp, to sum PrimOp with FCallOp, because it
        *is* useful to sum them together in Stg and AbsC land.  If
        nothing else, it minimises changes.
      
      
      Also generally rename "CCall" stuff to "FCall" where it's generic
      to all foreign calls.
      f16228e4
  28. 04 May, 2001 1 commit
  29. 02 May, 2001 1 commit
  30. 01 May, 2001 1 commit
  31. 30 Apr, 2001 1 commit
    • qrczak's avatar
      [project @ 2001-04-30 20:07:49 by qrczak] · 09d0b4a4
      qrczak authored
      Fix the inlining bug: exprIsConApp_maybe didn't recognize constructor
      applications inside notes.
      
      I'm not sure if it's the right place to fix. Should notes be ignored
      in other uses of collectArgs? Perhaps they should be ignored inside
      the loop of collectArgs? And why the function marked as inline was
      not inlined even though it's not a constructor application?
      09d0b4a4
  32. 05 Apr, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-04-05 11:28:36 by simonpj] · f05b6981
      simonpj authored
      ------------------
      	Better arity stuff
      	------------------
      
      * CoreToStg now has a local function, predictArity, to
        predict the code-gen arity of a function. Better not to
        use CoreUtils.exprArity, because predictArity is a very
        local thing
      
      * CoreUtils.exprArity is freed to do a better job.  Comments
        below.
      
      
      exprArity is a cheap-and-cheerful version of exprEtaExpandArity.
      It tells how many things the expression can be applied to before doing
      any work.  It doesn't look inside cases, lets, etc.  The idea is that
      exprEtaExpandArity will do the hard work, leaving something that's easy
      for exprArity to grapple with.  In particular, Simplify uses exprArity to
      compute the ArityInfo for the Id.
      
      Originally I thought that it was enough just to look for top-level lambdas, but
      it isn't.  I've seen this
      
      	foo = PrelBase.timesInt
      
      We want foo to get arity 2 even though the eta-expander will leave it
      unchanged, in the expectation that it'll be inlined.  But occasionally it
      isn't, because foo is blacklisted (used in a rule).
      
      Similarly, see the ok_note check in exprEtaExpandArity.  So
      	f = __inline_me (\x -> e)
      won't be eta-expanded.
      
      And in any case it seems more robust to have exprArity be a bit more intelligent.
      f05b6981
  33. 23 Mar, 2001 1 commit
  34. 19 Mar, 2001 2 commits
    • simonpj's avatar
      [project @ 2001-03-19 16:20:44 by simonpj] · 4fb9c8aa
      simonpj authored
      ------------------------------------
      	Be more gung-ho about INLINE pragmas
      	------------------------------------
      
      When we see 
      
      	{-# INLINE f #-}
      	f = g $ h
      
      should we inline f inside a lambda?  Previously we said 'no'
      because f looks like a redex, but that's a great mistake sometimes.
      So this commit is more gung-ho: if you say INLINE that's what you get.
      
      The changes are to exprIsDupable and exprIsCheap.
      4fb9c8aa
    • simonmar's avatar
      [project @ 2001-03-19 16:17:44 by simonmar] · ff39a56b
      simonmar authored
      exprIsAtom shouldn't return True for an SCC.
      ff39a56b
  35. 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