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