Add a note to NOTES
[ghc-hetmet.git] / compiler / NOTES
1 More type functions
2 ~~~~~~~~~~~~~~~~~~~
3 * Allow {tv = TYPE ty) as a non-rec binding in Core
4 * Use this to make equality constraints more uniform
5 * Make DictBinds into Core
6
7
8 Type functions
9 ~~~~~~~~~~~~~~
10 * A Given inst should be a CoVar, not a coercion
11
12 * finaliseEqInst should not need to call zonk
13
14 * Why do we need fromGivenEqDict?  How could we construct       
15         a Dict that had an EqPred?
16         newDictBndr should make an EqInst directly
17
18 * tc_co should be accessed only inside Inst
19
20 * Inst.mkImplicTy needs a commment about filtering out EqInsts
21   How *do* we deal with wanted equalities?
22
23 * Inst.instType behaves inconsistently for EqInsts: it should
24   return an EqPred, like the instType' hack in pprDictsTheta
25
26   Consequences: adjust the uses of instType in TcSimplify
27
28 * tcDeref* functions are unused, except in tcGenericNormalizeFamInst, when
29   we can equally well use TcMType.lookupTcTyVar
30
31 * Coercion.mkEqPredCoI looks very peculiar.
32
33
34
35
36 -------------------------
37 *** unexpected failure for jtod_circint(opt)
38
39
40         New back end thoughts
41
42 -----------------------------------------------------------------------------
43 Codegen notes
44
45 * jumps to ImpossibleBranch should be removed.
46
47 * Profiling:
48         - when updating a closure with an indirection to a function,
49           we should make a permanent indirection.
50
51         - check that we're bumping the scc count appropriately
52
53 * check perf & binary sizes against the HEAD
54
55 -----------------------------------------------------------------------------
56 C backend notes
57
58 * use STGCALL macros for foreign calls (doesn't look like volatile regs
59   are handled properly at the mo).
60
61 -----------------------------------------------------------------------------
62 Cmm parser notes
63
64 * switches
65
66 * need to cater for unexported procedures/info tables?
67
68 * We should be able to get rid of entry labels, use info labels only.
69   - we need a %ENTRY_LBL(info_lbl) macro, so that instead of
70      JMP_(foo_entry) we can write jump %ENTRY_LBL(foo_info).
71
72 -----------------------------------------------------------------------------
73
74 * Move arg-descr from LFInfo to ClosureInfo? 
75   But: only needed for functions
76
77 * Move all of CgClosure.link_caf into NewCaf, and newDynCaf
78
79 * If the case binder is dead, and the constr is nullary,
80   do we need to assign to Node?
81
82
83 -------------------------------
84 NB: all floats are let-binds, but some non-rec lets
85     may be unlifted (with RHS ok-for-speculation)
86
87
88 simplArg:  [use strictness]
89            [used for non-top-lvl non-rec RHS or function arg]
90   if strict-type || demanded
91         simplStrictExpr
92   else
93         simplExpr ---> (floats,expr)
94         float all the floats if exposes constr app, return expr
95
96 simpl (applied lambda)      ==> simplNonRecBind
97 simpl (Let (NonRec ...) ..) ==> simplNonRecBind
98
99 simpl (Let (Rec ...)    ..) ==> simplRecBind
100
101 simplRecBind:
102   simplify binders (but not its IdInfo)
103   simplify the pairs one at a time
104         using simplRecPair
105
106 simplNonRecBind:        [was simplBeta]
107         [used for non-top-lvl non-rec bindings]
108   - check for PreInlineUnconditionally
109   - simplify binder, including its IdInfo
110   - simplArg
111   - if strict-type 
112         addCaseBind [which makes a let if ok-for-spec]
113     else
114         completeLazyBind
115
116 simplLazyBind:  [binder already simplified, but not its IdInfo]
117                 [used for both rec and top-lvl non-rec]
118                 [must not be strict/unboxed; case not allowed]
119   - check for PreInlineUnconditionally
120   - substituteIdInfo and add result to in-scope 
121         [so that rules are available in rec rhs]
122   - simplExpr --> (floats,expr)
123   - float: lifted floats only
124         if exposes constructor or pap (even if non-triv args)
125         or if top level
126   - completeLazyBind
127   
128
129 completeLazyBind:       [given a simplified RHS]
130         [used for both rec and non-rec bindings, top level and not]
131   - try discarding dead
132   - try PostInlineUnconditionally
133   - let-bind coerce arg and repeat
134   - try rhs tylam (float)
135   - try eta expand (float)    [not if any float is unlifted && (non-spec || top_lvl || rec)]
136   - let-bind constructor args [not if any float is ..as above..]
137
138   - add unfolding [this is the only place we add an unfolding]
139     add arity
140
141
142
143
144 Eta expansion
145 ~~~~~~~~~~~~~~
146 For eta expansion, we want to catch things like
147
148         case e of (a,b) -> \x -> case a of (p,q) -> \y -> r
149
150 If the \x was on the RHS of a let, we'd eta expand to bring the two
151 lambdas together.  And in general that's a good thing to do.  Perhaps
152 we should eta expand wherever we find a (value) lambda?  Then the eta
153 expansion at a let RHS can concentrate solely on the PAP case.