{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE MultiWayIf #-}

-- disable this warning because of all the lambdas matching on primops'
-- arguments.
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}

module GHC.StgToJS.Prim
  ( genPrim
  )
where

import GHC.Prelude

import GHC.JS.Syntax hiding (JUOp (..))
import GHC.JS.Make

import GHC.StgToJS.Heap
import GHC.StgToJS.Types
import GHC.StgToJS.Profiling
import GHC.StgToJS.Regs

import GHC.Core.Type

import GHC.Builtin.PrimOps
import GHC.Tc.Utils.TcType (isBoolTy)
import GHC.Utils.Encoding (zEncodeString)

import GHC.Data.FastString
import GHC.Utils.Outputable (renderWithContext, defaultSDocContext, ppr)


genPrim :: Bool     -- ^ Profiling (cost-centres) enabled
        -> Bool     -- ^ Array bounds-checking enabled
        -> Type
        -> PrimOp   -- ^ the primitive operation
        -> [JExpr]  -- ^ where to store the result
        -> [JExpr]  -- ^ arguments
        -> PrimRes
genPrim :: Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
op = case PrimOp
op of
  PrimOp
CharGtOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>. JExpr
y)
  PrimOp
CharGeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=. JExpr
y)
  PrimOp
CharEqOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
CharNeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)
  PrimOp
CharLtOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<. JExpr
y)
  PrimOp
CharLeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=. JExpr
y)
  PrimOp
OrdOp           -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x

  PrimOp
Int8ToWord8Op   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 JExpr
x
  PrimOp
Word8ToInt8Op   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 JExpr
x
  PrimOp
Int16ToWord16Op -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 JExpr
x
  PrimOp
Word16ToInt16Op -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 JExpr
x
  PrimOp
Int32ToWord32Op -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
zero_
  PrimOp
Word32ToInt32Op -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
x

------------------------------ Int ----------------------------------------------

  PrimOp
IntAddOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y)
  PrimOp
IntSubOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
IntMulOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$mulInt32" [JExpr
x, JExpr
y]
  PrimOp
IntMul2Op       -> \[JExpr
c,JExpr
hr,JExpr
lr] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
c,JExpr
hr,JExpr
lr] FastString
"h$hs_timesInt2" [JExpr
x, JExpr
y]
  PrimOp
IntMulMayOfloOp -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
tmp -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                            [ JExpr
tmp JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y
                                            , JExpr
r   JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if01 (JExpr
tmp JExpr -> JExpr -> JExpr
.===. JExpr -> JExpr
toI32 JExpr
tmp)
                                            ]
  PrimOp
IntQuotOp       -> \[JExpr
r]   [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
  PrimOp
IntRemOp        -> \[JExpr
r]   [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
x JExpr
y
  PrimOp
IntQuotRemOp    -> \[JExpr
q,JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                            [ JExpr
q JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
                                            , JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
`Sub` (JExpr -> JExpr -> JExpr
Mul JExpr
y JExpr
q)
                                            ]
  PrimOp
IntAndOp        -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BAnd JExpr
x JExpr
y
  PrimOp
IntOrOp         -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BOr  JExpr
x JExpr
y
  PrimOp
IntXorOp        -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BXor JExpr
x JExpr
y
  PrimOp
IntNotOp        -> \[JExpr
r] [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
BNot JExpr
x

  PrimOp
IntNegOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr
Negate JExpr
x)
-- add with carry: overflow == 0 iff no overflow
  PrimOp
IntAddCOp       -> \[JExpr
r,JExpr
overf] [JExpr
x,JExpr
y] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
rt -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
rt    JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y
        , JExpr
r     JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
rt
        , JExpr
overf JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
r JExpr -> JExpr -> JExpr
.!=. JExpr
rt)
        ]
  PrimOp
IntSubCOp       -> \[JExpr
r,JExpr
overf] [JExpr
x,JExpr
y] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
rt -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
rt    JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y
        , JExpr
r     JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
rt
        , JExpr
overf JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
r JExpr -> JExpr -> JExpr
.!=. JExpr
rt)
        ]
  PrimOp
IntGtOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>. JExpr
y)
  PrimOp
IntGeOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=. JExpr
y)
  PrimOp
IntEqOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
IntNeOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10(JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)
  PrimOp
IntLtOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<. JExpr
y)
  PrimOp
IntLeOp           -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=. JExpr
y)
  PrimOp
ChrOp             -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntToWordOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
0
  PrimOp
IntToFloatOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntToDoubleOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntSllOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
y
  PrimOp
IntSraOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>. JExpr
y
  PrimOp
IntSrlOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
y)

------------------------------ Int8 ---------------------------------------------

  PrimOp
Int8ToIntOp       -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntToInt8Op       -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 JExpr
x
  PrimOp
Int8NegOp         -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr
Negate JExpr
x)
  PrimOp
Int8AddOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y)
  PrimOp
Int8SubOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
Int8MulOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y)
  PrimOp
Int8QuotOp        -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (Int -> JExpr -> JExpr -> JExpr
quotShortInt Int
8 JExpr
x JExpr
y)
  PrimOp
Int8RemOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (Int -> JExpr -> JExpr -> JExpr
remShortInt Int
8 JExpr
x JExpr
y)
  PrimOp
Int8QuotRemOp     -> \[JExpr
r1,JExpr
r2] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (Int -> JExpr -> JExpr -> JExpr
quotShortInt Int
8 JExpr
x JExpr
y)
                                                , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (Int -> JExpr -> JExpr -> JExpr
remShortInt Int
8 JExpr
x JExpr
y)
                                                ]
  PrimOp
Int8EqOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
Int8GeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)) JExpr -> JExpr -> JExpr
.>=. (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)))
  PrimOp
Int8GtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)) JExpr -> JExpr -> JExpr
.>.  (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)))
  PrimOp
Int8LeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)) JExpr -> JExpr -> JExpr
.<=. (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)))
  PrimOp
Int8LtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)) JExpr -> JExpr -> JExpr
.<.  (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24)))
  PrimOp
Int8NeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)

  PrimOp
Int8SraOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>. JExpr
i
  PrimOp
Int8SrlOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr
mask8 JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
i)
  PrimOp
Int8SllOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8 (JExpr -> JExpr
mask8 (JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
i))

------------------------------ Word8 --------------------------------------------

  PrimOp
Word8ToWordOp      -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 JExpr
x
  PrimOp
WordToWord8Op      -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 JExpr
x

  PrimOp
Word8AddOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 (JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y)
  PrimOp
Word8SubOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
Word8MulOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 (JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y)
  PrimOp
Word8QuotOp        -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
  PrimOp
Word8RemOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
x JExpr
y
  PrimOp
Word8QuotRemOp     -> \[JExpr
r1,JExpr
r2] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                  [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
                                                  , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
x JExpr
y
                                                  ]
  PrimOp
Word8EqOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
Word8GeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=. JExpr
y)
  PrimOp
Word8GtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>. JExpr
y)
  PrimOp
Word8LeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=. JExpr
y)
  PrimOp
Word8LtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<. JExpr
y)
  PrimOp
Word8NeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)

  PrimOp
Word8AndOp         -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BAnd JExpr
x JExpr
y
  PrimOp
Word8OrOp          -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BOr  JExpr
x JExpr
y
  PrimOp
Word8XorOp         -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BXor JExpr
x JExpr
y
  PrimOp
Word8NotOp         -> \[JExpr
r] [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BXor JExpr
x (Integer -> JExpr
Int Integer
0xff)

  PrimOp
Word8SllOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8 (JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
i)
  PrimOp
Word8SrlOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
i

------------------------------ Int16 -------------------------------------------

  PrimOp
Int16ToIntOp       -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntToInt16Op       -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 JExpr
x

  PrimOp
Int16NegOp         -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr -> JExpr
Negate JExpr
x)
  PrimOp
Int16AddOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y)
  PrimOp
Int16SubOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
Int16MulOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y)
  PrimOp
Int16QuotOp        -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (Int -> JExpr -> JExpr -> JExpr
quotShortInt Int
16 JExpr
x JExpr
y)
  PrimOp
Int16RemOp         -> \[JExpr
r] [JExpr
x,JExpr
y]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (Int -> JExpr -> JExpr -> JExpr
remShortInt Int
16 JExpr
x JExpr
y)
  PrimOp
Int16QuotRemOp     -> \[JExpr
r1,JExpr
r2] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (Int -> JExpr -> JExpr -> JExpr
quotShortInt Int
16 JExpr
x JExpr
y)
                                                , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (Int -> JExpr -> JExpr -> JExpr
remShortInt Int
16 JExpr
x JExpr
y)
                                                ]
  PrimOp
Int16EqOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
Int16GeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)) JExpr -> JExpr -> JExpr
.>=. (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)))
  PrimOp
Int16GtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)) JExpr -> JExpr -> JExpr
.>.  (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)))
  PrimOp
Int16LeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)) JExpr -> JExpr -> JExpr
.<=. (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)))
  PrimOp
Int16LtOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)) JExpr -> JExpr -> JExpr
.<.  (JExpr
y JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
16)))
  PrimOp
Int16NeOp          -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)

  PrimOp
Int16SraOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>. JExpr
i
  PrimOp
Int16SrlOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr -> JExpr
mask16 JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
i)
  PrimOp
Int16SllOp         -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 (JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
i)

------------------------------ Word16 ------------------------------------------

  PrimOp
Word16ToWordOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
WordToWord16Op     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 JExpr
x

  PrimOp
Word16AddOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 (JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y)
  PrimOp
Word16SubOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
Word16MulOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 (JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y)
  PrimOp
Word16QuotOp       -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
  PrimOp
Word16RemOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
x JExpr
y
  PrimOp
Word16QuotRemOp    -> \[JExpr
r1,JExpr
r2] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y)
                                                , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
x JExpr
y
                                                ]
  PrimOp
Word16EqOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
Word16GeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=. JExpr
y)
  PrimOp
Word16GtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>. JExpr
y)
  PrimOp
Word16LeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=. JExpr
y)
  PrimOp
Word16LtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<. JExpr
y)
  PrimOp
Word16NeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)

  PrimOp
Word16AndOp        -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BAnd JExpr
x JExpr
y
  PrimOp
Word16OrOp         -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BOr  JExpr
x JExpr
y
  PrimOp
Word16XorOp        -> \[JExpr
r] [JExpr
x,JExpr
y]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BXor JExpr
x JExpr
y
  PrimOp
Word16NotOp        -> \[JExpr
r] [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BXor JExpr
x (Integer -> JExpr
Int Integer
0xffff)

  PrimOp
Word16SllOp        -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 (JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
i)
  PrimOp
Word16SrlOp        -> \[JExpr
r] [JExpr
x,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
i

------------------------------ Int32 --------------------------------------------

  PrimOp
Int32ToIntOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
IntToInt32Op       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x

  PrimOp
Int32NegOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntNegOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32AddOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntAddOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32SubOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntSubOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32MulOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntMulOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32QuotOp        -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntQuotOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32RemOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntRemOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32QuotRemOp     -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntQuotRemOp [JExpr]
rs [JExpr]
xs

  PrimOp
Int32EqOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntEqOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32GeOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntGeOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32GtOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntGtOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32LeOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntLeOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32LtOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntLtOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32NeOp          -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntNeOp [JExpr]
rs [JExpr]
xs

  PrimOp
Int32SraOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntSraOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32SrlOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntSrlOp [JExpr]
rs [JExpr]
xs
  PrimOp
Int32SllOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
IntSllOp [JExpr]
rs [JExpr]
xs

------------------------------ Word32 -------------------------------------------

  PrimOp
Word32ToWordOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
WordToWord32Op     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x

  PrimOp
Word32AddOp        -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordAddOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32SubOp        -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordSubOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32MulOp        -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordMulOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32QuotOp       -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordQuotOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32RemOp        -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordRemOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32QuotRemOp    -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordQuotRemOp [JExpr]
rs [JExpr]
xs

  PrimOp
Word32EqOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordEqOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32GeOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordGeOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32GtOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordGtOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32LeOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordLeOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32LtOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordLtOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32NeOp         -> \[JExpr]
rs  [JExpr]
xs    -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordNeOp [JExpr]
rs [JExpr]
xs

  PrimOp
Word32AndOp        -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordAndOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32OrOp         -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordOrOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32XorOp        -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordXorOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32NotOp        -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordNotOp [JExpr]
rs [JExpr]
xs

  PrimOp
Word32SllOp        -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordSllOp [JExpr]
rs [JExpr]
xs
  PrimOp
Word32SrlOp        -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
WordSrlOp [JExpr]
rs [JExpr]
xs

------------------------------ Int64 --------------------------------------------

  PrimOp
Int64ToIntOp      -> \[JExpr
r] [JExpr
_h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
l

  PrimOp
Int64NegOp        -> \[JExpr
r_h,JExpr
r_l] [JExpr
h,JExpr
l] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
r_l JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr
BNot JExpr
l JExpr -> JExpr -> JExpr
forall a. Num a => a -> a -> a
+ JExpr
1)
        , JExpr
r_h JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 (JExpr -> JExpr
BNot JExpr
h JExpr -> JExpr -> JExpr
forall a. Num a => a -> a -> a
+ JExpr -> JExpr
Not JExpr
r_l)
        ]

  PrimOp
Int64AddOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_plusInt64"  [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Int64SubOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_minusInt64" [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Int64MulOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_timesInt64" [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Int64QuotOp -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_quotInt64"  [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Int64RemOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_remInt64"   [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]

  PrimOp
Int64SllOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h,JExpr
l,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_uncheckedShiftLLInt64" [JExpr
h,JExpr
l,JExpr
n]
  PrimOp
Int64SraOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h,JExpr
l,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_uncheckedShiftRAInt64" [JExpr
h,JExpr
l,JExpr
n]
  PrimOp
Int64SrlOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h,JExpr
l,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_uncheckedShiftRLInt64" [JExpr
h,JExpr
l,JExpr
n]

  PrimOp
Int64ToWord64Op   -> \[JExpr
r1,JExpr
r2] [JExpr
x1,JExpr
x2] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
       [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 JExpr
x1
       , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr
x2
       ]
  PrimOp
