StgCmmGran.hs 3.9 KB
Newer Older
1 2 3 4 5
-----------------------------------------------------------------------------
--
-- (c) The University of Glasgow -2006
--
-- Code generation relaed to GpH
6 7
--      (a) parallel
--      (b) GranSim
8 9 10 11
--
-----------------------------------------------------------------------------

module StgCmmGran (
12 13 14
        staticGranHdr,staticParHdr,
        granThunk, granYield,
        doGranAllocate
15 16 17 18 19 20 21
  ) where

-- This entire module consists of no-op stubs at the moment
-- GranSim worked once, but it certainly doesn't any more
-- I've left the calls, though, in case anyone wants to resurrect it

import StgCmmMonad
22
import CmmExpr
23 24 25 26 27 28 29 30 31

staticGranHdr :: [CmmLit]
staticGranHdr = []

staticParHdr :: [CmmLit]
staticParHdr = []

doGranAllocate :: VirtualHpOffset -> FCode ()
-- Must be lazy in the amount of allocation
Ian Lynagh's avatar
Ian Lynagh committed
32
doGranAllocate _ = return ()
33 34

granYield :: [LocalReg] -> Bool -> FCode ()
Ian Lynagh's avatar
Ian Lynagh committed
35
granYield _regs _node_reqd = return ()
36 37

granThunk :: Bool -> FCode ()
Ian Lynagh's avatar
Ian Lynagh committed
38
granThunk _node_points = return ()
39 40 41 42 43 44 45 46 47 48 49 50 51 52

-----------------------------------------------------------------
{-   ------- Everything below here is commented out -------------
-----------------------------------------------------------------

-- Parallel header words in a static closure
staticParHdr :: [CmmLit]
-- Parallel header words in a static closure
staticParHdr = []

staticGranHdr :: [CmmLit]
-- Gransim header words in a static closure
staticGranHdr = []

53
doGranAllocate :: CmmExpr -> Code
54
-- macro DO_GRAN_ALLOCATE
55
doGranAllocate hp
56
  | not opt_GranMacros = return ()
57
  | otherwise          = panic "doGranAllocate"
58 59 60 61 62 63 64



-------------------------
granThunk :: Bool -> FCode ()
-- HWL: insert macros for GrAnSim; 2 versions depending on liveness of node
-- (we prefer fetchAndReschedule-style context switches to yield ones)
65 66 67
granThunk node_points
  | node_points = granFetchAndReschedule [] node_points
  | otherwise   = granYield              [] node_points
68 69

granFetchAndReschedule :: [(Id,GlobalReg)]  -- Live registers
70 71
                       -> Bool                  -- Node reqd?
                       -> Code
72 73 74 75 76 77
-- Emit code for simulating a fetch and then reschedule.
granFetchAndReschedule regs node_reqd
  | opt_GranMacros && (node `elem` map snd regs || node_reqd)
  = do { fetch
       ; reschedule liveness node_reqd }
  | otherwise
78
  = return ()
79 80 81 82
  where
    liveness = mkRegLiveness regs 0 0

fetch = panic "granFetch"
83 84 85
        -- Was: absC (CMacroStmt GRAN_FETCH [])
        --HWL: generate GRAN_FETCH macro for GrAnSim
        --     currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
86 87

reschedule liveness node_reqd = panic "granReschedule"
88 89 90 91
        -- Was: absC  (CMacroStmt GRAN_RESCHEDULE [
        --                mkIntCLit (I# (word2Int# liveness_mask)),
        --                mkIntCLit (if node_reqd then 1 else 0)])

92 93 94 95 96 97 98

-------------------------
-- The @GRAN_YIELD@ macro is taken from JSM's  code for Concurrent Haskell. It
-- allows to context-switch at  places where @node@ is  not alive (it uses the
-- @Continue@ rather  than the @EnterNodeCode@  function in the  RTS). We emit
-- this kind of macro at the beginning of the following kinds of basic bocks:
-- \begin{itemize}
Simon Marlow's avatar
Simon Marlow committed
99
--  \item Slow entry code where node is not alive (see @StgCmmClosure.lhs@). Normally
100 101 102
--        we use @fetchAndReschedule@ at a slow entry code.
--  \item Fast entry code (see @CgClosure.lhs@).
--  \item Alternatives in case expressions (@CLabelledCode@ structures), provided
103
--        that they are not inlined (see @CgCases.lhs@). These alternatives will
104 105 106 107
--        be turned into separate functions.

granYield :: [(Id,GlobalReg)]   -- Live registers
          -> Bool               -- Node reqd?
108
          -> Code
109 110 111

granYield regs node_reqd
  | opt_GranMacros && node_reqd = yield liveness
112
  | otherwise                   = return ()
113 114 115 116
  where
     liveness = mkRegLiveness regs 0 0

yield liveness = panic "granYield"
117
        -- Was : absC (CMacroStmt GRAN_YIELD
118 119 120
        --                  [mkIntCLit (I# (word2Int# liveness_mask))])

-}