1 -----------------------------------------------------------------------------
3 -- (c) The University of Glasgow -2006
5 -- Code generation relaed to GpH
9 -----------------------------------------------------------------------------
12 staticGranHdr,staticParHdr,
13 granFetchAndReschedule, granYield,
25 staticParHdr :: [CmmLit]
26 -- Parallel header words in a static closure
29 --------------------------------------------------------
31 --------------------------------------------------------
33 staticGranHdr :: [CmmLit]
34 -- Gransim header words in a static closure
37 doGranAllocate :: CmmExpr -> Code
38 -- macro DO_GRAN_ALLOCATE
40 | not opt_GranMacros = nopC
41 | otherwise = panic "doGranAllocate"
45 -------------------------
46 granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
49 -- Emit code for simulating a fetch and then reschedule.
50 granFetchAndReschedule regs node_reqd
51 | opt_GranMacros && (node `elem` map snd regs || node_reqd)
53 ; reschedule liveness node_reqd }
57 liveness = mkRegLiveness regs 0 0
60 fetch = panic "granFetch"
61 -- Was: absC (CMacroStmt GRAN_FETCH [])
62 --HWL: generate GRAN_FETCH macro for GrAnSim
63 -- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
65 reschedule :: StgWord -> Bool -> Code
66 reschedule _liveness _node_reqd = panic "granReschedule"
67 -- Was: absC (CMacroStmt GRAN_RESCHEDULE [
68 -- mkIntCLit (I# (word2Int# liveness_mask)),
69 -- mkIntCLit (if node_reqd then 1 else 0)])
72 -------------------------
73 -- The @GRAN_YIELD@ macro is taken from JSM's code for Concurrent Haskell. It
74 -- allows to context-switch at places where @node@ is not alive (it uses the
75 -- @Continue@ rather than the @EnterNodeCode@ function in the RTS). We emit
76 -- this kind of macro at the beginning of the following kinds of basic bocks:
78 -- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
79 -- we use @fetchAndReschedule@ at a slow entry code.
80 -- \item Fast entry code (see @CgClosure.lhs@).
81 -- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
82 -- that they are not inlined (see @CgCases.lhs@). These alternatives will
83 -- be turned into separate functions.
85 granYield :: [(Id,GlobalReg)] -- Live registers
89 granYield regs node_reqd
90 | opt_GranMacros && node_reqd = yield liveness
93 liveness = mkRegLiveness regs 0 0
95 yield :: StgWord -> Code
96 yield _liveness = panic "granYield"
97 -- Was : absC (CMacroStmt GRAN_YIELD
98 -- [mkIntCLit (I# (word2Int# liveness_mask))])