IntToInt64Op      -> \[JExpr
r1,JExpr
r2] [JExpr
x] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
       [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr -> JExpr
if_ (JExpr
x JExpr -> JExpr -> JExpr
.<. JExpr
0) (-JExpr
1) JExpr
0 -- sign-extension
       , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 JExpr
x
       ]

  PrimOp
Int64EqOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LAnd (JExpr
l0 JExpr -> JExpr -> JExpr
.===. JExpr
l1) (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1))
  PrimOp
Int64NeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
l0 JExpr -> JExpr -> JExpr
.!==. JExpr
l1) (JExpr
h0 JExpr -> JExpr -> JExpr
.!==. JExpr
h1))
  PrimOp
Int64GeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.>. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.>=. JExpr
l1)))
  PrimOp
Int64GtOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.>. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.>. JExpr
l1)))
  PrimOp
Int64LeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.<. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.<=. JExpr
l1)))
  PrimOp
Int64LtOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.<. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.<. JExpr
l1)))

------------------------------ Word64 -------------------------------------------

  PrimOp
Word64ToWordOp    -> \[JExpr
r] [JExpr
_x1,JExpr
x2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x2

  PrimOp
WordToWord64Op    -> \[JExpr
rh,JExpr
rl] [JExpr
x] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
     [ JExpr
rh JExpr -> JExpr -> JStat
|= JExpr
0
     , JExpr
rl JExpr -> JExpr -> JStat
|= JExpr
x
     ]

  PrimOp
Word64ToInt64Op   -> \[JExpr
r1,JExpr
r2] [JExpr
x1,JExpr
x2] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
     [ JExpr
r1 JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
x1
     , JExpr
r2 JExpr -> JExpr -> JStat
|= JExpr
x2
     ]

  PrimOp
Word64EqOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LAnd (JExpr
l0 JExpr -> JExpr -> JExpr
.===. JExpr
l1) (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1))
  PrimOp
Word64NeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
l0 JExpr -> JExpr -> JExpr
.!==. JExpr
l1) (JExpr
h0 JExpr -> JExpr -> JExpr
.!==. JExpr
h1))
  PrimOp
Word64GeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.>. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.>=. JExpr
l1)))
  PrimOp
Word64GtOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.>. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.>. JExpr
l1)))
  PrimOp
Word64LeOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.<. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.<=. JExpr
l1)))
  PrimOp
Word64LtOp -> \[JExpr
r] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr -> JExpr -> JExpr
LOr (JExpr
h0 JExpr -> JExpr -> JExpr
.<. JExpr
h1) (JExpr -> JExpr -> JExpr
LAnd (JExpr
h0 JExpr -> JExpr -> JExpr
.===. JExpr
h1) (JExpr
l0 JExpr -> JExpr -> JExpr
.<. JExpr
l1)))

  PrimOp
Word64SllOp -> \[JExpr
hr,JExpr
lr] [JExpr
h,JExpr
l,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_uncheckedShiftLWord64" [JExpr
h,JExpr
l,JExpr
n]
  PrimOp
Word64SrlOp -> \[JExpr
hr,JExpr
lr] [JExpr
h,JExpr
l,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_uncheckedShiftRWord64" [JExpr
h,JExpr
l,JExpr
n]

  PrimOp
Word64OrOp  -> \[JExpr
hr,JExpr
hl] [JExpr
h0, JExpr
l0, JExpr
h1, JExpr
l1] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
hr JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BOr JExpr
h0 JExpr
h1)
        , JExpr
hl JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BOr JExpr
l0 JExpr
l1)
        ]

  PrimOp
Word64AndOp -> \[JExpr
hr,JExpr
hl] [JExpr
h0, JExpr
l0, JExpr
h1, JExpr
l1] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
hr JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BAnd JExpr
h0 JExpr
h1)
        , JExpr
hl JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BAnd JExpr
l0 JExpr
l1)
        ]

  PrimOp
Word64XorOp -> \[JExpr
hr,JExpr
hl] [JExpr
h0, JExpr
l0, JExpr
h1, JExpr
l1] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
hr JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BXor JExpr
h0 JExpr
h1)
        , JExpr
hl JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BXor JExpr
l0 JExpr
l1)
        ]

  PrimOp
Word64NotOp -> \[JExpr
hr,JExpr
hl] [JExpr
h, JExpr
l] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
hr JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr
BNot JExpr
h)
        , JExpr
hl JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr
BNot JExpr
l)
        ]

  PrimOp
Word64AddOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_plusWord64"  [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Word64SubOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_minusWord64" [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Word64MulOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_timesWord64" [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Word64QuotOp -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_quotWord64"  [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]
  PrimOp
Word64RemOp  -> \[JExpr
hr,JExpr
lr] [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
hr,JExpr
lr] FastString
"h$hs_remWord64"   [JExpr
h0,JExpr
l0,JExpr
h1,JExpr
l1]

------------------------------ Word ---------------------------------------------

  PrimOp
WordAddOp  -> \[JExpr
r]   [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= (JExpr
x JExpr -> JExpr -> JExpr
`Add` JExpr
y) JExpr -> JExpr -> JExpr
.>>>. JExpr
zero_
  PrimOp
WordAddCOp -> \[JExpr
r,JExpr
c] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$
      (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
t -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
t JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
`Add` JExpr
y
        , JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 JExpr
t
        , JExpr
c JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
t JExpr -> JExpr -> JExpr
.!==. JExpr
r)
        ]
  PrimOp
WordSubCOp  -> \[JExpr
r,JExpr
c] [JExpr
x,JExpr
y] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
        , JExpr
c JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
y JExpr -> JExpr -> JExpr
.>. JExpr
x)
        ]
  PrimOp
WordAdd2Op    -> \[JExpr
h,JExpr
l] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
h,JExpr
l] FastString
"h$wordAdd2" [JExpr
x,JExpr
y]
  PrimOp
WordSubOp     -> \  [JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y)
  PrimOp
WordMulOp     -> \  [JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$mulWord32" [JExpr
x, JExpr
y]
  PrimOp
WordMul2Op    -> \[JExpr
h,JExpr
l] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
h,JExpr
l] FastString
"h$mul2Word32" [JExpr
x,JExpr
y]
  PrimOp
WordQuotOp    -> \  [JExpr
q] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
q JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$quotWord32" [JExpr
x,JExpr
y]
  PrimOp
WordRemOp     -> \  [JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$remWord32" [JExpr
x,JExpr
y]
  PrimOp
WordQuotRemOp -> \[JExpr
q,JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
q,JExpr
r] FastString
"h$quotRemWord32" [JExpr
x,JExpr
y]
  PrimOp
WordQuotRem2Op   -> \[JExpr
q,JExpr
r] [JExpr
xh,JExpr
xl,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
q,JExpr
r] FastString
"h$quotRem2Word32" [JExpr
xh,JExpr
xl,JExpr
y]
  PrimOp
WordAndOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BAnd JExpr
x JExpr
y)
  PrimOp
WordOrOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BOr  JExpr
x JExpr
y)
  PrimOp
WordXorOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
BXor JExpr
x JExpr
y)
  PrimOp
WordNotOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr -> JExpr
BNot JExpr
x)
  PrimOp
WordSllOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 (JExpr
x JExpr -> JExpr -> JExpr
.<<. JExpr
y)
  PrimOp
WordSrlOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x JExpr -> JExpr -> JExpr
.>>>. JExpr
y
  PrimOp
WordToIntOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
x
  PrimOp
WordGtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>.  JExpr
y)
  PrimOp
WordGeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=. JExpr
y)
  PrimOp
WordEqOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
WordNeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)
  PrimOp
WordLtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<.  JExpr
y)
  PrimOp
WordLeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=. JExpr
y)
  PrimOp
WordToDoubleOp   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
WordToFloatOp    -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr
x]
  PrimOp
PopCnt8Op        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$popCntTab" JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr
mask8 JExpr
x)
  PrimOp
PopCnt16Op       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Add (FastString -> JExpr
var FastString
"h$popCntTab" JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr
mask8 JExpr
x))
                                                      (FastString -> JExpr
var FastString
"h$popCntTab" JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr
mask8 (JExpr
x JExpr -> JExpr -> JExpr
.>>>. Integer -> JExpr
Int Integer
8)))

  PrimOp
PopCnt32Op  -> \[JExpr
r] [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$popCnt32" [JExpr
x]
  PrimOp
PopCnt64Op  -> \[JExpr
r] [JExpr
x1,JExpr
x2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$popCnt64" [JExpr
x1,JExpr
x2]
  PrimOp
PopCntOp    -> \[JExpr
r] [JExpr
x]     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
PopCnt32Op [JExpr
r] [JExpr
x]
  PrimOp
Pdep8Op     -> \[JExpr
r] [JExpr
s,JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pdep8"  [JExpr
s,JExpr
m]
  PrimOp
Pdep16Op    -> \[JExpr
r] [JExpr
s,JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pdep16" [JExpr
s,JExpr
m]
  PrimOp
Pdep32Op    -> \[JExpr
r] [JExpr
s,JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pdep32" [JExpr
s,JExpr
m]
  PrimOp
Pdep64Op    -> \[JExpr
ra,JExpr
rb] [JExpr
sa,JExpr
sb,JExpr
ma,JExpr
mb] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
ra,JExpr
rb] FastString
"h$pdep64" [JExpr
sa,JExpr
sb,JExpr
ma,JExpr
mb]
  PrimOp
PdepOp      -> \[JExpr]
rs [JExpr]
xs                 -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
Pdep32Op [JExpr]
rs [JExpr]
xs
  PrimOp
Pext8Op     -> \[JExpr
r] [JExpr
s,JExpr
m] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pext8" [JExpr
s,JExpr
m]
  PrimOp
Pext16Op    -> \[JExpr
r] [JExpr
s,JExpr
m] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pext16" [JExpr
s,JExpr
m]
  PrimOp
Pext32Op    -> \[JExpr
r] [JExpr
s,JExpr
m] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$pext32" [JExpr
s,JExpr
m]
  PrimOp
Pext64Op    -> \[JExpr
ra,JExpr
rb] [JExpr
sa,JExpr
sb,JExpr
ma,JExpr
mb] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
ra,JExpr
rb] FastString
"h$pext64" [JExpr
sa,JExpr
sb,JExpr
ma,JExpr
mb]
  PrimOp
PextOp      -> \[JExpr]
rs [JExpr]
xs     -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
Pext32Op [JExpr]
rs [JExpr]
xs

  PrimOp
ClzOp       -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$clz32" [JExpr
x]
  PrimOp
Clz8Op      -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$clz8"  [JExpr
x]
  PrimOp
Clz16Op     -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$clz16" [JExpr
x]
  PrimOp
Clz32Op     -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$clz32" [JExpr
x]
  PrimOp
Clz64Op     -> \[JExpr
r]   [JExpr
x1,JExpr
x2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$clz64" [JExpr
x1,JExpr
x2]
  PrimOp
CtzOp       -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$ctz32" [JExpr
x]
  PrimOp
Ctz8Op      -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$ctz8"  [JExpr
x]
  PrimOp
Ctz16Op     -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$ctz16" [JExpr
x]
  PrimOp
Ctz32Op     -> \[JExpr
r]   [JExpr
x]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$ctz32" [JExpr
x]
  PrimOp
Ctz64Op     -> \[JExpr
r]   [JExpr
x1,JExpr
x2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$ctz64" [JExpr
x1,JExpr
x2]

  PrimOp
BSwap16Op   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$
      JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
BOr ((JExpr -> JExpr
mask8 JExpr
x) JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
8))
               (JExpr -> JExpr
mask8 (JExpr
x JExpr -> JExpr -> JExpr
.>>>. (Integer -> JExpr
Int Integer
8)))
  PrimOp
BSwap32Op   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$
      JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32 ((JExpr
x JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
24))
            JExpr -> JExpr -> JExpr
`BOr` ((JExpr -> JExpr -> JExpr
BAnd JExpr
x (Integer -> JExpr
Int Integer
0xFF00)) JExpr -> JExpr -> JExpr
.<<. (Integer -> JExpr
Int Integer
8))
            JExpr -> JExpr -> JExpr
`BOr` ((JExpr -> JExpr -> JExpr
BAnd JExpr
x (Integer -> JExpr
Int Integer
0xFF0000)) JExpr -> JExpr -> JExpr
.>>. (Integer -> JExpr
Int Integer
8))
            JExpr -> JExpr -> JExpr
`BOr` (JExpr
x JExpr -> JExpr -> JExpr
.>>>. (Integer -> JExpr
Int Integer
24)))
  PrimOp
BSwap64Op   -> \[JExpr
r1,JExpr
r2] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r1,JExpr
r2] FastString
"h$bswap64" [JExpr
x,JExpr
y]
  PrimOp
BSwapOp     -> \[JExpr
r] [JExpr
x]       -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
BSwap32Op [JExpr
r] [JExpr
x]

  PrimOp
BRevOp      -> \[JExpr
r] [JExpr
w] -> Bool -> Bool -> Type -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
genPrim Bool
prof Bool
bound Type
ty PrimOp
BRev32Op [JExpr
r] [JExpr
w]
  PrimOp
BRev8Op     -> \[JExpr
r] [JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= (FastString -> [JExpr] -> JExpr
app FastString
"h$reverseWord" [JExpr
w] JExpr -> JExpr -> JExpr
.>>>. JExpr
24)
  PrimOp
BRev16Op    -> \[JExpr
r] [JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= (FastString -> [JExpr] -> JExpr
app FastString
"h$reverseWord" [JExpr
w] JExpr -> JExpr -> JExpr
.>>>. JExpr
16)
  PrimOp
BRev32Op    -> \[JExpr
r] [JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$reverseWord" [JExpr
w]
  PrimOp
BRev64Op    -> \[JExpr
rh,JExpr
rl] [JExpr
h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [ JExpr
rl JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$reverseWord" [JExpr
h]
                                                        , JExpr
rh JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$reverseWord" [JExpr
l]
                                                        ]

------------------------------ Narrow -------------------------------------------

  PrimOp
Narrow8IntOp    -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend8  JExpr
x
  PrimOp
Narrow16IntOp   -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
signExtend16 JExpr
x
  PrimOp
Narrow32IntOp   -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32  JExpr
x
  PrimOp
Narrow8WordOp   -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask8  JExpr
x
  PrimOp
Narrow16WordOp  -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
mask16 JExpr
x
  PrimOp
Narrow32WordOp  -> \[JExpr
r] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toU32  JExpr
x

------------------------------ Double -------------------------------------------

  PrimOp
DoubleGtOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>.   JExpr
y)
  PrimOp
DoubleGeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=.  JExpr
y)
  PrimOp
DoubleEqOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
DoubleNeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)
  PrimOp
DoubleLtOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<.   JExpr
y)
  PrimOp
DoubleLeOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=.  JExpr
y)
  PrimOp
DoubleAddOp       -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y
  PrimOp
DoubleSubOp       -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y
  PrimOp
DoubleMulOp       -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y
  PrimOp
DoubleDivOp       -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y
  PrimOp
DoubleNegOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
Negate JExpr
x
  PrimOp
DoubleFabsOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_abs [JExpr
x]
  PrimOp
DoubleToIntOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
x
  PrimOp
DoubleToFloatOp   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr
x]
  PrimOp
DoubleExpOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_exp  [JExpr
x]
  PrimOp
DoubleExpM1Op     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_expm1 [JExpr
x]
  PrimOp
DoubleLogOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_log  [JExpr
x]
  PrimOp
DoubleLog1POp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_log1p [JExpr
x]
  PrimOp
DoubleSqrtOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_sqrt [JExpr
x]
  PrimOp
DoubleSinOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_sin  [JExpr
x]
  PrimOp
DoubleCosOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_cos  [JExpr
x]
  PrimOp
DoubleTanOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_tan  [JExpr
x]
  PrimOp
DoubleAsinOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_asin [JExpr
x]
  PrimOp
DoubleAcosOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_acos [JExpr
x]
  PrimOp
DoubleAtanOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_atan [JExpr
x]
  PrimOp
DoubleSinhOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_sinh [JExpr
x]
  PrimOp
DoubleCoshOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_cosh [JExpr
x]
  PrimOp
DoubleTanhOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_tanh [JExpr
x]
  PrimOp
DoubleAsinhOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_asinh [JExpr
x]
  PrimOp
DoubleAcoshOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_acosh [JExpr
x]
  PrimOp
DoubleAtanhOp     -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_atanh [JExpr
x]
  PrimOp
DoublePowerOp     -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_pow [JExpr
x,JExpr
y]
  PrimOp
DoubleDecode_2IntOp  -> \[JExpr
s,JExpr
h,JExpr
l,JExpr
e] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
s,JExpr
h,JExpr
l,JExpr
e] FastString
"h$decodeDouble2Int" [JExpr
x]
  PrimOp
DoubleDecode_Int64Op -> \[JExpr
s1,JExpr
s2,JExpr
e] [JExpr
d] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
e,JExpr
s1,JExpr
s2] FastString
"h$decodeDoubleInt64" [JExpr
d]

------------------------------ Float --------------------------------------------

  PrimOp
FloatGtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>.   JExpr
y)
  PrimOp
FloatGeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.>=.  JExpr
y)
  PrimOp
FloatEqOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
y)
  PrimOp
FloatNeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.!==. JExpr
y)
  PrimOp
FloatLtOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<.   JExpr
y)
  PrimOp
FloatLeOp         -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
x JExpr -> JExpr -> JExpr
.<=.  JExpr
y)
  PrimOp
FloatAddOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr -> JExpr -> JExpr
Add JExpr
x JExpr
y]
  PrimOp
FloatSubOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr -> JExpr -> JExpr
Sub JExpr
x JExpr
y]
  PrimOp
FloatMulOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr -> JExpr -> JExpr
Mul JExpr
x JExpr
y]
  PrimOp
FloatDivOp        -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [JExpr -> JExpr -> JExpr
Div JExpr
x JExpr
y]
  PrimOp
FloatNegOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
Negate JExpr
x
  PrimOp
FloatFabsOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_abs [JExpr
x]
  PrimOp
FloatToIntOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
toI32 JExpr
x
  PrimOp
FloatExpOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_exp [JExpr
x]]
  PrimOp
FloatExpM1Op      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_expm1 [JExpr
x]]
  PrimOp
FloatLogOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_log [JExpr
x]]
  PrimOp
FloatLog1POp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_log1p [JExpr
x]]
  PrimOp
FloatSqrtOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_sqrt [JExpr
x]]
  PrimOp
FloatSinOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_sin [JExpr
x]]
  PrimOp
FloatCosOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_cos [JExpr
x]]
  PrimOp
FloatTanOp        -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_tan [JExpr
x]]
  PrimOp
FloatAsinOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_asin [JExpr
x]]
  PrimOp
FloatAcosOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_acos [JExpr
x]]
  PrimOp
FloatAtanOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_atan [JExpr
x]]
  PrimOp
FloatSinhOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_sinh [JExpr
x]]
  PrimOp
FloatCoshOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_cosh [JExpr
x]]
  PrimOp
FloatTanhOp       -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_tanh [JExpr
x]]
  PrimOp
FloatAsinhOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_asinh [JExpr
x]]
  PrimOp
FloatAcoshOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_acosh [JExpr
x]]
  PrimOp
FloatAtanhOp      -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_atanh [JExpr
x]]
  PrimOp
FloatPowerOp      -> \[JExpr
r] [JExpr
x,JExpr
y] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= [JExpr] -> JExpr
math_fround [[JExpr] -> JExpr
math_pow [JExpr
x,JExpr
y]]
  PrimOp
FloatToDoubleOp   -> \[JExpr
r] [JExpr
x]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
FloatDecode_IntOp -> \[JExpr
s,JExpr
e] [JExpr
x] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
s,JExpr
e] FastString
"h$decodeFloatInt" [JExpr
x]

------------------------------ Arrays -------------------------------------------

  PrimOp
NewArrayOp           -> \[JExpr
r] [JExpr
l,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$newArray" [JExpr
l,JExpr
e]
  PrimOp
ReadArrayOp          -> \[JExpr
r] [JExpr
a,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i)
  PrimOp
WriteArrayOp         -> \[]  [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v)
  PrimOp
SizeofArrayOp        -> \[JExpr
r] [JExpr
a]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"length"
  PrimOp
SizeofMutableArrayOp -> \[JExpr
r] [JExpr
a]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"length"
  PrimOp
IndexArrayOp         -> \[JExpr
r] [JExpr
a,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i)
  PrimOp
UnsafeFreezeArrayOp  -> \[JExpr
r] [JExpr
a]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a
  PrimOp
UnsafeThawArrayOp    -> \[JExpr
r] [JExpr
a]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a
  PrimOp
CopyArrayOp          -> \[] [JExpr
a,JExpr
o1,JExpr
ma,JExpr
o2,JExpr
n] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a JExpr
o1 JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
ma JExpr
o2 JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> (JExpr -> JExpr) -> (JExpr -> [JStat]) -> JStat
loopBlockS (Integer -> JExpr
Int Integer
0) (JExpr -> JExpr -> JExpr
.<. JExpr
n) \JExpr
i ->
      [ JExpr
ma JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr -> JExpr
Add JExpr
i JExpr
o2) JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr -> JExpr
Add JExpr
i JExpr
o1)
      , JExpr -> JStat
preIncrS JExpr
i
      ]
  PrimOp
CopyMutableArrayOp  -> \[]  [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a1 JExpr
o1 JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a2 JExpr
o2 JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$copyMutableArray" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n]

  PrimOp
CloneArrayOp        -> \[JExpr
r] [JExpr
a,JExpr
start,JExpr
n]     ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a JExpr
start JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$sliceArray" [JExpr
a,JExpr
start,JExpr
n]

  PrimOp
CloneMutableArrayOp -> \[JExpr
r] [JExpr
a,JExpr
start,JExpr
n]     ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a JExpr
start JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$sliceArray" [JExpr
a,JExpr
start,JExpr
n]

  PrimOp
FreezeArrayOp       -> \[JExpr
r] [JExpr
a,JExpr
start,JExpr
n]     ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a JExpr
start JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$sliceArray" [JExpr
a,JExpr
start,JExpr
n]

  PrimOp
ThawArrayOp         -> \[JExpr
r] [JExpr
a,JExpr
start,JExpr
n]     ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
a JExpr
start JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$sliceArray" [JExpr
a,JExpr
start,JExpr
n]

  PrimOp
CasArrayOp          -> \[JExpr
s,JExpr
o] [JExpr
a,JExpr
i,JExpr
old,JExpr
new] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
x -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
          [ JExpr
x JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i
          , JExpr -> [JStat] -> [JStat] -> JStat
ifBlockS (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
old)
                     [ JExpr
o JExpr -> JExpr -> JStat
|= JExpr
new
                     , JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i JExpr -> JExpr -> JStat
|= JExpr
new
                     , JExpr
s JExpr -> JExpr -> JStat
|= JExpr
zero_
                     ]
                     [ JExpr
s JExpr -> JExpr -> JStat
|= JExpr
one_
                     , JExpr
o JExpr -> JExpr -> JStat
|= JExpr
x
                     ]
          ]

------------------------------ Small Arrays -------------------------------------

  PrimOp
NewSmallArrayOp            -> \[JExpr
a]   [JExpr
n,JExpr
e]         -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
a JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$newArray" [JExpr
n,JExpr
e]
  PrimOp
ReadSmallArrayOp           -> \[JExpr
r]   [JExpr
a,JExpr
i]         -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i)
  PrimOp
WriteSmallArrayOp          -> \[]    [JExpr
a,JExpr
i,JExpr
e]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i JExpr -> JExpr -> JStat
|= JExpr
e)
  PrimOp
SizeofSmallArrayOp         -> \[JExpr
r]   [JExpr
a]           -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"length"
  PrimOp
SizeofSmallMutableArrayOp  -> \[JExpr
r]   [JExpr
a]           -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"length"
  PrimOp
IndexSmallArrayOp          -> \[JExpr
r]   [JExpr
a,JExpr
i]         -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i (JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i)
  PrimOp
UnsafeFreezeSmallArrayOp   -> \[JExpr
r]   [JExpr
a]           -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a
  PrimOp
UnsafeThawSmallArrayOp     -> \[JExpr
r]   [JExpr
a]           -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a
  PrimOp
CopySmallArrayOp           -> \[]    [JExpr
s,JExpr
si,JExpr
d,JExpr
di,JExpr
n] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
s JExpr
si JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
d JExpr
di JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> (JExpr -> JExpr) -> (JExpr -> [JStat]) -> JStat
loopBlockS (JExpr -> JExpr -> JExpr
Sub JExpr
n JExpr
one_) (JExpr -> JExpr -> JExpr
.>=. JExpr
zero_) \JExpr
i ->
          [ JExpr
d JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr -> JExpr
Add JExpr
di JExpr
i) JExpr -> JExpr -> JStat
|= JExpr
s JExpr -> JExpr -> JExpr
.! (JExpr -> JExpr -> JExpr
Add JExpr
si JExpr
i)
          , JExpr -> JStat
postDecrS JExpr
i
          ]
  PrimOp
CopySmallMutableArrayOp    -> \[]    [JExpr
s,JExpr
si,JExpr
d,JExpr
di,JExpr
n] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
s JExpr
si JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound JExpr
d JExpr
di JExpr
n
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$copyMutableArray" [JExpr
s,JExpr
si,JExpr
d,JExpr
di,JExpr
n]

  PrimOp
CloneSmallArrayOp          -> \[JExpr
r]   [JExpr
a,JExpr
o,JExpr
n]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray Bool
bound JExpr
r JExpr
a JExpr
o JExpr
n
  PrimOp
CloneSmallMutableArrayOp   -> \[JExpr
r]   [JExpr
a,JExpr
o,JExpr
n]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray Bool
bound JExpr
r JExpr
a JExpr
o JExpr
n
  PrimOp
FreezeSmallArrayOp         -> \[JExpr
r]   [JExpr
a,JExpr
o,JExpr
n]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray Bool
bound JExpr
r JExpr
a JExpr
o JExpr
n
  PrimOp
ThawSmallArrayOp           -> \[JExpr
r]   [JExpr
a,JExpr
o,JExpr
n]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray Bool
bound JExpr
r JExpr
a JExpr
o JExpr
n

  PrimOp
CasSmallArrayOp            -> \[JExpr
s,JExpr
o] [JExpr
a,JExpr
i,JExpr
old,JExpr
new] ->
    JStat -> PrimRes
PrimInline
      (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
bound JExpr
a JExpr
i
      (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JStat) -> JStat
forall a. ToSat a => a -> JStat
jVar \JExpr
x -> [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
x JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i
        , JExpr -> [JStat] -> [JStat] -> JStat
ifBlockS (JExpr
x JExpr -> JExpr -> JExpr
.===. JExpr
old)
            [ JExpr
o JExpr -> JExpr -> JStat
|= JExpr
new
            , JExpr
a JExpr -> JExpr -> JExpr
.! JExpr
i JExpr -> JExpr -> JStat
|= JExpr
new
            , JExpr
s JExpr -> JExpr -> JStat
|= JExpr
zero_
            ]
            [ JExpr
s JExpr -> JExpr -> JStat
|= JExpr
one_
            , JExpr
o JExpr -> JExpr -> JStat
|= JExpr
x
            ]
        ]

------------------------------- Byte Arrays -------------------------------------

  PrimOp
NewByteArrayOp_Char               -> \[JExpr
r]   [JExpr
l]        -> JStat -> PrimRes
PrimInline (JExpr -> JExpr -> JStat
newByteArray JExpr
r JExpr
l)
  PrimOp
NewPinnedByteArrayOp_Char         -> \[JExpr
r]   [JExpr
l]        -> JStat -> PrimRes
PrimInline (JExpr -> JExpr -> JStat
newByteArray JExpr
r JExpr
l)
  PrimOp
NewAlignedPinnedByteArrayOp_Char  -> \[JExpr
r]   [JExpr
l,JExpr
_align] -> JStat -> PrimRes
PrimInline (JExpr -> JExpr -> JStat
newByteArray JExpr
r JExpr
l)
  PrimOp
MutableByteArrayIsPinnedOp        -> \[JExpr
r]   [JExpr
_]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
one_
  PrimOp
ByteArrayIsPinnedOp               -> \[JExpr
r]   [JExpr
_]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
one_
  PrimOp
ByteArrayContents_Char            -> \[JExpr
a,JExpr
o] [JExpr
b]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
a JExpr -> JExpr -> JStat
|= JExpr
b, JExpr
o JExpr -> JExpr -> JStat
|= JExpr
zero_]
  PrimOp
