blob: 682f28aad4ba6333524b8c275b1df9606ad1a6e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
-----------------------------------------------------------------------------
--
-- (c) The University of Glasgow -2006
--
-- Code generation relaed to GpH
-- (a) parallel
-- (b) GranSim
--
-----------------------------------------------------------------------------
module CgParallel(
staticGranHdr,staticParHdr,
granFetchAndReschedule, granYield,
doGranAllocate
) where
import CgMonad
import CgCallConv
import Id
import OldCmm
import StaticFlags
import Outputable
import SMRep
staticParHdr :: [CmmLit]
-- Parallel header words in a static closure
staticParHdr = []
--------------------------------------------------------
-- GranSim stuff
--------------------------------------------------------
staticGranHdr :: [CmmLit]
-- Gransim header words in a static closure
staticGranHdr = []
doGranAllocate :: CmmExpr -> Code
-- macro DO_GRAN_ALLOCATE
doGranAllocate _hp
| not opt_GranMacros = nopC
| otherwise = panic "doGranAllocate"
-------------------------
granFetchAndReschedule :: [(Id,GlobalReg)] -- Live registers
-> Bool -- Node reqd?
-> Code
-- 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
= nopC
where
liveness = mkRegLiveness regs 0 0
fetch :: FCode ()
fetch = panic "granFetch"
-- Was: absC (CMacroStmt GRAN_FETCH [])
--HWL: generate GRAN_FETCH macro for GrAnSim
-- currently GRAN_FETCH and GRAN_FETCH_AND_RESCHEDULE are miai
reschedule :: StgWord -> Bool -> Code
reschedule _liveness _node_reqd = panic "granReschedule"
-- Was: absC (CMacroStmt GRAN_RESCHEDULE [
-- mkIntCLit (I# (word2Int# liveness_mask)),
-- mkIntCLit (if node_reqd then 1 else 0)])
-------------------------
-- 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}
-- \item Slow entry code where node is not alive (see @CgClosure.lhs@). Normally
-- we use @fetchAndReschedule@ at a slow entry code.
-- \item Fast entry code (see @CgClosure.lhs@).
-- \item Alternatives in case expressions (@CLabelledCode@ structures), provided
-- that they are not inlined (see @CgCases.lhs@). These alternatives will
-- be turned into separate functions.
granYield :: [(Id,GlobalReg)] -- Live registers
-> Bool -- Node reqd?
-> Code
granYield regs node_reqd
| opt_GranMacros && node_reqd = yield liveness
| otherwise = nopC
where
liveness = mkRegLiveness regs 0 0
yield :: StgWord -> Code
yield _liveness = panic "granYield"
-- Was : absC (CMacroStmt GRAN_YIELD
-- [mkIntCLit (I# (word2Int# liveness_mask))])
|