1 -- Code generation relaed to GpH
6 staticGranHdr,staticParHdr,
7 granFetchAndReschedule, granYield,
12 import CgCallConv ( mkRegLiveness )
14 import Cmm ( CmmLit, GlobalReg(..), node, CmmExpr )
15 import StaticFlags ( opt_GranMacros )
18 staticParHdr :: [CmmLit]
19 -- Parallel header words in a static closure
22 --------------------------------------------------------
24 --------------------------------------------------------
26 staticGranHdr :: [CmmLit]
27 -- Gransim header words in a static closure
30 doGranAllocate :: CmmExpr -> Code
31 -- macro DO_GRAN_ALLOCATE
33 | not opt_GranMacros = nopC
34 | otherwise = panic "doGranAllocate"
38 -------------------------
39 granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
42 -- Emit code for simulating a fetch and then reschedule.
43 granFetchAndReschedule regs node_reqd
44 | opt_GranMacros && (node `elem` map snd regs || node_reqd)
46 ; reschedule liveness node_reqd }
50 liveness = mkRegLiveness regs 0 0
52 fetch = panic "granFetch"
53 -- Was: absC (CMacroStmt GRAN_FETCH [])
54 --HWL: generate GRAN_FETCH macro for GrAnSim
55 -- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
57 reschedule liveness node_reqd = panic "granReschedule"
58 -- Was: absC (CMacroStmt GRAN_RESCHEDULE [
59 -- mkIntCLit (I# (word2Int# liveness_mask)),
60 -- mkIntCLit (if node_reqd then 1 else 0)])
63 -------------------------
64 -- The @GRAN_YIELD@ macro is taken from JSM's code for Concurrent Haskell. It
65 -- allows to context-switch at places where @node@ is not alive (it uses the
66 -- @Continue@ rather than the @EnterNodeCode@ function in the RTS). We emit
67 -- this kind of macro at the beginning of the following kinds of basic bocks:
69 -- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
70 -- we use @fetchAndReschedule@ at a slow entry code.
71 -- \item Fast entry code (see @CgClosure.lhs@).
72 -- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
73 -- that they are not inlined (see @CgCases.lhs@). These alternatives will
74 -- be turned into separate functions.
76 granYield :: [(Id,GlobalReg)] -- Live registers
80 granYield regs node_reqd
81 | opt_GranMacros && node_reqd = yield liveness
84 liveness = mkRegLiveness regs 0 0
86 yield liveness = panic "granYield"
87 -- Was : absC (CMacroStmt GRAN_YIELD
88 -- [mkIntCLit (I# (word2Int# liveness_mask))])