MutableByteArrayContents_Char     -> \[JExpr
a,JExpr
o] [JExpr
b]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
a JExpr -> JExpr -> JStat
|= JExpr
b, JExpr
o JExpr -> JExpr -> JStat
|= JExpr
zero_]
  PrimOp
ShrinkMutableByteArrayOp_Char     -> \[]    [JExpr
a,JExpr
n]      -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$shrinkMutableByteArray" [JExpr
a,JExpr
n]
  PrimOp
ResizeMutableByteArrayOp_Char     -> \[JExpr
r]   [JExpr
a,JExpr
n]      -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$resizeMutableByteArray" [JExpr
a,JExpr
n]
  PrimOp
UnsafeFreezeByteArrayOp           -> \[JExpr
a]   [JExpr
b]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
a JExpr -> JExpr -> JStat
|= JExpr
b
  PrimOp
SizeofByteArrayOp                 -> \[JExpr
r]   [JExpr
a]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"len"
  PrimOp
SizeofMutableByteArrayOp          -> \[JExpr
r]   [JExpr
a]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"len"
  PrimOp
GetSizeofMutableByteArrayOp       -> \[JExpr
r]   [JExpr
a]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"len"

  PrimOp
IndexByteArrayOp_Char      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u8  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_WideChar  -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Int       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Addr      -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
IndexByteArrayOp_Float     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_f32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Double    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_f64 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_StablePtr -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_stableptr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
IndexByteArrayOp_Int8      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i8  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Int16     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i16 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Int32     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Int64     -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
IndexByteArrayOp_Word8     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u8  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word16    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u16 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word32    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word64    -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_u64 JExpr
a JExpr
i JExpr
h JExpr
l

  PrimOp
ReadByteArrayOp_Char       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u8  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_WideChar   -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Int        -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Addr       -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
ReadByteArrayOp_Float      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_f32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Double     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_f64 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_StablePtr  -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_stableptr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
ReadByteArrayOp_Int8       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i8  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Int16      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i16 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Int32      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Int64      -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
ReadByteArrayOp_Word8      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u8  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word16     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u16 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word32     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word64     -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_u64 JExpr
a JExpr
i JExpr
h JExpr
l

  PrimOp
WriteByteArrayOp_Char      -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_u8  JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_WideChar  -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Int       -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word      -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Addr      -> \[] [JExpr
a,JExpr
i,JExpr
r,JExpr
o] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
WriteByteArrayOp_Float     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_f32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Double    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_f64 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_StablePtr -> \[] [JExpr
a,JExpr
i,JExpr
r,JExpr
o] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_stableptr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
WriteByteArrayOp_Int8      -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i8  JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Int16     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i16 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Int32     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Int64     -> \[] [JExpr
a,JExpr
i,JExpr
h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
WriteByteArrayOp_Word8     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_u8  JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word16    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_u16 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word32    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word64    -> \[] [JExpr
a,JExpr
i,JExpr
h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_u64 JExpr
a JExpr
i JExpr
h JExpr
l

  PrimOp
CompareByteArraysOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> (JStat -> JStat) -> JStat -> PrimRes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
bound JExpr
a1 JExpr
o1 JExpr
n
                 (JStat -> JStat) -> (JStat -> JStat) -> JStat -> JStat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
bound JExpr
a2 JExpr
o2 JExpr
n
                 (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$compareByteArrays" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n]

  -- We assume the arrays aren't overlapping since they're of different types
  -- (ByteArray vs MutableByteArray, Addr# vs MutableByteArray#, [Mutable]ByteArray# vs Addr#)
  PrimOp
CopyByteArrayOp                      -> \[] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] -> Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
False Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n
  PrimOp
CopyAddrToByteArrayOp                -> \[] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] -> Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
False Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n
  PrimOp
CopyMutableByteArrayToAddrOp         -> \[] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] -> Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
False Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n
  PrimOp
CopyByteArrayToAddrOp                -> \[] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] -> Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
False Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n

  PrimOp
CopyMutableByteArrayOp               -> \[] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n] -> Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
True  Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n

  PrimOp
SetByteArrayOp -> \[] [JExpr
a,JExpr
o,JExpr
n,JExpr
v] ->
      JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> (JStat -> JStat) -> JStat -> PrimRes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
bound JExpr
a JExpr
o JExpr
n (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> (JExpr -> JExpr) -> (JExpr -> [JStat]) -> JStat
loopBlockS JExpr
zero_ (JExpr -> JExpr -> JExpr
.<. JExpr
n) \JExpr
i ->
        [ JExpr -> JExpr -> JExpr -> JStat
write_u8 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
o JExpr
i) JExpr
v
        , JExpr -> JStat
postIncrS JExpr
i
        ]

  PrimOp
AtomicReadByteArrayOp_Int  -> \[JExpr
r]   [JExpr
a,JExpr
i]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  PrimOp
AtomicWriteByteArrayOp_Int -> \[]    [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
v
  PrimOp
FetchAddByteArrayOp_Int    -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
Add  JExpr
r JExpr
a JExpr
i JExpr
v
  PrimOp
FetchSubByteArrayOp_Int    -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
Sub  JExpr
r JExpr
a JExpr
i JExpr
v
  PrimOp
FetchAndByteArrayOp_Int    -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
BAnd JExpr
r JExpr
a JExpr
i JExpr
v
  PrimOp
FetchOrByteArrayOp_Int     -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
BOr  JExpr
r JExpr
a JExpr
i JExpr
v
  PrimOp
FetchNandByteArrayOp_Int   -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray (\JExpr
x JExpr
y -> JExpr -> JExpr
BNot (JExpr -> JExpr -> JExpr
BAnd JExpr
x JExpr
y)) JExpr
r JExpr
a JExpr
i JExpr
v
  PrimOp
FetchXorByteArrayOp_Int    -> \[JExpr
r]   [JExpr
a,JExpr
i,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
BXor JExpr
r JExpr
a JExpr
i JExpr
v

------------------------------- Addr# ------------------------------------------

  PrimOp
AddrAddOp   -> \[JExpr
a',JExpr
o'] [JExpr
a,JExpr
o,JExpr
i]         -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
a' JExpr -> JExpr -> JStat
|= JExpr
a, JExpr
o' JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Add JExpr
o JExpr
i]
  PrimOp
AddrSubOp   -> \[JExpr
i]     [JExpr
_a1,JExpr
o1,JExpr
_a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
i JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Sub JExpr
o1 JExpr
o2
  PrimOp
AddrRemOp   -> \[JExpr
r]     [JExpr
_a,JExpr
o,JExpr
i]        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
Mod JExpr
o JExpr
i
  PrimOp
AddrToIntOp -> \[JExpr
i]     [JExpr
_a,JExpr
o]          -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
i JExpr -> JExpr -> JStat
|= JExpr
o -- only usable for comparisons within one range
  PrimOp
IntToAddrOp -> \[JExpr
a,JExpr
o]   [JExpr
i]             -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
a JExpr -> JExpr -> JStat
|= JExpr
null_, JExpr
o JExpr -> JExpr -> JStat
|= JExpr
i]
  PrimOp
AddrGtOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.>. JExpr
zero_)
  PrimOp
AddrGeOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.>=. JExpr
zero_)
  PrimOp
AddrEqOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.===. JExpr
zero_)
  PrimOp
AddrNeOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.!==. JExpr
zero_)
  PrimOp
AddrLtOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.<. JExpr
zero_)
  PrimOp
AddrLeOp -> \[JExpr
r] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (FastString -> [JExpr] -> JExpr
app FastString
"h$comparePointer" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] JExpr -> JExpr -> JExpr
.<=. JExpr
zero_)

------------------------------- Addr Indexing: Unboxed Arrays -------------------

  PrimOp
IndexOffAddrOp_Char      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_WideChar  -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Int       -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Word      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Addr      -> \[JExpr
ra,JExpr
ro] [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
ra JExpr
ro
  PrimOp
IndexOffAddrOp_Float     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Double    -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_StablePtr -> \[JExpr
ra,JExpr
ro] [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
ra JExpr
ro
  PrimOp
IndexOffAddrOp_Int8      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Int16     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Int32     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Int64     -> \[JExpr
h,JExpr
l]   [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l
  PrimOp
IndexOffAddrOp_Word8     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Word16    -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Word32    -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
IndexOffAddrOp_Word64    -> \[JExpr
h,JExpr
l]   [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l

  PrimOp
ReadOffAddrOp_Char       -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_WideChar   -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Int        -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Word       -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Addr       -> \[JExpr
ra,JExpr
ro] [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
ra JExpr
ro
  PrimOp
ReadOffAddrOp_Float      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Double     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_StablePtr  -> \[JExpr
ra,JExpr
ro] [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
ra JExpr
ro
  PrimOp
ReadOffAddrOp_Int8       -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Int16      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Int32      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Int64      -> \[JExpr
h,JExpr
l]   [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l
  PrimOp
ReadOffAddrOp_Word8      -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Word16     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Word32     -> \[JExpr
r]     [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i)
  PrimOp
ReadOffAddrOp_Word64     -> \[JExpr
h,JExpr
l]   [JExpr
a,JExpr
o,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l

  PrimOp
WriteOffAddrOp_Char      -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_WideChar  -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Int       -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Word      -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Addr      -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
va,JExpr
vo] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
va JExpr
vo
  PrimOp
WriteOffAddrOp_Float     -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_f32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Double    -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_f64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_StablePtr -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
va,JExpr
vo] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_stableptr JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
va JExpr
vo
  PrimOp
WriteOffAddrOp_Int8      -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Int16     -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Int32     -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Int64     -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
h,JExpr
l]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_i64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l
  PrimOp
WriteOffAddrOp_Word8     -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u8  JExpr
a (JExpr -> JExpr -> JExpr
off8  JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Word16    -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u16 JExpr
a (JExpr -> JExpr -> JExpr
off16 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Word32    -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
v]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
off32 JExpr
o JExpr
i) JExpr
v
  PrimOp
WriteOffAddrOp_Word64    -> \[] [JExpr
a,JExpr
o,JExpr
i,JExpr
h,JExpr
l]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_u64 JExpr
a (JExpr -> JExpr -> JExpr
off64 JExpr
o JExpr
i) JExpr
h JExpr
l

------------------------------- Mutable varialbes --------------------------------------
  PrimOp
NewMutVarOp           -> \[JExpr
r] [JExpr
x]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
New (FastString -> [JExpr] -> JExpr
app FastString
"h$MutVar" [JExpr
x])
  PrimOp
ReadMutVarOp          -> \[JExpr
r] [JExpr
m]       -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
m JExpr -> FastString -> JExpr
.^ FastString
"val"
  PrimOp
WriteMutVarOp         -> \[] [JExpr
m,JExpr
x]      -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
m JExpr -> FastString -> JExpr
.^ FastString
"val" JExpr -> JExpr -> JStat
|= JExpr
x
  PrimOp
AtomicModifyMutVar2Op -> \[JExpr
r1,JExpr
r2] [JExpr
m,JExpr
f] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r1,JExpr
r2] FastString
"h$atomicModifyMutVar2" [JExpr
m,JExpr
f]
  PrimOp
AtomicModifyMutVar_Op -> \[JExpr
r1,JExpr
r2] [JExpr
m,JExpr
f] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r1,JExpr
r2] FastString
"h$atomicModifyMutVar" [JExpr
m,JExpr
f]

  PrimOp
CasMutVarOp -> \[JExpr
status,JExpr
r] [JExpr
mv,JExpr
o,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat -> JStat -> JStat
ifS (JExpr
mv JExpr -> FastString -> JExpr
.^ FastString
"val" JExpr -> JExpr -> JExpr
.===. JExpr
o)
                   ([JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
status JExpr -> JExpr -> JStat
|= JExpr
zero_, JExpr
r JExpr -> JExpr -> JStat
|= JExpr
n, JExpr
mv JExpr -> FastString -> JExpr
.^ FastString
"val" JExpr -> JExpr -> JStat
|= JExpr
n])
                   ([JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat [JExpr
status JExpr -> JExpr -> JStat
|= JExpr
one_ , JExpr
r JExpr -> JExpr -> JStat
|= JExpr
mv JExpr -> FastString -> JExpr
.^ FastString
"val"])

------------------------------- Exceptions --------------------------------------

  PrimOp
CatchOp -> \[JExpr
_r] [JExpr
a,JExpr
handler] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$catch" [JExpr
a, JExpr
handler])

                             -- fully ignore the result arity as it can use 1 or 2
                             -- slots, depending on the return type.
  PrimOp
RaiseOp                 -> \[JExpr]
_r [JExpr
a] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$throw" [JExpr
a, JExpr
false_])
  PrimOp
RaiseIOOp               -> \[JExpr]
_r [JExpr
a] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$throw" [JExpr
a, JExpr
false_])
  PrimOp
RaiseUnderflowOp        -> \[JExpr]
_r []  -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$throw" [FastString -> JExpr
var FastString
"h$baseZCGHCziExceptionziTypeziunderflowException", JExpr
false_])
  PrimOp
RaiseOverflowOp         -> \[JExpr]
_r []  -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$throw" [FastString -> JExpr
var FastString
"h$baseZCGHCziExceptionziTypezioverflowException", JExpr
false_])
  PrimOp
RaiseDivZeroOp          -> \[JExpr]
_r []  -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$throw" [FastString -> JExpr
var FastString
"h$baseZCGHCziExceptionziTypezidivZZeroException", JExpr
false_])
  PrimOp
MaskAsyncExceptionsOp   -> \[JExpr]
_r [JExpr
a] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$maskAsync" [JExpr
a])
  PrimOp
MaskUninterruptibleOp   -> \[JExpr]
_r [JExpr
a] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$maskUnintAsync" [JExpr
a])
  PrimOp
UnmaskAsyncExceptionsOp -> \[JExpr]
_r [JExpr
a] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$unmaskAsync" [JExpr
a])

  PrimOp
MaskStatus -> \[JExpr
r] [] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$maskStatus" []

------------------------------- STM-accessible Mutable Variables  --------------

  PrimOp
