Commit 568fdb14 authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Use oFFSET_* from platformConstants rather than Constants

parent 4279ab50
......@@ -275,15 +275,15 @@ emitOpenNursery =
]
nursery_bdescr_free, nursery_bdescr_start, nursery_bdescr_blocks :: DynFlags -> CmmExpr
nursery_bdescr_free dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_free
nursery_bdescr_start dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_start
nursery_bdescr_blocks dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_blocks
nursery_bdescr_free dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_free dflags)
nursery_bdescr_start dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_start dflags)
nursery_bdescr_blocks dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_blocks dflags)
tso_stackobj, tso_CCCS, stack_STACK, stack_SP :: DynFlags -> ByteOff
tso_stackobj dflags = closureField dflags oFFSET_StgTSO_stackobj
tso_CCCS dflags = closureField dflags oFFSET_StgTSO_cccs
stack_STACK dflags = closureField dflags oFFSET_StgStack_stack
stack_SP dflags = closureField dflags oFFSET_StgStack_sp
tso_stackobj dflags = closureField dflags (oFFSET_StgTSO_stackobj dflags)
tso_CCCS dflags = closureField dflags (oFFSET_StgTSO_cccs dflags)
stack_STACK dflags = closureField dflags (oFFSET_StgStack_stack dflags)
stack_SP dflags = closureField dflags (oFFSET_StgStack_sp dflags)
closureField :: DynFlags -> ByteOff -> ByteOff
closureField dflags off = off + fixedHdrSize dflags * wORD_SIZE
......
......@@ -286,7 +286,7 @@ emitPrimOp _ [] WriteArrayArrayOp_MutableArrayArray [obj,ix,v] _ = doWrit
emitPrimOp dflags [res] SizeofArrayOp [arg] _
= stmtC $ CmmAssign (CmmLocal res)
(cmmLoadIndexW dflags arg (fixedHdrSize dflags + oFFSET_StgMutArrPtrs_ptrs) (bWord dflags))
(cmmLoadIndexW dflags arg (fixedHdrSize dflags + oFFSET_StgMutArrPtrs_ptrs dflags) (bWord dflags))
emitPrimOp dflags [res] SizeofMutableArrayOp [arg] live
= emitPrimOp dflags [res] SizeofArrayOp [arg] live
emitPrimOp dflags [res] SizeofArrayArrayOp [arg] live
......@@ -851,7 +851,7 @@ doWritePtrArrayOp addr idx val
loadArrPtrsSize :: DynFlags -> CmmExpr -> CmmExpr
loadArrPtrsSize dflags addr = CmmLoad (cmmOffsetB dflags addr off) (bWord dflags)
where off = fixedHdrSize dflags * wORD_SIZE + oFFSET_StgMutArrPtrs_ptrs
where off = fixedHdrSize dflags * wORD_SIZE + oFFSET_StgMutArrPtrs_ptrs dflags
mkBasicIndexedRead :: ByteOff -> Maybe MachOp -> CmmType
-> LocalReg -> CmmExpr -> CmmExpr -> Code
......@@ -1027,7 +1027,7 @@ emitCloneArray info_p res_r src0 src_off0 n0 live = do
let arrPtrsHdrSizeW dflags = CmmLit $ mkIntCLit dflags $ fixedHdrSize dflags +
(sIZEOF_StgMutArrPtrs_NoHdr dflags `div` wORD_SIZE)
myCapability = cmmSubWord dflags (CmmReg baseReg)
(CmmLit (mkIntCLit dflags oFFSET_Capability_r))
(CmmLit (mkIntCLit dflags (oFFSET_Capability_r dflags)))
-- Assign the arguments to temporaries so the code generator can
-- calculate liveness for us.
src <- assignTemp_ src0
......@@ -1046,9 +1046,9 @@ emitCloneArray info_p res_r src0 src_off0 n0 live = do
let arr = CmmReg (CmmLocal arr_r)
emitSetDynHdr arr (CmmLit (CmmLabel info_p)) curCCS
stmtC $ CmmStore (cmmOffsetB dflags arr (fixedHdrSize dflags * wORD_SIZE +
oFFSET_StgMutArrPtrs_ptrs)) n
oFFSET_StgMutArrPtrs_ptrs dflags)) n
stmtC $ CmmStore (cmmOffsetB dflags arr (fixedHdrSize dflags * wORD_SIZE +
oFFSET_StgMutArrPtrs_size)) size
oFFSET_StgMutArrPtrs_size dflags)) size
dst_p <- assignTemp $ cmmOffsetB dflags arr (arrPtrsHdrSize dflags)
src_p <- assignTemp $ cmmOffsetExprW dflags (cmmOffsetB dflags src (arrPtrsHdrSize dflags))
......
......@@ -74,7 +74,7 @@ costCentreFrom :: DynFlags
-> CmmExpr -- A closure pointer
-> CmmExpr -- The cost centre from that closure
costCentreFrom dflags cl
= CmmLoad (cmmOffsetB dflags cl oFFSET_StgHeader_ccs) (bWord dflags)
= CmmLoad (cmmOffsetB dflags cl (oFFSET_StgHeader_ccs dflags)) (bWord dflags)
staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit]
-- The profiling header words in a static closure
......@@ -91,7 +91,7 @@ initUpdFrameProf :: CmmExpr -> Code
initUpdFrameProf frame_amode
= ifProfiling $ -- frame->header.prof.ccs = CCCS
do dflags <- getDynFlags
stmtC (CmmStore (cmmOffsetB dflags frame_amode oFFSET_StgHeader_ccs) curCCS)
stmtC (CmmStore (cmmOffsetB dflags frame_amode (oFFSET_StgHeader_ccs dflags)) curCCS)
-- frame->header.prof.hp.rs = NULL (or frame-header.prof.hp.ldvw = 0)
-- is unnecessary because it is not used anyhow.
......@@ -117,7 +117,7 @@ profAlloc words ccs
= ifProfiling $
do dflags <- getDynFlags
stmtC (addToMemE alloc_rep
(cmmOffsetB dflags ccs oFFSET_CostCentreStack_mem_alloc)
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_mem_alloc dflags))
(CmmMachOp (MO_UU_Conv (wordWidth dflags) alloc_rep) $
[CmmMachOp (mo_wordSub dflags) [words,
mkIntExpr dflags (profHdrSize dflags)]]))
......@@ -244,7 +244,7 @@ pushCostCentre result ccs cc
bumpSccCount :: DynFlags -> CmmExpr -> CmmStmt
bumpSccCount dflags ccs
= addToMem (typeWidth REP_CostCentreStack_scc_count)
(cmmOffsetB dflags ccs oFFSET_CostCentreStack_scc_count) 1
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_scc_count dflags)) 1
-----------------------------------------------------------------------------
--
......@@ -312,7 +312,8 @@ loadEra dflags = CmmMachOp (MO_UU_Conv cIntWidth (wordWidth dflags))
ldvWord :: DynFlags -> CmmExpr -> CmmExpr
-- Takes the address of a closure, and returns
-- the address of the LDV word in the closure
ldvWord dflags closure_ptr = cmmOffsetB dflags closure_ptr oFFSET_StgHeader_ldvw
ldvWord dflags closure_ptr
= cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
-- LDV constants, from ghc/includes/Constants.h
lDV_SHIFT :: Int
......
......@@ -322,7 +322,7 @@ emitSpecPushUpdateFrame lbl frame_addr updatee = do
off_updatee :: DynFlags -> ByteOff
off_updatee dflags
= fixedHdrSize dflags * wORD_SIZE + oFFSET_StgUpdateFrame_updatee
= fixedHdrSize dflags * wORD_SIZE + (oFFSET_StgUpdateFrame_updatee dflags)
\end{code}
......
......@@ -59,7 +59,6 @@ import Id
import IdInfo
import BasicTypes
import FastString
import Constants
import Outputable
import Module
......@@ -161,10 +160,11 @@ tickyUpdateBhCaf cl_info
tickyEnterFun :: ClosureInfo -> Code
tickyEnterFun cl_info
= ifTicky $
do { bumpTickyCounter ctr
do { dflags <- getDynFlags
; bumpTickyCounter ctr
; fun_ctr_lbl <- getTickyCtrLabel
; registerTickyCtr fun_ctr_lbl
; bumpTickyCounter' (cmmLabelOffB fun_ctr_lbl oFFSET_StgEntCounter_entry_count)
; bumpTickyCounter' (cmmLabelOffB fun_ctr_lbl (oFFSET_StgEntCounter_entry_count dflags))
}
where
ctr | isStaticClosure cl_info = fsLit "ENT_STATIC_FUN_DIRECT_ctr"
......@@ -181,14 +181,14 @@ registerTickyCtr ctr_lbl
let -- krc: code generator doesn't handle Not, so we test for Eq 0 instead
test = CmmMachOp (MO_Eq (wordWidth dflags))
[CmmLoad (CmmLit (cmmLabelOffB ctr_lbl
oFFSET_StgEntCounter_registeredp)) (bWord dflags),
(oFFSET_StgEntCounter_registeredp dflags))) (bWord dflags),
CmmLit (mkIntCLit dflags 0)]
register_stmts
= [ CmmStore (CmmLit (cmmLabelOffB ctr_lbl oFFSET_StgEntCounter_link))
= [ CmmStore (CmmLit (cmmLabelOffB ctr_lbl (oFFSET_StgEntCounter_link dflags)))
(CmmLoad ticky_entry_ctrs (bWord dflags))
, CmmStore ticky_entry_ctrs (mkLblExpr ctr_lbl)
, CmmStore (CmmLit (cmmLabelOffB ctr_lbl
oFFSET_StgEntCounter_registeredp))
(oFFSET_StgEntCounter_registeredp dflags)))
(CmmLit (mkIntCLit dflags 1)) ]
ticky_entry_ctrs = mkLblExpr (mkCmmDataLabel rtsPackageId (fsLit "ticky_entry_ctrs"))
emitIf test (stmtsC register_stmts)
......@@ -292,14 +292,15 @@ tickyAllocHeap :: VirtualHpOffset -> Code
-- Called when doing a heap check [TICK_ALLOC_HEAP]
tickyAllocHeap hp
= ifTicky $
do { ticky_ctr <- getTickyCtrLabel
do { dflags <- getDynFlags
; ticky_ctr <- getTickyCtrLabel
; stmtsC $
if hp == 0 then [] -- Inside the stmtC to avoid control
else [ -- dependency on the argument
-- Bump the allcoation count in the StgEntCounter
addToMem (typeWidth REP_StgEntCounter_allocs)
(CmmLit (cmmLabelOffB ticky_ctr
oFFSET_StgEntCounter_allocs)) hp,
(oFFSET_StgEntCounter_allocs dflags))) hp,
-- Bump ALLOC_HEAP_ctr
addToMemLbl cLongWidth (mkCmmDataLabel rtsPackageId $ fsLit "ALLOC_HEAP_ctr") 1,
-- Bump ALLOC_HEAP_tot
......
......@@ -323,42 +323,42 @@ callerSaveVolatileRegs dflags vols = (caller_save, caller_load)
-- -----------------------------------------------------------------------------
-- Information about global registers
baseRegOffset :: GlobalReg -> Int
baseRegOffset (VanillaReg 1 _) = oFFSET_StgRegTable_rR1
baseRegOffset (VanillaReg 2 _) = oFFSET_StgRegTable_rR2
baseRegOffset (VanillaReg 3 _) = oFFSET_StgRegTable_rR3
baseRegOffset (VanillaReg 4 _) = oFFSET_StgRegTable_rR4
baseRegOffset (VanillaReg 5 _) = oFFSET_StgRegTable_rR5
baseRegOffset (VanillaReg 6 _) = oFFSET_StgRegTable_rR6
baseRegOffset (VanillaReg 7 _) = oFFSET_StgRegTable_rR7
baseRegOffset (VanillaReg 8 _) = oFFSET_StgRegTable_rR8
baseRegOffset (VanillaReg 9 _) = oFFSET_StgRegTable_rR9
baseRegOffset (VanillaReg 10 _) = oFFSET_StgRegTable_rR10
baseRegOffset (VanillaReg n _) = panic ("Registers above R10 are not supported (tried to use R" ++ show n ++ ")")
baseRegOffset (FloatReg 1) = oFFSET_StgRegTable_rF1
baseRegOffset (FloatReg 2) = oFFSET_StgRegTable_rF2
baseRegOffset (FloatReg 3) = oFFSET_StgRegTable_rF3
baseRegOffset (FloatReg 4) = oFFSET_StgRegTable_rF4
baseRegOffset (FloatReg n) = panic ("Registers above F4 are not supported (tried to use F" ++ show n ++ ")")
baseRegOffset (DoubleReg 1) = oFFSET_StgRegTable_rD1
baseRegOffset (DoubleReg 2) = oFFSET_StgRegTable_rD2
baseRegOffset (DoubleReg n) = panic ("Registers above D2 are not supported (tried to use D" ++ show n ++ ")")
baseRegOffset Sp = oFFSET_StgRegTable_rSp
baseRegOffset SpLim = oFFSET_StgRegTable_rSpLim
baseRegOffset (LongReg 1) = oFFSET_StgRegTable_rL1
baseRegOffset (LongReg n) = panic ("Registers above L1 are not supported (tried to use L" ++ show n ++ ")")
baseRegOffset Hp = oFFSET_StgRegTable_rHp
baseRegOffset HpLim = oFFSET_StgRegTable_rHpLim
baseRegOffset CCCS = oFFSET_StgRegTable_rCCCS
baseRegOffset CurrentTSO = oFFSET_StgRegTable_rCurrentTSO
baseRegOffset CurrentNursery = oFFSET_StgRegTable_rCurrentNursery
baseRegOffset HpAlloc = oFFSET_StgRegTable_rHpAlloc
baseRegOffset EagerBlackholeInfo = oFFSET_stgEagerBlackholeInfo
baseRegOffset GCEnter1 = oFFSET_stgGCEnter1
baseRegOffset GCFun = oFFSET_stgGCFun
baseRegOffset BaseReg = panic "baseRegOffset:BaseReg"
baseRegOffset PicBaseReg = panic "baseRegOffset:PicBaseReg"
baseRegOffset :: DynFlags -> GlobalReg -> Int
baseRegOffset dflags (VanillaReg 1 _) = oFFSET_StgRegTable_rR1 dflags
baseRegOffset dflags (VanillaReg 2 _) = oFFSET_StgRegTable_rR2 dflags
baseRegOffset dflags (VanillaReg 3 _) = oFFSET_StgRegTable_rR3 dflags
baseRegOffset dflags (VanillaReg 4 _) = oFFSET_StgRegTable_rR4 dflags
baseRegOffset dflags (VanillaReg 5 _) = oFFSET_StgRegTable_rR5 dflags
baseRegOffset dflags (VanillaReg 6 _) = oFFSET_StgRegTable_rR6 dflags
baseRegOffset dflags (VanillaReg 7 _) = oFFSET_StgRegTable_rR7 dflags
baseRegOffset dflags (VanillaReg 8 _) = oFFSET_StgRegTable_rR8 dflags
baseRegOffset dflags (VanillaReg 9 _) = oFFSET_StgRegTable_rR9 dflags
baseRegOffset dflags (VanillaReg 10 _) = oFFSET_StgRegTable_rR10 dflags
baseRegOffset _ (VanillaReg n _) = panic ("Registers above R10 are not supported (tried to use R" ++ show n ++ ")")
baseRegOffset dflags (FloatReg 1) = oFFSET_StgRegTable_rF1 dflags
baseRegOffset dflags (FloatReg 2) = oFFSET_StgRegTable_rF2 dflags
baseRegOffset dflags (FloatReg 3) = oFFSET_StgRegTable_rF3 dflags
baseRegOffset dflags (FloatReg 4) = oFFSET_StgRegTable_rF4 dflags
baseRegOffset _ (FloatReg n) = panic ("Registers above F4 are not supported (tried to use F" ++ show n ++ ")")
baseRegOffset dflags (DoubleReg 1) = oFFSET_StgRegTable_rD1 dflags
baseRegOffset dflags (DoubleReg 2) = oFFSET_StgRegTable_rD2 dflags
baseRegOffset _ (DoubleReg n) = panic ("Registers above D2 are not supported (tried to use D" ++ show n ++ ")")
baseRegOffset dflags Sp = oFFSET_StgRegTable_rSp dflags
baseRegOffset dflags SpLim = oFFSET_StgRegTable_rSpLim dflags
baseRegOffset dflags (LongReg 1) = oFFSET_StgRegTable_rL1 dflags
baseRegOffset _ (LongReg n) = panic ("Registers above L1 are not supported (tried to use L" ++ show n ++ ")")
baseRegOffset dflags Hp = oFFSET_StgRegTable_rHp dflags
baseRegOffset dflags HpLim = oFFSET_StgRegTable_rHpLim dflags
baseRegOffset dflags CCCS = oFFSET_StgRegTable_rCCCS dflags
baseRegOffset dflags CurrentTSO = oFFSET_StgRegTable_rCurrentTSO dflags
baseRegOffset dflags CurrentNursery = oFFSET_StgRegTable_rCurrentNursery dflags
baseRegOffset dflags HpAlloc = oFFSET_StgRegTable_rHpAlloc dflags
baseRegOffset dflags EagerBlackholeInfo = oFFSET_stgEagerBlackholeInfo dflags
baseRegOffset dflags GCEnter1 = oFFSET_stgGCEnter1 dflags
baseRegOffset dflags GCFun = oFFSET_stgGCFun dflags
baseRegOffset _ BaseReg = panic "baseRegOffset:BaseReg"
baseRegOffset _ PicBaseReg = panic "baseRegOffset:PicBaseReg"
-------------------------------------------------------------------------
......@@ -823,22 +823,22 @@ srt_escape = -1
-- a GlobalReg, get_GlobalReg_addr always produces the
-- register table address for it.
get_GlobalReg_addr :: DynFlags -> GlobalReg -> CmmExpr
get_GlobalReg_addr _ BaseReg = regTableOffset 0
get_GlobalReg_addr dflags BaseReg = regTableOffset dflags 0
get_GlobalReg_addr dflags mid
= get_Regtable_addr_from_offset dflags
(globalRegType dflags mid) (baseRegOffset mid)
(globalRegType dflags mid) (baseRegOffset dflags mid)
-- Calculate a literal representing an offset into the register table.
-- Used when we don't have an actual BaseReg to offset from.
regTableOffset :: Int -> CmmExpr
regTableOffset n =
CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r + n))
regTableOffset :: DynFlags -> Int -> CmmExpr
regTableOffset dflags n =
CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r dflags + n))
get_Regtable_addr_from_offset :: DynFlags -> CmmType -> Int -> CmmExpr
get_Regtable_addr_from_offset dflags _ offset =
if haveRegBase (targetPlatform dflags)
then CmmRegOff (CmmGlobal BaseReg) offset
else regTableOffset offset
else regTableOffset dflags offset
-- | Fixup global registers so that they assign to locations within the
-- RegTable if they aren't pinned for the current target.
......
......@@ -636,7 +636,7 @@ pushUpdateFrame lbl updatee body
let
hdr = fixedHdrSize dflags * wORD_SIZE
frame = updfr + hdr + sIZEOF_StgUpdateFrame_NoHdr dflags
off_updatee = hdr + oFFSET_StgUpdateFrame_updatee
off_updatee = hdr + oFFSET_StgUpdateFrame_updatee dflags
--
emitStore (CmmStackSlot Old frame) (mkLblExpr lbl)
emitStore (CmmStackSlot Old (frame - off_updatee)) updatee
......
......@@ -351,15 +351,15 @@ emitOpenNursery = do dflags <- getDynFlags
emit $ openNursery dflags
nursery_bdescr_free, nursery_bdescr_start, nursery_bdescr_blocks :: DynFlags -> CmmExpr
nursery_bdescr_free dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_free
nursery_bdescr_start dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_start
nursery_bdescr_blocks dflags = cmmOffset dflags stgCurrentNursery oFFSET_bdescr_blocks
nursery_bdescr_free dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_free dflags)
nursery_bdescr_start dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_start dflags)
nursery_bdescr_blocks dflags = cmmOffset dflags stgCurrentNursery (oFFSET_bdescr_blocks dflags)
tso_stackobj, tso_CCCS, stack_STACK, stack_SP :: DynFlags -> ByteOff
tso_stackobj dflags = closureField dflags oFFSET_StgTSO_stackobj
tso_CCCS dflags = closureField dflags oFFSET_StgTSO_cccs
stack_STACK dflags = closureField dflags oFFSET_StgStack_stack
stack_SP dflags = closureField dflags oFFSET_StgStack_sp
tso_stackobj dflags = closureField dflags (oFFSET_StgTSO_stackobj dflags)
tso_CCCS dflags = closureField dflags (oFFSET_StgTSO_cccs dflags)
stack_STACK dflags = closureField dflags (oFFSET_StgStack_stack dflags)
stack_SP dflags = closureField dflags (oFFSET_StgStack_sp dflags)
closureField :: DynFlags -> ByteOff -> ByteOff
......
......@@ -362,7 +362,7 @@ emitPrimOp _ [] WriteArrayArrayOp_ArrayArray [obj,ix,v] = doWritePt
emitPrimOp _ [] WriteArrayArrayOp_MutableArrayArray [obj,ix,v] = doWritePtrArrayOp obj ix v
emitPrimOp dflags [res] SizeofArrayOp [arg]
= emit $ mkAssign (CmmLocal res) (cmmLoadIndexW dflags arg (fixedHdrSize dflags + oFFSET_StgMutArrPtrs_ptrs) (bWord dflags))
= emit $ mkAssign (CmmLocal res) (cmmLoadIndexW dflags arg (fixedHdrSize dflags + oFFSET_StgMutArrPtrs_ptrs dflags) (bWord dflags))
emitPrimOp dflags [res] SizeofMutableArrayOp [arg]
= emitPrimOp dflags [res] SizeofArrayOp [arg]
emitPrimOp dflags [res] SizeofArrayArrayOp [arg]
......@@ -919,7 +919,7 @@ doWritePtrArrayOp addr idx val
loadArrPtrsSize :: DynFlags -> CmmExpr -> CmmExpr
loadArrPtrsSize dflags addr = CmmLoad (cmmOffsetB dflags addr off) (bWord dflags)
where off = fixedHdrSize dflags * wORD_SIZE + oFFSET_StgMutArrPtrs_ptrs
where off = fixedHdrSize dflags * wORD_SIZE + oFFSET_StgMutArrPtrs_ptrs dflags
mkBasicIndexedRead :: ByteOff -> Maybe MachOp -> CmmType
-> LocalReg -> CmmExpr -> CmmExpr -> FCode ()
......@@ -1102,7 +1102,7 @@ emitCloneArray info_p res_r src0 src_off0 n0 = do
dflags <- getDynFlags
let arrPtrsHdrSizeW dflags = mkIntExpr dflags (fixedHdrSize dflags +
(sIZEOF_StgMutArrPtrs_NoHdr dflags `div` wORD_SIZE))
myCapability = cmmSubWord dflags (CmmReg baseReg) (mkIntExpr dflags oFFSET_Capability_r)
myCapability = cmmSubWord dflags (CmmReg baseReg) (mkIntExpr dflags (oFFSET_Capability_r dflags))
-- Passed as arguments (be careful)
src <- assignTempE src0
src_off <- assignTempE src_off0
......@@ -1120,9 +1120,9 @@ emitCloneArray info_p res_r src0 src_off0 n0 = do
let arr = CmmReg (CmmLocal arr_r)
emitSetDynHdr arr (CmmLit (CmmLabel info_p)) curCCS
emit $ mkStore (cmmOffsetB dflags arr (fixedHdrSize dflags * wORD_SIZE +
oFFSET_StgMutArrPtrs_ptrs)) n
oFFSET_StgMutArrPtrs_ptrs dflags)) n
emit $ mkStore (cmmOffsetB dflags arr (fixedHdrSize dflags * wORD_SIZE +
oFFSET_StgMutArrPtrs_size)) size
oFFSET_StgMutArrPtrs_size dflags)) size
dst_p <- assignTempE $ cmmOffsetB dflags arr (arrPtrsHdrSize dflags)
src_p <- assignTempE $ cmmOffsetExprW dflags (cmmOffsetB dflags src (arrPtrsHdrSize dflags))
......
......@@ -88,7 +88,7 @@ mkCCostCentreStack ccs = CmmLabel (mkCCSLabel ccs)
costCentreFrom :: DynFlags
-> CmmExpr -- A closure pointer
-> CmmExpr -- The cost centre from that closure
costCentreFrom dflags cl = CmmLoad (cmmOffsetB dflags cl oFFSET_StgHeader_ccs) (ccsType dflags)
costCentreFrom dflags cl = CmmLoad (cmmOffsetB dflags cl (oFFSET_StgHeader_ccs dflags)) (ccsType dflags)
staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit]
-- The profiling header words in a static closure
......@@ -104,7 +104,9 @@ initUpdFrameProf :: ByteOff -> FCode ()
-- Initialise the profiling field of an update frame
initUpdFrameProf frame_off
= ifProfiling $ -- frame->header.prof.ccs = CCCS
emitStore (CmmStackSlot Old (frame_off - oFFSET_StgHeader_ccs)) curCCS
do dflags <- getDynFlags
emitStore (CmmStackSlot Old (frame_off - oFFSET_StgHeader_ccs dflags))
curCCS
-- frame->header.prof.hp.rs = NULL (or frame-header.prof.hp.ldvw = 0)
-- is unnecessary because it is not used anyhow.
......@@ -174,7 +176,7 @@ profAlloc words ccs
= ifProfiling $
do dflags <- getDynFlags
emit (addToMemE alloc_rep
(cmmOffsetB dflags ccs oFFSET_CostCentreStack_mem_alloc)
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_mem_alloc dflags))
(CmmMachOp (MO_UU_Conv (wordWidth dflags) (typeWidth alloc_rep)) $
[CmmMachOp (mo_wordSub dflags) [words,
mkIntExpr dflags (profHdrSize dflags)]]))
......@@ -307,7 +309,7 @@ pushCostCentre result ccs cc
bumpSccCount :: DynFlags -> CmmExpr -> CmmAGraph
bumpSccCount dflags ccs
= addToMem REP_CostCentreStack_scc_count
(cmmOffsetB dflags ccs oFFSET_CostCentreStack_scc_count) 1
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_scc_count dflags)) 1
-----------------------------------------------------------------------------
--
......@@ -374,7 +376,8 @@ loadEra dflags = CmmMachOp (MO_UU_Conv cIntWidth (wordWidth dflags))
ldvWord :: DynFlags -> CmmExpr -> CmmExpr
-- Takes the address of a closure, and returns
-- the address of the LDV word in the closure
ldvWord dflags closure_ptr = cmmOffsetB dflags closure_ptr oFFSET_StgHeader_ldvw
ldvWord dflags closure_ptr
= cmmOffsetB dflags closure_ptr (oFFSET_StgHeader_ldvw dflags)
-- LDV constants, from ghc/includes/Constants.h
lDV_SHIFT :: Int
......
......@@ -65,7 +65,6 @@ import Name
import Id
import BasicTypes
import FastString
import Constants
import Outputable
import DynFlags
......@@ -164,10 +163,11 @@ tickyUpdateBhCaf cl_info
tickyEnterFun :: ClosureInfo -> FCode ()
tickyEnterFun cl_info
= ifTicky $
do { bumpTickyCounter ctr
do { dflags <- getDynFlags
; bumpTickyCounter ctr
; fun_ctr_lbl <- getTickyCtrLabel
; registerTickyCtr fun_ctr_lbl
; bumpTickyCounter' (cmmLabelOffB fun_ctr_lbl oFFSET_StgEntCounter_entry_count)
; bumpTickyCounter' (cmmLabelOffB fun_ctr_lbl (oFFSET_StgEntCounter_entry_count dflags))
}
where
ctr | isStaticClosure cl_info = (fsLit "ENT_STATIC_FUN_DIRECT_ctr")
......@@ -185,14 +185,14 @@ registerTickyCtr ctr_lbl = do
-- krc: code generator doesn't handle Not, so we test for Eq 0 instead
test = CmmMachOp (MO_Eq (wordWidth dflags))
[CmmLoad (CmmLit (cmmLabelOffB ctr_lbl
oFFSET_StgEntCounter_registeredp)) (bWord dflags),
(oFFSET_StgEntCounter_registeredp dflags))) (bWord dflags),
zeroExpr dflags]
register_stmts
= [ mkStore (CmmLit (cmmLabelOffB ctr_lbl oFFSET_StgEntCounter_link))
= [ mkStore (CmmLit (cmmLabelOffB ctr_lbl (oFFSET_StgEntCounter_link dflags)))
(CmmLoad ticky_entry_ctrs (bWord dflags))
, mkStore ticky_entry_ctrs (mkLblExpr ctr_lbl)
, mkStore (CmmLit (cmmLabelOffB ctr_lbl
oFFSET_StgEntCounter_registeredp))
(oFFSET_StgEntCounter_registeredp dflags)))
(mkIntExpr dflags 1) ]
ticky_entry_ctrs = mkLblExpr (mkCmmDataLabel rtsPackageId (fsLit "ticky_entry_ctrs"))
emit =<< mkCmmIfThen test (catAGraphs register_stmts)
......@@ -315,14 +315,15 @@ tickyAllocHeap :: VirtualHpOffset -> FCode ()
-- Must be lazy in the amount of allocation!
tickyAllocHeap hp
= ifTicky $
do { ticky_ctr <- getTickyCtrLabel
do { dflags <- getDynFlags
; ticky_ctr <- getTickyCtrLabel
; emit $ catAGraphs $
if hp == 0 then [] -- Inside the emitMiddle to avoid control
else [ -- dependency on the argument
-- Bump the allcoation count in the StgEntCounter
addToMem REP_StgEntCounter_allocs
(CmmLit (cmmLabelOffB ticky_ctr
oFFSET_StgEntCounter_allocs)) hp,
(oFFSET_StgEntCounter_allocs dflags))) hp,
-- Bump ALLOC_HEAP_ctr
addToMemLbl cLong (mkCmmDataLabel rtsPackageId (fsLit "ALLOC_HEAP_ctr")) 1,
-- Bump ALLOC_HEAP_tot
......
......@@ -68,7 +68,6 @@ import Unique
import DynFlags
import FastString
import Outputable
import Platform
import Data.Char
import Data.List
......@@ -269,41 +268,41 @@ callerSaveVolatileRegs dflags = (caller_save, caller_load)
-- (See also get_GlobalReg_reg_or_addr in MachRegs)
get_GlobalReg_addr :: DynFlags -> GlobalReg -> CmmExpr
get_GlobalReg_addr _ BaseReg = regTableOffset 0
get_GlobalReg_addr dflags BaseReg = regTableOffset dflags 0
get_GlobalReg_addr dflags mid
= get_Regtable_addr_from_offset (targetPlatform dflags)
(globalRegType dflags mid) (baseRegOffset mid)
= get_Regtable_addr_from_offset dflags
(globalRegType dflags mid) (baseRegOffset dflags mid)
-- Calculate a literal representing an offset into the register table.
-- Used when we don't have an actual BaseReg to offset from.
regTableOffset :: Int -> CmmExpr
regTableOffset n =
CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r + n))
regTableOffset :: DynFlags -> Int -> CmmExpr
regTableOffset dflags n =
CmmLit (CmmLabelOff mkMainCapabilityLabel (oFFSET_Capability_r dflags + n))
get_Regtable_addr_from_offset :: Platform -> CmmType -> Int -> CmmExpr
get_Regtable_addr_from_offset platform _rep offset =
if haveRegBase platform
get_Regtable_addr_from_offset :: DynFlags -> CmmType -> Int -> CmmExpr
get_Regtable_addr_from_offset dflags _rep offset =
if haveRegBase (targetPlatform dflags)
then CmmRegOff (CmmGlobal BaseReg) offset
else regTableOffset offset
else regTableOffset dflags offset
-- -----------------------------------------------------------------------------
-- Information about global registers
baseRegOffset :: GlobalReg -> Int
baseRegOffset Sp = oFFSET_StgRegTable_rSp
baseRegOffset SpLim = oFFSET_StgRegTable_rSpLim
baseRegOffset (LongReg 1) = oFFSET_StgRegTable_rL1
baseRegOffset Hp = oFFSET_StgRegTable_rHp
baseRegOffset HpLim = oFFSET_StgRegTable_rHpLim
baseRegOffset CCCS = oFFSET_StgRegTable_rCCCS
baseRegOffset CurrentTSO = oFFSET_StgRegTable_rCurrentTSO
baseRegOffset CurrentNursery = oFFSET_StgRegTable_rCurrentNursery
baseRegOffset HpAlloc = oFFSET_StgRegTable_rHpAlloc
baseRegOffset GCEnter1 = oFFSET_stgGCEnter1
baseRegOffset GCFun = oFFSET_stgGCFun
baseRegOffset reg = pprPanic "baseRegOffset:" (ppr reg)
baseRegOffset :: DynFlags -> GlobalReg -> Int
baseRegOffset dflags Sp = oFFSET_StgRegTable_rSp dflags
baseRegOffset dflags SpLim = oFFSET_StgRegTable_rSpLim dflags
baseRegOffset dflags (LongReg 1) = oFFSET_StgRegTable_rL1 dflags
baseRegOffset dflags Hp = oFFSET_StgRegTable_rHp dflags
baseRegOffset dflags HpLim = oFFSET_StgRegTable_rHpLim dflags
baseRegOffset dflags CCCS = oFFSET_StgRegTable_rCCCS dflags
baseRegOffset dflags CurrentTSO = oFFSET_StgRegTable_rCurrentTSO dflags
baseRegOffset dflags CurrentNursery = oFFSET_StgRegTable_rCurrentNursery dflags
baseRegOffset dflags HpAlloc = oFFSET_StgRegTable_rHpAlloc dflags
baseRegOffset dflags GCEnter1 = oFFSET_stgGCEnter1 dflags
baseRegOffset dflags GCFun = oFFSET_stgGCFun dflags
baseRegOffset _ reg = pprPanic "baseRegOffset:" (ppr reg)
-------------------------------------------------------------------------
--
......
......@@ -42,8 +42,6 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappe
#define def_offset(str, offset) \
switch (mode) { \
case Gen_Haskell: \
printf("oFFSET_" str " :: Int\n"); \
printf("oFFSET_" str " = %" FMT_SizeT "\n", (size_t)offset); \
break; \
case Gen_Haskell_Type: \
printf(" , pc_OFFSET_" str " :: Int\n"); \
......@@ -52,11 +50,11 @@ enum Mode { Gen_Haskell, Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappe
printf(" , pc_OFFSET_" str " = %" FMT_SizeT "\n", (size_t)offset); \
break; \
case Gen_Haskell_Wrappers: \
printf("-- oFFSET_" str " :: DynFlags -> Int\n"); \
printf("-- oFFSET_" str " dflags = pc_OFFSET_" str " (sPlatformConstants (settings dflags))\n"); \
printf("oFFSET_" str " :: DynFlags -> Int\n"); \
printf("oFFSET_" str " dflags = pc_OFFSET_" str " (sPlatformConstants (settings dflags))\n"); \
break; \
case Gen_Haskell_Exports: \
printf("-- oFFSET_" str ",\n"); \
printf(" oFFSET_" str ",\n"); \
break; \
case Gen_Header: \
printf("#define OFFSET_" str " %" FMT_SizeT "\n", (size_t)offset); \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment