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