{-# LANGUAGE CPP, MagicHash #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
module ByteCodeInstr (
BCInstr(..), ProtoBCO(..), bciStackUse,
) where
#include "HsVersions.h"
import GhcPrelude
import ByteCodeTypes
import GHCi.RemoteTypes
import GHCi.FFI (C_ffi_cif)
import GHC.StgToCmm.Layout ( ArgRep(..) )
import PprCore
import Outputable
import FastString
import Name
import Unique
import Id
import CoreSyn
import Literal
import DataCon
import VarSet
import PrimOp
import SMRep
import Data.Word
import GHC.Stack.CCS (CostCentre)
data ProtoBCO a
= ProtoBCO {
ProtoBCO a -> a
protoBCOName :: a,
ProtoBCO a -> [BCInstr]
protoBCOInstrs :: [BCInstr],
ProtoBCO a -> [StgWord]
protoBCOBitmap :: [StgWord],
ProtoBCO a -> Word16
protoBCOBitmapSize :: Word16,
ProtoBCO a -> Int
protoBCOArity :: Int,
ProtoBCO a -> Either [AnnAlt Id DVarSet] (AnnExpr Id DVarSet)
protoBCOExpr :: Either [AnnAlt Id DVarSet] (AnnExpr Id DVarSet),
ProtoBCO a -> [FFIInfo]
protoBCOFFIs :: [FFIInfo]
}
type LocalLabel = Word16
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_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_UBX ArgRep
| 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 [AnnAlt Id DVarSet] (AnnExpr Id DVarSet)
protoBCOExpr = Either [AnnAlt Id DVarSet] (AnnExpr Id DVarSet)
origin
, protoBCOFFIs :: forall a. ProtoBCO a -> [FFIInfo]
protoBCOFFIs = [FFIInfo]
ffis })
= (String -> SDoc
text String
"ProtoBCO" SDoc -> SDoc -> SDoc
<+> a -> SDoc
forall a. Outputable a => a -> SDoc
ppr a
name SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'#' SDoc -> SDoc -> SDoc
<> Int -> SDoc
int Int
arity
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text ([FFIInfo] -> String
forall a. Show a => a -> String
show [FFIInfo]
ffis) SDoc -> SDoc -> SDoc
<> SDoc
colon)
SDoc -> SDoc -> SDoc
$$ Int -> SDoc -> SDoc
nest Int
3 (case Either [AnnAlt Id DVarSet] (AnnExpr Id DVarSet)
origin of
Left [AnnAlt Id DVarSet]
alts -> [SDoc] -> SDoc
vcat ((SDoc -> SDoc -> SDoc) -> [SDoc] -> [SDoc] -> [SDoc]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith SDoc -> SDoc -> SDoc
(<+>) (Char -> SDoc
char Char
'{' SDoc -> [SDoc] -> [SDoc]
forall a. a -> [a] -> [a]
: SDoc -> [SDoc]
forall a. a -> [a]
repeat (Char -> SDoc
char Char
';'))
((AnnAlt Id DVarSet -> SDoc) -> [AnnAlt Id DVarSet] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (CoreAlt -> SDoc
pprCoreAltShort(CoreAlt -> SDoc)
-> (AnnAlt Id DVarSet -> CoreAlt) -> AnnAlt Id DVarSet -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AnnAlt Id DVarSet -> CoreAlt
forall bndr annot. AnnAlt bndr annot -> Alt bndr
deAnnAlt) [AnnAlt Id DVarSet]
alts)) SDoc -> SDoc -> SDoc
<+> Char -> SDoc
char Char
'}'
Right AnnExpr Id DVarSet
rhs -> CoreExpr -> SDoc
pprCoreExprShort (AnnExpr Id DVarSet -> CoreExpr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr Id DVarSet
rhs))
SDoc -> SDoc -> SDoc
$$ Int -> SDoc -> SDoc
nest Int
3 (String -> SDoc
text String
"bitmap: " SDoc -> SDoc -> SDoc
<+> String -> SDoc
text (Word16 -> String
forall a. Show a => a -> String
show Word16
bsize) SDoc -> SDoc -> SDoc
<+> [StgWord] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [StgWord]
bitmap)
SDoc -> SDoc -> SDoc
$$ Int -> SDoc -> SDoc
nest Int
3 ([SDoc] -> SDoc
vcat ((BCInstr -> SDoc) -> [BCInstr] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map BCInstr -> SDoc
forall a. Outputable a => a -> SDoc
ppr [BCInstr]
instrs))
pprCoreExprShort :: CoreExpr -> SDoc
pprCoreExprShort :: CoreExpr -> SDoc
pprCoreExprShort expr :: CoreExpr
expr@(Lam Id
_ CoreExpr
_)
= let
([Id]
bndrs, CoreExpr
_) = CoreExpr -> ([Id], CoreExpr)
forall b. Expr b -> ([b], Expr b)
collectBinders CoreExpr
expr
in
Char -> SDoc
char Char
'\\' SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep ((Id -> SDoc) -> [Id] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (BindingSite -> Id -> SDoc
forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LambdaBind) [Id]
bndrs) SDoc -> SDoc -> SDoc
<+> SDoc
arrow SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"..."
pprCoreExprShort (Case CoreExpr
_expr Id
var Type
_ty [CoreAlt]
_alts)
= String -> SDoc
text String
"case of" SDoc -> SDoc -> SDoc
<+> Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
var
pprCoreExprShort (Let (NonRec Id
x CoreExpr
_) CoreExpr
_) = String -> SDoc
text String
"let" SDoc -> SDoc -> SDoc
<+> Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
x SDoc -> SDoc -> SDoc
<+> PtrString -> SDoc
ptext (String -> PtrString
sLit (String
"= ... in ..."))
pprCoreExprShort (Let (Rec [(Id, CoreExpr)]
bs) CoreExpr
_) = String -> SDoc
text String
"let {" SDoc -> SDoc -> SDoc
<+> Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr ((Id, CoreExpr) -> Id
forall a b. (a, b) -> a
fst ([(Id, CoreExpr)] -> (Id, CoreExpr)
forall a. [a] -> a
head [(Id, CoreExpr)]
bs)) SDoc -> SDoc -> SDoc
<+> PtrString -> SDoc
ptext (String -> PtrString
sLit (String
"= ...; ... } in ..."))
pprCoreExprShort (Tick Tickish Id
t CoreExpr
e) = Tickish Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Tickish Id
t SDoc -> SDoc -> SDoc
<+> CoreExpr -> SDoc
pprCoreExprShort CoreExpr
e
pprCoreExprShort (Cast CoreExpr
e Coercion
_) = CoreExpr -> SDoc
pprCoreExprShort CoreExpr
e SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"`cast` T"
pprCoreExprShort CoreExpr
e = CoreExpr -> SDoc
forall b. OutputableBndr b => Expr b -> SDoc
pprCoreExpr CoreExpr
e
pprCoreAltShort :: CoreAlt -> SDoc
pprCoreAltShort :: CoreAlt -> SDoc
pprCoreAltShort (AltCon
con, [Id]
args, CoreExpr
expr) = AltCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr AltCon
con SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep ((Id -> SDoc) -> [Id] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Id]
args) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"->" SDoc -> SDoc -> SDoc
<+> CoreExpr -> SDoc
pprCoreExprShort CoreExpr
expr
instance Outputable BCInstr where
ppr :: BCInstr -> SDoc
ppr (STKCHECK Word
n) = String -> SDoc
text String
"STKCHECK" SDoc -> SDoc -> SDoc
<+> Word -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word
n
ppr (PUSH_L Word16
offset) = String -> SDoc
text String
"PUSH_L " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH_LL Word16
o1 Word16
o2) = String -> SDoc
text String
"PUSH_LL " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
o1 SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
o2
ppr (PUSH_LLL Word16
o1 Word16
o2 Word16
o3) = String -> SDoc
text String
"PUSH_LLL" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
o1 SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
o2 SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
o3
ppr (PUSH8 Word16
offset) = String -> SDoc
text String
"PUSH8 " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH16 Word16
offset) = String -> SDoc
text String
"PUSH16 " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH32 Word16
offset) = String -> SDoc
text String
"PUSH32 " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH8_W Word16
offset) = String -> SDoc
text String
"PUSH8_W " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH16_W Word16
offset) = String -> SDoc
text String
"PUSH16_W " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH32_W Word16
offset) = String -> SDoc
text String
"PUSH32_W " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset
ppr (PUSH_G Name
nm) = String -> SDoc
text String
"PUSH_G " SDoc -> SDoc -> SDoc
<+> Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
nm
ppr (PUSH_PRIMOP PrimOp
op) = String -> SDoc
text String
"PUSH_G " SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"GHC.PrimopWrappers."
SDoc -> SDoc -> SDoc
<> PrimOp -> SDoc
forall a. Outputable a => a -> SDoc
ppr PrimOp
op
ppr (PUSH_BCO ProtoBCO Name
bco) = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"PUSH_BCO") Int
2 (ProtoBCO Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr (PUSH_ALTS ProtoBCO Name
bco) = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"PUSH_ALTS") Int
2 (ProtoBCO Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr (PUSH_ALTS_UNLIFTED ProtoBCO Name
bco ArgRep
pk) = SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"PUSH_ALTS_UNLIFTED" SDoc -> SDoc -> SDoc
<+> ArgRep -> SDoc
forall a. Outputable a => a -> SDoc
ppr ArgRep
pk) Int
2 (ProtoBCO Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr ProtoBCO Name
bco)
ppr BCInstr
PUSH_PAD8 = String -> SDoc
text String
"PUSH_PAD8"
ppr BCInstr
PUSH_PAD16 = String -> SDoc
text String
"PUSH_PAD16"
ppr BCInstr
PUSH_PAD32 = String -> SDoc
text String
"PUSH_PAD32"
ppr (PUSH_UBX8 Literal
lit) = String -> SDoc
text String
"PUSH_UBX8" SDoc -> SDoc -> SDoc
<+> Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX16 Literal
lit) = String -> SDoc
text String
"PUSH_UBX16" SDoc -> SDoc -> SDoc
<+> Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX32 Literal
lit) = String -> SDoc
text String
"PUSH_UBX32" SDoc -> SDoc -> SDoc
<+> Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr (PUSH_UBX Literal
lit Word16
nw) = String -> SDoc
text String
"PUSH_UBX" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
nw) SDoc -> SDoc -> SDoc
<+> Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr BCInstr
PUSH_APPLY_N = String -> SDoc
text String
"PUSH_APPLY_N"
ppr BCInstr
PUSH_APPLY_V = String -> SDoc
text String
"PUSH_APPLY_V"
ppr BCInstr
PUSH_APPLY_F = String -> SDoc
text String
"PUSH_APPLY_F"
ppr BCInstr
PUSH_APPLY_D = String -> SDoc
text String
"PUSH_APPLY_D"
ppr BCInstr
PUSH_APPLY_L = String -> SDoc
text String
"PUSH_APPLY_L"
ppr BCInstr
PUSH_APPLY_P = String -> SDoc
text String
"PUSH_APPLY_P"
ppr BCInstr
PUSH_APPLY_PP = String -> SDoc
text String
"PUSH_APPLY_PP"
ppr BCInstr
PUSH_APPLY_PPP = String -> SDoc
text String
"PUSH_APPLY_PPP"
ppr BCInstr
PUSH_APPLY_PPPP = String -> SDoc
text String
"PUSH_APPLY_PPPP"
ppr BCInstr
PUSH_APPLY_PPPPP = String -> SDoc
text String
"PUSH_APPLY_PPPPP"
ppr BCInstr
PUSH_APPLY_PPPPPP = String -> SDoc
text String
"PUSH_APPLY_PPPPPP"
ppr (SLIDE Word16
n Word16
d) = String -> SDoc
text String
"SLIDE " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
n SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
d
ppr (ALLOC_AP Word16
sz) = String -> SDoc
text String
"ALLOC_AP " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (ALLOC_AP_NOUPD Word16
sz) = String -> SDoc
text String
"ALLOC_AP_NOUPD " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (ALLOC_PAP Word16
arity Word16
sz) = String -> SDoc
text String
"ALLOC_PAP " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
arity SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (MKAP Word16
offset Word16
sz) = String -> SDoc
text String
"MKAP " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"words,"
SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"stkoff"
ppr (MKPAP Word16
offset Word16
sz) = String -> SDoc
text String
"MKPAP " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"words,"
SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
offset SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"stkoff"
ppr (UNPACK Word16
sz) = String -> SDoc
text String
"UNPACK " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (PACK DataCon
dcon Word16
sz) = String -> SDoc
text String
"PACK " SDoc -> SDoc -> SDoc
<+> DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
dcon SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
sz
ppr (LABEL Word16
lab) = String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab SDoc -> SDoc -> SDoc
<> SDoc
colon
ppr (TESTLT_I Int
i Word16
lab) = String -> SDoc
text String
"TESTLT_I" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int Int
i SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTEQ_I Int
i Word16
lab) = String -> SDoc
text String
"TESTEQ_I" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int Int
i SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTLT_W Word
i Word16
lab) = String -> SDoc
text String
"TESTLT_W" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int (Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
i) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTEQ_W Word
i Word16
lab) = String -> SDoc
text String
"TESTEQ_W" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
int (Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
i) SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTLT_F Float
f Word16
lab) = String -> SDoc
text String
"TESTLT_F" SDoc -> SDoc -> SDoc
<+> Float -> SDoc
float Float
f SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTEQ_F Float
f Word16
lab) = String -> SDoc
text String
"TESTEQ_F" SDoc -> SDoc -> SDoc
<+> Float -> SDoc
float Float
f SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTLT_D Double
d Word16
lab) = String -> SDoc
text String
"TESTLT_D" SDoc -> SDoc -> SDoc
<+> Double -> SDoc
double Double
d SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTEQ_D Double
d Word16
lab) = String -> SDoc
text String
"TESTEQ_D" SDoc -> SDoc -> SDoc
<+> Double -> SDoc
double Double
d SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTLT_P Word16
i Word16
lab) = String -> SDoc
text String
"TESTLT_P" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
i SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (TESTEQ_P Word16
i Word16
lab) = String -> SDoc
text String
"TESTEQ_P" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
i SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"__" SDoc -> SDoc -> SDoc
<> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr BCInstr
CASEFAIL = String -> SDoc
text String
"CASEFAIL"
ppr (JMP Word16
lab) = String -> SDoc
text String
"JMP" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
lab
ppr (CCALL Word16
off RemotePtr C_ffi_cif
marshall_addr Word16
flags) = String -> SDoc
text String
"CCALL " SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
off
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"marshall code at"
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text (RemotePtr C_ffi_cif -> String
forall a. Show a => a -> String
show RemotePtr C_ffi_cif
marshall_addr)
SDoc -> SDoc -> SDoc
<+> (case Word16
flags of
Word16
0x1 -> String -> SDoc
text String
"(interruptible)"
Word16
0x2 -> String -> SDoc
text String
"(unsafe)"
Word16
_ -> SDoc
empty)
ppr (SWIZZLE Word16
stkoff Word16
n) = String -> SDoc
text String
"SWIZZLE " SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"stkoff" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
stkoff
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"by" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
n
ppr BCInstr
ENTER = String -> SDoc
text String
"ENTER"
ppr BCInstr
RETURN = String -> SDoc
text String
"RETURN"
ppr (RETURN_UBX ArgRep
pk) = String -> SDoc
text String
"RETURN_UBX " SDoc -> SDoc -> SDoc
<+> ArgRep -> SDoc
forall a. Outputable a => a -> SDoc
ppr ArgRep
pk
ppr (BRK_FUN Word16
index Unique
uniq RemotePtr CostCentre
_cc) = String -> SDoc
text String
"BRK_FUN" SDoc -> SDoc -> SDoc
<+> Word16 -> SDoc
forall a. Outputable a => a -> SDoc
ppr Word16
index SDoc -> SDoc -> SDoc
<+> Unique -> SDoc
forall a. Outputable a => a -> SDoc
ppr Unique
uniq SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"<cc>"
protoBCOStackUse :: ProtoBCO a -> Word
protoBCOStackUse :: ProtoBCO a -> Word
protoBCOStackUse ProtoBCO a
bco = [Word] -> Word
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ((BCInstr -> Word) -> [BCInstr] -> [Word]
forall a b. (a -> b) -> [a] -> [b]
map BCInstr -> Word
bciStackUse (ProtoBCO a -> [BCInstr]
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 Word -> Word -> Word
forall a. Num a => a -> a -> a
+ ProtoBCO Name -> Word
forall a. ProtoBCO a -> Word
protoBCOStackUse ProtoBCO Name
bco
bciStackUse (PUSH_ALTS_UNLIFTED ProtoBCO Name
bco ArgRep
_) = Word
2 Word -> Word -> Word
forall a. Num a => a -> a -> a
+ ProtoBCO Name -> Word
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) = Word16 -> Word
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) = Word16 -> Word
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_UBX{} = 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