AtomicallyOp -> \[JExpr
_r] [JExpr
a]   -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$atomically" [JExpr
a])
  PrimOp
RetryOp      -> \[JExpr]
_r   []    -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$stmRetry" [])
  PrimOp
CatchRetryOp -> \[JExpr
_r] [JExpr
a,JExpr
b] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$stmCatchRetry" [JExpr
a,JExpr
b])
  PrimOp
CatchSTMOp   -> \[JExpr
_r] [JExpr
a,JExpr
h] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$catchStm" [JExpr
a,JExpr
h])
  PrimOp
NewTVarOp    -> \[JExpr
tv] [JExpr
v]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
tv JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$newTVar" [JExpr
v]
  PrimOp
ReadTVarOp   -> \[JExpr
r] [JExpr
tv]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$readTVar" [JExpr
tv]
  PrimOp
ReadTVarIOOp -> \[JExpr
r] [JExpr
tv]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$readTVarIO" [JExpr
tv]
  PrimOp
WriteTVarOp  -> \[] [JExpr
tv,JExpr
v]  -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$writeTVar" [JExpr
tv,JExpr
v]

------------------------------- Synchronized Mutable Variables ------------------

  PrimOp
NewMVarOp     -> \[JExpr
r]   []    -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
New (FastString -> [JExpr] -> JExpr
app FastString
"h$MVar" [])
  PrimOp
TakeMVarOp    -> \[JExpr
_r]  [JExpr
m]   -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$takeMVar" [JExpr
m])
  PrimOp
TryTakeMVarOp -> \[JExpr
r,JExpr
v] [JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r,JExpr
v] FastString
"h$tryTakeMVar" [JExpr
m]
  PrimOp
PutMVarOp     -> \[]    [JExpr
m,JExpr
v] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$putMVar" [JExpr
m,JExpr
v])
  PrimOp
TryPutMVarOp  -> \[JExpr
r]   [JExpr
m,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$tryPutMVar" [JExpr
m,JExpr
v]
  PrimOp
ReadMVarOp    -> \[JExpr
_r]  [JExpr
m]   -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$readMVar" [JExpr
m])
  PrimOp
TryReadMVarOp -> \[JExpr
r,JExpr
v] [JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                    [ JExpr
v JExpr -> JExpr -> JStat
|= JExpr
m JExpr -> FastString -> JExpr
.^ FastString
"val"
                                                    , JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if01 (JExpr
v JExpr -> JExpr -> JExpr
.===. JExpr
null_)
                                                    ]
  PrimOp
IsEmptyMVarOp -> \[JExpr
r]   [JExpr
m]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
m JExpr -> FastString -> JExpr
.^ FastString
"val" JExpr -> JExpr -> JExpr
.===. JExpr
null_)

------------------------------- Delay/Wait Ops ---------------------------------

  PrimOp
DelayOp     -> \[] [JExpr
t]  -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$delayThread" [JExpr
t])
  PrimOp
WaitReadOp  -> \[] [JExpr
fd] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$waidRead" [JExpr
fd])
  PrimOp
WaitWriteOp -> \[] [JExpr
fd] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$waitWrite" [JExpr
fd])

------------------------------- Concurrency Primitives -------------------------

  PrimOp
ForkOp                 -> \[JExpr
_tid] [JExpr
x]    -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$fork" [JExpr
x, JExpr
true_])
  PrimOp
ForkOnOp               -> \[JExpr
_tid] [JExpr
_p,JExpr
x] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$fork" [JExpr
x, JExpr
true_]) -- ignore processor argument
  PrimOp
KillThreadOp           -> \[] [JExpr
tid,JExpr
ex]   -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$killThread" [JExpr
tid,JExpr
ex])
  PrimOp
YieldOp                -> \[] []         -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$yield" [])
  PrimOp
MyThreadIdOp           -> \[JExpr
r] []        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$currentThread"
  PrimOp
IsCurrentThreadBoundOp -> \[JExpr
r] []        -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
one_
  PrimOp
NoDuplicateOp          -> \[] []         -> JStat -> PrimRes
PrimInline JStat
forall a. Monoid a => a
mempty -- don't need to do anything as long as we have eager blackholing
  PrimOp
ThreadStatusOp         -> \[JExpr
stat,JExpr
cap,JExpr
locked] [JExpr
tid] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
stat, JExpr
cap, JExpr
locked] FastString
"h$threadStatus" [JExpr
tid]
  PrimOp
ListThreadsOp          -> \[JExpr
r] [] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r] FastString
"h$listThreads" []
  PrimOp
GetThreadLabelOp       -> \[JExpr
r1, JExpr
r2] [JExpr
t]  -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
r1, JExpr
r2] FastString
"h$getThreadLabel" [JExpr
t]
  PrimOp
LabelThreadOp          -> \[] [JExpr
t,JExpr
l]      -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
t JExpr -> FastString -> JExpr
.^ FastString
"label" JExpr -> JExpr -> JStat
|= JExpr
l

------------------------------- Weak Pointers -----------------------------------

  PrimOp
MkWeakOp              -> \[JExpr
r] [JExpr
o,JExpr
b,JExpr
c] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$makeWeak" [JExpr
o,JExpr
b,JExpr
c]
  PrimOp
MkWeakNoFinalizerOp   -> \[JExpr
r] [JExpr
o,JExpr
b]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$makeWeakNoFinalizer" [JExpr
o,JExpr
b]
  PrimOp
AddCFinalizerToWeakOp -> \[JExpr
r] [JExpr
_a1,JExpr
_a1o,JExpr
_a2,JExpr
_a2o,JExpr
_i,JExpr
_a3,JExpr
_a3o,JExpr
_w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
one_
  PrimOp
DeRefWeakOp           -> \[JExpr
f,JExpr
v] [JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                                        [ JExpr
v JExpr -> JExpr -> JStat
|= JExpr
w JExpr -> FastString -> JExpr
.^ FastString
"val"
                                                        , JExpr
f JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if01 (JExpr
v JExpr -> JExpr -> JExpr
.===. JExpr
null_)
                                                        ]
  PrimOp
FinalizeWeakOp     -> \[JExpr
fl,JExpr
fin] [JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
fin, JExpr
fl] FastString
"h$finalizeWeak" [JExpr
w]
  PrimOp
TouchOp            -> \[] [JExpr
_e]      -> JStat -> PrimRes
PrimInline JStat
forall a. Monoid a => a
mempty
  PrimOp
KeepAliveOp        -> \[JExpr
_r] [JExpr
x, JExpr
f]  -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
ReturnStat (FastString -> [JExpr] -> JExpr
app FastString
"h$keepAlive" [JExpr
x, JExpr
f])


------------------------------ Stable pointers and names ------------------------

  PrimOp
MakeStablePtrOp -> \[JExpr
s1,JExpr
s2] [JExpr
a] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
      [ JExpr
s1 JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$stablePtrBuf"
      , JExpr
s2 JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$makeStablePtr" [JExpr
a]
      ]
  PrimOp
DeRefStablePtrOp -> \[JExpr
r] [JExpr
_s1,JExpr
s2]            -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$deRefStablePtr" [JExpr
s2]
  PrimOp
EqStablePtrOp    -> \[JExpr
r] [JExpr
_sa1,JExpr
sa2,JExpr
_sb1,JExpr
sb2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
sa2 JExpr -> JExpr -> JExpr
.===. JExpr
sb2)

  PrimOp
MakeStableNameOp  -> \[JExpr
r] [JExpr
a] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$makeStableName" [JExpr
a]
  PrimOp
StableNameToIntOp -> \[JExpr
r] [JExpr
s] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$stableNameInt" [JExpr
s]

------------------------------ Compact normal form -----------------------------

  PrimOp
CompactNewOp           -> \[JExpr
c] [JExpr
s]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
c JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$compactNew" [JExpr
s]
  PrimOp
CompactResizeOp        -> \[]  [JExpr
c,JExpr
s] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$compactResize" [JExpr
c,JExpr
s]
  PrimOp
CompactContainsOp      -> \[JExpr
r] [JExpr
c,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$compactContains" [JExpr
c,JExpr
v]
  PrimOp
CompactContainsAnyOp   -> \[JExpr
r] [JExpr
v]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$compactContainsAny" [JExpr
v]
  PrimOp
CompactGetFirstBlockOp -> \[JExpr
ra,JExpr
ro,JExpr
s] [JExpr
c] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
ra,JExpr
ro,JExpr
s] FastString
"h$compactGetFirstBlock" [JExpr
c]
  PrimOp
CompactGetNextBlockOp -> \[JExpr
ra,JExpr
ro,JExpr
s] [JExpr
c,JExpr
a,JExpr
o] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
ra,JExpr
ro,JExpr
s] FastString
"h$compactGetNextBlock" [JExpr
c,JExpr
a,JExpr
o]
  PrimOp
CompactAllocateBlockOp -> \[JExpr
ra,JExpr
ro] [JExpr
size,JExpr
sa,JExpr
so] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
ra,JExpr
ro] FastString
"h$compactAllocateBlock" [JExpr
size,JExpr
sa,JExpr
so]
  PrimOp
CompactFixupPointersOp -> \[JExpr
c,JExpr
newroota, JExpr
newrooto] [JExpr
blocka,JExpr
blocko,JExpr
roota,JExpr
rooto] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JExpr] -> FastString -> [JExpr] -> JStat
appT [JExpr
c,JExpr
newroota,JExpr
newrooto] FastString
"h$compactFixupPointers" [JExpr
blocka,JExpr
blocko,JExpr
roota,JExpr
rooto]
  PrimOp
CompactAdd -> \[JExpr
_r] [JExpr
c,JExpr
o] ->
    JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$compactAdd" [JExpr
c,JExpr
o])
  PrimOp
CompactAddWithSharing -> \[JExpr
_r] [JExpr
c,JExpr
o] ->
    JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$compactAddWithSharing" [JExpr
c,JExpr
o])
  PrimOp
CompactSize -> \[JExpr
s] [JExpr
c] ->
    JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
s JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$compactSize" [JExpr
c]

------------------------------ Unsafe pointer equality --------------------------

  PrimOp
ReallyUnsafePtrEqualityOp -> \[JExpr
r] [JExpr
p1,JExpr
p2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr
if10 (JExpr
p1 JExpr -> JExpr -> JExpr
.===. JExpr
p2)

------------------------------ Parallelism --------------------------------------

  PrimOp
ParOp     -> \[JExpr
r] [JExpr
_a] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
zero_
  PrimOp
SparkOp   -> \[JExpr
r] [JExpr
a]  -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a
  PrimOp
SeqOp     -> \[JExpr
_r] [JExpr
e] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$e" [JExpr
e])
  PrimOp
NumSparks -> \[JExpr
r] []   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
zero_

------------------------------ Tag to enum stuff --------------------------------

  PrimOp
DataToTagOp -> \[JExpr
_r] [JExpr
d] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
      [ JExpr
stack JExpr -> JExpr -> JExpr
.! JExpr -> JExpr
PreInc JExpr
sp JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$dataToTag_e"
      , JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$e" [JExpr
d])
      ]
  PrimOp
TagToEnumOp -> \[JExpr
r] [JExpr
tag] -> if
    | Type -> Bool
isBoolTy Type
ty -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr -> JExpr
IfExpr JExpr
tag JExpr
true_ JExpr
false_
    | Bool
otherwise   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$tagToEnum" [JExpr
tag]

------------------------------ Bytecode operations ------------------------------

  PrimOp
AddrToAnyOp -> \[JExpr
r] [JExpr
d,JExpr
_o] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
d

------------------------------ Profiling (CCS)  ------------------------------

  PrimOp
GetCCSOfOp -> \[JExpr
a, JExpr
o] [JExpr
obj] -> if
    | Bool
prof -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
a JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr -> JExpr
if_ (JExpr -> JExpr
isObject JExpr
obj)
                    (FastString -> [JExpr] -> JExpr
app FastString
"h$buildCCSPtr" [JExpr
obj JExpr -> FastString -> JExpr
.^ FastString
"cc"])
                    JExpr
null_
        , JExpr
o JExpr -> JExpr -> JStat
|= JExpr
zero_
        ]
    | Bool
otherwise -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                    [ JExpr
a JExpr -> JExpr -> JStat
|= JExpr
null_
                    , JExpr
o JExpr -> JExpr -> JStat
|= JExpr
zero_
                    ]

  PrimOp
GetCurrentCCSOp -> \[JExpr
a, JExpr
o] [JExpr
_dummy_arg] ->
    let ptr :: JExpr
ptr = if Bool
prof then FastString -> [JExpr] -> JExpr
app FastString
"h$buildCCSPtr" [JExpr
jCurrentCCS]
                      else JExpr
null_
    in JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
        [ JExpr
a JExpr -> JExpr -> JStat
|= JExpr
ptr
        , JExpr
o JExpr -> JExpr -> JStat
|= JExpr
zero_
        ]

  PrimOp
ClearCCSOp -> \[JExpr
_r] [JExpr
x] -> JStat -> PrimRes
PRPrimCall (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JStat
ReturnStat (FastString -> [JExpr] -> JExpr
app FastString
"h$clearCCS" [JExpr
x])

------------------------------ Eventlog -------------------

  PrimOp
TraceEventOp       -> \[] [JExpr
ed,JExpr
eo]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$traceEvent" [JExpr
ed,JExpr
eo]
  PrimOp
TraceEventBinaryOp -> \[] [JExpr
ed,JExpr
eo,JExpr
len] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$traceEventBinary" [JExpr
ed,JExpr
eo,JExpr
len]
  PrimOp
TraceMarkerOp      -> \[] [JExpr
ed,JExpr
eo]     -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$traceMarker" [JExpr
ed,JExpr
eo]

------------------------------ ByteArray -------------------

  PrimOp
IndexByteArrayOp_Word8AsChar      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsWideChar  -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsAddr      -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
IndexByteArrayOp_Word8AsFloat     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsDouble    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f64 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsStablePtr -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
IndexByteArrayOp_Word8AsInt16     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i16 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsInt32     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsInt64     -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
IndexByteArrayOp_Word8AsInt       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsWord16    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u16  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsWord32    -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32  JExpr
a JExpr
i
  PrimOp
IndexByteArrayOp_Word8AsWord64    -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
IndexByteArrayOp_Word8AsWord      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32  JExpr
a JExpr
i

  PrimOp
