{-|
  Copyright   :  (C) 2013-2016, University of Twente,
                     2016-2017, Myrtle Software Ltd,
                     2017-2022, Google Inc.,
                     2017-2026, QBayLogic B.V.
  License     :  BSD2 (see the file LICENSE)
  Maintainer  :  QBayLogic B.V. <devops@qbaylogic.com>
-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UnboxedTuples #-}

#include "MachDeps.h"

module Clash.GHC.Evaluator.Primitives.Clash.Class.BitPack.Internal
  ( primitives
  ) where

import           Data.Text           (Text)
import           GHC.Word

import           Clash.Class.BitPack (pack,unpack)
import           Clash.Core.Evaluator.Types
import           Clash.Core.Literal  (Literal (..))
import Clash.Core.Term (Term (..))
import Clash.Util (textNameLit)

import Clash.Sized.Internal.BitVector (BitVector(..))
import Clash.Sized.Internal.Signed   (Signed   (..))
import Clash.Sized.Internal.Unsigned (Unsigned (..))

import {-# SOURCE #-} Clash.GHC.Evaluator

import qualified Clash.Class.BitPack.Internal

import {-# SOURCE #-} Clash.GHC.Evaluator.Primitive
import Clash.GHC.Evaluator.Primitive.Util

primitives :: [(Text, PrimStep)]
primitives :: [(Text, PrimStep)]
primitives =
  [ Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packInt8#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
..} -- :: Int8 -> BitVector 8
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Int8Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (IntLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packInt16#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Int16 -> BitVector 16
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Int16Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (IntLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packInt32#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Int32 -> BitVector 32
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Int32Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (IntLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packInt64#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Int64 -> BitVector 64
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Int64Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (IntLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packWord#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Word -> BitVector WORD_SIZE_IN_BITS
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (WordLiteral Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packWord8#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Word8 -> BitVector 8
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Word8Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (WordLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packWord16#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Word16 -> BitVector 16
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Word16Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (WordLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packWord32#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Word32 -> BitVector 32
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Word32Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (WordLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packWord64#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Word64 -> BitVector 64
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Word64Literal Integer
i)} <-
              Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (WordLiteral i)} <-
              whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packDouble#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Double -> BitVector 64
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
        , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
        , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (DoubleLiteral Word64
i)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
        -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
            in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                 { mStack = mStack mach
                 , mTerm = mkBitVectorLit' resTyInfo 0 (toInteger $ (pack :: Word64 -> BitVector 64) i)
                 }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packFloat#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: Float -> BitVector 32
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
        , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
        , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (FloatLiteral Word32
i)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
        -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
            in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                 { mStack = mStack mach
                 , mTerm = mkBitVectorLit' resTyInfo 0 (toInteger $ (pack :: Word32 -> BitVector 32) i)
                 }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.packCUShort#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- :: CUShort -> BitVector 16
        | [DC DataCon
_ [Left Term
arg]] <- [Value]
args
          , Evaluator
eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
Evaluator Step
ghcStep Unwind
ghcUnwind PrimStep
ghcPrimStep PrimUnwind
ghcPrimUnwind
#if MIN_VERSION_base(4,16,0)
          , mach2 :: Machine
mach2@Machine{mStack :: Machine -> Stack
mStack=[],mTerm :: Machine -> Term
mTerm=Literal (Word16Literal Integer
i)}
              <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
whnf Evaluator
eval TyConMap
tcm Bool
True (Term -> Machine -> Machine
setTerm Term
arg (Machine -> Machine) -> Machine -> Machine
forall a b. (a -> b) -> a -> b
$ Machine -> Machine
stackClear Machine
mach)
#else
          , mach2@Machine{mStack=[],mTerm=Literal (WordLiteral i)}
              <- whnf eval tcm True (setTerm arg $ stackClear mach)
#endif
          -> let resTyInfo :: (Type, Type, Integer)
resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
extractTySizeInfo TyConMap
tcm Type
ty [Type]
tys
              in Machine -> Maybe Machine
forall a. a -> Maybe a
Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
forall a b. (a -> b) -> a -> b
$ Machine
mach2
                  { mStack = mStack mach
                  , mTerm = mkBitVectorLit' resTyInfo 0 i
                  }
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackInt8#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 8 -> Int8
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Signed 8 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Signed 8)) -> Signed 8
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 8
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Signed 8)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Int8Literal
#else
               proj = IntLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackInt16#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 16 -> Int16
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Signed 16 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Signed 16)) -> Signed 16
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 16
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Signed 16)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Int16Literal
#else
               proj = IntLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackInt32#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 32 -> Int32
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Signed 32 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Signed 32)) -> Signed 32
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 32
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Signed 32)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Int32Literal
#else
               proj = IntLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackInt64#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 64 -> Int64
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Signed 64 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Signed 64)) -> Signed 64
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 64
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Signed 64)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Int64Literal
#else
               proj = IntLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackWord#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector WORD_SIZE_IN_BITS -> Word
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 64 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 64)) -> Unsigned 64
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 64
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 64)
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
WordLiteral Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackWord8#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 8 -> Word8
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 8 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 8)) -> Unsigned 8
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 8
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 8)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Word8Literal
#else
               proj = WordLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackWord16#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 16 -> Word16
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 16 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 16)) -> Unsigned 16
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 16
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 16)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Word16Literal
#else
               proj = WordLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackWord32#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 32 -> Word32
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 32 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 32)) -> Unsigned 32
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 32
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 32)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Word32Literal
#else
               proj = WordLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackWord64#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..} -- BitVector 64 -> Word64
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 64 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 64)) -> Unsigned 64
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 64
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 64)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Word64Literal
#else
               proj = WordLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackFloat#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..}
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Word32
val = BitVector (BitSize Word32) -> Word32
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 32
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i :: BitVector 32)
            in Term -> Maybe Machine
