{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Array.Accelerate.LLVM.CodeGen.Intrinsic (
Intrinsic(..)
) where
import LLVM.AST.Type.Name
import Data.Monoid
import Data.ByteString.Short ( ShortByteString )
import Data.HashMap.Strict ( HashMap )
import qualified Data.HashMap.Strict as HashMap
import Prelude as P
class Intrinsic arch where
intrinsicForTarget :: HashMap ShortByteString Label
intrinsicForTarget = HashMap ShortByteString Label
llvmIntrinsic
llvmIntrinsic :: HashMap ShortByteString Label
llvmIntrinsic :: HashMap ShortByteString Label
llvmIntrinsic =
let floating :: ShortByteString
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)]
floating ShortByteString
base [(ShortByteString, Label)]
rest
= (ShortByteString
base, ShortByteString -> Label
Label (ShortByteString
"llvm." ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
base ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
".f64"))
(ShortByteString, Label)
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)]
forall a. a -> [a] -> [a]
: (ShortByteString
base ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
"f", ShortByteString -> Label
Label (ShortByteString
"llvm." ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
base ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
".f32"))
(ShortByteString, Label)
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)]
forall a. a -> [a] -> [a]
: (ShortByteString
base ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
"l", ShortByteString -> Label
Label (ShortByteString
"llvm." ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
base ShortByteString -> ShortByteString -> ShortByteString
forall a. Semigroup a => a -> a -> a
<> ShortByteString
".f128"))
(ShortByteString, Label)
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)]
forall a. a -> [a] -> [a]
: [(ShortByteString, Label)]
rest
in
[(ShortByteString, Label)] -> HashMap ShortByteString Label
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList ([(ShortByteString, Label)] -> HashMap ShortByteString Label)
-> [(ShortByteString, Label)] -> HashMap ShortByteString Label
forall a b. (a -> b) -> a -> b
$ (ShortByteString
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)])
-> [(ShortByteString, Label)]
-> [ShortByteString]
-> [(ShortByteString, Label)]
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShortByteString
-> [(ShortByteString, Label)] -> [(ShortByteString, Label)]
floating []
[ ShortByteString
"sqrt"
, ShortByteString
"powi"
, ShortByteString
"sin"
, ShortByteString
"cos"
, ShortByteString
"pow"
, ShortByteString
"exp"
, ShortByteString
"exp2"
, ShortByteString
"log"
, ShortByteString
"log10"
, ShortByteString
"log2"
, ShortByteString
"fma"
, ShortByteString
"fabs"
, ShortByteString
"copysign"
, ShortByteString
"floor"
, ShortByteString
"ceil"
, ShortByteString
"trunc"
, ShortByteString
"rint"
, ShortByteString
"nearbyint"
, ShortByteString
"round"
]