ReadByteArrayOp_Word8AsChar       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsWideChar   -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsAddr       -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
ReadByteArrayOp_Word8AsFloat      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsDouble     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_f64 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsStablePtr  -> \[JExpr
r,JExpr
o] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
ReadByteArrayOp_Word8AsInt16      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i16 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsInt32      -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsInt64      -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
ReadByteArrayOp_Word8AsInt        -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsWord16     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u16  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsWord32     -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32  JExpr
a JExpr
i
  PrimOp
ReadByteArrayOp_Word8AsWord64     -> \[JExpr
h,JExpr
l] [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
ReadByteArrayOp_Word8AsWord       -> \[JExpr
r]   [JExpr
a,JExpr
i] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32  JExpr
a JExpr
i

  PrimOp
WriteByteArrayOp_Word8AsChar      -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i8  JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsWideChar  -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsAddr      -> \[] [JExpr
a,JExpr
i,JExpr
r,JExpr
o] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr JExpr
a JExpr
i JExpr
r JExpr
o
  PrimOp
WriteByteArrayOp_Word8AsFloat     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_f32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsDouble    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_f64 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsStablePtr -> \[] [JExpr
a,JExpr
i,JExpr
_,JExpr
o] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
o
  PrimOp
WriteByteArrayOp_Word8AsInt16     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i16 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsInt32     -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsInt64     -> \[] [JExpr
a,JExpr
i,JExpr
h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_i64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
WriteByteArrayOp_Word8AsInt       -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsWord16    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u16 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsWord32    -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
i JExpr
e
  PrimOp
WriteByteArrayOp_Word8AsWord64    -> \[] [JExpr
a,JExpr
i,JExpr
h,JExpr
l] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_u64 JExpr
a JExpr
i JExpr
h JExpr
l
  PrimOp
WriteByteArrayOp_Word8AsWord      -> \[] [JExpr
a,JExpr
i,JExpr
e]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
i JExpr
e

  PrimOp
CasByteArrayOp_Int                -> \[JExpr
r] [JExpr
a,JExpr
i,JExpr
o,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_i32 JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
r JExpr
a JExpr
i JExpr
o JExpr
n
  PrimOp
CasByteArrayOp_Int8               -> \[JExpr
r] [JExpr
a,JExpr
i,JExpr
o,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8  Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_i8  JExpr -> JExpr -> JExpr -> JStat
write_i8  JExpr
r JExpr
a JExpr
i JExpr
o JExpr
n
  PrimOp
CasByteArrayOp_Int16              -> \[JExpr
r] [JExpr
a,JExpr
i,JExpr
o,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_i16 JExpr -> JExpr -> JExpr -> JStat
write_i16 JExpr
r JExpr
a JExpr
i JExpr
o JExpr
n
  PrimOp
CasByteArrayOp_Int32              -> \[JExpr
r] [JExpr
a,JExpr
i,JExpr
o,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_i32 JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
r JExpr
a JExpr
i JExpr
o JExpr
n

  PrimOp
CasByteArrayOp_Int64              -> \[JExpr
rh,JExpr
rl] [JExpr
a,JExpr
i,JExpr
oh,JExpr
ol,JExpr
nh,JExpr
nl] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
bound JExpr
a JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr, JExpr)
-> JExpr
-> JExpr
-> (JExpr, JExpr)
-> (JExpr, JExpr)
-> JStat
casOp2 JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_i64 JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_i64 (JExpr
rh,JExpr
rl) JExpr
a JExpr
i (JExpr
oh,JExpr
ol) (JExpr
nh,JExpr
nl)

  PrimOp
CasAddrOp_Addr                    -> \[JExpr
ra,JExpr
ro] [JExpr
a,JExpr
o,JExpr
oa,JExpr
oo,JExpr
na,JExpr
no] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr, JExpr)
-> JExpr
-> JExpr
-> (JExpr, JExpr)
-> (JExpr, JExpr)
-> JStat
casOp2 JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr (JExpr
ra,JExpr
ro) JExpr
a JExpr
o (JExpr
oa,JExpr
oo) (JExpr
na,JExpr
no)
  PrimOp
CasAddrOp_Word                    -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
old,JExpr
new] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_u32 JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
r JExpr
a JExpr
o JExpr
old JExpr
new
  PrimOp
CasAddrOp_Word8                   -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
old,JExpr
new] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_u8  JExpr -> JExpr -> JExpr -> JStat
write_u8  JExpr
r JExpr
a JExpr
o JExpr
old JExpr
new
  PrimOp
CasAddrOp_Word16                  -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
old,JExpr
new] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_u16 JExpr -> JExpr -> JExpr -> JStat
write_u16 JExpr
r JExpr
a JExpr
o JExpr
old JExpr
new
  PrimOp
CasAddrOp_Word32                  -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
old,JExpr
new] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read_u32 JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
r JExpr
a JExpr
o JExpr
old JExpr
new
  PrimOp
CasAddrOp_Word64                  -> \[JExpr
rh,JExpr
rl] [JExpr
a,JExpr
o,JExpr
oh,JExpr
ol,JExpr
nh,JExpr
nl] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr, JExpr)
-> JExpr
-> JExpr
-> (JExpr, JExpr)
-> (JExpr, JExpr)
-> JStat
casOp2 JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_u64 JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_u64 (JExpr
rh,JExpr
rl) JExpr
a JExpr
o (JExpr
oh,JExpr
ol) (JExpr
nh,JExpr
nl)

  PrimOp
FetchAddAddrOp_Word               -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
Add   JExpr
r JExpr
a JExpr
o JExpr
v
  PrimOp
FetchSubAddrOp_Word               -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
Sub   JExpr
r JExpr
a JExpr
o JExpr
v
  PrimOp
FetchAndAddrOp_Word               -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
BAnd  JExpr
r JExpr
a JExpr
o JExpr
v
  PrimOp
FetchNandAddrOp_Word              -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr ((JExpr -> JExpr
BNot (JExpr -> JExpr) -> (JExpr -> JExpr) -> JExpr -> JExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((JExpr -> JExpr) -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr) -> JExpr -> JExpr -> JExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JExpr -> JExpr -> JExpr
BAnd) JExpr
r JExpr
a JExpr
o JExpr
v
  PrimOp
FetchOrAddrOp_Word                -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
BOr   JExpr
r JExpr
a JExpr
o JExpr
v
  PrimOp
FetchXorAddrOp_Word               -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
v] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
BXor  JExpr
r JExpr
a JExpr
o JExpr
v

  PrimOp
InterlockedExchange_Addr          -> \[JExpr
ra,JExpr
ro] [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                          [ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a1 JExpr
o1 JExpr
ra JExpr
ro
                                          , JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2
                                          ]
  PrimOp
InterlockedExchange_Word          -> \[JExpr
r] [JExpr
a,JExpr
o,JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
                                          [ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a JExpr
o
                                          , JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
o JExpr
w
                                          ]

  PrimOp
ShrinkSmallMutableArrayOp_Char    -> \[]  [JExpr
a,JExpr
n] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$shrinkMutableCharArray" [JExpr
a,JExpr
n]
  PrimOp
GetSizeofSmallMutableArrayOp      -> \[JExpr
r] [JExpr
a]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"length"

  PrimOp
AtomicReadAddrOp_Word             -> \[JExpr
r] [JExpr
a,JExpr
o]   -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a JExpr
o
  PrimOp
AtomicWriteAddrOp_Word            -> \[]  [JExpr
a,JExpr
o,JExpr
w] -> JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
o JExpr
w


------------------------------ Unhandled primops -------------------

  PrimOp
NewPromptTagOp                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
PromptOp                          -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
Control0Op                        -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op

  PrimOp
NewIOPortOp                       -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
ReadIOPortOp                      -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
WriteIOPortOp                     -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op

  PrimOp
GetSparkOp                        -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
AnyToAddrOp                       -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
MkApUpd0_Op                       -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
NewBCOOp                          -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
UnpackClosureOp                   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
ClosureSizeOp                     -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
GetApStackValOp                   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  PrimOp
WhereFromOp                       -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op -- should be easily implementable with o.f.n

  PrimOp
SetThreadAllocationCounter        -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op

------------------------------- Vector -----------------------------------------
-- For now, vectors are unsupported on the JS backend. Simply put, they do not
-- make much sense to support given support for arrays and lack of SIMD support
-- in JS. We could try to roll something special but we would not be able to
-- give any performance guarentees to the user and so we leave these has
-- unhandled for now.
  VecBroadcastOp PrimOpVecCat
_ Int
_ Width
_              -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecPackOp PrimOpVecCat
_ Int
_ Width
_                   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecUnpackOp PrimOpVecCat
_ Int
_ Width
_                 -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecInsertOp PrimOpVecCat
_ Int
_ Width
_                 -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecAddOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecSubOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecMulOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecDivOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecQuotOp PrimOpVecCat
_ Int
_ Width
_                   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecRemOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecNegOp PrimOpVecCat
_ Int
_ Width
_                    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecIndexByteArrayOp PrimOpVecCat
_ Int
_ Width
_         -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecReadByteArrayOp PrimOpVecCat
_ Int
_ Width
_          -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecWriteByteArrayOp PrimOpVecCat
_ Int
_ Width
_         -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecIndexOffAddrOp PrimOpVecCat
_ Int
_ Width
_           -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecReadOffAddrOp PrimOpVecCat
_ Int
_ Width
_            -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecWriteOffAddrOp PrimOpVecCat
_ Int
_ Width
_           -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op

  VecIndexScalarByteArrayOp PrimOpVecCat
_ Int
_ Width
_   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecReadScalarByteArrayOp PrimOpVecCat
_ Int
_ Width
_    -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecWriteScalarByteArrayOp PrimOpVecCat
_ Int
_ Width
_   -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecIndexScalarOffAddrOp PrimOpVecCat
_ Int
_ Width
_     -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecReadScalarOffAddrOp PrimOpVecCat
_ Int
_ Width
_      -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op
  VecWriteScalarOffAddrOp PrimOpVecCat
_ Int
_ Width
_     -> PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op

  PrimOp
PrefetchByteArrayOp3              -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchMutableByteArrayOp3       -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchAddrOp3                   -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchValueOp3                  -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchByteArrayOp2              -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchMutableByteArrayOp2       -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchAddrOp2                   -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchValueOp2                  -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchByteArrayOp1              -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchMutableByteArrayOp1       -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchAddrOp1                   -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchValueOp1                  -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchByteArrayOp0              -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchMutableByteArrayOp0       -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchAddrOp0                   -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp
  PrimOp
PrefetchValueOp0                  -> [JExpr] -> [JExpr] -> PrimRes
forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp

unhandledPrimop :: PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop :: PrimOp -> [JExpr] -> [JExpr] -> PrimRes
unhandledPrimop PrimOp
op [JExpr]
rs [JExpr]
as = JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ FastString -> [JExpr] -> JStat
appS FastString
"h$log" [String -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr (String -> JExpr) -> String -> JExpr
forall a b. (a -> b) -> a -> b
$ [String] -> String
forall a. Monoid a => [a] -> a
mconcat
      [ String
"warning, unhandled primop: "
      , SDocContext -> SDoc -> String
renderWithContext SDocContext
defaultSDocContext (PrimOp -> SDoc
forall a. Outputable a => a -> SDoc
ppr PrimOp
op)
      , String
" "
      , (Int, Int) -> String
forall a. Show a => a -> String
show ([JExpr] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [JExpr]
rs, [JExpr] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [JExpr]
as)
      ]]
  , FastString -> [JExpr] -> JStat
appS (String -> FastString
mkFastString (String -> FastString) -> String -> FastString
forall a b. (a -> b) -> a -> b
$ String
"h$primop_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
zEncodeString (SDocContext -> SDoc -> String
renderWithContext SDocContext
defaultSDocContext (PrimOp -> SDoc
forall a. Outputable a => a -> SDoc
ppr PrimOp
op))) [JExpr]
as
    -- copyRes
  , [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat ([JStat] -> JStat) -> [JStat] -> JStat
forall a b. (a -> b) -> a -> b
$ (JExpr -> StgRet -> JStat) -> [JExpr] -> [StgRet] -> [JStat]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\JExpr
r StgRet
reg -> JExpr
r JExpr -> JExpr -> JStat
|= StgRet -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr StgRet
reg) [JExpr]
rs (StgRet -> [StgRet]
forall a. Enum a => a -> [a]
enumFrom StgRet
Ret1)
  ]

-- | A No Op, used for primops the JS platform cannot or do not support. For
-- example, the prefetching primops do not make sense on the JS platform because
-- we do not have enough control over memory to provide any kind of prefetching
-- mechanism. Hence, these are NoOps.
noOp :: Foldable f => f a -> f a -> PrimRes
noOp :: forall (f :: * -> *) a. Foldable f => f a -> f a -> PrimRes
noOp = (f a -> PrimRes) -> f a -> f a -> PrimRes
forall a b. a -> b -> a
const ((f a -> PrimRes) -> f a -> f a -> PrimRes)
-> (PrimRes -> f a -> PrimRes) -> PrimRes -> f a -> f a -> PrimRes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimRes -> f a -> PrimRes
forall a b. a -> b -> a
const (PrimRes -> f a -> f a -> PrimRes)
-> PrimRes -> f a -> f a -> PrimRes
forall a b. (a -> b) -> a -> b
$ JStat -> PrimRes
PrimInline JStat
forall a. Monoid a => a
mempty

-- tuple returns
appT :: [JExpr] -> FastString -> [JExpr] -> JStat
appT :: [JExpr] -> FastString -> [JExpr] -> JStat
appT []     FastString
f [JExpr]
xs = FastString -> [JExpr] -> JStat
appS FastString
f [JExpr]
xs
appT (JExpr
r:[JExpr]
rs) FastString
f [JExpr]
xs = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
f [JExpr]
xs
  , [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat ((JExpr -> StgRet -> JStat) -> [JExpr] -> [StgRet] -> [JStat]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\JExpr
r StgRet
ret -> JExpr
r JExpr -> JExpr -> JStat
|= StgRet -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr StgRet
ret) [JExpr]
rs (StgRet -> [StgRet]
forall a. Enum a => a -> [a]
enumFrom StgRet
Ret1))
  ]

--------------------------------------------
-- ByteArray indexing
--------------------------------------------

