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