2 -- The above warning supression flag is a temporary kludge.
3 -- While working on this module you are encouraged to remove it and fix
4 -- any warnings in the module. See
5 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
8 -----------------------------------------------------------------------------
10 -- (c) The University of Glasgow -2006
12 -- Code generation relaed to GpH
16 -----------------------------------------------------------------------------
19 staticGranHdr,staticParHdr,
20 granFetchAndReschedule, granYield,
31 staticParHdr :: [CmmLit]
32 -- Parallel header words in a static closure
35 --------------------------------------------------------
37 --------------------------------------------------------
39 staticGranHdr :: [CmmLit]
40 -- Gransim header words in a static closure
43 doGranAllocate :: CmmExpr -> Code
44 -- macro DO_GRAN_ALLOCATE
46 | not opt_GranMacros = nopC
47 | otherwise = panic "doGranAllocate"
51 -------------------------
52 granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
55 -- Emit code for simulating a fetch and then reschedule.
56 granFetchAndReschedule regs node_reqd
57 | opt_GranMacros && (node `elem` map snd regs || node_reqd)
59 ; reschedule liveness node_reqd }
63 liveness = mkRegLiveness regs 0 0
65 fetch = panic "granFetch"
66 -- Was: absC (CMacroStmt GRAN_FETCH [])
67 --HWL: generate GRAN_FETCH macro for GrAnSim
68 -- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
70 reschedule liveness node_reqd = panic "granReschedule"
71 -- Was: absC (CMacroStmt GRAN_RESCHEDULE [
72 -- mkIntCLit (I# (word2Int# liveness_mask)),
73 -- mkIntCLit (if node_reqd then 1 else 0)])
76 -------------------------
77 -- The @GRAN_YIELD@ macro is taken from JSM's code for Concurrent Haskell. It
78 -- allows to context-switch at places where @node@ is not alive (it uses the
79 -- @Continue@ rather than the @EnterNodeCode@ function in the RTS). We emit
80 -- this kind of macro at the beginning of the following kinds of basic bocks:
82 -- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
83 -- we use @fetchAndReschedule@ at a slow entry code.
84 -- \item Fast entry code (see @CgClosure.lhs@).
85 -- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
86 -- that they are not inlined (see @CgCases.lhs@). These alternatives will
87 -- be turned into separate functions.
89 granYield :: [(Id,GlobalReg)] -- Live registers
93 granYield regs node_reqd
94 | opt_GranMacros && node_reqd = yield liveness
97 liveness = mkRegLiveness regs 0 0
99 yield liveness = panic "granYield"
100 -- Was : absC (CMacroStmt GRAN_YIELD
101 -- [mkIntCLit (I# (word2Int# liveness_mask))])