-- For every ByteArray, the RTS creates the following views:
--  i3: Int32 view
--  u8: Word8 view
--  u1: Word16 view
--  f3: Float32 view
--  f6: Float64 view
--  dv: generic DataView
-- It seems a bit weird to mix Int and Word views like this, but perhaps they
-- are the more common.
--
-- See 'h$newByteArray' in 'ghc/rts/js/mem.js' for details.
--
-- Note that *byte* indexing can only be done with the generic DataView. Use
-- read_boff_* and write_boff_* for this.
--
-- Other read_* and write_* helpers directly use the more specific views.
-- Prefer using them over idx_* to make your intent clearer.

idx_i32, idx_u8, idx_u16, idx_f64, idx_f32 :: JExpr -> JExpr -> JExpr
idx_i32 :: JExpr -> JExpr -> JExpr
idx_i32 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
IdxExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"i3") JExpr
i
idx_u8 :: JExpr -> JExpr -> JExpr
idx_u8  JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
IdxExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"u8") JExpr
i
idx_u16 :: JExpr -> JExpr -> JExpr
idx_u16 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
IdxExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"u1") JExpr
i
idx_f64 :: JExpr -> JExpr -> JExpr
idx_f64 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
IdxExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"f6") JExpr
i
idx_f32 :: JExpr -> JExpr -> JExpr
idx_f32 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
IdxExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"f3") JExpr
i

read_u8 :: JExpr -> JExpr -> JExpr
read_u8 :: JExpr -> JExpr -> JExpr
read_u8 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
idx_u8 JExpr
a JExpr
i

read_u16 :: JExpr -> JExpr -> JExpr
read_u16 :: JExpr -> JExpr -> JExpr
read_u16 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
idx_u16 JExpr
a JExpr
i

read_u32 :: JExpr -> JExpr -> JExpr
read_u32 :: JExpr -> JExpr -> JExpr
read_u32 JExpr
a JExpr
i = JExpr -> JExpr
toU32 (JExpr -> JExpr -> JExpr
idx_i32 JExpr
a JExpr
i)

read_i8 :: JExpr -> JExpr -> JExpr
read_i8 :: JExpr -> JExpr -> JExpr
read_i8 JExpr
a JExpr
i = JExpr -> JExpr
signExtend8 (JExpr -> JExpr -> JExpr
idx_u8 JExpr
a JExpr
i)

read_i16 :: JExpr -> JExpr -> JExpr
read_i16 :: JExpr -> JExpr -> JExpr
read_i16 JExpr
a JExpr
i = JExpr -> JExpr
signExtend16 (JExpr -> JExpr -> JExpr
idx_u16 JExpr
a JExpr
i)

read_i32 :: JExpr -> JExpr -> JExpr
read_i32 :: JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
idx_i32 JExpr
a JExpr
i

read_f32 :: JExpr -> JExpr -> JExpr
read_f32 :: JExpr -> JExpr -> JExpr
read_f32 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
idx_f32 JExpr
a JExpr
i

read_f64 :: JExpr -> JExpr -> JExpr
read_f64 :: JExpr -> JExpr -> JExpr
read_f64 JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
idx_f64 JExpr
a JExpr
i

read_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_u64 JExpr
a JExpr
i JExpr
rh JExpr
rl = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
rl JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)
  , JExpr
rh JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
1 (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1))
  ]

read_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_i64 JExpr
a JExpr
i JExpr
rh JExpr
rl = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
rl JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_u32 JExpr
a (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)
  , JExpr
rh JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
1 (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1))
  ]

--------------------------------------
-- Addr#
--------------------------------------

write_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_addr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
o
    -- create the hidden array for arrays if it doesn't exist
  , JExpr -> JStat -> JStat -> JStat
ifS (JExpr -> JExpr
Not (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr")) (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JStat
|= JVal -> JExpr
ValExpr ([JExpr] -> JVal
JList [])) JStat
forall a. Monoid a => a
mempty
  , JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
2) JExpr -> JExpr -> JStat
|= JExpr
r
  ]

read_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_addr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
o JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  , JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr -> JExpr
if_ ((JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr") JExpr -> JExpr -> JExpr
.&&. (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
2)))
            (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
2))
            JExpr
null_
  ]

read_boff_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_addr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
o JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  , JExpr
r JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr -> JExpr
if_ ((JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr") JExpr -> JExpr -> JExpr
.&&. (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! JExpr
i))
            (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! JExpr
i)
            JExpr
null_
  ]

write_boff_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_addr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
o
    -- create the hidden array for arrays if it doesn't exist
  , JExpr -> JStat -> JStat -> JStat
ifS (JExpr -> JExpr
Not (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr")) (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JStat
|= JVal -> JExpr
ValExpr ([JExpr] -> JVal
JList [])) JStat
forall a. Monoid a => a
mempty
  , JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"arr" JExpr -> JExpr -> JExpr
.! JExpr
i JExpr -> JExpr -> JStat
|= JExpr
r
  ]


--------------------------------------
-- StablePtr
--------------------------------------

read_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_stableptr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$stablePtrBuf" -- stable pointers are always in this array
  , JExpr
o JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
a JExpr
i
  ]

read_boff_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_stableptr JExpr
a JExpr
i JExpr
r JExpr
o = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
r JExpr -> JExpr -> JStat
|= FastString -> JExpr
var FastString
"h$stablePtrBuf" -- stable pointers are always in this array
  , JExpr
o JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i
  ]

write_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_stableptr JExpr
a JExpr
i JExpr
_r JExpr
o = JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
o
  -- don't store "r" as it must be h$stablePtrBuf

write_boff_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_stableptr :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_stableptr JExpr
a JExpr
i JExpr
_r JExpr
o = JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
o
  -- don't store "r" as it must be h$stablePtrBuf

write_u8 :: JExpr -> JExpr -> JExpr -> JStat
write_u8 :: JExpr -> JExpr -> JExpr -> JStat
write_u8 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_u8 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_u16 :: JExpr -> JExpr -> JExpr -> JStat
write_u16 :: JExpr -> JExpr -> JExpr -> JStat
write_u16 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_u16 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_u32 :: JExpr -> JExpr -> JExpr -> JStat
write_u32 :: JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_i32 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_i8 :: JExpr -> JExpr -> JExpr -> JStat
write_i8 :: JExpr -> JExpr -> JExpr -> JStat
write_i8 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_u8 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_i16 :: JExpr -> JExpr -> JExpr -> JStat
write_i16 :: JExpr -> JExpr -> JExpr -> JStat
write_i16 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_u16 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_i32 :: JExpr -> JExpr -> JExpr -> JStat
write_i32 :: JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_i32 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_f32 :: JExpr -> JExpr -> JExpr -> JStat
write_f32 :: JExpr -> JExpr -> JExpr -> JStat
write_f32 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_f32 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_f64 :: JExpr -> JExpr -> JExpr -> JStat
write_f64 :: JExpr -> JExpr -> JExpr -> JStat
write_f64 JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr
idx_f64 JExpr
a JExpr
i JExpr -> JExpr -> JStat
|= JExpr
v

write_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_u64 JExpr
a JExpr
i JExpr
h JExpr
l = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)         JExpr
l
  , JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
1 (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)) JExpr
h
  ]

write_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_i64 JExpr
a JExpr
i JExpr
h JExpr
l = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_u32 JExpr
a (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)         JExpr
l
  , JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
1 (JExpr
i JExpr -> JExpr -> JExpr
.<<. JExpr
1)) JExpr
h
  ]

-- Data View helper functions: byte indexed!
--
-- The argument list consists of the array @a@, the index @i@, and the new value
-- to set (in the case of a setter) @v@.

write_boff_i8, write_boff_u8, write_boff_i16, write_boff_u16, write_boff_i32, write_boff_u32, write_boff_f32, write_boff_f64 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_i8 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_i8  JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr -> JStat
write_i8 JExpr
a JExpr
i JExpr
v
write_boff_u8 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_u8  JExpr
a JExpr
i JExpr
v = JExpr -> JExpr -> JExpr -> JStat
write_u8 JExpr
a JExpr
i JExpr
v
write_boff_i16 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_i16 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setInt16"  ) [JExpr
i, JExpr
v, JExpr
true_]
write_boff_u16 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_u16 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setUint16" ) [JExpr
i, JExpr
v, JExpr
true_]
write_boff_i32 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setInt32"  ) [JExpr
i, JExpr
v, JExpr
true_]
write_boff_u32 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setUint32" ) [JExpr
i, JExpr
v, JExpr
true_]
write_boff_f32 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_f32 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setFloat32") [JExpr
i, JExpr
v, JExpr
true_]
write_boff_f64 :: JExpr -> JExpr -> JExpr -> JStat
write_boff_f64 JExpr
a JExpr
i JExpr
v = JExpr -> [JExpr] -> JStat
ApplStat (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"setFloat64") [JExpr
i, JExpr
v, JExpr
true_]

write_boff_i64, write_boff_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_i64 JExpr
a JExpr
i JExpr
h JExpr
l = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
i (Integer -> JExpr
Int Integer
4)) JExpr
h
  , JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
i JExpr
l
  ]
write_boff_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
write_boff_u64 JExpr
a JExpr
i JExpr
h JExpr
l = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
i (Integer -> JExpr
Int Integer
4)) JExpr
h
  , JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
a JExpr
i JExpr
l
  ]

read_boff_i8, read_boff_u8, read_boff_i16, read_boff_u16, read_boff_i32, read_boff_u32, read_boff_f32, read_boff_f64 :: JExpr -> JExpr -> JExpr
read_boff_i8 :: JExpr -> JExpr -> JExpr
read_boff_i8  JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
read_i8 JExpr
a JExpr
i
read_boff_u8 :: JExpr -> JExpr -> JExpr
read_boff_u8  JExpr
a JExpr
i = JExpr -> JExpr -> JExpr
read_u8 JExpr
a JExpr
i
read_boff_i16 :: JExpr -> JExpr -> JExpr
read_boff_i16 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getInt16"  ) [JExpr
i, JExpr
true_]
read_boff_u16 :: JExpr -> JExpr -> JExpr
read_boff_u16 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getUint16" ) [JExpr
i, JExpr
true_]
read_boff_i32 :: JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getInt32"  ) [JExpr
i, JExpr
true_]
read_boff_u32 :: JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getUint32" ) [JExpr
i, JExpr
true_]
read_boff_f32 :: JExpr -> JExpr -> JExpr
read_boff_f32 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getFloat32") [JExpr
i, JExpr
true_]
read_boff_f64 :: JExpr -> JExpr -> JExpr
read_boff_f64 JExpr
a JExpr
i = JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
a JExpr -> FastString -> JExpr
.^ FastString
"dv" JExpr -> FastString -> JExpr
.^ FastString
"getFloat64") [JExpr
i, JExpr
true_]

read_boff_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_i64 JExpr
a JExpr
i JExpr
rh JExpr
rl = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
rh JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_i32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
i (Integer -> JExpr
Int Integer
4))
  , JExpr
rl JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a JExpr
i
  ]

read_boff_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 :: JExpr -> JExpr -> JExpr -> JExpr -> JStat
read_boff_u64 JExpr
a JExpr
i JExpr
rh JExpr
rl = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
rh JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a (JExpr -> JExpr -> JExpr
Add JExpr
i (Integer -> JExpr
Int Integer
4))
  , JExpr
rl JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
a JExpr
i
  ]

fetchOpByteArray :: (JExpr -> JExpr -> JExpr) -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray :: (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpByteArray JExpr -> JExpr -> JExpr
op JExpr
tgt JExpr
src JExpr
i JExpr
v = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
tgt JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_i32 JExpr
src JExpr
i
  , JExpr -> JExpr -> JExpr -> JStat
write_i32 JExpr
src JExpr
i (JExpr -> JExpr -> JExpr
op JExpr
tgt JExpr
v)
  ]

fetchOpAddr :: (JExpr -> JExpr -> JExpr) -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr :: (JExpr -> JExpr -> JExpr)
-> JExpr -> JExpr -> JExpr -> JExpr -> JStat
fetchOpAddr JExpr -> JExpr -> JExpr
op JExpr
tgt JExpr
src JExpr
i JExpr
v = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
tgt JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read_boff_u32 JExpr
src JExpr
i
  , JExpr -> JExpr -> JExpr -> JStat
write_boff_u32 JExpr
src JExpr
i (JExpr -> JExpr -> JExpr
op JExpr
tgt JExpr
v)
  ]

casOp
  :: (JExpr -> JExpr -> JExpr)          -- read
  -> (JExpr -> JExpr -> JExpr -> JStat) -- write
  -> JExpr                     -- target register to store result
  -> JExpr                     -- source array
  -> JExpr                     -- index
  -> JExpr                     -- old value to compare
  -> JExpr                     -- new value to write
  -> JStat
casOp :: (JExpr -> JExpr -> JExpr)
-> (JExpr -> JExpr -> JExpr -> JStat)
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JExpr
-> JStat
casOp JExpr -> JExpr -> JExpr
read JExpr -> JExpr -> JExpr -> JStat
write JExpr
tgt JExpr
src JExpr
i JExpr
old JExpr
new = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr
tgt JExpr -> JExpr -> JStat
|= JExpr -> JExpr -> JExpr
read JExpr
src JExpr
i
  , JExpr -> JStat -> JStat -> JStat
ifS (JExpr
tgt JExpr -> JExpr -> JExpr
.===. JExpr
old)
        (JExpr -> JExpr -> JExpr -> JStat
write JExpr
src JExpr
i JExpr
new)
         JStat
forall a. Monoid a => a
mempty
  ]

casOp2
  :: (JExpr -> JExpr -> JExpr -> JExpr -> JStat) -- read
  -> (JExpr -> JExpr -> JExpr -> JExpr -> JStat) -- write
  -> (JExpr,JExpr)             -- target registers to store result
  -> JExpr                     -- source array
  -> JExpr                     -- index
  -> (JExpr,JExpr)             -- old value to compare
  -> (JExpr,JExpr)             -- new value to write
  -> JStat
