{-# LANGUAGE CPP #-}
module GHC.Cmm.Info (
mkEmptyContInfoTable,
cmmToRawCmm,
srtEscape,
closureInfoPtr,
entryCode,
getConstrTag,
cmmGetClosureType,
infoTable,
infoTableConstrTag,
infoTableSrtBitmap,
infoTableClosureType,
infoTablePtrs,
infoTableNonPtrs,
funInfoTable,
funInfoArity,
stdInfoTableSizeW,
fixedInfoTableSizeW,
profInfoTableSizeW,
maxStdInfoTableSizeW,
maxRetInfoTableSizeW,
stdInfoTableSizeB,
conInfoTableSizeB,
stdSrtBitmapOffset,
stdClosureTypeOffset,
stdPtrsOffset, stdNonPtrsOffset,
) where
#include "HsVersions.h"
import GHC.Prelude
import GHC.Cmm
import GHC.Cmm.Utils
import GHC.Cmm.CLabel
import GHC.Runtime.Heap.Layout
import GHC.Data.Bitmap
import GHC.Data.Stream (Stream)
import qualified GHC.Data.Stream as Stream
import GHC.Cmm.Dataflow.Collections
import GHC.Platform
import GHC.Data.Maybe
import GHC.Driver.Session
import GHC.Utils.Error (withTimingSilent)
import GHC.Utils.Panic
import GHC.Types.Unique.Supply
import GHC.Utils.Monad
import GHC.Utils.Misc
import GHC.Utils.Outputable
import Data.ByteString (ByteString)
import Data.Bits
mkEmptyContInfoTable :: CLabel -> CmmInfoTable
mkEmptyContInfoTable :: CLabel -> CmmInfoTable
mkEmptyContInfoTable CLabel
info_lbl
= CmmInfoTable :: CLabel
-> SMRep
-> ProfilingInfo
-> Maybe CLabel
-> Maybe (Id, CostCentreStack)
-> CmmInfoTable
CmmInfoTable { cit_lbl :: CLabel
cit_lbl = CLabel
info_lbl
, cit_rep :: SMRep
cit_rep = [Bool] -> SMRep
mkStackRep []
, cit_prof :: ProfilingInfo
cit_prof = ProfilingInfo
NoProfilingInfo
, cit_srt :: Maybe CLabel
cit_srt = Maybe CLabel
forall a. Maybe a
Nothing
, cit_clo :: Maybe (Id, CostCentreStack)
cit_clo = Maybe (Id, CostCentreStack)
forall a. Maybe a
Nothing }
cmmToRawCmm :: DynFlags -> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a)
cmmToRawCmm :: forall a.
DynFlags
-> Stream IO CmmGroupSRTs a -> IO (Stream IO RawCmmGroup a)
cmmToRawCmm DynFlags
dflags Stream IO CmmGroupSRTs a
cmms
= do { UniqSupply
uniqs <- Char -> IO UniqSupply
mkSplitUniqSupply Char
'i'
; let do_one :: UniqSupply -> [CmmDeclSRTs] -> IO (UniqSupply, [RawCmmDecl])
do_one :: UniqSupply -> CmmGroupSRTs -> IO (UniqSupply, RawCmmGroup)
do_one UniqSupply
uniqs CmmGroupSRTs
cmm =
DynFlags
-> SDoc
-> ((UniqSupply, RawCmmGroup) -> ())
-> IO (UniqSupply, RawCmmGroup)
-> IO (UniqSupply, RawCmmGroup)
forall (m :: * -> *) a.
MonadIO m =>
DynFlags -> SDoc -> (a -> ()) -> m a -> m a
withTimingSilent DynFlags
dflags (String -> SDoc
text String
"Cmm -> Raw Cmm")
(UniqSupply, RawCmmGroup) -> ()
forall {t :: * -> *} {a} {a}. Foldable t => (a, t a) -> ()
forceRes (IO (UniqSupply, RawCmmGroup) -> IO (UniqSupply, RawCmmGroup))
-> IO (UniqSupply, RawCmmGroup) -> IO (UniqSupply, RawCmmGroup)
forall a b. (a -> b) -> a -> b
$
case UniqSupply -> UniqSM RawCmmGroup -> (RawCmmGroup, UniqSupply)
forall a. UniqSupply -> UniqSM a -> (a, UniqSupply)
initUs UniqSupply
uniqs (UniqSM RawCmmGroup -> (RawCmmGroup, UniqSupply))
-> UniqSM RawCmmGroup -> (RawCmmGroup, UniqSupply)
forall a b. (a -> b) -> a -> b
$ (CmmDeclSRTs -> UniqSM RawCmmGroup)
-> CmmGroupSRTs -> UniqSM RawCmmGroup
forall (m :: * -> *) a b. Monad m => (a -> m [b]) -> [a] -> m [b]
concatMapM (DynFlags -> CmmDeclSRTs -> UniqSM RawCmmGroup
mkInfoTable DynFlags
dflags) CmmGroupSRTs
cmm of
(RawCmmGroup
b,UniqSupply
uniqs') -> (UniqSupply, RawCmmGroup) -> IO (UniqSupply, RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (UniqSupply
uniqs',RawCmmGroup
b)
; Stream IO RawCmmGroup a -> IO (Stream IO RawCmmGroup a)
forall (m :: * -> *) a. Monad m => a -> m a
return ((UniqSupply, a) -> a
forall a b. (a, b) -> b
snd ((UniqSupply, a) -> a)
-> Stream IO RawCmmGroup (UniqSupply, a) -> Stream IO RawCmmGroup a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (UniqSupply -> CmmGroupSRTs -> IO (UniqSupply, RawCmmGroup))
-> UniqSupply
-> Stream IO CmmGroupSRTs a
-> Stream IO RawCmmGroup (UniqSupply, a)
forall (m :: * -> *) c a b r.
Monad m =>
(c -> a -> m (c, b)) -> c -> Stream m a r -> Stream m b (c, r)
Stream.mapAccumL_ UniqSupply -> CmmGroupSRTs -> IO (UniqSupply, RawCmmGroup)
do_one UniqSupply
uniqs Stream IO CmmGroupSRTs a
cmms)
}
where forceRes :: (a, t a) -> ()
forceRes (a
uniqs, t a
rawcmms) =
a
uniqs a -> () -> ()
`seq` (a -> () -> ()) -> () -> t a -> ()
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\a
decl ()
r -> a
decl a -> () -> ()
`seq` ()
r) () t a
rawcmms
mkInfoTable :: DynFlags -> CmmDeclSRTs -> UniqSM [RawCmmDecl]
mkInfoTable :: DynFlags -> CmmDeclSRTs -> UniqSM RawCmmGroup
mkInfoTable DynFlags
_ (CmmData Section
sec RawCmmStatics
dat) = RawCmmGroup -> UniqSM RawCmmGroup
forall (m :: * -> *) a. Monad m => a -> m a
return [Section
-> RawCmmStatics
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall d h g. Section -> d -> GenCmmDecl d h g
CmmData Section
sec RawCmmStatics
dat]
mkInfoTable DynFlags
dflags proc :: CmmDeclSRTs
proc@(CmmProc CmmTopInfo
infos CLabel
entry_lbl [GlobalReg]
live CmmGraph
blocks)
| Bool -> Bool
not (Platform -> Bool
platformTablesNextToCode (DynFlags -> Platform
targetPlatform DynFlags
dflags))
= case CmmDeclSRTs -> Maybe CmmInfoTable
forall a (n :: Extensibility -> Extensibility -> *).
GenCmmDecl a CmmTopInfo (GenCmmGraph n) -> Maybe CmmInfoTable
topInfoTable CmmDeclSRTs
proc of
Maybe CmmInfoTable
Nothing ->
RawCmmGroup -> UniqSM RawCmmGroup
forall (m :: * -> *) a. Monad m => a -> m a
return [LabelMap RawCmmStatics
-> CLabel
-> [GlobalReg]
-> CmmGraph
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall d h g. h -> CLabel -> [GlobalReg] -> g -> GenCmmDecl d h g
CmmProc LabelMap RawCmmStatics
forall (map :: * -> *) a. IsMap map => map a
mapEmpty CLabel
entry_lbl [GlobalReg]
live CmmGraph
blocks]
Just info :: CmmInfoTable
info@CmmInfoTable { cit_lbl :: CmmInfoTable -> CLabel
cit_lbl = CLabel
info_lbl } -> do
(RawCmmGroup
top_decls, ([CmmLit]
std_info, [CmmLit]
extra_bits)) <-
DynFlags
-> CmmInfoTable
-> Maybe WordOff
-> UniqSM (RawCmmGroup, InfoTableContents)
mkInfoTableContents DynFlags
dflags CmmInfoTable
info Maybe WordOff
forall a. Maybe a
Nothing
let
rel_std_info :: [CmmLit]
rel_std_info = (CmmLit -> CmmLit) -> [CmmLit] -> [CmmLit]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo Platform
platform CLabel
info_lbl) [CmmLit]
std_info
rel_extra_bits :: [CmmLit]
rel_extra_bits = (CmmLit -> CmmLit) -> [CmmLit] -> [CmmLit]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo Platform
platform CLabel
info_lbl) [CmmLit]
extra_bits
RawCmmGroup -> UniqSM RawCmmGroup
forall (m :: * -> *) a. Monad m => a -> m a
return (RawCmmGroup
top_decls RawCmmGroup -> RawCmmGroup -> RawCmmGroup
forall a. [a] -> [a] -> [a]
++
[LabelMap RawCmmStatics
-> CLabel
-> [GlobalReg]
-> CmmGraph
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall d h g. h -> CLabel -> [GlobalReg] -> g -> GenCmmDecl d h g
CmmProc LabelMap RawCmmStatics
forall (map :: * -> *) a. IsMap map => map a
mapEmpty CLabel
entry_lbl [GlobalReg]
live CmmGraph
blocks,
CLabel
-> [CmmLit]
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall (raw :: Bool) info stmt.
CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt
mkRODataLits CLabel
info_lbl
(CLabel -> CmmLit
CmmLabel CLabel
entry_lbl CmmLit -> [CmmLit] -> [CmmLit]
forall a. a -> [a] -> [a]
: [CmmLit]
rel_std_info [CmmLit] -> [CmmLit] -> [CmmLit]
forall a. [a] -> [a] -> [a]
++ [CmmLit]
rel_extra_bits)])
| Bool
otherwise
= do
([RawCmmGroup]
top_declss, [(Label, RawCmmStatics)]
raw_infos) <-
[(RawCmmGroup, (Label, RawCmmStatics))]
-> ([RawCmmGroup], [(Label, RawCmmStatics)])
forall a b. [(a, b)] -> ([a], [b])
unzip ([(RawCmmGroup, (Label, RawCmmStatics))]
-> ([RawCmmGroup], [(Label, RawCmmStatics)]))
-> UniqSM [(RawCmmGroup, (Label, RawCmmStatics))]
-> UniqSM ([RawCmmGroup], [(Label, RawCmmStatics)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ((Label, CmmInfoTable)
-> UniqSM (RawCmmGroup, (Label, RawCmmStatics)))
-> [(Label, CmmInfoTable)]
-> UniqSM [(RawCmmGroup, (Label, RawCmmStatics))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Label, CmmInfoTable)
-> UniqSM (RawCmmGroup, (Label, RawCmmStatics))
forall {a} {rawOnly :: Bool}.
(a, CmmInfoTable)
-> UniqSM (RawCmmGroup, (a, GenCmmStatics rawOnly))
do_one_info (LabelMap CmmInfoTable -> [(KeyOf LabelMap, CmmInfoTable)]
forall (map :: * -> *) a. IsMap map => map a -> [(KeyOf map, a)]
mapToList (CmmTopInfo -> LabelMap CmmInfoTable
info_tbls CmmTopInfo
infos))
RawCmmGroup -> UniqSM RawCmmGroup
forall (m :: * -> *) a. Monad m => a -> m a
return ([RawCmmGroup] -> RawCmmGroup
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [RawCmmGroup]
top_declss RawCmmGroup -> RawCmmGroup -> RawCmmGroup
forall a. [a] -> [a] -> [a]
++
[LabelMap RawCmmStatics
-> CLabel
-> [GlobalReg]
-> CmmGraph
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall d h g. h -> CLabel -> [GlobalReg] -> g -> GenCmmDecl d h g
CmmProc ([(KeyOf LabelMap, RawCmmStatics)] -> LabelMap RawCmmStatics
forall (map :: * -> *) a. IsMap map => [(KeyOf map, a)] -> map a
mapFromList [(KeyOf LabelMap, RawCmmStatics)]
[(Label, RawCmmStatics)]
raw_infos) CLabel
entry_lbl [GlobalReg]
live CmmGraph
blocks])
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
do_one_info :: (a, CmmInfoTable)
-> UniqSM (RawCmmGroup, (a, GenCmmStatics rawOnly))
do_one_info (a
lbl,CmmInfoTable
itbl) = do
(RawCmmGroup
top_decls, ([CmmLit]
std_info, [CmmLit]
extra_bits)) <-
DynFlags
-> CmmInfoTable
-> Maybe WordOff
-> UniqSM (RawCmmGroup, InfoTableContents)
mkInfoTableContents DynFlags
dflags CmmInfoTable
itbl Maybe WordOff
forall a. Maybe a
Nothing
let
info_lbl :: CLabel
info_lbl = CmmInfoTable -> CLabel
cit_lbl CmmInfoTable
itbl
rel_std_info :: [CmmLit]
rel_std_info = (CmmLit -> CmmLit) -> [CmmLit] -> [CmmLit]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo Platform
platform CLabel
info_lbl) [CmmLit]
std_info
rel_extra_bits :: [CmmLit]
rel_extra_bits = (CmmLit -> CmmLit) -> [CmmLit] -> [CmmLit]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo Platform
platform CLabel
info_lbl) [CmmLit]
extra_bits
(RawCmmGroup, (a, GenCmmStatics rawOnly))
-> UniqSM (RawCmmGroup, (a, GenCmmStatics rawOnly))
forall (m :: * -> *) a. Monad m => a -> m a
return (RawCmmGroup
top_decls, (a
lbl, CLabel -> [CmmStatic] -> GenCmmStatics rawOnly
forall (rawOnly :: Bool).
CLabel -> [CmmStatic] -> GenCmmStatics rawOnly
CmmStaticsRaw CLabel
info_lbl ([CmmStatic] -> GenCmmStatics rawOnly)
-> [CmmStatic] -> GenCmmStatics rawOnly
forall a b. (a -> b) -> a -> b
$ (CmmLit -> CmmStatic) -> [CmmLit] -> [CmmStatic]
forall a b. (a -> b) -> [a] -> [b]
map CmmLit -> CmmStatic
CmmStaticLit ([CmmLit] -> [CmmStatic]) -> [CmmLit] -> [CmmStatic]
forall a b. (a -> b) -> a -> b
$
[CmmLit] -> [CmmLit]
forall a. [a] -> [a]
reverse [CmmLit]
rel_extra_bits [CmmLit] -> [CmmLit] -> [CmmLit]
forall a. [a] -> [a] -> [a]
++ [CmmLit]
rel_std_info))
type InfoTableContents = ( [CmmLit]
, [CmmLit] )
mkInfoTableContents :: DynFlags
-> CmmInfoTable
-> Maybe Int
-> UniqSM ([RawCmmDecl],
InfoTableContents)
mkInfoTableContents :: DynFlags
-> CmmInfoTable
-> Maybe WordOff
-> UniqSM (RawCmmGroup, InfoTableContents)
mkInfoTableContents DynFlags
dflags
info :: CmmInfoTable
info@(CmmInfoTable { cit_lbl :: CmmInfoTable -> CLabel
cit_lbl = CLabel
info_lbl
, cit_rep :: CmmInfoTable -> SMRep
cit_rep = SMRep
smrep
, cit_prof :: CmmInfoTable -> ProfilingInfo
cit_prof = ProfilingInfo
prof
, cit_srt :: CmmInfoTable -> Maybe CLabel
cit_srt = Maybe CLabel
srt })
Maybe WordOff
mb_rts_tag
| RTSRep WordOff
rts_tag SMRep
rep <- SMRep
smrep
= DynFlags
-> CmmInfoTable
-> Maybe WordOff
-> UniqSM (RawCmmGroup, InfoTableContents)
mkInfoTableContents DynFlags
dflags CmmInfoTable
info{cit_rep :: SMRep
cit_rep = SMRep
rep} (WordOff -> Maybe WordOff
forall a. a -> Maybe a
Just WordOff
rts_tag)
| StackRep [Bool]
frame <- SMRep
smrep
= do { ((CmmLit, CmmLit)
prof_lits, RawCmmGroup
prof_data) <- Platform -> ProfilingInfo -> UniqSM ((CmmLit, CmmLit), RawCmmGroup)
mkProfLits Platform
platform ProfilingInfo
prof
; let ([CmmLit]
srt_label, CmmLit
srt_bitmap) = Platform -> CLabel -> Maybe CLabel -> ([CmmLit], CmmLit)
mkSRTLit Platform
platform CLabel
info_lbl Maybe CLabel
srt
; (CmmLit
liveness_lit, RawCmmGroup
liveness_data) <- DynFlags -> [Bool] -> UniqSM (CmmLit, RawCmmGroup)
mkLivenessBits DynFlags
dflags [Bool]
frame
; let
std_info :: [CmmLit]
std_info = DynFlags
-> (CmmLit, CmmLit) -> WordOff -> CmmLit -> CmmLit -> [CmmLit]
mkStdInfoTable DynFlags
dflags (CmmLit, CmmLit)
prof_lits WordOff
rts_tag CmmLit
srt_bitmap CmmLit
liveness_lit
rts_tag :: WordOff
rts_tag | Just WordOff
tag <- Maybe WordOff
mb_rts_tag = WordOff
tag
| RawCmmGroup -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null RawCmmGroup
liveness_data = WordOff
rET_SMALL
| Bool
otherwise = WordOff
rET_BIG
; (RawCmmGroup, InfoTableContents)
-> UniqSM (RawCmmGroup, InfoTableContents)
forall (m :: * -> *) a. Monad m => a -> m a
return (RawCmmGroup
prof_data RawCmmGroup -> RawCmmGroup -> RawCmmGroup
forall a. [a] -> [a] -> [a]
++ RawCmmGroup
liveness_data, ([CmmLit]
std_info, [CmmLit]
srt_label)) }
| HeapRep Bool
_ WordOff
ptrs WordOff
nonptrs ClosureTypeInfo
closure_type <- SMRep
smrep
= do { let layout :: CmmLit
layout = Platform -> WordOff -> WordOff -> CmmLit
packIntsCLit Platform
platform WordOff
ptrs WordOff
nonptrs
; ((CmmLit, CmmLit)
prof_lits, RawCmmGroup
prof_data) <- Platform -> ProfilingInfo -> UniqSM ((CmmLit, CmmLit), RawCmmGroup)
mkProfLits Platform
platform ProfilingInfo
prof
; let ([CmmLit]
srt_label, CmmLit
srt_bitmap) = Platform -> CLabel -> Maybe CLabel -> ([CmmLit], CmmLit)
mkSRTLit Platform
platform CLabel
info_lbl Maybe CLabel
srt
; (Maybe CmmLit
mb_srt_field, Maybe CmmLit
mb_layout, [CmmLit]
extra_bits, RawCmmGroup
ct_data)
<- ClosureTypeInfo
-> [CmmLit]
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
mk_pieces ClosureTypeInfo
closure_type [CmmLit]
srt_label
; let std_info :: [CmmLit]
std_info = DynFlags
-> (CmmLit, CmmLit) -> WordOff -> CmmLit -> CmmLit -> [CmmLit]
mkStdInfoTable DynFlags
dflags (CmmLit, CmmLit)
prof_lits
(Maybe WordOff
mb_rts_tag Maybe WordOff -> WordOff -> WordOff
forall a. Maybe a -> a -> a
`orElse` SMRep -> WordOff
rtsClosureType SMRep
smrep)
(Maybe CmmLit
mb_srt_field Maybe CmmLit -> CmmLit -> CmmLit
forall a. Maybe a -> a -> a
`orElse` CmmLit
srt_bitmap)
(Maybe CmmLit
mb_layout Maybe CmmLit -> CmmLit -> CmmLit
forall a. Maybe a -> a -> a
`orElse` CmmLit
layout)
; (RawCmmGroup, InfoTableContents)
-> UniqSM (RawCmmGroup, InfoTableContents)
forall (m :: * -> *) a. Monad m => a -> m a
return (RawCmmGroup
prof_data RawCmmGroup -> RawCmmGroup -> RawCmmGroup
forall a. [a] -> [a] -> [a]
++ RawCmmGroup
ct_data, ([CmmLit]
std_info, [CmmLit]
extra_bits)) }
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
mk_pieces :: ClosureTypeInfo -> [CmmLit]
-> UniqSM ( Maybe CmmLit
, Maybe CmmLit
, [CmmLit]
, [RawCmmDecl])
mk_pieces :: ClosureTypeInfo
-> [CmmLit]
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
mk_pieces (Constr WordOff
con_tag ConstrDescription
con_descr) [CmmLit]
_no_srt
= do { (CmmLit
descr_lit, GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
decl) <- ConstrDescription
-> UniqSM
(CmmLit,
GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph)
forall info stmt.
ConstrDescription
-> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
newStringLit ConstrDescription
con_descr
; (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return ( CmmLit -> Maybe CmmLit
forall a. a -> Maybe a
Just (Integer -> Width -> CmmLit
CmmInt (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
con_tag)
(Platform -> Width
halfWordWidth Platform
platform))
, Maybe CmmLit
forall a. Maybe a
Nothing, [CmmLit
descr_lit], [GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
decl]) }
mk_pieces ClosureTypeInfo
Thunk [CmmLit]
srt_label
= (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe CmmLit
forall a. Maybe a
Nothing, Maybe CmmLit
forall a. Maybe a
Nothing, [CmmLit]
srt_label, [])
mk_pieces (ThunkSelector WordOff
offset) [CmmLit]
_no_srt
= (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (CmmLit -> Maybe CmmLit
forall a. a -> Maybe a
Just (Integer -> Width -> CmmLit
CmmInt Integer
0 (Platform -> Width
halfWordWidth Platform
platform)),
CmmLit -> Maybe CmmLit
forall a. a -> Maybe a
Just (Platform -> Integer -> CmmLit
mkWordCLit Platform
platform (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
offset)), [], [])
mk_pieces (Fun WordOff
arity (ArgSpec WordOff
fun_type)) [CmmLit]
srt_label
= do { let extra_bits :: [CmmLit]
extra_bits = Platform -> WordOff -> WordOff -> CmmLit
packIntsCLit Platform
platform WordOff
fun_type WordOff
arity CmmLit -> [CmmLit] -> [CmmLit]
forall a. a -> [a] -> [a]
: [CmmLit]
srt_label
; (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe CmmLit
forall a. Maybe a
Nothing, Maybe CmmLit
forall a. Maybe a
Nothing, [CmmLit]
extra_bits, []) }
mk_pieces (Fun WordOff
arity (ArgGen [Bool]
arg_bits)) [CmmLit]
srt_label
= do { (CmmLit
liveness_lit, RawCmmGroup
liveness_data) <- DynFlags -> [Bool] -> UniqSM (CmmLit, RawCmmGroup)
mkLivenessBits DynFlags
dflags [Bool]
arg_bits
; let fun_type :: WordOff
fun_type | RawCmmGroup -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null RawCmmGroup
liveness_data = WordOff
aRG_GEN
| Bool
otherwise = WordOff
aRG_GEN_BIG
extra_bits :: [CmmLit]
extra_bits = [ Platform -> WordOff -> WordOff -> CmmLit
packIntsCLit Platform
platform WordOff
fun_type WordOff
arity ]
[CmmLit] -> [CmmLit] -> [CmmLit]
forall a. [a] -> [a] -> [a]
++ (if Platform -> Bool
inlineSRT Platform
platform then [] else [ CmmLit
srt_lit ])
[CmmLit] -> [CmmLit] -> [CmmLit]
forall a. [a] -> [a] -> [a]
++ [ CmmLit
liveness_lit, CmmLit
slow_entry ]
; (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe CmmLit
forall a. Maybe a
Nothing, Maybe CmmLit
forall a. Maybe a
Nothing, [CmmLit]
extra_bits, RawCmmGroup
liveness_data) }
where
slow_entry :: CmmLit
slow_entry = CLabel -> CmmLit
CmmLabel (CLabel -> CLabel
toSlowEntryLbl CLabel
info_lbl)
srt_lit :: CmmLit
srt_lit = case [CmmLit]
srt_label of
[] -> Platform -> WordOff -> CmmLit
mkIntCLit Platform
platform WordOff
0
(CmmLit
lit:[CmmLit]
_rest) -> ASSERT( null _rest ) lit
mk_pieces ClosureTypeInfo
other [CmmLit]
_ = String
-> SDoc
-> UniqSM (Maybe CmmLit, Maybe CmmLit, [CmmLit], RawCmmGroup)
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"mk_pieces" (ClosureTypeInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr ClosureTypeInfo
other)
mkInfoTableContents DynFlags
_ CmmInfoTable
_ Maybe WordOff
_ = String -> UniqSM (RawCmmGroup, InfoTableContents)
forall a. String -> a
panic String
"mkInfoTableContents"
packIntsCLit :: Platform -> Int -> Int -> CmmLit
packIntsCLit :: Platform -> WordOff -> WordOff -> CmmLit
packIntsCLit Platform
platform WordOff
a WordOff
b = Platform -> StgHalfWord -> StgHalfWord -> CmmLit
packHalfWordsCLit Platform
platform
(Platform -> Integer -> StgHalfWord
toStgHalfWord Platform
platform (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
a))
(Platform -> Integer -> StgHalfWord
toStgHalfWord Platform
platform (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
b))
mkSRTLit :: Platform
-> CLabel
-> Maybe CLabel
-> ([CmmLit],
CmmLit)
mkSRTLit :: Platform -> CLabel -> Maybe CLabel -> ([CmmLit], CmmLit)
mkSRTLit Platform
platform CLabel
info_lbl (Just CLabel
lbl)
| Platform -> Bool
inlineSRT Platform
platform
= ([], CLabel -> CLabel -> WordOff -> Width -> CmmLit
CmmLabelDiffOff CLabel
lbl CLabel
info_lbl WordOff
0 (Platform -> Width
halfWordWidth Platform
platform))
mkSRTLit Platform
platform CLabel
_ Maybe CLabel
Nothing = ([], Integer -> Width -> CmmLit
CmmInt Integer
0 (Platform -> Width
halfWordWidth Platform
platform))
mkSRTLit Platform
platform CLabel
_ (Just CLabel
lbl) = ([CLabel -> CmmLit
CmmLabel CLabel
lbl], Integer -> Width -> CmmLit
CmmInt Integer
1 (Platform -> Width
halfWordWidth Platform
platform))
inlineSRT :: Platform -> Bool
inlineSRT :: Platform -> Bool
inlineSRT Platform
platform = Platform -> Arch
platformArch Platform
platform Arch -> Arch -> Bool
forall a. Eq a => a -> a -> Bool
== Arch
ArchX86_64
Bool -> Bool -> Bool
&& Platform -> Bool
platformTablesNextToCode Platform
platform
makeRelativeRefTo :: Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo :: Platform -> CLabel -> CmmLit -> CmmLit
makeRelativeRefTo Platform
platform CLabel
info_lbl CmmLit
lit
= if Platform -> Bool
platformTablesNextToCode Platform
platform
then case CmmLit
lit of
CmmLabel CLabel
lbl -> CLabel -> CLabel -> WordOff -> Width -> CmmLit
CmmLabelDiffOff CLabel
lbl CLabel
info_lbl WordOff
0 (Platform -> Width
wordWidth Platform
platform)
CmmLabelOff CLabel
lbl WordOff
off -> CLabel -> CLabel -> WordOff -> Width -> CmmLit
CmmLabelDiffOff CLabel
lbl CLabel
info_lbl WordOff
off (Platform -> Width
wordWidth Platform
platform)
CmmLit
_ -> CmmLit
lit
else CmmLit
lit
mkLivenessBits :: DynFlags -> Liveness -> UniqSM (CmmLit, [RawCmmDecl])
mkLivenessBits :: DynFlags -> [Bool] -> UniqSM (CmmLit, RawCmmGroup)
mkLivenessBits DynFlags
dflags [Bool]
liveness
| WordOff
n_bits WordOff -> WordOff -> Bool
forall a. Ord a => a -> a -> Bool
> Platform -> WordOff
mAX_SMALL_BITMAP_SIZE Platform
platform
= do { Unique
uniq <- UniqSM Unique
forall (m :: * -> *). MonadUnique m => m Unique
getUniqueM
; let bitmap_lbl :: CLabel
bitmap_lbl = Unique -> CLabel
mkBitmapLabel Unique
uniq
; (CmmLit, RawCmmGroup) -> UniqSM (CmmLit, RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (CLabel -> CmmLit
CmmLabel CLabel
bitmap_lbl,
[CLabel
-> [CmmLit]
-> GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
forall (raw :: Bool) info stmt.
CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt
mkRODataLits CLabel
bitmap_lbl [CmmLit]
lits]) }
| Bool
otherwise
= (CmmLit, RawCmmGroup) -> UniqSM (CmmLit, RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return (Platform -> StgWord -> CmmLit
mkStgWordCLit Platform
platform StgWord
bitmap_word, [])
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
n_bits :: WordOff
n_bits = [Bool] -> WordOff
forall (t :: * -> *) a. Foldable t => t a -> WordOff
length [Bool]
liveness
bitmap :: Bitmap
bitmap :: Bitmap
bitmap = Platform -> [Bool] -> Bitmap
mkBitmap Platform
platform [Bool]
liveness
small_bitmap :: StgWord
small_bitmap = case Bitmap
bitmap of
[] -> Platform -> Integer -> StgWord
toStgWord Platform
platform Integer
0
[StgWord
b] -> StgWord
b
Bitmap
_ -> String -> StgWord
forall a. String -> a
panic String
"mkLiveness"
bitmap_word :: StgWord
bitmap_word = Platform -> Integer -> StgWord
toStgWord Platform
platform (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
n_bits)
StgWord -> StgWord -> StgWord
forall a. Bits a => a -> a -> a
.|. (StgWord
small_bitmap StgWord -> WordOff -> StgWord
forall a. Bits a => a -> WordOff -> a
`shiftL` DynFlags -> WordOff
bITMAP_BITS_SHIFT DynFlags
dflags)
lits :: [CmmLit]
lits = Platform -> Integer -> CmmLit
mkWordCLit Platform
platform (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
n_bits)
CmmLit -> [CmmLit] -> [CmmLit]
forall a. a -> [a] -> [a]
: (StgWord -> CmmLit) -> Bitmap -> [CmmLit]
forall a b. (a -> b) -> [a] -> [b]
map (Platform -> StgWord -> CmmLit
mkStgWordCLit Platform
platform) Bitmap
bitmap
mkStdInfoTable
:: DynFlags
-> (CmmLit,CmmLit)
-> Int
-> CmmLit
-> CmmLit
-> [CmmLit]
mkStdInfoTable :: DynFlags
-> (CmmLit, CmmLit) -> WordOff -> CmmLit -> CmmLit -> [CmmLit]
mkStdInfoTable DynFlags
dflags (CmmLit
type_descr, CmmLit
closure_descr) WordOff
cl_type CmmLit
srt CmmLit
layout_lit
=
[CmmLit]
prof_info
[CmmLit] -> [CmmLit] -> [CmmLit]
forall a. [a] -> [a] -> [a]
++ [CmmLit
layout_lit, CmmLit
tag, CmmLit
srt]
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
prof_info :: [CmmLit]
prof_info
| DynFlags -> Bool
sccProfilingEnabled DynFlags
dflags = [CmmLit
type_descr, CmmLit
closure_descr]
| Bool
otherwise = []
tag :: CmmLit
tag = Integer -> Width -> CmmLit
CmmInt (WordOff -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral WordOff
cl_type) (Platform -> Width
halfWordWidth Platform
platform)
mkProfLits :: Platform -> ProfilingInfo -> UniqSM ((CmmLit,CmmLit), [RawCmmDecl])
mkProfLits :: Platform -> ProfilingInfo -> UniqSM ((CmmLit, CmmLit), RawCmmGroup)
mkProfLits Platform
platform ProfilingInfo
NoProfilingInfo = ((CmmLit, CmmLit), RawCmmGroup)
-> UniqSM ((CmmLit, CmmLit), RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Platform -> CmmLit
zeroCLit Platform
platform, Platform -> CmmLit
zeroCLit Platform
platform), [])
mkProfLits Platform
_ (ProfilingInfo ConstrDescription
td ConstrDescription
cd)
= do { (CmmLit
td_lit, GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
td_decl) <- ConstrDescription
-> UniqSM
(CmmLit,
GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph)
forall info stmt.
ConstrDescription
-> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
newStringLit ConstrDescription
td
; (CmmLit
cd_lit, GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
cd_decl) <- ConstrDescription
-> UniqSM
(CmmLit,
GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph)
forall info stmt.
ConstrDescription
-> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
newStringLit ConstrDescription
cd
; ((CmmLit, CmmLit), RawCmmGroup)
-> UniqSM ((CmmLit, CmmLit), RawCmmGroup)
forall (m :: * -> *) a. Monad m => a -> m a
return ((CmmLit
td_lit,CmmLit
cd_lit), [GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
td_decl,GenCmmDecl RawCmmStatics (LabelMap RawCmmStatics) CmmGraph
cd_decl]) }
newStringLit :: ByteString -> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
newStringLit :: forall info stmt.
ConstrDescription
-> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
newStringLit ConstrDescription
bytes
= do { Unique
uniq <- UniqSM Unique
forall (m :: * -> *). MonadUnique m => m Unique
getUniqueM
; (CmmLit, GenCmmDecl RawCmmStatics info stmt)
-> UniqSM (CmmLit, GenCmmDecl RawCmmStatics info stmt)
forall (m :: * -> *) a. Monad m => a -> m a
return (CLabel
-> ConstrDescription
-> (CmmLit, GenCmmDecl RawCmmStatics info stmt)
forall (raw :: Bool) info stmt.
CLabel
-> ConstrDescription
-> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt)
mkByteStringCLit (Unique -> CLabel
mkStringLitLabel Unique
uniq) ConstrDescription
bytes) }
srtEscape :: Platform -> StgHalfWord
srtEscape :: Platform -> StgHalfWord
srtEscape Platform
platform = Platform -> Integer -> StgHalfWord
toStgHalfWord Platform
platform (-Integer
1)
wordAligned :: DynFlags -> CmmExpr -> CmmExpr
wordAligned :: DynFlags -> CmmExpr -> CmmExpr
wordAligned DynFlags
dflags CmmExpr
e
| GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_AlignmentSanitisation DynFlags
dflags
= MachOp -> [CmmExpr] -> CmmExpr
CmmMachOp (WordOff -> Width -> MachOp
MO_AlignmentCheck (Platform -> WordOff
platformWordSizeInBytes Platform
platform) (Platform -> Width
wordWidth Platform
platform)) [CmmExpr
e]
| Bool
otherwise
= CmmExpr
e
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
closureInfoPtr :: DynFlags -> CmmExpr -> CmmExpr
closureInfoPtr :: DynFlags -> CmmExpr -> CmmExpr
closureInfoPtr DynFlags
dflags CmmExpr
e =
CmmExpr -> CmmType -> CmmExpr
CmmLoad (DynFlags -> CmmExpr -> CmmExpr
wordAligned DynFlags
dflags CmmExpr
e) (Platform -> CmmType
bWord (DynFlags -> Platform
targetPlatform DynFlags
dflags))
entryCode :: Platform -> CmmExpr -> CmmExpr
entryCode :: Platform -> CmmExpr -> CmmExpr
entryCode Platform
platform CmmExpr
e =
if Platform -> Bool
platformTablesNextToCode Platform
platform
then CmmExpr
e
else CmmExpr -> CmmType -> CmmExpr
CmmLoad CmmExpr
e (Platform -> CmmType
bWord Platform
platform)
getConstrTag :: DynFlags -> CmmExpr -> CmmExpr
getConstrTag :: DynFlags -> CmmExpr -> CmmExpr
getConstrTag DynFlags
dflags CmmExpr
closure_ptr
= MachOp -> [CmmExpr] -> CmmExpr
CmmMachOp (Width -> Width -> MachOp
MO_UU_Conv (Platform -> Width
halfWordWidth Platform
platform) (Platform -> Width
wordWidth Platform
platform)) [DynFlags -> CmmExpr -> CmmExpr
infoTableConstrTag DynFlags
dflags CmmExpr
info_table]
where
info_table :: CmmExpr
info_table = DynFlags -> CmmExpr -> CmmExpr
infoTable DynFlags
dflags (DynFlags -> CmmExpr -> CmmExpr
closureInfoPtr DynFlags
dflags CmmExpr
closure_ptr)
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
cmmGetClosureType :: DynFlags -> CmmExpr -> CmmExpr
cmmGetClosureType :: DynFlags -> CmmExpr -> CmmExpr
cmmGetClosureType DynFlags
dflags CmmExpr
closure_ptr
= MachOp -> [CmmExpr] -> CmmExpr
CmmMachOp (Width -> Width -> MachOp
MO_UU_Conv (Platform -> Width
halfWordWidth Platform
platform) (Platform -> Width
wordWidth Platform
platform)) [DynFlags -> CmmExpr -> CmmExpr
infoTableClosureType DynFlags
dflags CmmExpr
info_table]
where
info_table :: CmmExpr
info_table = DynFlags -> CmmExpr -> CmmExpr
infoTable DynFlags
dflags (DynFlags -> CmmExpr -> CmmExpr
closureInfoPtr DynFlags
dflags CmmExpr
closure_ptr)
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
infoTable :: DynFlags -> CmmExpr -> CmmExpr
infoTable :: DynFlags -> CmmExpr -> CmmExpr
infoTable DynFlags
dflags CmmExpr
info_ptr
| Platform -> Bool
platformTablesNextToCode Platform
platform = Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_ptr (- DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags)
| Bool
otherwise = Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetW Platform
platform CmmExpr
info_ptr WordOff
1
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
infoTableConstrTag :: DynFlags -> CmmExpr -> CmmExpr
infoTableConstrTag :: DynFlags -> CmmExpr -> CmmExpr
infoTableConstrTag = DynFlags -> CmmExpr -> CmmExpr
infoTableSrtBitmap
infoTableSrtBitmap :: DynFlags -> CmmExpr -> CmmExpr
infoTableSrtBitmap :: DynFlags -> CmmExpr -> CmmExpr
infoTableSrtBitmap DynFlags
dflags CmmExpr
info_tbl
= CmmExpr -> CmmType -> CmmExpr
CmmLoad (Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_tbl (DynFlags -> WordOff
stdSrtBitmapOffset DynFlags
dflags)) (Platform -> CmmType
bHalfWord Platform
platform)
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
infoTableClosureType :: DynFlags -> CmmExpr -> CmmExpr
infoTableClosureType :: DynFlags -> CmmExpr -> CmmExpr
infoTableClosureType DynFlags
dflags CmmExpr
info_tbl
= CmmExpr -> CmmType -> CmmExpr
CmmLoad (Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_tbl (DynFlags -> WordOff
stdClosureTypeOffset DynFlags
dflags)) (Platform -> CmmType
bHalfWord Platform
platform)
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
infoTablePtrs :: DynFlags -> CmmExpr -> CmmExpr
infoTablePtrs :: DynFlags -> CmmExpr -> CmmExpr
infoTablePtrs DynFlags
dflags CmmExpr
info_tbl
= CmmExpr -> CmmType -> CmmExpr
CmmLoad (Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_tbl (DynFlags -> WordOff
stdPtrsOffset DynFlags
dflags)) (Platform -> CmmType
bHalfWord Platform
platform)
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
infoTableNonPtrs :: DynFlags -> CmmExpr -> CmmExpr
infoTableNonPtrs :: DynFlags -> CmmExpr -> CmmExpr
infoTableNonPtrs DynFlags
dflags CmmExpr
info_tbl
= CmmExpr -> CmmType -> CmmExpr
CmmLoad (Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_tbl (DynFlags -> WordOff
stdNonPtrsOffset DynFlags
dflags)) (Platform -> CmmType
bHalfWord Platform
platform)
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
funInfoTable :: DynFlags -> CmmExpr -> CmmExpr
funInfoTable :: DynFlags -> CmmExpr -> CmmExpr
funInfoTable DynFlags
dflags CmmExpr
info_ptr
| Platform -> Bool
platformTablesNextToCode Platform
platform
= Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetB Platform
platform CmmExpr
info_ptr (- DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
- DynFlags -> WordOff
sIZEOF_StgFunInfoExtraRev DynFlags
dflags)
| Bool
otherwise
= Platform -> CmmExpr -> WordOff -> CmmExpr
cmmOffsetW Platform
platform CmmExpr
info_ptr (WordOff
1 WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ DynFlags -> WordOff
stdInfoTableSizeW DynFlags
dflags)
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
funInfoArity :: DynFlags -> CmmExpr -> CmmExpr
funInfoArity :: DynFlags -> CmmExpr -> CmmExpr
funInfoArity DynFlags
dflags CmmExpr
iptr
= Platform -> CmmExpr -> CmmExpr
cmmToWord Platform
platform (Platform -> CmmType -> CmmExpr -> WordOff -> CmmExpr
cmmLoadIndex Platform
platform CmmType
rep CmmExpr
fun_info (WordOff
offset WordOff -> WordOff -> WordOff
forall a. Integral a => a -> a -> a
`div` WordOff
rep_bytes))
where
platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
fun_info :: CmmExpr
fun_info = DynFlags -> CmmExpr -> CmmExpr
funInfoTable DynFlags
dflags CmmExpr
iptr
rep :: CmmType
rep = Width -> CmmType
cmmBits (WordOff -> Width
widthFromBytes WordOff
rep_bytes)
tablesNextToCode :: Bool
tablesNextToCode = Platform -> Bool
platformTablesNextToCode Platform
platform
(WordOff
rep_bytes, WordOff
offset)
| Bool
tablesNextToCode = ( PlatformConstants -> WordOff
pc_REP_StgFunInfoExtraRev_arity PlatformConstants
pc
, DynFlags -> WordOff
oFFSET_StgFunInfoExtraRev_arity DynFlags
dflags )
| Bool
otherwise = ( PlatformConstants -> WordOff
pc_REP_StgFunInfoExtraFwd_arity PlatformConstants
pc
, DynFlags -> WordOff
oFFSET_StgFunInfoExtraFwd_arity DynFlags
dflags )
pc :: PlatformConstants
pc = DynFlags -> PlatformConstants
platformConstants DynFlags
dflags
stdInfoTableSizeW :: DynFlags -> WordOff
stdInfoTableSizeW :: DynFlags -> WordOff
stdInfoTableSizeW DynFlags
dflags
= WordOff
fixedInfoTableSizeW
WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ if DynFlags -> Bool
sccProfilingEnabled DynFlags
dflags
then WordOff
profInfoTableSizeW
else WordOff
0
fixedInfoTableSizeW :: WordOff
fixedInfoTableSizeW :: WordOff
fixedInfoTableSizeW = WordOff
2
profInfoTableSizeW :: WordOff
profInfoTableSizeW :: WordOff
profInfoTableSizeW = WordOff
2
maxStdInfoTableSizeW :: WordOff
maxStdInfoTableSizeW :: WordOff
maxStdInfoTableSizeW =
WordOff
1
WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ WordOff
fixedInfoTableSizeW
WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ WordOff
profInfoTableSizeW
maxRetInfoTableSizeW :: WordOff
maxRetInfoTableSizeW :: WordOff
maxRetInfoTableSizeW =
WordOff
maxStdInfoTableSizeW
WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ WordOff
1
stdInfoTableSizeB :: DynFlags -> ByteOff
stdInfoTableSizeB :: DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeW DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
* Platform -> WordOff
platformWordSizeInBytes Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
stdSrtBitmapOffset :: DynFlags -> ByteOff
stdSrtBitmapOffset :: DynFlags -> WordOff
stdSrtBitmapOffset DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
- Platform -> WordOff
halfWordSize Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
stdClosureTypeOffset :: DynFlags -> ByteOff
stdClosureTypeOffset :: DynFlags -> WordOff
stdClosureTypeOffset DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
- Platform -> WordOff
platformWordSizeInBytes Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
stdPtrsOffset, stdNonPtrsOffset :: DynFlags -> ByteOff
stdPtrsOffset :: DynFlags -> WordOff
stdPtrsOffset DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
- WordOff
2 WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
* Platform -> WordOff
platformWordSizeInBytes Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
stdNonPtrsOffset :: DynFlags -> WordOff
stdNonPtrsOffset DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
- WordOff
2 WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
* Platform -> WordOff
platformWordSizeInBytes Platform
platform WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ Platform -> WordOff
halfWordSize Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags
conInfoTableSizeB :: DynFlags -> Int
conInfoTableSizeB :: DynFlags -> WordOff
conInfoTableSizeB DynFlags
dflags = DynFlags -> WordOff
stdInfoTableSizeB DynFlags
dflags WordOff -> WordOff -> WordOff
forall a. Num a => a -> a -> a
+ Platform -> WordOff
platformWordSizeInBytes Platform
platform
where platform :: Platform
platform = DynFlags -> Platform
targetPlatform DynFlags
dflags