Commit 6a4d60a5 authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Add the necessary REP_* constants to platformConstants

parent 20670cc6
......@@ -12,6 +12,9 @@ module CmmType
, wordWidth, halfWordWidth, cIntWidth, cLongWidth
, halfWordMask
, narrowU, narrowS
, rEP_CostCentreStack_mem_alloc
, rEP_CostCentreStack_scc_count
, rEP_StgEntCounter_allocs
)
where
......@@ -238,6 +241,26 @@ narrowS W32 x = fromIntegral (fromIntegral x :: Int32)
narrowS W64 x = fromIntegral (fromIntegral x :: Int64)
narrowS _ _ = panic "narrowTo"
-------------------------------------------------------------------------
-- These don't really belong here, but I don't know where is best to
-- put them.
rEP_CostCentreStack_mem_alloc :: DynFlags -> CmmType
rEP_CostCentreStack_mem_alloc dflags
= cmmBits (widthFromBytes (pc_REP_CostCentreStack_mem_alloc pc))
where pc = sPlatformConstants (settings dflags)
rEP_CostCentreStack_scc_count :: DynFlags -> CmmType
rEP_CostCentreStack_scc_count dflags
= cmmBits (widthFromBytes (pc_REP_CostCentreStack_scc_count pc))
where pc = sPlatformConstants (settings dflags)
rEP_StgEntCounter_allocs :: DynFlags -> CmmType
rEP_StgEntCounter_allocs dflags
= cmmBits (widthFromBytes (pc_REP_StgEntCounter_allocs pc))
where pc = sPlatformConstants (settings dflags)
-------------------------------------------------------------------------
{- Note [Signed vs unsigned]
~~~~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -23,8 +23,6 @@ module CgProf (
) where
#include "HsVersions.h"
#include "../includes/dist-derivedconstants/header/DerivedConstants.h"
-- For REP_xxx constants, which are MachReps
import ClosureInfo
import CgUtils
......@@ -110,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) $
......@@ -117,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
......@@ -215,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
......@@ -239,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
-----------------------------------------------------------------------------
......
......@@ -43,9 +43,6 @@ module CgTicky (
staticTickyHdr,
) where
#include "../includes/dist-derivedconstants/header/DerivedConstants.h"
-- For REP_xxx constants, which are MachReps
import ClosureInfo
import CgUtils
import CgMonad
......@@ -298,7 +295,7 @@ tickyAllocHeap hp
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)
addToMem (typeWidth (rEP_StgEntCounter_allocs dflags))
(CmmLit (cmmLabelOffB ticky_ctr
(oFFSET_StgEntCounter_allocs dflags))) hp,
-- Bump ALLOC_HEAP_ctr
......
......@@ -31,8 +31,6 @@ module StgCmmProf (
) where
#include "HsVersions.h"
#include "../includes/dist-derivedconstants/header/DerivedConstants.h"
-- For REP_xxx constants, which are MachReps
import StgCmmClosure
import StgCmmUtils
......@@ -169,6 +167,7 @@ profAlloc :: CmmExpr -> CmmExpr -> FCode ()
profAlloc words ccs
= ifProfiling $
do dflags <- getDynFlags
let alloc_rep = rEP_CostCentreStack_mem_alloc dflags
emit (addToMemE alloc_rep
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_mem_alloc dflags))
(CmmMachOp (MO_UU_Conv (wordWidth dflags) (typeWidth alloc_rep)) $
......@@ -176,8 +175,6 @@ profAlloc words ccs
mkIntExpr dflags (profHdrSize dflags)]]))
-- subtract the "profiling overhead", which is the
-- profiling header in a closure.
where
alloc_rep = REP_CostCentreStack_mem_alloc
-- -----------------------------------------------------------------------
-- Setting the current cost centre on entry to a closure
......@@ -277,7 +274,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
......@@ -302,7 +299,7 @@ pushCostCentre result ccs cc
bumpSccCount :: DynFlags -> CmmExpr -> CmmAGraph
bumpSccCount dflags ccs
= addToMem REP_CostCentreStack_scc_count
= addToMem (rEP_CostCentreStack_scc_count dflags)
(cmmOffsetB dflags ccs (oFFSET_CostCentreStack_scc_count dflags)) 1
-----------------------------------------------------------------------------
......
......@@ -46,8 +46,6 @@ module StgCmmTicky (
) where
#include "HsVersions.h"
#include "../includes/dist-derivedconstants/header/DerivedConstants.h"
-- For REP_xxx constants, which are MachReps
import StgCmmClosure
import StgCmmUtils
......@@ -321,7 +319,7 @@ tickyAllocHeap hp
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
addToMem (rEP_StgEntCounter_allocs dflags)
(CmmLit (cmmLabelOffB ticky_ctr
(oFFSET_StgEntCounter_allocs dflags))) hp,
-- Bump ALLOC_HEAP_ctr
......
......@@ -79,10 +79,18 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
and the names of the CmmTypes in the compiler
b32 :: CmmType
*/
#define field_type_(str, s_type, field) \
#define field_type_(want_haskell, str, s_type, field) \
switch (mode) { \
case Gen_Haskell_Type: \
if (want_haskell) { \
printf(" , pc_REP_" str " :: Int\n"); \
break; \
} \
case Gen_Haskell_Value: \
if (want_haskell) { \
printf(" , pc_REP_" str " = %" PRIdPTR "\n", (intptr_t)(FIELD_SIZE(s_type, field))); \
break; \
} \
case Gen_Haskell_Wrappers: \
case Gen_Haskell_Exports: \
break; \
......@@ -104,8 +112,8 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
break; \
}
#define field_type(s_type, field) \
field_type_(str(s_type,field),s_type,field);
#define field_type(want_haskell, s_type, field) \
field_type_(want_haskell,str(s_type,field),s_type,field);
#define field_offset_(str, s_type, field) \
def_offset(str, OFFSET(s_type,field));
......@@ -127,14 +135,20 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
}
/* Outputs the byte offset and MachRep for a field */
#define struct_field(s_type, field) \
field_offset(s_type, field); \
field_type(s_type, field); \
#define struct_field_helper(want_haskell, s_type, field) \
field_offset(s_type, field); \
field_type(want_haskell, s_type, field); \
struct_field_macro(str(s_type,field))
#define struct_field(s_type, field) \
struct_field_helper(0, s_type, field)
#define struct_field_h(s_type, field) \
struct_field_helper(1, s_type, field)
#define struct_field_(str, s_type, field) \
field_offset_(str, s_type, field); \
field_type_(str, s_type, field); \
field_type_(0,str, s_type, field); \
struct_field_macro(str)
#define def_size(str, size) \
......@@ -222,7 +236,7 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
/* Byte offset and MachRep for a closure field, minus the header */
#define closure_field_(str, s_type, field) \
closure_field_offset_(str,s_type,field) \
field_type_(str, s_type, field); \
field_type_(0, str, s_type, field); \
closure_field_macro(str)
#define closure_field(s_type, field) \
......@@ -270,9 +284,9 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
break; \
}
#define tso_field(s_type, field) \
field_type(s_type, field); \
tso_field_offset(s_type,field); \
#define tso_field(s_type, field) \
field_type(0, s_type, field); \
tso_field_offset(s_type,field); \
tso_field_macro(str(s_type,field))
#define opt_struct_size(s_type, option) \
......@@ -479,8 +493,8 @@ main(int argc, char *argv[])
struct_size(CostCentreStack);
struct_field(CostCentreStack, ccsID);
struct_field(CostCentreStack, mem_alloc);
struct_field(CostCentreStack, scc_count);
struct_field_h(CostCentreStack, mem_alloc);
struct_field_h(CostCentreStack, scc_count);
struct_field(CostCentreStack, prevStack);
struct_field(CostCentre, ccID);
......@@ -494,7 +508,7 @@ main(int argc, char *argv[])
closure_payload(StgClosure,payload);
struct_field(StgEntCounter, allocs);
struct_field_h(StgEntCounter, allocs);
struct_field(StgEntCounter, registeredp);
struct_field(StgEntCounter, link);
struct_field(StgEntCounter, entry_count);
......
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