1 -----------------------------------------------------------------------------
3 -- (c) The University of Glasgow -2006
5 -- Code generation relaed to GpH
9 -----------------------------------------------------------------------------
12 -- The above warning supression flag is a temporary kludge.
13 -- While working on this module you are encouraged to remove it and fix
14 -- any warnings in the module. See
15 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
19 staticGranHdr,staticParHdr,
24 -- This entire module consists of no-op stubs at the moment
25 -- GranSim worked once, but it certainly doesn't any more
26 -- I've left the calls, though, in case anyone wants to resurrect it
32 staticGranHdr :: [CmmLit]
35 staticParHdr :: [CmmLit]
38 doGranAllocate :: VirtualHpOffset -> FCode ()
39 -- Must be lazy in the amount of allocation
40 doGranAllocate n = return ()
42 granFetchAndReschedule :: [(Id,GlobalReg)] -> Bool -> FCode ()
43 granFetchAndReschedule regs node_reqd = return ()
45 granYield :: [LocalReg] -> Bool -> FCode ()
46 granYield regs node_reqd = return ()
48 granThunk :: Bool -> FCode ()
49 granThunk node_points = return ()
51 -----------------------------------------------------------------
52 {- ------- Everything below here is commented out -------------
53 -----------------------------------------------------------------
55 -- Parallel header words in a static closure
56 staticParHdr :: [CmmLit]
57 -- Parallel header words in a static closure
60 staticGranHdr :: [CmmLit]
61 -- Gransim header words in a static closure
64 doGranAllocate :: CmmExpr -> Code
65 -- macro DO_GRAN_ALLOCATE
67 | not opt_GranMacros = nopC
68 | otherwise = panic "doGranAllocate"
72 -------------------------
73 granThunk :: Bool -> FCode ()
74 -- HWL: insert macros for GrAnSim; 2 versions depending on liveness of node
75 -- (we prefer fetchAndReschedule-style context switches to yield ones)
77 | node_points = granFetchAndReschedule [] node_points
78 | otherwise = granYield [] node_points
80 granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
83 -- Emit code for simulating a fetch and then reschedule.
84 granFetchAndReschedule regs node_reqd
85 | opt_GranMacros && (node `elem` map snd regs || node_reqd)
87 ; reschedule liveness node_reqd }
91 liveness = mkRegLiveness regs 0 0
93 fetch = panic "granFetch"
94 -- Was: absC (CMacroStmt GRAN_FETCH [])
95 --HWL: generate GRAN_FETCH macro for GrAnSim
96 -- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
98 reschedule liveness node_reqd = panic "granReschedule"
99 -- Was: absC (CMacroStmt GRAN_RESCHEDULE [
100 -- mkIntCLit (I# (word2Int# liveness_mask)),
101 -- mkIntCLit (if node_reqd then 1 else 0)])
104 -------------------------
105 -- The @GRAN_YIELD@ macro is taken from JSM's code for Concurrent Haskell. It
106 -- allows to context-switch at places where @node@ is not alive (it uses the
107 -- @Continue@ rather than the @EnterNodeCode@ function in the RTS). We emit
108 -- this kind of macro at the beginning of the following kinds of basic bocks:
110 -- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
111 -- we use @fetchAndReschedule@ at a slow entry code.
112 -- \item Fast entry code (see @CgClosure.lhs@).
113 -- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
114 -- that they are not inlined (see @CgCases.lhs@). These alternatives will
115 -- be turned into separate functions.
117 granYield :: [(Id,GlobalReg)] -- Live registers
118 -> Bool -- Node reqd?
121 granYield regs node_reqd
122 | opt_GranMacros && node_reqd = yield liveness
125 liveness = mkRegLiveness regs 0 0
127 yield liveness = panic "granYield"
128 -- Was : absC (CMacroStmt GRAN_YIELD
129 -- [mkIntCLit (I# (word2Int# liveness_mask))])