%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CgMonad.lhs,v 1.30 2001/09/26 15:11:50 simonpj Exp $
+% $Id: CgMonad.lhs,v 1.35 2002/09/13 15:02:28 simonpj Exp $
%
\section[CgMonad]{The code generation monad}
StackUsage, Slot(..), HeapUsage,
- profCtrC, profCtrAbsC,
+ profCtrC, profCtrAbsC, ldvEnter,
costCentresC, moduleName,
import Id ( Id )
import VarEnv
import PrimRep ( PrimRep(..) )
+import FastString
import Outputable
infixr 9 `thenC` -- Right-associative!
initC cg_info (FCode code)
= case (code (MkCgInfoDown
cg_info
- (error "initC: statics")
+ emptyVarEnv -- (error "initC: statics")
(error "initC: srt")
(mkTopTickyCtrLabel)
initEobInfo)
nothing.
\begin{code}
-costCentresC :: FAST_STRING -> [CAddrMode] -> Code
+costCentresC :: FastString -> [CAddrMode] -> Code
+costCentresC macro args
+ | opt_SccProfilingOn = absC (CCallProfCCMacro macro args)
+ | otherwise = nopC
-costCentresC macro args =
- if opt_SccProfilingOn then do
- (MkCgState absC binds usage) <- getState
- setState $ MkCgState (mkAbsCStmts absC (CCallProfCCMacro macro args)) binds usage
- else
- nopC
-
-profCtrC :: FAST_STRING -> [CAddrMode] -> Code
-
-profCtrC macro args =
- if not opt_DoTickyProfiling
- then nopC
- else do
- (MkCgState absC binds usage) <- getState
- setState $ MkCgState (mkAbsCStmts absC (CCallProfCtrMacro macro args)) binds usage
-
-profCtrAbsC :: FAST_STRING -> [CAddrMode] -> AbstractC
+profCtrC :: FastString -> [CAddrMode] -> Code
+profCtrC macro args
+ | opt_DoTickyProfiling = absC (CCallProfCtrMacro macro args)
+ | otherwise = nopC
+profCtrAbsC :: FastString -> [CAddrMode] -> AbstractC
profCtrAbsC macro args
- = if not opt_DoTickyProfiling
- then AbsCNop
- else CCallProfCtrMacro macro args
+ | opt_DoTickyProfiling = CCallProfCtrMacro macro args
+ | otherwise = AbsCNop
+
+ldvEnter :: Code
+ldvEnter = costCentresC FSLIT("LDV_ENTER") [CReg node]
{- Try to avoid adding too many special compilation strategies here.
It's better to modify the header files as necessary for particular
return eob_info
\end{code}
+There is just one SRT for each top level binding; all the nested
+bindings use sub-sections of this SRT. The label is passed down to
+the nested bindings via the monad.
+
\begin{code}
getSRTInfo :: SRT -> FCode C_SRT
getSRTInfo NoSRT = return NoC_SRT