{-# LANGUAGE GADTs #-}
{-# OPTIONS_HADDOCK hide #-}
-- |
-- Module      : Data.Array.Accelerate.LLVM.CodeGen.Type
-- Copyright   : [2015..2020] The Accelerate Team
-- License     : BSD3
--
-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--

module Data.Array.Accelerate.LLVM.CodeGen.Type
  where

import LLVM.AST.Type.Representation
import Data.Array.Accelerate.Sugar.Elt

import Data.Constraint


-- | Extract some evidence that a reified type implies that type is a valid
-- element
--
singleElt :: SingleType a -> Dict (Elt a)
singleElt :: SingleType a -> Dict (Elt a)
singleElt (NumSingleType    NumType a
t) = NumType a -> Dict (Elt a)
forall a. NumType a -> Dict (Elt a)
numElt NumType a
t

numElt :: NumType a -> Dict (Elt a)
numElt :: NumType a -> Dict (Elt a)
numElt (IntegralNumType IntegralType a
t) = IntegralType a -> Dict (Elt a)
forall a. IntegralType a -> Dict (Elt a)
integralElt IntegralType a
t
numElt (FloatingNumType FloatingType a
t) = FloatingType a -> Dict (Elt a)
forall a. FloatingType a -> Dict (Elt a)
floatingElt FloatingType a
t

integralElt :: IntegralType a -> Dict (Elt a)
integralElt :: IntegralType a -> Dict (Elt a)
integralElt TypeInt{}    = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeInt8{}   = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeInt16{}  = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeInt32{}  = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeInt64{}  = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeWord{}   = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeWord8{}  = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeWord16{} = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeWord32{} = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
integralElt TypeWord64{} = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict

floatingElt :: FloatingType a -> Dict (Elt a)
floatingElt :: FloatingType a -> Dict (Elt a)
floatingElt TypeHalf{}   = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
floatingElt TypeFloat{}  = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict
floatingElt TypeDouble{} = Dict (Elt a)
forall (a :: Constraint). a => Dict a
Dict