casOp2 :: (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr -> JExpr -> JExpr -> JExpr -> JStat)
-> (JExpr, JExpr)
-> JExpr
-> JExpr
-> (JExpr, JExpr)
-> (JExpr, JExpr)
-> JStat
casOp2 JExpr -> JExpr -> JExpr -> JExpr -> JStat
read JExpr -> JExpr -> JExpr -> JExpr -> JStat
write (JExpr
tgt1,JExpr
tgt2) JExpr
src JExpr
i (JExpr
old1,JExpr
old2) (JExpr
new1,JExpr
new2) = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JExpr -> JExpr -> JExpr -> JStat
read JExpr
src JExpr
i JExpr
tgt1 JExpr
tgt2
  , JExpr -> JStat -> JStat -> JStat
ifS ((JExpr
tgt2 JExpr -> JExpr -> JExpr
.===. JExpr
old2) JExpr -> JExpr -> JExpr
.&&. (JExpr
tgt1 JExpr -> JExpr -> JExpr
.===. JExpr
old1))
        (JExpr -> JExpr -> JExpr -> JExpr -> JStat
write JExpr
src JExpr
i JExpr
new1 JExpr
new2)
         JStat
forall a. Monoid a => a
mempty
  ]

--------------------------------------------------------------------------------
--                            Lifted Arrays
--------------------------------------------------------------------------------
-- | lifted arrays
cloneArray :: Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray :: Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JStat
cloneArray Bool
bound_check JExpr
tgt JExpr
src JExpr
start JExpr
len =
  Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
bound_check JExpr
src JExpr
start JExpr
len
  (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
      [ JExpr
tgt JExpr -> JExpr -> JStat
|= JExpr -> [JExpr] -> JExpr
ApplExpr (JExpr
src JExpr -> FastString -> JExpr
.^ FastString
"slice") [JExpr
start, JExpr -> JExpr -> JExpr
Add JExpr
len JExpr
start]
      , JExpr
tgt JExpr -> FastString -> JExpr
.^ FastString
closureMeta_   JExpr -> JExpr -> JStat
|= JExpr
zero_
      , JExpr
tgt JExpr -> FastString -> JExpr
.^ FastString
"__ghcjsArray" JExpr -> JExpr -> JStat
|= JExpr
true_
      ]

newByteArray :: JExpr -> JExpr -> JStat
newByteArray :: JExpr -> JExpr -> JStat
newByteArray JExpr
tgt JExpr
len =
  JExpr
tgt JExpr -> JExpr -> JStat
|= FastString -> [JExpr] -> JExpr
app FastString
"h$newByteArray" [JExpr
len]

-- | Check that index is positive and below a max value. Halt the process with
-- error code 134 otherwise. This is used to implement -fcheck-prim-bounds
check_bound
  :: JExpr -- ^ Max index expression
  -> Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ Index
  -> JStat -- ^ Result
  -> JStat
check_bound :: JExpr -> Bool -> JExpr -> JStat -> JStat
check_bound JExpr
_         Bool
False JExpr
_ JStat
r = JStat
r
check_bound JExpr
max_index Bool
True  JExpr
i JStat
r = [JStat] -> JStat
forall a. Monoid a => [a] -> a
mconcat
  [ JExpr -> JStat -> JStat
jwhenS ((JExpr
i JExpr -> JExpr -> JExpr
.<. JExpr
zero_) JExpr -> JExpr -> JExpr
.||. (JExpr
i JExpr -> JExpr -> JExpr
.>=. JExpr
max_index)) (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$
      JExpr -> JStat
returnS (FastString -> [JExpr] -> JExpr
app FastString
"h$exitProcess" [Integer -> JExpr
Int Integer
134])
  , JStat
r
  ]

-- | Bounds checking using ".length" property (Arrays)
bnd_arr
  :: Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ Array
  -> JExpr -- ^ Index
  -> JStat -- ^ Result
  -> JStat
bnd_arr :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
do_check JExpr
arr = JExpr -> Bool -> JExpr -> JStat -> JStat
check_bound (JExpr
arr JExpr -> FastString -> JExpr
.^ FastString
"length") Bool
do_check

-- | Range bounds checking using ".length" property (Arrays)
--
-- Empty ranges trivially pass the check
bnd_arr_range
  :: Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ Array
  -> JExpr -- ^ Index
  -> JExpr -- ^ Range size
  -> JStat -- ^ Result
  -> JStat
bnd_arr_range :: Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_arr_range Bool
False JExpr
_arr JExpr
_i JExpr
_n JStat
r = JStat
r
bnd_arr_range Bool
True   JExpr
arr  JExpr
i  JExpr
n JStat
r =
  JExpr -> JStat -> JStat -> JStat
ifS (JExpr
n JExpr -> JExpr -> JExpr
.<. JExpr
zero_) (JExpr -> JStat
returnS (JExpr -> JStat) -> JExpr -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JExpr
app FastString
"h$exitProcess" [Integer -> JExpr
Int Integer
134]) (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$
  -- Empty ranges trivially pass the check
  JExpr -> JStat -> JStat -> JStat
ifS (JExpr
n JExpr -> JExpr -> JExpr
.===. JExpr
zero_)
      JStat
r
      (Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
True JExpr
arr JExpr
i (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_arr Bool
True JExpr
arr (JExpr -> JExpr -> JExpr
Add JExpr
i (JExpr -> JExpr -> JExpr
Sub JExpr
n JExpr
1)) JStat
r)

-- | Bounds checking using ".len" property (ByteArrays)
bnd_ba
  :: Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ Array
  -> JExpr -- ^ Index
  -> JStat -- ^ Result
  -> JStat
bnd_ba :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr = JExpr -> Bool -> JExpr -> JStat -> JStat
check_bound (JExpr
arr JExpr -> FastString -> JExpr
.^ FastString
"len") Bool
do_check

-- | ByteArray bounds checking (byte offset, 8-bit value)
bnd_ba8 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8 = Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba

-- | ByteArray bounds checking (byte offset, 16-bit value)
bnd_ba16 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
do_check JExpr
arr JExpr
idx JStat
r =
  -- check that idx non incremented is in range:
  -- (idx + 1) may be in range while idx isn't
  Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr JExpr
idx
  (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr (JExpr -> JExpr -> JExpr
Add JExpr
idx JExpr
1) JStat
r

-- | ByteArray bounds checking (byte offset, 32-bit value)
bnd_ba32 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
do_check JExpr
arr JExpr
idx JStat
r =
  -- check that idx non incremented is in range:
  -- (idx + 3) may be in range while idx isn't
  Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr JExpr
idx
  (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr (JExpr -> JExpr -> JExpr
Add JExpr
idx JExpr
3) JStat
r

-- | ByteArray bounds checking (byte offset, 64-bit value)
bnd_ba64 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
do_check JExpr
arr JExpr
idx JStat
r =
  -- check that idx non incremented is in range:
  -- (idx + 7) may be in range while idx isn't
  Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr JExpr
idx
  (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
do_check JExpr
arr (JExpr -> JExpr -> JExpr
Add JExpr
idx JExpr
7) JStat
r

-- | ByteArray bounds checking (8-bit offset, 8-bit value)
bnd_ix8 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix8 = Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba8

-- | ByteArray bounds checking (16-bit offset, 16-bit value)
bnd_ix16 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix16 Bool
do_check JExpr
arr JExpr
idx JStat
r = Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba16 Bool
do_check JExpr
arr (JExpr
idx JExpr -> JExpr -> JExpr
.<<. JExpr
1) JStat
r

-- | ByteArray bounds checking (32-bit offset, 32-bit value)
bnd_ix32 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix32 Bool
do_check JExpr
arr JExpr
idx JStat
r = Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba32 Bool
do_check JExpr
arr (JExpr
idx JExpr -> JExpr -> JExpr
.<<. JExpr
2) JStat
r

-- | ByteArray bounds checking (64-bit offset, 64-bit value)
bnd_ix64 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 :: Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ix64 Bool
do_check JExpr
arr JExpr
idx JStat
r = Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba64 Bool
do_check JExpr
arr (JExpr
idx JExpr -> JExpr -> JExpr
.<<. JExpr
3) JStat
r

-- | Bounds checking on a range and using ".len" property (ByteArrays)
--
-- Empty ranges trivially pass the check
bnd_ba_range
  :: Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ Array
  -> JExpr -- ^ Index
  -> JExpr -- ^ Range size
  -> JStat -- ^ Result
  -> JStat
bnd_ba_range :: Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
False JExpr
_  JExpr
_ JExpr
_ JStat
r = JStat
r
bnd_ba_range Bool
True  JExpr
xs JExpr
i JExpr
n JStat
r =
  JExpr -> JStat -> JStat -> JStat
ifS (JExpr
n JExpr -> JExpr -> JExpr
.<. JExpr
zero_) (JExpr -> JStat
returnS (JExpr -> JStat) -> JExpr -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JExpr
app FastString
"h$exitProcess" [Integer -> JExpr
Int Integer
134]) (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$
  -- Empty ranges trivially pass the check
  JExpr -> JStat -> JStat -> JStat
ifS (JExpr
n JExpr -> JExpr -> JExpr
.===. JExpr
zero_)
      JStat
r
      (Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
True JExpr
xs (JExpr -> JExpr -> JExpr
Add JExpr
i (JExpr -> JExpr -> JExpr
Sub JExpr
n JExpr
1)) (Bool -> JExpr -> JExpr -> JStat -> JStat
bnd_ba Bool
True JExpr
xs JExpr
i JStat
r))

checkOverlapByteArray
  :: Bool  -- ^ Should we do bounds checking?
  -> JExpr -- ^ First array
  -> JExpr -- ^ First offset
  -> JExpr -- ^ Second array
  -> JExpr -- ^ Second offset
  -> JExpr -- ^ Range size
  -> JStat -- ^ Result
  -> JStat
checkOverlapByteArray :: Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> JStat -> JStat
checkOverlapByteArray Bool
False JExpr
_ JExpr
_ JExpr
_ JExpr
_ JExpr
_ JStat
r    = JStat
r
checkOverlapByteArray Bool
True JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n JStat
r =
  JExpr -> JStat -> JStat -> JStat
ifS (FastString -> [JExpr] -> JExpr
app FastString
"h$checkOverlapByteArray" [JExpr
a1, JExpr
o1, JExpr
a2, JExpr
o2, JExpr
n])
    JStat
r
    (JExpr -> JStat
returnS (JExpr -> JStat) -> JExpr -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JExpr
app FastString
"h$exitProcess" [Integer -> JExpr
Int Integer
134])

copyByteArray :: Bool -> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray :: Bool
-> Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> PrimRes
copyByteArray Bool
allow_overlap Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n = JStat -> PrimRes
PrimInline (JStat -> PrimRes) -> JStat -> PrimRes
forall a b. (a -> b) -> a -> b
$ JStat -> JStat
check (JStat -> JStat) -> JStat -> JStat
forall a b. (a -> b) -> a -> b
$ FastString -> [JExpr] -> JStat
appS FastString
"h$copyMutableByteArray" [JExpr
a1,JExpr
o1,JExpr
a2,JExpr
o2,JExpr
n]
  where
      check :: JStat -> JStat
check = Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
bound JExpr
a1 JExpr
o1 JExpr
n
              (JStat -> JStat) -> (JStat -> JStat) -> JStat -> JStat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> JExpr -> JExpr -> JExpr -> JStat -> JStat
bnd_ba_range Bool
bound JExpr
a2 JExpr
o2 JExpr
n
              (JStat -> JStat) -> (JStat -> JStat) -> JStat -> JStat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (if Bool -> Bool
not Bool
allow_overlap then Bool -> JExpr -> JExpr -> JExpr -> JExpr -> JExpr -> JStat -> JStat
checkOverlapByteArray Bool
bound JExpr
a1 JExpr
o1 JExpr
a2 JExpr
o2 JExpr
n else JStat -> JStat
forall a. a -> a
id)

-- e|0 (32 bit signed integer truncation) required because of JS numbers. e|0
-- converts e to an Int32. Note that e|0 _is still a Double_ because JavaScript.
-- So (x|0) * (y|0) can still return values outside of the Int32 range. You have
-- been warned!
toI32 :: JExpr -> JExpr
toI32 :: JExpr -> JExpr
toI32 JExpr
e = JExpr -> JExpr -> JExpr
BOr JExpr
e JExpr
zero_

-- e>>>0  (32 bit unsigned integer truncation)
-- required because of JS numbers. e>>>0 converts e to a Word32
-- so  (-2147483648)       >>> 0  = 2147483648
-- and ((-2147483648) >>>0) | 0   = -2147483648
toU32 :: JExpr -> JExpr
toU32 :: JExpr -> JExpr
toU32 JExpr
e = JExpr
e JExpr -> JExpr -> JExpr
.>>>. JExpr
zero_

quotShortInt :: Int -> JExpr -> JExpr -> JExpr
quotShortInt :: Int -> JExpr -> JExpr -> JExpr
quotShortInt Int
bits JExpr
x JExpr
y = JExpr -> JExpr -> JExpr
BAnd (JExpr -> JExpr
signed JExpr
x JExpr -> JExpr -> JExpr
`Div` JExpr -> JExpr
signed JExpr
y) JExpr
mask
  where
    signed :: JExpr -> JExpr
signed JExpr
z = (JExpr
z JExpr -> JExpr -> JExpr
.<<. JExpr
shift) JExpr -> JExpr -> JExpr
.>>. JExpr
shift
    shift :: JExpr
shift    = Int -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr (Int
32 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
bits)
    mask :: JExpr
mask     = Integer -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr (((Integer
2::Integer) Integer -> Int -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ Int
bits) Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
1)

remShortInt :: Int -> JExpr -> JExpr -> JExpr
remShortInt :: Int -> JExpr -> JExpr -> JExpr
remShortInt Int
bits JExpr
x JExpr
y = JExpr -> JExpr -> JExpr
BAnd (JExpr -> JExpr
signed JExpr
x JExpr -> JExpr -> JExpr
`Mod` JExpr -> JExpr
signed JExpr
y) JExpr
mask
  where
    signed :: JExpr -> JExpr
signed JExpr
z = (JExpr
z JExpr -> JExpr -> JExpr
.<<. JExpr
shift) JExpr -> JExpr -> JExpr
.>>. JExpr
shift
    shift :: JExpr
shift    = Int -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr (Int
32 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
bits)
    mask :: JExpr
mask     = Integer -> JExpr
forall a. ToJExpr a => a -> JExpr
toJExpr (((Integer
2::Integer) Integer -> Int -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ Int
bits) Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
1)