1 -----------------------------------------------------------------------------
3 -- (c) The University of Glasgow -2006
5 -- Code generation relaed to GpH
9 -----------------------------------------------------------------------------
12 staticGranHdr,staticParHdr,
17 -- This entire module consists of no-op stubs at the moment
18 -- GranSim worked once, but it certainly doesn't any more
19 -- I've left the calls, though, in case anyone wants to resurrect it
24 staticGranHdr :: [CmmLit]
27 staticParHdr :: [CmmLit]
30 doGranAllocate :: VirtualHpOffset -> FCode ()
31 -- Must be lazy in the amount of allocation
32 doGranAllocate _ = return ()
34 granYield :: [LocalReg] -> Bool -> FCode ()
35 granYield _regs _node_reqd = return ()
37 granThunk :: Bool -> FCode ()
38 granThunk _node_points = return ()
40 -----------------------------------------------------------------
41 {- ------- Everything below here is commented out -------------
42 -----------------------------------------------------------------
44 -- Parallel header words in a static closure
45 staticParHdr :: [CmmLit]
46 -- Parallel header words in a static closure
49 staticGranHdr :: [CmmLit]
50 -- Gransim header words in a static closure
53 doGranAllocate :: CmmExpr -> Code
54 -- macro DO_GRAN_ALLOCATE
56 | not opt_GranMacros = nopC
57 | otherwise = panic "doGranAllocate"
61 -------------------------
62 granThunk :: Bool -> FCode ()
63 -- HWL: insert macros for GrAnSim; 2 versions depending on liveness of node
64 -- (we prefer fetchAndReschedule-style context switches to yield ones)
66 | node_points = granFetchAndReschedule [] node_points
67 | otherwise = granYield [] node_points
69 granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
72 -- Emit code for simulating a fetch and then reschedule.
73 granFetchAndReschedule regs node_reqd
74 | opt_GranMacros && (node `elem` map snd regs || node_reqd)
76 ; reschedule liveness node_reqd }
80 liveness = mkRegLiveness regs 0 0
82 fetch = panic "granFetch"
83 -- Was: absC (CMacroStmt GRAN_FETCH [])
84 --HWL: generate GRAN_FETCH macro for GrAnSim
85 -- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
87 reschedule liveness node_reqd = panic "granReschedule"
88 -- Was: absC (CMacroStmt GRAN_RESCHEDULE [
89 -- mkIntCLit (I# (word2Int# liveness_mask)),
90 -- mkIntCLit (if node_reqd then 1 else 0)])
93 -------------------------
94 -- The @GRAN_YIELD@ macro is taken from JSM's code for Concurrent Haskell. It
95 -- allows to context-switch at places where @node@ is not alive (it uses the
96 -- @Continue@ rather than the @EnterNodeCode@ function in the RTS). We emit
97 -- this kind of macro at the beginning of the following kinds of basic bocks:
99 -- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
100 -- we use @fetchAndReschedule@ at a slow entry code.
101 -- \item Fast entry code (see @CgClosure.lhs@).
102 -- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
103 -- that they are not inlined (see @CgCases.lhs@). These alternatives will
104 -- be turned into separate functions.
106 granYield :: [(Id,GlobalReg)] -- Live registers
107 -> Bool -- Node reqd?
110 granYield regs node_reqd
111 | opt_GranMacros && node_reqd = yield liveness
114 liveness = mkRegLiveness regs 0 0
116 yield liveness = panic "granYield"
117 -- Was : absC (CMacroStmt GRAN_YIELD
118 -- [mkIntCLit (I# (word2Int# liveness_mask))])