[project @ 2001-03-19 16:08:37 by simonpj]
[ghc-hetmet.git] / ghc / compiler / NOTES
index d0332b1..67b4c62 100644 (file)
@@ -1,25 +1,56 @@
-Notes June 99
-~~~~~~~~~~~~~
-* In nofib/spectral/mandel2/Main.check_radius, there's a call to (fromIntegral m), where
-  m is defined at top level. The full-laziness pass doesn't catch this because by
-  the time it runs, enough inlining has happened that it looks like
-       case ccall ... of (# a,b #) -> ...
-  and the full laziness pass doesn't float unboxed things.
+NB: all floats are let-binds, but some non-rec lets
+    may be unlifted (with RHS ok-for-speculation)
 
-* The same function is an excellent example of where liberate-case would be a win.
 
-* Don't forget to try CSE
+simplArg:  [use strictness]
+          [used for non-top-lvl non-rec RHS or function arg]
+  if strict-type || demanded
+       simplStrictExpr
+  else
+       simplExpr ---> (floats,expr)
+       float all the floats if exposes constr app, return expr
 
-Interface files
-~~~~~~~~~~~~~~~
-* Don't need to pin a kind on the type variable in a interface class decl,
-  because it'll be correctly re-inferred when we read it in.
+simpl (applied lambda)     ==> simplNonRecBind
+simpl (Let (NonRec ...) ..) ==> simplNonRecBind
 
-* The double semicolon at the end of an interface-file signature is so that
-  the lexer can run through the pragmas very fast when -O isn't being used.
+simpl (Let (Rec ...)    ..) ==> simplRecBind
 
-* In export lists, T|(A,B) says that constructors A and B are exported, 
-  but not the type T.  Similarly for classes.  
-  We can't say T(T,A,B) and T(A,B) to export or not-export T respectively,
-  because the type T might have a constructor T.
+simplRecBind:
+  simplify binders (but not its IdInfo)
+  simplify the pairs one at a time
+       using simplRecPair
 
+simplNonRecBind:       [was simplBeta]
+       [used for non-top-lvl non-rec bindings]
+  - check for PreInlineUnconditionally
+  - simplify binder, including its IdInfo
+  - simplArg
+  - if strict-type 
+       addCaseBind [which makes a let if ok-for-spec]
+    else
+       completeLazyBind
+
+simplRecPair:  [binder already simplified, but not its IdInfo]
+               [used for both rec and top-lvl non-rec]
+               [must not be strict/unboxed; case not allowed]
+  - check for PreInlineUnconditionally
+  - substituteIdInfo and add result to in-scope 
+       [so that rules are available in rec rhs]
+  - simplExpr --> (floats,expr)
+  - float: lifted floats only
+       if exposes constructor or pap (even if non-triv args)
+       or if top level
+  - completeLazyBind
+  
+
+completeLazyBind:      [given a simplified RHS]
+       [used for both rec and non-rec bindings, top level and not]
+  - try discarding dead
+  - try PostInlineUnconditionally
+  - let-bind coerce arg and repeat
+  - try rhs tylam (float)
+  - try eta expand (float)    [not if any float is unlifted && (non-spec || top_lvl || rec)]
+  - let-bind constructor args [not if any float is ..as above..]
+
+  - add unfolding [this is the only place we add an unfolding]
+    add arity