reduce (TyConMap -> Word32 -> Type -> Term
mkFloatCLit TyConMap
tcm Word32
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackDouble#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..}
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Word64
val = BitVector (BitSize Word64) -> Word64
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 64
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i :: BitVector 64)
            in Term -> Maybe Machine
reduce (TyConMap -> Word64 -> Type -> Term
mkDoubleCLit TyConMap
tcm Word64
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  , Text -> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
primStepEntry $(textNameLit 'Clash.Class.BitPack.Internal.unpackCUShort#) ((PrimStepContext -> Maybe Machine) -> (Text, PrimStep))
-> (PrimStepContext -> Maybe Machine) -> (Text, PrimStep)
forall a b. (a -> b) -> a -> b
$ \case
      PrimStepContext{Bool
[Type]
[Value]
Type
TyConMap
Machine
PrimInfo
Term -> Maybe Machine
Term -> Term
Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
Type -> Integer -> (Nat -> Nat) -> Term
Type -> [Integer] -> ([Nat] -> Term) -> Term
Machine -> Term -> Maybe Machine
tcm :: PrimStepContext -> TyConMap
isSubj :: PrimStepContext -> Bool
pInfo :: PrimStepContext -> PrimInfo
tys :: PrimStepContext -> [Type]
args :: PrimStepContext -> [Value]
mach :: PrimStepContext -> Machine
ty :: PrimStepContext -> Type
checkNaturalRange1 :: PrimStepContext -> Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: PrimStepContext
-> Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: PrimStepContext -> Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: PrimStepContext -> Term -> Maybe Machine
reduceWith :: PrimStepContext -> Machine -> Term -> Maybe Machine
reduceWHNF :: PrimStepContext -> Term -> Maybe Machine
reduceWHNF' :: PrimStepContext -> Machine -> Term -> Maybe Machine
catchDivByZero :: PrimStepContext -> Term -> Term
catchErrorCall :: PrimStepContext -> Term -> Term
tcm :: TyConMap
isSubj :: Bool
pInfo :: PrimInfo
tys :: [Type]
args :: [Value]
mach :: Machine
ty :: Type
checkNaturalRange1 :: Type -> Integer -> (Nat -> Nat) -> Term
checkNaturalRange2 :: Type -> Integer -> Integer -> (Nat -> Nat -> Nat) -> Term
checkNaturalRange :: Type -> [Integer] -> ([Nat] -> Term) -> Term
reduce :: Term -> Maybe Machine
reduceWith :: Machine -> Term -> Maybe Machine
reduceWHNF :: Term -> Maybe Machine
reduceWHNF' :: Machine -> Term -> Maybe Machine
catchDivByZero :: Term -> Term
catchErrorCall :: Term -> Term
..}
        | [(Integer, Integer)
i] <- [Value] -> [(Integer, Integer)]
bitVectorLiterals' [Value]
args
        -> let resTy :: Type
resTy = TyConMap -> Type -> [Type] -> Type
getResultTy TyConMap
tcm Type
ty [Type]
tys
               val :: Integer
val = Unsigned 16 -> Integer
forall a. Integral a => a -> Integer
toInteger (BitVector (BitSize (Unsigned 16)) -> Unsigned 16
forall a. BitPack a => BitVector (BitSize a) -> a
unpack ((Integer, Integer) -> BitVector 16
forall (n :: Nat). (Integer, Integer) -> BitVector n
toBV (Integer, Integer)
i) :: Unsigned 16)
#if MIN_VERSION_base(4,16,0)
               proj :: Integer -> Literal
proj = Integer -> Literal
Word16Literal
#else
               proj = WordLiteral
#endif
            in Term -> Maybe Machine
reduce (TyConMap -> (Integer -> Literal) -> Integer -> Type -> Term
mkIntCLit TyConMap
tcm Integer -> Literal
proj Integer
val Type
resTy)
      PrimStepContext
_ -> Maybe Machine
forall a. Maybe a
Nothing

  ]