summaryrefslogtreecommitdiff
path: root/compiler/codeGen/StgCmmGran.hs
diff options
context:
space:
mode:
authordias@eecs.harvard.edu <unknown>2008-08-14 12:40:27 +0000
committerdias@eecs.harvard.edu <unknown>2008-08-14 12:40:27 +0000
commit176fa33f17dd78355cc572e006d2ab26898e2c69 (patch)
tree54f951a515eac57626f8f15d57f7bc75f1096a7a /compiler/codeGen/StgCmmGran.hs
parente06951a75a1f519e8f015880c363a8dedc08ff9c (diff)
downloadhaskell-176fa33f17dd78355cc572e006d2ab26898e2c69.tar.gz
Merging in the new codegen branch
This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
Diffstat (limited to 'compiler/codeGen/StgCmmGran.hs')
-rw-r--r--compiler/codeGen/StgCmmGran.hs131
1 files changed, 131 insertions, 0 deletions
diff --git a/compiler/codeGen/StgCmmGran.hs b/compiler/codeGen/StgCmmGran.hs
new file mode 100644
index 0000000000..5fad2bfc09
--- /dev/null
+++ b/compiler/codeGen/StgCmmGran.hs
@@ -0,0 +1,131 @@
+-----------------------------------------------------------------------------
+--
+-- (c) The University of Glasgow -2006
+--
+-- Code generation relaed to GpH
+-- (a) parallel
+-- (b) GranSim
+--
+-----------------------------------------------------------------------------
+
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
+module StgCmmGran (
+ staticGranHdr,staticParHdr,
+ granThunk, granYield,
+ doGranAllocate
+ ) 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
+import Id
+import Cmm
+
+staticGranHdr :: [CmmLit]
+staticGranHdr = []
+
+staticParHdr :: [CmmLit]
+staticParHdr = []
+
+doGranAllocate :: VirtualHpOffset -> FCode ()
+-- Must be lazy in the amount of allocation
+doGranAllocate n = return ()
+
+granFetchAndReschedule :: [(Id,GlobalReg)] -> Bool -> FCode ()
+granFetchAndReschedule regs node_reqd = return ()
+
+granYield :: [LocalReg] -> Bool -> FCode ()
+granYield regs node_reqd = return ()
+
+granThunk :: Bool -> FCode ()
+granThunk node_points = return ()
+
+-----------------------------------------------------------------
+{- ------- 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 = []
+
+doGranAllocate :: CmmExpr -> Code
+-- macro DO_GRAN_ALLOCATE
+doGranAllocate hp
+ | not opt_GranMacros = nopC
+ | otherwise = panic "doGranAllocate"
+
+
+
+-------------------------
+granThunk :: Bool -> FCode ()
+-- HWL: insert macros for GrAnSim; 2 versions depending on liveness of node
+-- (we prefer fetchAndReschedule-style context switches to yield ones)
+granThunk node_points
+ | node_points = granFetchAndReschedule [] node_points
+ | otherwise = granYield [] node_points
+
+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 = 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 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 liveness = panic "granYield"
+ -- Was : absC (CMacroStmt GRAN_YIELD
+ -- [mkIntCLit (I# (word2Int# liveness_mask))])
+
+-}