summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgProf.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/codeGen/CgProf.hs')
-rw-r--r--compiler/codeGen/CgProf.hs45
1 files changed, 15 insertions, 30 deletions
diff --git a/compiler/codeGen/CgProf.hs b/compiler/codeGen/CgProf.hs
index 6d87ee7127..c124b5f68a 100644
--- a/compiler/codeGen/CgProf.hs
+++ b/compiler/codeGen/CgProf.hs
@@ -23,13 +23,6 @@ module CgProf (
) where
#include "HsVersions.h"
-#include "../includes/MachDeps.h"
- -- For WORD_SIZE_IN_BITS only.
-#include "../includes/rts/Constants.h"
- -- For LDV_CREATE_MASK, LDV_STATE_USE
- -- which are StgWords
-#include "../includes/dist-derivedconstants/header/DerivedConstants.h"
- -- For REP_xxx constants, which are MachReps
import ClosureInfo
import CgUtils
@@ -115,6 +108,7 @@ profAlloc :: CmmExpr -> CmmExpr -> Code
profAlloc words ccs
= ifProfiling $
do dflags <- getDynFlags
+ let alloc_rep = typeWidth (rEP_CostCentreStack_mem_alloc dflags)
stmtC (addToMemE alloc_rep
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_mem_alloc dflags))
(CmmMachOp (MO_UU_Conv (wordWidth dflags) alloc_rep) $
@@ -122,8 +116,6 @@ profAlloc words ccs
mkIntExpr dflags (profHdrSize dflags)]]))
-- subtract the "profiling overhead", which is the
-- profiling header in a closure.
- where
- alloc_rep = typeWidth REP_CostCentreStack_mem_alloc
-- -----------------------------------------------------------------------
-- Setting the current cost centre on entry to a closure
@@ -220,7 +212,7 @@ sizeof_ccs_words dflags
| ms == 0 = ws
| otherwise = ws + 1
where
- (ws,ms) = SIZEOF_CostCentreStack `divMod` wORD_SIZE dflags
+ (ws,ms) = sIZEOF_CostCentreStack dflags `divMod` wORD_SIZE dflags
-- ---------------------------------------------------------------------------
-- Set the current cost centre stack
@@ -244,7 +236,7 @@ pushCostCentre result ccs cc
bumpSccCount :: DynFlags -> CmmExpr -> CmmStmt
bumpSccCount dflags ccs
- = addToMem (typeWidth REP_CostCentreStack_scc_count)
+ = addToMem (typeWidth (rEP_CostCentreStack_scc_count dflags))
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_scc_count dflags)) 1
-----------------------------------------------------------------------------
@@ -265,8 +257,8 @@ staticLdvInit = zeroCLit
dynLdvInit :: DynFlags -> CmmExpr
dynLdvInit dflags = -- (era << LDV_SHIFT) | LDV_STATE_CREATE
CmmMachOp (mo_wordOr dflags) [
- CmmMachOp (mo_wordShl dflags) [loadEra dflags, mkIntExpr dflags lDV_SHIFT ],
- CmmLit (mkWordCLit dflags lDV_STATE_CREATE)
+ CmmMachOp (mo_wordShl dflags) [loadEra dflags, mkIntExpr dflags (lDV_SHIFT dflags)],
+ CmmLit (mkWordCLit dflags (lDV_STATE_CREATE dflags))
]
--
@@ -297,8 +289,8 @@ ldvEnter cl_ptr = do
-- don't forget to substract node's tag
ldv_wd = ldvWord dflags cl_ptr
new_ldv_wd = cmmOrWord dflags (cmmAndWord dflags (CmmLoad ldv_wd (bWord dflags))
- (CmmLit (mkWordCLit dflags lDV_CREATE_MASK)))
- (cmmOrWord dflags (loadEra dflags) (CmmLit (mkWordCLit dflags lDV_STATE_USE)))
+ (CmmLit (mkWordCLit dflags (lDV_CREATE_MASK dflags))))
+ (cmmOrWord dflags (loadEra dflags) (CmmLit (mkWordCLit dflags (lDV_STATE_USE dflags))))
ifProfiling $
-- if (era > 0) {
-- LDVW((c)) = (LDVW((c)) & LDV_CREATE_MASK) |
@@ -307,8 +299,8 @@ ldvEnter cl_ptr = do
(stmtC (CmmStore ldv_wd new_ldv_wd))
loadEra :: DynFlags -> CmmExpr
-loadEra dflags = CmmMachOp (MO_UU_Conv cIntWidth (wordWidth dflags))
- [CmmLoad (mkLblExpr (mkCmmDataLabel rtsPackageId $ fsLit("era"))) cInt]
+loadEra dflags = CmmMachOp (MO_UU_Conv (cIntWidth dflags) (wordWidth dflags))
+ [CmmLoad (mkLblExpr (mkCmmDataLabel rtsPackageId $ fsLit("era"))) (cInt dflags)]
ldvWord :: DynFlags -> CmmExpr -> CmmExpr
-- Takes the address of a closure, and returns
@@ -316,17 +308,10 @@ ldvWord :: DynFlags -> CmmExpr -> CmmExpr
ldvWord dflags closure_ptr
= cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
--- LDV constants, from ghc/includes/Constants.h
-lDV_SHIFT :: Int
-lDV_SHIFT = LDV_SHIFT
---lDV_STATE_MASK :: StgWord
---lDV_STATE_MASK = LDV_STATE_MASK
-lDV_CREATE_MASK :: StgWord
-lDV_CREATE_MASK = LDV_CREATE_MASK
---lDV_LAST_MASK :: StgWord
---lDV_LAST_MASK = LDV_LAST_MASK
-lDV_STATE_CREATE :: StgWord
-lDV_STATE_CREATE = LDV_STATE_CREATE
-lDV_STATE_USE :: StgWord
-lDV_STATE_USE = LDV_STATE_USE
+lDV_CREATE_MASK :: DynFlags -> StgWord
+lDV_CREATE_MASK dflags = toStgWord dflags (iLDV_CREATE_MASK dflags)
+lDV_STATE_CREATE :: DynFlags -> StgWord
+lDV_STATE_CREATE dflags = toStgWord dflags (iLDV_STATE_CREATE dflags)
+lDV_STATE_USE :: DynFlags -> StgWord
+lDV_STATE_USE dflags = toStgWord dflags (iLDV_STATE_USE dflags)