{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
module GHC.ByteCode.Instr (
BCInstr(..), ProtoBCO(..), bciStackUse, LocalLabel(..)
) where
import GHC.Prelude
import GHC.ByteCode.Types
import GHCi.RemoteTypes
import GHCi.FFI (C_ffi_cif)
import GHC.StgToCmm.Layout ( ArgRep(..) )
import GHC.Utils.Outputable
import GHC.Types.Name
import GHC.Types.Unique
import GHC.Types.Literal
import GHC.Core.DataCon
import GHC.Builtin.PrimOps
import GHC.Runtime.Heap.Layout
import Data.Word
import GHC.Stack.CCS (CostCentre)
import GHC.Stg.Syntax
data ProtoBCO a
= ProtoBCO {
forall a. ProtoBCO a -> a
protoBCOName :: a,
forall a. ProtoBCO a -> [BCInstr]
protoBCOInstrs :: [BCInstr],
forall a. ProtoBCO a -> [StgWord]
protoBCOBitmap :: [StgWord],
forall a. ProtoBCO a -> Word16
protoBCOBitmapSize :: Word16,
forall a. ProtoBCO a -> Int
protoBCOArity :: Int,
forall a. ProtoBCO a -> Either [CgStgAlt] CgStgRhs
protoBCOExpr :: Either [CgStgAlt] CgStgRhs,
forall a. ProtoBCO a -> [FFIInfo]
protoBCOFFIs :: [FFIInfo]
}
newtype LocalLabel = LocalLabel { LocalLabel -> Word32
getLocalLabel :: Word32 }
deriving (LocalLabel -> LocalLabel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalLabel -> LocalLabel -> Bool
$c/= :: LocalLabel -> LocalLabel -> Bool
== :: LocalLabel -> LocalLabel -> Bool
$c== :: LocalLabel -> LocalLabel -> Bool
Eq, Eq LocalLabel
LocalLabel -> LocalLabel -> Bool
LocalLabel -> LocalLabel -> Ordering
LocalLabel -> LocalLabel -> LocalLabel
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LocalLabel -> LocalLabel -> LocalLabel
$cmin :: LocalLabel -> LocalLabel -> LocalLabel
max :: LocalLabel -> LocalLabel -> LocalLabel
$cmax :: LocalLabel -> LocalLabel -> LocalLabel
>= :: LocalLabel -> LocalLabel -> Bool
$c>= :: LocalLabel -> LocalLabel -> Bool
> :: LocalLabel -> LocalLabel -> Bool
$c> :: LocalLabel -> LocalLabel -> Bool
<= :: LocalLabel -> LocalLabel -> Bool
$c<= :: LocalLabel -> LocalLabel -> Bool
< :: LocalLabel -> LocalLabel -> Bool
$c< :: LocalLabel -> LocalLabel -> Bool
compare :: LocalLabel -> LocalLabel -> Ordering
$ccompare :: LocalLabel -> LocalLabel -> Ordering
Ord)
instance Outputable LocalLabel where
ppr :: LocalLabel -> SDoc
ppr (LocalLabel Word32
lbl) = forall doc. IsLine doc => String -> doc
text String
"lbl:" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr Word32
lbl
data BCInstr
= STKCHECK Word
| PUSH_L !Word16
| PUSH_LL !Word16 !Word16
| PUSH_LLL !Word16 !Word16 !Word16
| PUSH8 !Word16
| PUSH16 !Word16
| PUSH32 !Word16
| PUSH8_W !Word16
| PUSH16_W !Word16
| PUSH32_W !Word16
| PUSH_G Name
| PUSH_PRIMOP PrimOp
| PUSH_BCO (ProtoBCO Name)
| PUSH_ALTS (ProtoBCO Name)
| PUSH_ALTS_UNLIFTED (ProtoBCO Name) ArgRep
| PUSH_ALTS_TUPLE (ProtoBCO Name)
!TupleInfo
(ProtoBCO Name)
| PUSH_PAD8
| PUSH_PAD16
| PUSH_PAD32
| PUSH_UBX8 Literal
| PUSH_UBX16 Literal
| PUSH_UBX32 Literal
| PUSH_UBX Literal Word16
| PUSH_APPLY_N
| PUSH_APPLY_V
| PUSH_APPLY_F
| PUSH_APPLY_D
| PUSH_APPLY_L
| PUSH_APPLY_P
| PUSH_APPLY_PP
| PUSH_APPLY_PPP
| PUSH_APPLY_PPPP
| PUSH_APPLY_PPPPP
| PUSH_APPLY_PPPPPP
| SLIDE Word16 Word16
| ALLOC_AP !Word16
| ALLOC_AP_NOUPD !Word16
| ALLOC_PAP !Word16 !Word16
| MKAP !Word16 !Word16
| MKPAP !Word16 !Word16
| UNPACK !Word16
| PACK DataCon !Word16
| LABEL LocalLabel
| TESTLT_I Int LocalLabel
| TESTEQ_I Int LocalLabel
| TESTLT_W Word LocalLabel
| TESTEQ_W Word LocalLabel
| TESTLT_F Float LocalLabel
| TESTEQ_F Float LocalLabel
| TESTLT_D Double LocalLabel
| TESTEQ_D Double LocalLabel
| TESTLT_P Word16 LocalLabel
| TESTEQ_P Word16 LocalLabel
| CASEFAIL
| JMP LocalLabel
| CCALL Word16
(RemotePtr C_ffi_cif)
Word16
| SWIZZLE Word16
Word16
| ENTER
| RETURN
| RETURN_UNLIFTED ArgRep
| RETURN_TUPLE
| BRK_FUN Word16 Unique (RemotePtr CostCentre)
instance Outputable a => Outputable (ProtoBCO a) where
ppr :: ProtoBCO a -> SDoc
ppr (ProtoBCO { protoBCOName :: forall a. ProtoBCO a -> a
protoBCOName = a
name
, protoBCOInstrs :: forall a. ProtoBCO a -> [BCInstr]
protoBCOInstrs = [BCInstr]
instrs
, protoBCOBitmap :: forall a. ProtoBCO a -> [StgWord]
protoBCOBitmap = [StgWord]
bitmap
, protoBCOBitmapSize :: forall a. ProtoBCO a -> Word16
protoBCOBitmapSize = Word16
bsize
, protoBCOArity :: forall a. ProtoBCO a -> Int
protoBCOArity = Int
arity
, protoBCOExpr :: forall a. ProtoBCO a -> Either [CgStgAlt] CgStgRhs
protoBCOExpr = Either [CgStgAlt] CgStgRhs
origin
, protoBCOFFIs :: forall a. ProtoBCO a -> [FFIInfo]
protoBCOFFIs = [FFIInfo]
ffis })
= (forall doc. IsLine doc => String -> doc
text String
"ProtoBCO" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr a
name forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Char -> doc
char Char
'#' forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => Int -> doc
int Int
arity
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text (forall a. Show a => a -> String
show [FFIInfo]
ffis) forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
colon)
forall doc. IsDoc doc => doc -> doc -> doc
$$ Int -> SDoc -> SDoc
nest Int
3 (case Either [CgStgAlt] CgStgRhs
origin of
Left [CgStgAlt]
alts ->
forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall doc. IsLine doc => doc -> doc -> doc
(<+>) (forall doc. IsLine doc => Char -> doc
char Char
'{' forall a. a -> [a] -> [a]
: forall a. a -> [a]
repeat (forall doc. IsLine doc => Char -> doc
char Char
';'))
(forall a b. (a -> b) -> [a] -> [b]
map (forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgAlt pass -> SDoc
pprStgAltShort StgPprOpts
shortStgPprOpts) [CgStgAlt]
alts))
Right CgStgRhs
rhs ->
forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgRhs pass -> SDoc
pprStgRhsShort StgPprOpts
shortStgPprOpts CgStgRhs
rhs
)
forall doc. IsDoc doc => doc -> doc -> doc
$$ Int -> SDoc -> SDoc
nest Int
3 (forall doc. IsLine doc => String -> doc
text String
"bitmap: " forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text (forall a. Show a => a -> String
show Word16
bsize) forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr [StgWord]
bitmap)
forall doc. IsDoc doc => doc -> doc -> doc
$$ Int -> SDoc -> SDoc
nest Int
3 (forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [BCInstr]
instrs))
pprStgExprShort :: OutputablePass pass => StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExprShort :: forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExprShort StgPprOpts
_ (StgCase GenStgExpr pass
_expr BinderP pass
var AltType
_ty [GenStgAlt pass]
_alts) =
forall doc. IsLine doc => String -> doc
text String
"case of" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr BinderP pass
var
pprStgExprShort StgPprOpts
_ (StgLet XLet pass
_ GenStgBinding pass
bnd GenStgExpr pass
_) =
forall doc. IsLine doc => String -> doc
text String
"let" forall doc. IsLine doc => doc -> doc -> doc
<+> forall (pass :: StgPass).
OutputablePass pass =>
GenStgBinding pass -> SDoc
pprStgBindShort GenStgBinding pass
bnd forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"in ..."
pprStgExprShort StgPprOpts
_ (StgLetNoEscape XLetNoEscape pass
_ GenStgBinding pass
bnd GenStgExpr pass
_) =
forall doc. IsLine doc => String -> doc
text String
"let-no-escape" forall doc. IsLine doc => doc -> doc -> doc
<+> forall (pass :: StgPass).
OutputablePass pass =>
GenStgBinding pass -> SDoc
pprStgBindShort GenStgBinding pass
bnd forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"in ..."
pprStgExprShort StgPprOpts
opts (StgTick StgTickish
t GenStgExpr pass
e) = forall a. Outputable a => a -> SDoc
ppr StgTickish
t forall doc. IsLine doc => doc -> doc -> doc
<+> forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExprShort StgPprOpts
opts GenStgExpr pass
e
pprStgExprShort StgPprOpts
opts GenStgExpr pass
e = forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExpr StgPprOpts
opts GenStgExpr pass
e
pprStgBindShort :: OutputablePass pass => GenStgBinding pass -> SDoc
pprStgBindShort :: forall (pass :: StgPass).
OutputablePass pass =>
GenStgBinding pass -> SDoc
pprStgBindShort (StgNonRec BinderP pass
x GenStgRhs pass
_) =
forall a. Outputable a => a -> SDoc
ppr BinderP pass
x forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"= ..."
pprStgBindShort (StgRec [(BinderP pass, GenStgRhs pass)]
bs) =
forall doc. IsLine doc => Char -> doc
char Char
'{' forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr (forall a b. (a, b) -> a
fst (forall a. [a] -> a
head [(BinderP pass, GenStgRhs pass)]
bs)) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"= ...; ... }"
pprStgAltShort :: OutputablePass pass => StgPprOpts -> GenStgAlt pass -> SDoc
pprStgAltShort :: forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgAlt pass -> SDoc
pprStgAltShort StgPprOpts
opts GenStgAlt{alt_con :: forall (pass :: StgPass). GenStgAlt pass -> AltCon
alt_con=AltCon
con, alt_bndrs :: forall (pass :: StgPass). GenStgAlt pass -> [BinderP pass]
alt_bndrs=[BinderP pass]
args, alt_rhs :: forall (pass :: StgPass). GenStgAlt pass -> GenStgExpr pass
alt_rhs=GenStgExpr pass
expr} =
forall a. Outputable a => a -> SDoc
ppr AltCon
con forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
sep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [BinderP pass]
args) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"->" forall doc. IsLine doc => doc -> doc -> doc
<+> forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExprShort StgPprOpts
opts GenStgExpr pass
expr
pprStgRhsShort :: OutputablePass pass => StgPprOpts -> GenStgRhs pass -> SDoc
pprStgRhsShort :: forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgRhs pass -> SDoc
pprStgRhsShort StgPprOpts
opts (StgRhsClosure XRhsClosure pass
_ext CostCentreStack
_cc UpdateFlag
upd_flag [BinderP pass]
args GenStgExpr pass
body) =
SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => [doc] -> doc
hsep [ forall doc. IsLine doc => Char -> doc
char Char
'\\' forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr UpdateFlag
upd_flag, forall doc. IsLine doc => doc -> doc
brackets (forall a. Outputable a => [a] -> SDoc
interppSP [BinderP pass]
args) ])
Int
4 (forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgExpr pass -> SDoc
pprStgExprShort StgPprOpts
opts GenStgExpr pass
body)
pprStgRhsShort StgPprOpts
opts GenStgRhs pass
rhs = forall (pass :: StgPass).
OutputablePass pass =>
StgPprOpts -> GenStgRhs pass -> SDoc
pprStgRhs StgPprOpts
opts GenStgRhs pass
rhs
instance Outputable BCInstr where
ppr :: BCInstr -> SDoc
ppr (STKCHECK Word
n) = forall doc. IsLine doc => String -> doc
text String
"STKCHECK" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word
n
ppr (PUSH_L Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH_L " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH_LL Word16
o1 Word16
o2) = forall doc. IsLine doc => String -> doc
text String
"PUSH_LL " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
o1 forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
o2
ppr (PUSH_LLL Word16
o1 Word16
o2 Word16
o3) = forall doc. IsLine doc => String -> doc
text String
"PUSH_LLL" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
o1 forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
o2 forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
o3
ppr (PUSH8 Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH8 " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH16 Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH16 " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH32 Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH32 " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH8_W Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH8_W " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH16_W Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH16_W " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH32_W Word16
offset) = forall doc. IsLine doc => String -> doc
text String
"PUSH32_W " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH_G Name
nm) = forall doc. IsLine doc => String -> doc
text String
"PUSH_G " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Name
nm
ppr (PUSH_PRIMOP PrimOp
op) = forall doc. IsLine doc => String -> doc
text String
"PUSH_G " forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"GHC.PrimopWrappers."
forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr PrimOp
op
ppr (PUSH_BCO ProtoBCO Name
bco) = SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"PUSH_BCO") Int
2 (forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr (PUSH_ALTS ProtoBCO Name
bco) = SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"PUSH_ALTS") Int
2 (forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr (PUSH_ALTS_UNLIFTED ProtoBCO Name
bco ArgRep
pk) = SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"PUSH_ALTS_UNLIFTED" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr ArgRep
pk) Int
2 (forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr (PUSH_ALTS_TUPLE ProtoBCO Name
bco TupleInfo
tuple_info ProtoBCO Name
tuple_bco) =
SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"PUSH_ALTS_TUPLE" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr TupleInfo
tuple_info)
Int
2
(forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
tuple_bco SDoc -> SDoc -> SDoc
$+$ forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr BCInstr
PUSH_PAD8 = forall doc. IsLine doc => String -> doc
text String
"PUSH_PAD8"
ppr BCInstr
PUSH_PAD16 = forall doc. IsLine doc => String -> doc
text String
"PUSH_PAD16"
ppr BCInstr
PUSH_PAD32 = forall doc. IsLine doc => String -> doc
text String
"PUSH_PAD32"
ppr (PUSH_UBX8 Literal
lit) = forall doc. IsLine doc => String -> doc
text String
"PUSH_UBX8" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX16 Literal
lit) = forall doc. IsLine doc => String -> doc
text String
"PUSH_UBX16" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX32 Literal
lit) = forall doc. IsLine doc => String -> doc
text String
"PUSH_UBX32" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX Literal
lit Word16
nw) = forall doc. IsLine doc => String -> doc
text String
"PUSH_UBX" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => a -> SDoc
ppr Word16
nw) forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr BCInstr
PUSH_APPLY_N = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_N"
ppr BCInstr
PUSH_APPLY_V = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_V"
ppr BCInstr
PUSH_APPLY_F = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_F"
ppr BCInstr
PUSH_APPLY_D = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_D"
ppr BCInstr
PUSH_APPLY_L = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_L"
ppr BCInstr
PUSH_APPLY_P = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_P"
ppr BCInstr
PUSH_APPLY_PP = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_PP"
ppr BCInstr
PUSH_APPLY_PPP = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_PPP"
ppr BCInstr
PUSH_APPLY_PPPP = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_PPPP"
ppr BCInstr
PUSH_APPLY_PPPPP = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_PPPPP"
ppr BCInstr
PUSH_APPLY_PPPPPP = forall doc. IsLine doc => String -> doc
text String
"PUSH_APPLY_PPPPPP"
ppr (SLIDE Word16
n Word16
d) = forall doc. IsLine doc => String -> doc
text String
"SLIDE " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
n forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
d
ppr (ALLOC_AP Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"ALLOC_AP " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (ALLOC_AP_NOUPD Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"ALLOC_AP_NOUPD " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (ALLOC_PAP Word16
arity Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"ALLOC_PAP " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
arity forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (MKAP Word16
offset Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"MKAP " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"words,"
forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"stkoff"
ppr (MKPAP Word16
offset Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"MKPAP " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"words,"
forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
offset forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"stkoff"
ppr (UNPACK Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"UNPACK " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (PACK DataCon
dcon Word16
sz) = forall doc. IsLine doc => String -> doc
text String
"PACK " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr DataCon
dcon forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (LABEL LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
colon
ppr (TESTLT_I Int
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTLT_I" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Int -> doc
int Int
i forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTEQ_I Int
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTEQ_I" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Int -> doc
int Int
i forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTLT_W Word
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTLT_W" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Int -> doc
int (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
i) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTEQ_W Word
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTEQ_W" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Int -> doc
int (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
i) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTLT_F Float
f LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTLT_F" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Float -> doc
float Float
f forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTEQ_F Float
f LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTEQ_F" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Float -> doc
float Float
f forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTLT_D Double
d LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTLT_D" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Double -> doc
double Double
d forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTEQ_D Double
d LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTEQ_D" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => Double -> doc
double Double
d forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTLT_P Word16
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTLT_P" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
i forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (TESTEQ_P Word16
i LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"TESTEQ_P" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
i forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"__" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr BCInstr
CASEFAIL = forall doc. IsLine doc => String -> doc
text String
"CASEFAIL"
ppr (JMP LocalLabel
lab) = forall doc. IsLine doc => String -> doc
text String
"JMP" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr LocalLabel
lab
ppr (CCALL Word16
off RemotePtr C_ffi_cif
marshal_addr Word16
flags) = forall doc. IsLine doc => String -> doc
text String
"CCALL " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
off
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"marshal code at"
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text (forall a. Show a => a -> String
show RemotePtr C_ffi_cif
marshal_addr)
forall doc. IsLine doc => doc -> doc -> doc
<+> (case Word16
flags of
Word16
0x1 -> forall doc. IsLine doc => String -> doc
text String
"(interruptible)"
Word16
0x2 -> forall doc. IsLine doc => String -> doc
text String
"(unsafe)"
Word16
_ -> forall doc. IsOutput doc => doc
empty)
ppr (SWIZZLE Word16
stkoff Word16
n) = forall doc. IsLine doc => String -> doc
text String
"SWIZZLE " forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"stkoff" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
stkoff
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"by" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
n
ppr BCInstr
ENTER = forall doc. IsLine doc => String -> doc
text String
"ENTER"
ppr BCInstr
RETURN = forall doc. IsLine doc => String -> doc
text String
"RETURN"
ppr (RETURN_UNLIFTED ArgRep
pk) = forall doc. IsLine doc => String -> doc
text String
"RETURN_UNLIFTED " forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr ArgRep
pk
ppr (BCInstr
RETURN_TUPLE) = forall doc. IsLine doc => String -> doc
text String
"RETURN_TUPLE"
ppr (BRK_FUN Word16
index Unique
uniq RemotePtr CostCentre
_cc) = forall doc. IsLine doc => String -> doc
text String
"BRK_FUN" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Word16
index forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Unique
uniq forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"<cc>"
protoBCOStackUse :: ProtoBCO a -> Word
protoBCOStackUse :: forall a. ProtoBCO a -> Word
protoBCOStackUse ProtoBCO a
bco = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map BCInstr -> Word
bciStackUse (forall a. ProtoBCO a -> [BCInstr]
protoBCOInstrs ProtoBCO a
bco))
bciStackUse :: BCInstr -> Word
bciStackUse :: BCInstr -> Word
bciStackUse STKCHECK{} = Word
0
bciStackUse PUSH_L{} = Word
1
bciStackUse PUSH_LL{} = Word
2
bciStackUse PUSH_LLL{} = Word
3
bciStackUse PUSH8{} = Word
1
bciStackUse PUSH16{} = Word
1
bciStackUse PUSH32{} = Word
1
bciStackUse PUSH8_W{} = Word
1
bciStackUse PUSH16_W{} = Word
1
bciStackUse PUSH32_W{} = Word
1
bciStackUse PUSH_G{} = Word
1
bciStackUse PUSH_PRIMOP{} = Word
1
bciStackUse PUSH_BCO{} = Word
1
bciStackUse (PUSH_ALTS ProtoBCO Name
bco) = Word
2 forall a. Num a => a -> a -> a
+
Word
3 forall a. Num a => a -> a -> a
+ forall a. ProtoBCO a -> Word
protoBCOStackUse ProtoBCO Name
bco
bciStackUse (PUSH_ALTS_UNLIFTED ProtoBCO Name
bco ArgRep
_) = Word
2 forall a. Num a => a -> a -> a
+
Word
4 forall a. Num a => a -> a -> a
+ forall a. ProtoBCO a -> Word
protoBCOStackUse ProtoBCO Name
bco
bciStackUse (PUSH_ALTS_TUPLE ProtoBCO Name
bco TupleInfo
info ProtoBCO Name
_) =
Word
1 forall a. Num a => a -> a -> a
+
Word
7 forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral (TupleInfo -> WordOff
tupleSize TupleInfo
info) forall a. Num a => a -> a -> a
+ forall a. ProtoBCO a -> Word
protoBCOStackUse ProtoBCO Name
bco
bciStackUse (BCInstr
PUSH_PAD8) = Word
1
bciStackUse (BCInstr
PUSH_PAD16) = Word
1
bciStackUse (BCInstr
PUSH_PAD32) = Word
1
bciStackUse (PUSH_UBX8 Literal
_) = Word
1
bciStackUse (PUSH_UBX16 Literal
_) = Word
1
bciStackUse (PUSH_UBX32 Literal
_) = Word
1
bciStackUse (PUSH_UBX Literal
_ Word16
nw) = forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
nw
bciStackUse PUSH_APPLY_N{} = Word
1
bciStackUse PUSH_APPLY_V{} = Word
1
bciStackUse PUSH_APPLY_F{} = Word
1
bciStackUse PUSH_APPLY_D{} = Word
1
bciStackUse PUSH_APPLY_L{} = Word
1
bciStackUse PUSH_APPLY_P{} = Word
1
bciStackUse PUSH_APPLY_PP{} = Word
1
bciStackUse PUSH_APPLY_PPP{} = Word
1
bciStackUse PUSH_APPLY_PPPP{} = Word
1
bciStackUse PUSH_APPLY_PPPPP{} = Word
1
bciStackUse PUSH_APPLY_PPPPPP{} = Word
1
bciStackUse ALLOC_AP{} = Word
1
bciStackUse ALLOC_AP_NOUPD{} = Word
1
bciStackUse ALLOC_PAP{} = Word
1
bciStackUse (UNPACK Word16
sz) = forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
sz
bciStackUse LABEL{} = Word
0
bciStackUse TESTLT_I{} = Word
0
bciStackUse TESTEQ_I{} = Word
0
bciStackUse TESTLT_W{} = Word
0
bciStackUse TESTEQ_W{} = Word
0
bciStackUse TESTLT_F{} = Word
0
bciStackUse TESTEQ_F{} = Word
0
bciStackUse TESTLT_D{} = Word
0
bciStackUse TESTEQ_D{} = Word
0
bciStackUse TESTLT_P{} = Word
0
bciStackUse TESTEQ_P{} = Word
0
bciStackUse CASEFAIL{} = Word
0
bciStackUse JMP{} = Word
0
bciStackUse ENTER{} = Word
0
bciStackUse RETURN{} = Word
0
bciStackUse RETURN_UNLIFTED{} = Word
1
bciStackUse RETURN_TUPLE{} = Word
1
bciStackUse CCALL{} = Word
0
bciStackUse SWIZZLE{} = Word
0
bciStackUse BRK_FUN{} = Word
0
bciStackUse SLIDE{} = Word
0
bciStackUse MKAP{} = Word
0
bciStackUse MKPAP{} = Word
0
bciStackUse PACK{} = Word
1