Remove platform CPP from nativeGen/PPC/CodeGen.hs
[ghc-hetmet.git] / compiler / codeGen / StgCmmGran.hs
1 -----------------------------------------------------------------------------
2 --
3 -- (c) The University of Glasgow -2006
4 --
5 -- Code generation relaed to GpH
6 --      (a) parallel
7 --      (b) GranSim
8 --
9 -----------------------------------------------------------------------------
10
11 module StgCmmGran (
12         staticGranHdr,staticParHdr,
13         granThunk, granYield,
14         doGranAllocate
15   ) where
16
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
20
21 import StgCmmMonad
22 import CmmExpr
23
24 staticGranHdr :: [CmmLit]
25 staticGranHdr = []
26
27 staticParHdr :: [CmmLit]
28 staticParHdr = []
29
30 doGranAllocate :: VirtualHpOffset -> FCode ()
31 -- Must be lazy in the amount of allocation
32 doGranAllocate _ = return ()
33
34 granYield :: [LocalReg] -> Bool -> FCode ()
35 granYield _regs _node_reqd = return ()
36
37 granThunk :: Bool -> FCode ()
38 granThunk _node_points = return ()
39
40 -----------------------------------------------------------------
41 {-   ------- Everything below here is commented out -------------
42 -----------------------------------------------------------------
43
44 -- Parallel header words in a static closure
45 staticParHdr :: [CmmLit]
46 -- Parallel header words in a static closure
47 staticParHdr = []
48
49 staticGranHdr :: [CmmLit]
50 -- Gransim header words in a static closure
51 staticGranHdr = []
52
53 doGranAllocate :: CmmExpr -> Code       
54 -- macro DO_GRAN_ALLOCATE
55 doGranAllocate hp 
56   | not opt_GranMacros = nopC
57   | otherwise          = panic "doGranAllocate"
58
59
60
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)
65 granThunk node_points 
66   | node_points = granFetchAndReschedule [] node_points 
67   | otherwise   = granYield              [] node_points
68
69 granFetchAndReschedule :: [(Id,GlobalReg)]  -- Live registers
70                        -> Bool                  -- Node reqd?
71                        -> Code
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)
75   = do { fetch
76        ; reschedule liveness node_reqd }
77   | otherwise
78   = nopC
79   where
80     liveness = mkRegLiveness regs 0 0
81
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
86
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)])
91     
92
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:
98 -- \begin{itemize}
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.
105
106 granYield :: [(Id,GlobalReg)]   -- Live registers
107           -> Bool               -- Node reqd?
108           -> Code 
109
110 granYield regs node_reqd
111   | opt_GranMacros && node_reqd = yield liveness
112   | otherwise                   = nopC
113   where
114      liveness = mkRegLiveness regs 0 0
115
116 yield liveness = panic "granYield"
117         -- Was : absC (CMacroStmt GRAN_YIELD 
118         --                  [mkIntCLit (I# (word2Int# liveness_mask))])
119
120 -}