Commit 1cae73aa authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by David Feuer
Browse files

Move dataConTagZ to DataCon

Just a simple refactoring to remove duplication
parent 9ac22183
......@@ -28,8 +28,9 @@ module DataCon (
-- ** Type deconstruction
dataConRepType, dataConSig, dataConInstSig, dataConFullSig,
dataConName, dataConIdentity, dataConTag, dataConTyCon,
dataConOrigTyCon, dataConUserType,
dataConName, dataConIdentity, dataConTag, dataConTagZ,
dataConTyCon, dataConOrigTyCon,
dataConUserType,
dataConUnivTyVars, dataConUnivTyVarBinders,
dataConExTyVars, dataConExTyVarBinders,
dataConAllTyVars,
......@@ -861,6 +862,9 @@ dataConName = dcName
dataConTag :: DataCon -> ConTag
dataConTag = dcTag
dataConTagZ :: DataCon -> ConTagZ
dataConTagZ con = dataConTag con - fIRST_TAG
-- | The type constructor that we are building via this data constructor
dataConTyCon :: DataCon -> TyCon
dataConTyCon = dcRepTyCon
......
......@@ -50,6 +50,7 @@ module SMRep (
#include "../HsVersions.h"
#include "../includes/MachDeps.h"
import BasicTypes( ConTagZ )
import DynFlags
import Outputable
import Platform
......@@ -185,14 +186,13 @@ type IsStatic = Bool
-- rtsClosureType below.
data ClosureTypeInfo
= Constr ConstrTag ConstrDescription
= Constr ConTagZ ConstrDescription
| Fun FunArity ArgDescr
| Thunk
| ThunkSelector SelectorOffset
| BlackHole
| IndStatic
type ConstrTag = Int
type ConstrDescription = [Word8] -- result of dataConIdentity
type FunArity = Int
type SelectorOffset = Int
......
......@@ -13,7 +13,6 @@
module StgCmmClosure (
DynTag, tagForCon, isSmallFamily,
ConTagZ, dataConTagZ,
idPrimRep, isVoidRep, isGcPtrRep, addIdReps, addArgReps,
argPrimRep,
......@@ -360,17 +359,12 @@ type DynTag = Int -- The tag on a *pointer*
isSmallFamily :: DynFlags -> Int -> Bool
isSmallFamily dflags fam_size = fam_size <= mAX_PTR_TAG dflags
-- We keep the *zero-indexed* tag in the srt_len field of the info
-- table of a data constructor.
dataConTagZ :: DataCon -> ConTagZ
dataConTagZ con = dataConTag con - fIRST_TAG
tagForCon :: DynFlags -> DataCon -> DynTag
tagForCon dflags con
| isSmallFamily dflags fam_size = con_tag + 1
| isSmallFamily dflags fam_size = con_tag
| otherwise = 1
where
con_tag = dataConTagZ con
con_tag = dataConTag con -- NB: 1-indexed
fam_size = tyConFamilySize (dataConTyCon con)
tagForArity :: DynFlags -> RepArity -> DynTag
......@@ -1050,6 +1044,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds
info_lbl = mkConInfoTableLabel name NoCafRefs
sm_rep = mkHeapRep dflags is_static ptr_wds nonptr_wds cl_type
cl_type = Constr (dataConTagZ data_con) (dataConIdentity data_con)
-- We keep the *zero-indexed* tag in the srt_len field
-- of the info table of a data constructor.
prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo
| otherwise = ProfilingInfo ty_descr val_descr
......
......@@ -74,6 +74,7 @@ import Module
import Id
import VarEnv
import OrdList
import BasicTypes( ConTagZ )
import Unique
import UniqSupply
import FastString
......
......@@ -4,7 +4,7 @@ module Vectorise.Utils.Base
( voidType
, newLocalVVar
, mkDataConTag, dataConTagZ
, mkDataConTag
, mkWrapType
, mkClosureTypes
, mkPReprType
......@@ -66,9 +66,6 @@ newLocalVVar fs vty
mkDataConTag :: DynFlags -> DataCon -> CoreExpr
mkDataConTag dflags = mkIntLitInt dflags . dataConTagZ
dataConTagZ :: DataCon -> Int
dataConTagZ con = dataConTag con - fIRST_TAG
-- Type Construction ----------------------------------------------------------
......
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