summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-19 22:24:25 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-19 22:24:25 +0100
commit6a4d60a5e2ddcfafb30cfdf93c7a589398af054d (patch)
tree80ba22f7c5e212836ecc6c5022f0ff0fbbbd5705
parent20670cc63395397cf2b9d80d9da27c77c1ebb8da (diff)
downloadhaskell-6a4d60a5e2ddcfafb30cfdf93c7a589398af054d.tar.gz
Add the necessary REP_* constants to platformConstants
-rw-r--r--compiler/cmm/CmmType.hs23
-rw-r--r--compiler/codeGen/CgProf.hs9
-rw-r--r--compiler/codeGen/CgTicky.hs5
-rw-r--r--compiler/codeGen/StgCmmProf.hs9
-rw-r--r--compiler/codeGen/StgCmmTicky.hs4
-rw-r--r--includes/mkDerivedConstants.c42
6 files changed, 59 insertions, 33 deletions
diff --git a/compiler/cmm/CmmType.hs b/compiler/cmm/CmmType.hs
index b6deb01bcd..d6da5a4022 100644
--- a/compiler/cmm/CmmType.hs
+++ b/compiler/cmm/CmmType.hs
@@ -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
@@ -239,6 +242,26 @@ 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]
~~~~~~~~~~~~~~~~~~~~~~~~~
Should a CmmType include a signed vs. unsigned distinction?
diff --git a/compiler/codeGen/CgProf.hs b/compiler/codeGen/CgProf.hs
index 5537e575d4..c124b5f68a 100644
--- a/compiler/codeGen/CgProf.hs
+++ b/compiler/codeGen/CgProf.hs
@@ -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
-----------------------------------------------------------------------------
diff --git a/compiler/codeGen/CgTicky.hs b/compiler/codeGen/CgTicky.hs
index 79215f6582..21837e787b 100644
--- a/compiler/codeGen/CgTicky.hs
+++ b/compiler/codeGen/CgTicky.hs
@@ -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
diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs
index ba65a556b2..b666554403 100644
--- a/compiler/codeGen/StgCmmProf.hs
+++ b/compiler/codeGen/StgCmmProf.hs
@@ -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
-----------------------------------------------------------------------------
diff --git a/compiler/codeGen/StgCmmTicky.hs b/compiler/codeGen/StgCmmTicky.hs
index d7517e8256..79ad3ff822 100644
--- a/compiler/codeGen/StgCmmTicky.hs
+++ b/compiler/codeGen/StgCmmTicky.hs
@@ -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
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index 62c5ae8f1f..c0bfb0cf22 100644
--- a/includes/mkDerivedConstants.c
+++ b/includes/mkDerivedConstants.c
@@ -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);