546f9aeb4ce3f5a247aa478993bcbc28367d2387
[ghc-hetmet.git] / compiler / cmm / cmm-notes
1 More notes (June 11)\r
2 ~~~~~~~~~~~~~~~~~~~~\r
3 * Possible refactoring: Nuke AGraph in favour of \r
4       mkIfThenElse :: Expr -> Graph -> Graph -> FCode Graph\r
5   or even\r
6       mkIfThenElse :: HasUniques m => Expr -> Graph -> Graph -> m Graph\r
7   (Remmber that the .cmm file parser must use this function)\r
8 \r
9   or parameterise FCode over its envt; the CgState part seem useful for both\r
10 \r
11 * Move top and tail calls to runCmmContFlowOpts from HscMain to CmmCps.cpsTop\r
12   (and rename the latter!)\r
13 \r
14 * "Remove redundant reloads" in CmmSpillReload should be redundant; since\r
15   insertLateReloads is now gone, every reload is reloading a live variable.\r
16   Test and nuke.\r
17 \r
18 * Sink and inline S(RegSlot(x)) = e in precisely the same way that we\r
19   sink and inline x = e\r
20 \r
21 * Stack layout is very like register assignment: find non-conflicting assigments.\r
22   In particular we can use colouring or linear scan (etc).\r
23 \r
24   We'd fine-grain interference (on a word by word basis) to get maximum overlap.\r
25   But that may make very big interference graphs.  So linear scan might be\r
26   more attactive.\r
27 \r
28   NB: linear scan does on-the-fly live range splitting.\r
29 \r
30 * When stubbing dead slots be careful not to write into an area that\r
31   overlaps with an area that's in use.  So stubbing needs to *follow* \r
32   stack layout.\r
33 \r
34 \r
35 More notes (May 11)\r
36 ~~~~~~~~~~~~~~~~~~~\r
37 In CmmNode, consider spliting CmmCall into two: call and jump\r
38 \r
39 Notes on new codegen (Aug 10)\r
40 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
41 \r
42 Things to do:\r
43  - We insert spills for variables before the stack check! This is the reason for\r
44    some fishy code in StgCmmHeap.entryHeapCheck where we are doing some strange\r
45         things to fix up the stack pointer before GC calls/jumps.\r
46 \r
47         The reason spills are inserted before the sp check is that at the entry to a\r
48         function we always store the parameters passed in registers to local variables.\r
49         The spill pass simply inserts spills at variable definitions. We instead should\r
50         sink the spills so that we can avoid spilling them on branches that never\r
51         reload them.\r
52 \r
53         This will fix the spill before stack check problem but only really as a side\r
54         effect. A 'real fix' probably requires making the spiller know about sp checks.\r
55 \r
56    EZY: I don't understand this comment. David Terei, can you clarify?\r
57 \r
58  - Proc points pass all arguments on the stack, adding more code and\r
59    slowing down things a lot. We either need to fix this or even better\r
60    would be to get rid of proc points.\r
61 \r
62  - CmmInfo.cmmToRawCmm uses Old.Cmm, so it is called after converting Cmm.Cmm to\r
63    Old.Cmm. We should abstract it to work on both representations, it needs only to\r
64    convert a CmmInfoTable to [CmmStatic].\r
65 \r
66  - The MkGraph currenty uses a different semantics for <*> than Hoopl. Maybe\r
67    we could convert codeGen/StgCmm* clients to the Hoopl's semantics?\r
68    It's all deeply unsatisfactory.\r
69 \r
70  - Improve performance of Hoopl.\r
71 \r
72    A nofib comparison of -fasm vs -fnewcodegen nofib compilation parameters\r
73    (using the same ghc-cmm branch +libraries compiled by the old codegenerator)\r
74    is at http://fox.auryn.cz/msrc/0517_hoopl/32bit.oldghcoldgen.oldghchoopl.txt\r
75    - the code produced is 10.9% slower, the compilation is +118% slower!\r
76 \r
77    The same comparison with ghc-head with zip representation is at\r
78    http://fox.auryn.cz/msrc/0517_hoopl/32bit.oldghcoldgen.oldghczip.txt\r
79    - the code produced is 11.7% slower, the compilation is +78% slower.\r
80 \r
81    When compiling nofib, ghc-cmm + libraries compiled with -fnew-codegen\r
82    is 23.7% slower (http://fox.auryn.cz/msrc/0517_hoopl/32bit.oldghcoldgen.hooplghcoldgen.txt).\r
83    When compiling nofib, ghc-head + libraries compiled with -fnew-codegen\r
84    is 31.4% slower (http://fox.auryn.cz/msrc/0517_hoopl/32bit.oldghcoldgen.zipghcoldgen.txt).\r
85 \r
86    So we generate a bit better code, but it takes us longer!\r
87 \r
88    EZY: Also importantly, Hoopl uses dramatically more memory than the\r
89    old code generator.\r
90 \r
91  - Are all blockToNodeList and blockOfNodeList really needed? Maybe we could\r
92    splice blocks instead?\r
93 \r
94    In the CmmContFlowOpt.blockConcat, using Dataflow seems too clumsy. Still,\r
95    a block catenation function would be probably nicer than blockToNodeList\r
96    / blockOfNodeList combo.\r
97 \r
98  - lowerSafeForeignCall seems too lowlevel. Just use Dataflow. After that\r
99    delete splitEntrySeq from HooplUtils.\r
100 \r
101  - manifestSP seems to touch a lot of the graph representation. It is\r
102    also slow for CmmSwitch nodes O(block_nodes * switch_statements).\r
103    Maybe rewrite manifestSP to use Dataflow?\r
104 \r
105  - Sort out Label, LabelMap, LabelSet versus BlockId, BlockEnv, BlockSet\r
106    dichotomy. Mostly this means global replace, but we also need to make\r
107    Label an instance of Outputable (probably in the Outputable module).\r
108 \r
109  - NB that CmmProcPoint line 283 has a hack that works around a GADT-related\r
110    bug in 6.10.\r
111 \r
112  - SDM (2010-02-26) can we remove the Foreign constructor from Convention?\r
113    Reason: we never generate code for a function with the Foreign\r
114    calling convention, and the code for calling foreign calls is generated\r
115 \r
116  - AsmCodeGen has a generic Cmm optimiser; move this into new pipeline\r
117    EZY (2011-04-16): The mini-inliner has been generalized and ported,\r
118    but the constant folding and other optimizations need to still be\r
119    ported.\r
120 \r
121  - AsmCodeGen has post-native-cg branch eliminator (shortCutBranches);\r
122    we ultimately want to share this with the Cmm branch eliminator.\r
123 \r
124  - At the moment, references to global registers like Hp are "lowered" \r
125    late (in CgUtils.fixStgRegisters). We should do this early, in the\r
126         new native codegen, much in the way that we lower calling conventions.\r
127         Might need to be a bit sophisticated about aliasing.\r
128 \r
129  - Question: currently we lift procpoints to become separate\r
130    CmmProcs.  Do we still want to do this?\r
131     \r
132    NB: and advantage of continuing to do this is that\r
133    we can do common-proc elimination!\r
134 \r
135  - Move to new Cmm rep:\r
136      * Make native CG consume New Cmm; \r
137      * Convert Old Cmm->New Cmm to keep old path alive\r
138      * Produce New Cmm when reading in .cmm files\r
139 \r
140  - Consider module names\r
141 \r
142  - Top-level SRT threading is a bit ugly\r
143 \r
144  - Add type/newtype for CmmModule = [CmmGroup]    -- A module\r
145                         CmmGroup  = [CmmTop]      -- A .o file\r
146                         CmmTop    = Proc | Data   -- A procedure or data\r
147 \r
148  - This is a *change*: currently a CmmGroup is one function's-worth of code\r
149    regardless of SplitObjs.   Question: can we *always* generate M.o if there\r
150    is just one element in the list (rather than M/M1.o, M/M2.o etc)\r
151 \r
152    One SRT per group.\r
153 \r
154  - See "CAFs" below; we want to totally refactor the way SRTs are calculated\r
155 \r
156  - Pull out Areas into its own module\r
157    Parameterise AreaMap (note there are type synonyms in CmmStackLayout!)\r
158    Add ByteWidth = Int\r
159    type SubArea    = (Area, ByteOff, ByteWidth) \r
160    ByteOff should not be defined in SMRep -- that is too high up the hierarchy\r
161    \r
162  - SMRep should not be imported by any module in cmm/!  Make it so.\r
163         -- ByteOff etc   ==>  CmmExpr\r
164         -- rET_SMALL etc ==> CmmInfo\r
165    Check that there are no other imports from codeGen in cmm/\r
166 \r
167  - If you eliminate a label by branch chain elimination,\r
168    what happens if there's an Area associated with that label?\r
169 \r
170  - Think about a non-flattened representation?\r
171 \r
172  - LastCall: \r
173     * Use record fields for LastCall!\r
174     * cml_ret_off should be a ByteOff\r
175     * Split into \r
176          LastCall (which has a successor) and\r
177          LastJump (which does not, includes return?)\r
178            - does not have cml_cont, cml_ret_args, cml_ret_off\r
179          LastForeignCall \r
180            - safe! \r
181            - expands into save/MidForeignCall/restore/goto\r
182            - like any LastCall, target of the call gets an info table\r
183 \r
184  - JD: remind self of what goes wrong if you turn off the \r
185    liveness of the update frame\r
186 \r
187  - Garbage-collect http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/CPS\r
188    moving good stuff into \r
189    http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/NewCodeGenPipeline\r
190 \r
191 \r
192  - We believe that all of CmmProcPoint.addProcPointProtocols is dead.  What\r
193    goes wrong if we simply never call it?\r
194 \r
195  - Something fishy in CmmStackLayout.hs\r
196    * In particular, 'getAreaSize' returns an AreaMap, but we *know* the width of\r
197         LocalRegs, so it'd be better to return FiniteMap AreaId ByteWidth\r
198    * setSuccSPs looks fishy.  Rather than lookin in procPoints, it could\r
199         just lookup the block in areaSize which, after all, has a binding\r
200         for precisely successors of calls.  All other blocks (including proc\r
201         points that are not successors of a call, we think) can be treated\r
202         uniformly: zero-size Area, and use inSP.\r
203 \r
204 \r
205  - Currently AsmCodeGen top level calls AsmCodeGen.cmmToCmm, which is a small\r
206    C-- optimiser.  It has quite a lot of boilerplate folding code in AsmCodeGen\r
207    (cmmBlockConFold, cmmStmtConFold, cmmExprConFold), before calling out to\r
208    CmmOpt.  ToDo: see what optimisations are being done; and do them before\r
209    AsmCodeGen.\r
210 \r
211  - Modularise the CPS pipeline; instead of ...; A;B;C; ...\r
212                                 use  ..; ABC; ....\r
213 \r
214  - Most of HscMain.tryNewCodeGen does not belong in HscMain.  Instead\r
215         if new_cg then\r
216              StgCmm.codeGen\r
217              processCmm  [including generating "raw" cmm]\r
218         else\r
219              CodeGen.codeGen\r
220              cmmToRawCmm\r
221 \r
222 \r
223  - If we stick CAF and stack liveness info on a LastCall node (not LastRet/Jump)\r
224    then all CAF and stack liveness stuff be completed before we split\r
225    into separate C procedures.\r
226 \r
227    Short term:\r
228      compute and attach liveness into to LastCall\r
229      right at end, split, cvt to old rep\r
230      [must split before cvt, because old rep is not expressive enough]\r
231 \r
232    Longer term: \r
233      when old rep disappears, \r
234      move the whole splitting game into the C back end *only*\r
235          (guided by the procpoint set)\r
236 \r
237 ----------------------------------------------------\r
238         Modules in cmm/\r
239 ----------------------------------------------------\r
240 \r
241 -------- Testing stuff ------------\r
242 HscMain.optionallyConvertAndOrCPS\r
243         testCmmConversion\r
244 DynFlags:  -fconvert-to-zipper-and-back, -frun-cpsz\r
245 \r
246 -------- Moribund stuff ------------\r
247 OldCmm.hs      Definition of flowgraph of old representation\r
248 OldCmmUtil.hs  Utilites that operates mostly on on CmmStmt\r
249 OldPprCmm.hs   Pretty print for CmmStmt, GenBasicBlock and ListGraph\r
250 CmmCvt.hs      Conversion between old and new Cmm reps\r
251 CmmOpt.hs      Hopefully-redundant optimiser\r
252 \r
253 -------- Stuff to keep ------------\r
254 CmmCPS.hs                 Driver for new pipeline\r
255 \r
256 CmmLive.hs                Liveness analysis, dead code elim\r
257 CmmProcPoint.hs           Identifying and splitting out proc-points\r
258 \r
259 CmmSpillReload.hs         Save and restore across calls\r
260 \r
261 CmmCommonBlockElim.hs     Common block elim\r
262 CmmContFlowOpt.hs         Other optimisations (branch-chain, merging)\r
263 \r
264 CmmBuildInfoTables.hs     New info-table \r
265 CmmStackLayout.hs         and stack layout \r
266 CmmCallConv.hs\r
267 CmmInfo.hs                Defn of InfoTables, and conversion to exact byte layout\r
268 \r
269 ---------- Cmm data types --------------\r
270 Cmm.hs              Cmm instantiations of dataflow graph framework\r
271 MkGraph.hs          Interface for building Cmm for codeGen/Stg*.hs modules\r
272 \r
273 CmmDecl.hs          Shared Cmm types of both representations\r
274 CmmExpr.hs          Type of Cmm expression\r
275 CmmType.hs          Type of Cmm types and their widths\r
276 CmmMachOp.hs        MachOp type and accompanying utilities\r
277 \r
278 CmmUtils.hs\r
279 CmmLint.hs\r
280 \r
281 PprC.hs             Pretty print Cmm in C syntax\r
282 PprCmm.hs           Pretty printer for CmmGraph.\r
283 PprCmmDecl.hs       Pretty printer for common Cmm types.\r
284 PprCmmExpr.hs       Pretty printer for Cmm expressions.\r
285 \r
286 CLabel.hs           CLabel\r
287 BlockId.hs          BlockId, BlockEnv, BlockSet\r
288 \r
289 ----------------------------------------------------\r
290       Top-level structure\r
291 ----------------------------------------------------\r
292 \r
293 * New codgen called in HscMain.hscGenHardCode, by calling HscMain.tryNewCodeGen, \r
294   enabled by -fnew-codegen (Opt_TryNewCodeGen)\r
295 \r
296   THEN it calls CmmInfo.cmmToRawCmm to lay out the details of info tables\r
297       type Cmm    = GenCmm CmmStatic CmmInfo     (ListGraph CmmStmt)\r
298       type RawCmm = GenCmm CmmStatic [CmmStatic] (ListGraph CmmStmt)\r
299 \r
300 * HscMain.tryNewCodeGen\r
301     - STG->Cmm:    StgCmm.codeGen (new codegen)\r
302     - Optimise:    CmmContFlowOpt (simple optimisations, very self contained)\r
303     - Cps convert: CmmCPS.protoCmmCPS \r
304     - Optimise:    CmmContFlowOpt again\r
305     - Convert:     CmmCvt.cmmOfZgraph (convert to old rep) very self contained\r
306 \r
307 * StgCmm.hs  The new STG -> Cmm conversion code generator\r
308   Lots of modules StgCmmXXX\r
309 \r
310 \r
311 ----------------------------------------------------\r
312       CmmCPS.protoCmmCPS   The new pipeline\r
313 ----------------------------------------------------\r
314 \r
315 CmmCPS.protoCmmCPS:\r
316    1. Do cpsTop for each procedures separately\r
317    2. Build SRT representation; this spans multiple procedures\r
318         (unless split-objs)\r
319 \r
320 cpsTop:\r
321   * CmmCommonBlockElim.elimCommonBlocks:\r
322         eliminate common blocks \r
323 \r
324   * CmmProcPoint.minimalProcPointSet\r
325         identify proc-points\r
326         no change to graph\r
327 \r
328   * CmmProcPoint.addProcPointProtocols\r
329         something to do with the MA optimisation\r
330         probably entirely unnecessary\r
331 \r
332   * Spill and reload:\r
333      - CmmSpillReload.dualLivenessWithInsertion\r
334        insert spills/reloads across \r
335            LastCalls, and \r
336            Branches to proc-points\r
337      Now sink those reloads (and other instructions):\r
338      - CmmSpillReload.rewriteAssignments\r
339      - CmmSpillReload.removeDeadAssignmentsAndReloads\r
340 \r
341   * CmmStackLayout.stubSlotsOnDeath\r
342         debug only: zero out dead slots when they die\r
343 \r
344   * Stack layout\r
345      - CmmStackLayout.lifeSlotAnal: \r
346        find which sub-areas are live on entry to each block\r
347 \r
348      - CmmStackLayout.layout\r
349        Lay out the stack, returning an AreaMap\r
350          type AreaMap = FiniteMap Area ByteOff\r
351           -- Byte offset of the oldest byte of the Area, \r
352           -- relative to the oldest byte of the Old Area\r
353 \r
354      - CmmStackLayout.manifestSP\r
355        Manifest the stack pointer\r
356 \r
357    * Split into separate procedures\r
358       - CmmProcPoint.procPointAnalysis\r
359         Given set of proc points, which blocks are reachable from each\r
360         Claim: too few proc-points => code duplication, but program still works??\r
361 \r
362       - CmmProcPoint.splitAtProcPoints\r
363         Using this info, split into separate procedures\r
364 \r
365       - CmmBuildInfoTables.setInfoTableStackMap\r
366         Attach stack maps to each info table\r
367 \r
368 \r
369 ----------------------------------------------------\r
370         Proc-points\r
371 ----------------------------------------------------\r
372 \r
373 Consider this program, which has a diamond control flow, \r
374 with a call on one branch\r
375  fn(p,x) {\r
376         h()\r
377         if b then { ... f(x) ...; q=5; goto J }\r
378              else { ...; q=7; goto J }\r
379      J: ..p...q...\r
380   }\r
381 then the join point J is a "proc-point".  So, is 'p' passed to J\r
382 as a parameter?  Or, if 'p' was saved on the stack anyway, perhaps\r
383 to keep it alive across the call to h(), maybe 'p' gets communicated\r
384 to J that way. This is an awkward choice.  (We think that we currently\r
385 never pass variables to join points via arguments.)\r
386 \r
387 Furthermore, there is *no way* to pass q to J in a register (other\r
388 than a parameter register).\r
389 \r
390 What we want is to do register allocation across the whole caboodle.\r
391 Then we could drop all the code that deals with the above awkward\r
392 decisions about spilling variables across proc-points.\r
393 \r
394 Note that J doesn't need an info table.\r
395 \r
396 What we really want is for each LastCall (not LastJump/Ret) \r
397 to have an info table.   Note that ProcPoints that are not successors\r
398 of calls don't need an info table.\r
399 \r
400 Figuring out proc-points\r
401 ~~~~~~~~~~~~~~~~~~~~~~~~\r
402 Proc-points are identified by\r
403 CmmProcPoint.minimalProcPointSet/extendPPSet Although there isn't\r
404 that much code, JD thinks that it could be done much more nicely using\r
405 a dominator analysis, using the Dataflow Engine.\r
406 \r
407 ----------------------------------------------------\r
408                 CAFs\r
409 ----------------------------------------------------\r
410 \r
411 * The code for a procedure f may refer to either the *closure* \r
412   or the *entry point* of another top-level procedure g.  \r
413   If f is live, then so is g.  f's SRT must include g's closure.\r
414 \r
415 * The CLabel for the entry-point/closure reveals whether g is \r
416   a CAF (or refers to CAFs).  See the IdLabel constructor of CLabel.\r
417 \r
418 * The CAF-ness of the original top-level defininions is figured out\r
419   (by TidyPgm) before we generate C--.  This CafInfo is only set for\r
420   top-level Ids; nested bindings stay with MayHaveCafRefs.\r
421 \r
422 * Currently an SRT contains (only) pointers to (top-level) closures.\r
423 \r
424 * Consider this Core code\r
425         f = \x -> let g = \y -> ...x...y...h1...\r
426                   in ...h2...g...\r
427   and suppose that h1, h2 have IdInfo of MayHaveCafRefs.\r
428   Therefore, so will f,  But g will not (since it's nested).\r
429 \r
430   This generates C-- roughly like this:\r
431      f_closure: .word f_entry\r
432      f_entry() [info-tbl-for-f] { ...jump g_entry...jump h2... }\r
433      g_entry() [info-tbl-for-g] { ...jump h1... }\r
434 \r
435   Note that there is no top-level closure for g (only an info table).\r
436   This fact (whether or not there is a top-level closure) is recorded\r
437   in the InfoTable attached to the CmmProc for f, g\r
438   INVARIANT: \r
439      Any out-of-Group references to an IdLabel goes to\r
440      a Proc whose InfoTable says "I have a top-level closure".\r
441   Equivalently: \r
442      A CmmProc whose InfoTable says "I do not have a top-level\r
443      closure" is referred to only from its own Group.\r
444 \r
445 * So:   info-tbl-for-f must have an SRT that keeps h1,h2 alive\r
446         info-tbl-for-g must have an SRT that keeps h1 (only) alive\r
447 \r
448   But if we just look for the free CAF refs, we get:\r
449         f   h2 (only)\r
450         g   h1\r
451 \r
452   So we need to do a transitive closure thing to flesh out \r
453   f's keep-alive refs to include h1.\r
454 \r
455 * The SRT info is the C_SRT field of Cmm.ClosureTypeInfo in a\r
456   CmmInfoTable attached to each CmmProc.  CmmCPS.toTops actually does\r
457   the attaching, right at the end of the pipeline.  The C_SRT part\r
458   gives offsets within a single, shared table of closure pointers.\r
459 \r
460 * DECIDED: we can generate SRTs based on the final Cmm program\r
461   without knowledge of how it is generated.\r
462 \r
463 ----------------------------------------------------\r
464                 Foreign calls\r
465 ----------------------------------------------------\r
466 \r
467 See Note [Foreign calls] in CmmNode!  This explains that a safe\r
468 foreign call must do this:\r
469   save thread state\r
470   push info table (on thread stack) to describe frame\r
471   make call (via C stack)\r
472   pop info table\r
473   restore thread state\r
474 and explains why this expansion must be done late in the day.\r
475 \r
476 Hence, \r
477   - Every foreign call is represented as a middle node\r
478 \r
479   - *Unsafe* foreign calls are simply "fat machine instructions"\r
480       and are passed along to the native code generator\r
481 \r
482   - *Safe* foreign calls are "lowered" to unsafe calls by wrapping\r
483       them in the above save/restore sequence. This step is done\r
484       very late in the pipeline, just before handing to the native\r
485       code gen.   \r
486   \r
487       This lowering is done by BuildInfoTables.lowerSafeForeignCalls\r
488 \r
489 \r
490 NEW PLAN for foreign calls:\r
491   - Unsafe foreign calls remain as a middle node (fat machine instruction)\r
492     Even the parameter passing is not lowered (just as machine instrs\r
493     get arguments).\r
494 \r
495   - Initially, safe foreign calls appear as LastCalls with \r
496         \r
497 \r
498 ----------------------------------------------------\r
499                 Cmm representations\r
500 ----------------------------------------------------\r
501 \r
502 * CmmDecl.hs\r
503      The type [GenCmm d h g] represents a whole module, \r
504         ** one list element per .o file **\r
505         Without SplitObjs, the list has exactly one element\r
506 \r
507      newtype GenCmm d h g = Cmm [GenCmmTop d h g]  -- A whole .o file\r
508      data GenCmmTop d h g\r
509          = CmmProc h g           -- One procedure, graph d\r
510          | CmmData <stuff> [d]   -- Initialised data, items d\r
511 \r
512   Old and new piplines use different representations\r
513         (CmmCvt.hs converts between the two)\r
514 \r
515 \r
516 -------------\r
517 OLD BACK END representations (OldCmm.hs):  \r
518       type Cmm = GenCmm CmmStatic CmmInfo (ListGraph CmmStmt)\r
519                                 -- A whole module\r
520       newtype ListGraph i = ListGraph [GenBasicBlock i]\r
521 \r
522       data CmmStmt = Assign | Store | Return etc -- OLD BACK END ONLY\r
523 \r
524 \r
525    Once the info tables are laid out, we replace CmmInfo with [CmmStatic]\r
526       type RawCmm    = GenCmm CmmStatic [CmmStatic] (ListGraph CmmStmt)\r
527    which represents the info tables as data, that should \r
528    immediately precede the code\r
529   \r
530 -------------\r
531 NEW BACK END representations \r
532 * Uses Hoopl library, a zero-boot package\r
533 * CmmNode defines a node of a flow graph.\r
534 * Cmm defines CmmGraph, CmmTop, Cmm\r
535    - CmmGraph is a closed/closed graph + an entry node.\r
536 \r
537        data CmmGraph = CmmGraph { g_entry :: BlockId\r
538                                 , g_graph :: Graph CmmNode C C }\r
539 \r
540    - CmmTop is a top level chunk, specialization of GenCmmTop from CmmDecl.hs\r
541        with CmmGraph as a flow graph.\r
542    - Cmm is a collection of CmmTops.\r
543 \r
544        type Cmm          = GenCmm    CmmStatic CmmTopInfo CmmGraph\r
545        type CmmTop       = GenCmmTop CmmStatic CmmTopInfo CmmGraph\r
546 \r
547    - CmmTop uses CmmTopInfo, which is a CmmInfoTable and CmmStackInfo\r
548 \r
549        data CmmTopInfo   = TopInfo {info_tbl :: CmmInfoTable, stack_info :: CmmStackInfo}\r
550 \r
551    - CmmStackInfo\r
552 \r
553        data CmmStackInfo = StackInfo {arg_space :: ByteOff, updfr_space :: Maybe ByteOff}\r
554 \r
555          * arg_space = SP offset on entry\r
556          * updfr_space space = SP offset on exit\r
557        Once the staci is manifested, we could drom CmmStackInfo, ie. get\r
558          GenCmm CmmStatic CmmInfoTable CmmGraph, but we do not do that currently.\r
559 \r
560 \r
561 * MkGraph.hs: smart constructors for Cmm.hs\r
562   Beware, the CmmAGraph defined here does not use AGraph from Hoopl,\r
563   as CmmAGraph can be opened or closed at exit, See the notes in that module.\r
564 \r
565 -------------\r
566 * SHARED stuff\r
567   CmmDecl.hs - GenCmm and GenCmmTop types\r
568   CmmExpr.hs - defines the Cmm expression types\r
569              - CmmExpr, CmmReg, CmmLit, LocalReg, GlobalReg\r
570              - Area, AreaId etc     (separate module?)\r
571   CmmType.hs - CmmType, Width etc   (saparate module?)\r
572   CmmMachOp.hs - MachOp and CallishMachOp types\r
573 \r
574   BlockId.hs defines  BlockId, BlockEnv, BlockSet\r
575 -------------\r