{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}

module Language.Fortran.Intrinsics
  ( getVersionIntrinsics, getIntrinsicReturnType, getIntrinsicNames, getIntrinsicDefsUses, isIntrinsic
  , IntrinsicType(..), IntrinsicsTable, allIntrinsics )
where

import qualified Data.Map.Strict as M
import Data.Data
import Data.List
import GHC.Generics (Generic)
import Language.Fortran.ParserMonad (FortranVersion(..))


data IntrinsicType = ITReal | ITInteger | ITComplex | ITDouble | ITLogical | ITCharacter | ITParam Int
  deriving (Int -> IntrinsicType -> ShowS
[IntrinsicType] -> ShowS
IntrinsicType -> String
(Int -> IntrinsicType -> ShowS)
-> (IntrinsicType -> String)
-> ([IntrinsicType] -> ShowS)
-> Show IntrinsicType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntrinsicType] -> ShowS
$cshowList :: [IntrinsicType] -> ShowS
show :: IntrinsicType -> String
$cshow :: IntrinsicType -> String
showsPrec :: Int -> IntrinsicType -> ShowS
$cshowsPrec :: Int -> IntrinsicType -> ShowS
Show, IntrinsicType -> IntrinsicType -> Bool
(IntrinsicType -> IntrinsicType -> Bool)
-> (IntrinsicType -> IntrinsicType -> Bool) -> Eq IntrinsicType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntrinsicType -> IntrinsicType -> Bool
$c/= :: IntrinsicType -> IntrinsicType -> Bool
== :: IntrinsicType -> IntrinsicType -> Bool
$c== :: IntrinsicType -> IntrinsicType -> Bool
Eq, Eq IntrinsicType
Eq IntrinsicType
-> (IntrinsicType -> IntrinsicType -> Ordering)
-> (IntrinsicType -> IntrinsicType -> Bool)
-> (IntrinsicType -> IntrinsicType -> Bool)
-> (IntrinsicType -> IntrinsicType -> Bool)
-> (IntrinsicType -> IntrinsicType -> Bool)
-> (IntrinsicType -> IntrinsicType -> IntrinsicType)
-> (IntrinsicType -> IntrinsicType -> IntrinsicType)
-> Ord IntrinsicType
IntrinsicType -> IntrinsicType -> Bool
IntrinsicType -> IntrinsicType -> Ordering
IntrinsicType -> IntrinsicType -> IntrinsicType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IntrinsicType -> IntrinsicType -> IntrinsicType
$cmin :: IntrinsicType -> IntrinsicType -> IntrinsicType
max :: IntrinsicType -> IntrinsicType -> IntrinsicType
$cmax :: IntrinsicType -> IntrinsicType -> IntrinsicType
>= :: IntrinsicType -> IntrinsicType -> Bool
$c>= :: IntrinsicType -> IntrinsicType -> Bool
> :: IntrinsicType -> IntrinsicType -> Bool
$c> :: IntrinsicType -> IntrinsicType -> Bool
<= :: IntrinsicType -> IntrinsicType -> Bool
$c<= :: IntrinsicType -> IntrinsicType -> Bool
< :: IntrinsicType -> IntrinsicType -> Bool
$c< :: IntrinsicType -> IntrinsicType -> Bool
compare :: IntrinsicType -> IntrinsicType -> Ordering
$ccompare :: IntrinsicType -> IntrinsicType -> Ordering
$cp1Ord :: Eq IntrinsicType
Ord, Typeable, (forall x. IntrinsicType -> Rep IntrinsicType x)
-> (forall x. Rep IntrinsicType x -> IntrinsicType)
-> Generic IntrinsicType
forall x. Rep IntrinsicType x -> IntrinsicType
forall x. IntrinsicType -> Rep IntrinsicType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntrinsicType x -> IntrinsicType
$cfrom :: forall x. IntrinsicType -> Rep IntrinsicType x
Generic)

data IntrinsicsEntry = IEntry { IntrinsicsEntry -> IntrinsicType
iType :: IntrinsicType, IntrinsicsEntry -> ([Int], [Int])
iDefsUses :: ([Int], [Int]) }
  deriving (Int -> IntrinsicsEntry -> ShowS
[IntrinsicsEntry] -> ShowS
IntrinsicsEntry -> String
(Int -> IntrinsicsEntry -> ShowS)
-> (IntrinsicsEntry -> String)
-> ([IntrinsicsEntry] -> ShowS)
-> Show IntrinsicsEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntrinsicsEntry] -> ShowS
$cshowList :: [IntrinsicsEntry] -> ShowS
show :: IntrinsicsEntry -> String
$cshow :: IntrinsicsEntry -> String
showsPrec :: Int -> IntrinsicsEntry -> ShowS
$cshowsPrec :: Int -> IntrinsicsEntry -> ShowS
Show, IntrinsicsEntry -> IntrinsicsEntry -> Bool
(IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> (IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> Eq IntrinsicsEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c/= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
== :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c== :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
Eq, Eq IntrinsicsEntry
Eq IntrinsicsEntry
-> (IntrinsicsEntry -> IntrinsicsEntry -> Ordering)
-> (IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> (IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> (IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> (IntrinsicsEntry -> IntrinsicsEntry -> Bool)
-> (IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry)
-> (IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry)
-> Ord IntrinsicsEntry
IntrinsicsEntry -> IntrinsicsEntry -> Bool
IntrinsicsEntry -> IntrinsicsEntry -> Ordering
IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry
$cmin :: IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry
max :: IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry
$cmax :: IntrinsicsEntry -> IntrinsicsEntry -> IntrinsicsEntry
>= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c>= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
> :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c> :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
<= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c<= :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
< :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
$c< :: IntrinsicsEntry -> IntrinsicsEntry -> Bool
compare :: IntrinsicsEntry -> IntrinsicsEntry -> Ordering
$ccompare :: IntrinsicsEntry -> IntrinsicsEntry -> Ordering
$cp1Ord :: Eq IntrinsicsEntry
Ord, Typeable, (forall x. IntrinsicsEntry -> Rep IntrinsicsEntry x)
-> (forall x. Rep IntrinsicsEntry x -> IntrinsicsEntry)
-> Generic IntrinsicsEntry
forall x. Rep IntrinsicsEntry x -> IntrinsicsEntry
forall x. IntrinsicsEntry -> Rep IntrinsicsEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntrinsicsEntry x -> IntrinsicsEntry
$cfrom :: forall x. IntrinsicsEntry -> Rep IntrinsicsEntry x
Generic)

mkIEntry :: IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry :: IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry = IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
IEntry

type IntrinsicsTable = M.Map String IntrinsicsEntry

-- Main table of Fortran intrinsics by version
fortranVersionIntrinsics :: [(FortranVersion, IntrinsicsTable)]
fortranVersionIntrinsics :: [(FortranVersion, IntrinsicsTable)]
fortranVersionIntrinsics =
  [ (FortranVersion
Fortran66, IntrinsicsTable
fortran77intrinsics) -- FIXME: find list of original '66 intrinsics
  , (FortranVersion
Fortran77, IntrinsicsTable
fortran77intrinsics)
  , (FortranVersion
Fortran90, IntrinsicsTable
fortran90intrinisics) ]

-- | Obtain set of intrinsics that are most closely aligned with given version.
getVersionIntrinsics :: FortranVersion -> IntrinsicsTable
getVersionIntrinsics :: FortranVersion -> IntrinsicsTable
getVersionIntrinsics FortranVersion
v = (FortranVersion, IntrinsicsTable) -> IntrinsicsTable
forall a b. (a, b) -> b
snd ((FortranVersion, IntrinsicsTable) -> IntrinsicsTable)
-> ([(FortranVersion, IntrinsicsTable)]
    -> (FortranVersion, IntrinsicsTable))
-> [(FortranVersion, IntrinsicsTable)]
-> IntrinsicsTable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(FortranVersion, IntrinsicsTable)]
-> (FortranVersion, IntrinsicsTable)
forall a. [a] -> a
last ([(FortranVersion, IntrinsicsTable)]
 -> (FortranVersion, IntrinsicsTable))
-> ([(FortranVersion, IntrinsicsTable)]
    -> [(FortranVersion, IntrinsicsTable)])
-> [(FortranVersion, IntrinsicsTable)]
-> (FortranVersion, IntrinsicsTable)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((FortranVersion, IntrinsicsTable) -> Bool)
-> [(FortranVersion, IntrinsicsTable)]
-> [(FortranVersion, IntrinsicsTable)]
forall a. (a -> Bool) -> [a] -> [a]
filter ((FortranVersion -> FortranVersion -> Bool
forall a. Ord a => a -> a -> Bool
<= FortranVersion
v) (FortranVersion -> Bool)
-> ((FortranVersion, IntrinsicsTable) -> FortranVersion)
-> (FortranVersion, IntrinsicsTable)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FortranVersion, IntrinsicsTable) -> FortranVersion
forall a b. (a, b) -> a
fst) ([(FortranVersion, IntrinsicsTable)]
 -> [(FortranVersion, IntrinsicsTable)])
-> ([(FortranVersion, IntrinsicsTable)]
    -> [(FortranVersion, IntrinsicsTable)])
-> [(FortranVersion, IntrinsicsTable)]
-> [(FortranVersion, IntrinsicsTable)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(FortranVersion, IntrinsicsTable)]
-> [(FortranVersion, IntrinsicsTable)]
forall a. Ord a => [a] -> [a]
sort ([(FortranVersion, IntrinsicsTable)] -> IntrinsicsTable)
-> [(FortranVersion, IntrinsicsTable)] -> IntrinsicsTable
forall a b. (a -> b) -> a -> b
$ [(FortranVersion, IntrinsicsTable)]
fortranVersionIntrinsics

getIntrinsicReturnType :: String -> IntrinsicsTable -> Maybe IntrinsicType
getIntrinsicReturnType :: String -> IntrinsicsTable -> Maybe IntrinsicType
getIntrinsicReturnType String
i = (IntrinsicsEntry -> IntrinsicType)
-> Maybe IntrinsicsEntry -> Maybe IntrinsicType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IntrinsicsEntry -> IntrinsicType
iType (Maybe IntrinsicsEntry -> Maybe IntrinsicType)
-> (IntrinsicsTable -> Maybe IntrinsicsEntry)
-> IntrinsicsTable
-> Maybe IntrinsicType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IntrinsicsTable -> Maybe IntrinsicsEntry
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup String
i

getIntrinsicDefsUses :: String -> IntrinsicsTable -> Maybe ([Int], [Int])
getIntrinsicDefsUses :: String -> IntrinsicsTable -> Maybe ([Int], [Int])
getIntrinsicDefsUses String
i = (IntrinsicsEntry -> ([Int], [Int]))
-> Maybe IntrinsicsEntry -> Maybe ([Int], [Int])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IntrinsicsEntry -> ([Int], [Int])
iDefsUses (Maybe IntrinsicsEntry -> Maybe ([Int], [Int]))
-> (IntrinsicsTable -> Maybe IntrinsicsEntry)
-> IntrinsicsTable
-> Maybe ([Int], [Int])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IntrinsicsTable -> Maybe IntrinsicsEntry
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup String
i

getIntrinsicNames :: IntrinsicsTable -> [String]
getIntrinsicNames :: IntrinsicsTable -> [String]
getIntrinsicNames = IntrinsicsTable -> [String]
forall k a. Map k a -> [k]
M.keys

isIntrinsic :: String -> IntrinsicsTable -> Bool
isIntrinsic :: String -> IntrinsicsTable -> Bool
isIntrinsic = String -> IntrinsicsTable -> Bool
forall k a. Ord k => k -> Map k a -> Bool
M.member

allIntrinsics :: IntrinsicsTable
allIntrinsics :: IntrinsicsTable
allIntrinsics = [IntrinsicsTable] -> IntrinsicsTable
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
M.unions (((FortranVersion, IntrinsicsTable) -> IntrinsicsTable)
-> [(FortranVersion, IntrinsicsTable)] -> [IntrinsicsTable]
forall a b. (a -> b) -> [a] -> [b]
map (FortranVersion, IntrinsicsTable) -> IntrinsicsTable
forall a b. (a, b) -> b
snd [(FortranVersion, IntrinsicsTable)]
fortranVersionIntrinsics)

func1 :: ([Int], [Int])
func1 :: ([Int], [Int])
func1 = ([Int
0],[Int
1])
func2 :: ([Int], [Int])
func2 :: ([Int], [Int])
func2 = ([Int
0],[Int
1,Int
2])
func3 :: ([Int], [Int])
func3 :: ([Int], [Int])
func3 = ([Int
0],[Int
1,Int
2,Int
3])
func4 :: ([Int], [Int])
func4 :: ([Int], [Int])
func4 = ([Int
0],[Int
1,Int
2,Int
3,Int
4])
funcN :: ([Int], [Int])
funcN :: ([Int], [Int])
funcN = ([Int], [Int])
func2 -- FIXME: implement arbitrary-# parameter functions

-- | name => (return-unit, parameter-units)
-- This is an exhaustive list of intrinsics listed in 15.10 of X3.9-1978
fortran77intrinsics :: IntrinsicsTable
fortran77intrinsics :: IntrinsicsTable
fortran77intrinsics = [(String, IntrinsicsEntry)] -> IntrinsicsTable
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
  [ (String
"int"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"ifix"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"idint"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"real"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"float"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"sngl"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"dble"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"cmplx"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"ichar"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"char"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITCharacter ([Int], [Int])
func1)
  , (String
"achar"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITCharacter ([Int], [Int])
func1)
  , (String
"aint"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dint"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"anint"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dnint"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"nint"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"idnint"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"abs"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"iabs"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"dabs"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"cabs"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"mod"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func2)
  , (String
"amod"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func2)
  , (String
"dmod"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func2)
  , (String
"sign"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func2)
  , (String
"isign"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func2)
  , (String
"dsign"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func2)
  , (String
"dim"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func2)
  , (String
"idim"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func2)
  , (String
"ddim"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func2)
  , (String
"dprod"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func2)
  , (String
"max"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
funcN)
  , (String
"max0"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
funcN)
  , (String
"amax1"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
funcN)
  , (String
"dmax1"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
funcN)
  , (String
"amax0"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
funcN)
  , (String
"max1"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
funcN)
  , (String
"min"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
funcN)
  , (String
"min0"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
funcN)
  , (String
"amin1"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
funcN)
  , (String
"dmin1"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
funcN)
  , (String
"amin0"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
funcN)
  , (String
"min1"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
funcN)
  , (String
"len"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func1)
  , (String
"index"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger ([Int], [Int])
func2)
  , (String
"aimag"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"conjg"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"sqrt"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dsqrt"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"csqrt"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"exp"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dexp"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"cexp"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"log"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"alog"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"dlog"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"clog"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"log10"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"alog10"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITReal ([Int], [Int])
func1)
  , (String
"dlog10"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"sin"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dsin"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"csin"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"cos"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dcos"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"ccos"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITComplex ([Int], [Int])
func1)
  , (String
"tan"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dtan"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"asin"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dasin"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"acos"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dacos"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"atan"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"datan"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"atan2"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func2)
  , (String
"datan2"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func2)
  , (String
"sinh"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dsinh"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"cosh"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dcosh"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"tanh"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"dtanh"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITDouble ([Int], [Int])
func1)
  , (String
"lge"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical ([Int], [Int])
func2)
  , (String
"lgt"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical ([Int], [Int])
func2)
  , (String
"lle"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical ([Int], [Int])
func2)
  , (String
"llt"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical ([Int], [Int])
func2)
  -- https://gcc.gnu.org/onlinedocs/gfortran/Argument-list-functions.html
  , (String
"%loc", IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"%ref", IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  , (String
"%val", IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1) ([Int], [Int])
func1)
  ]

fortran90intrinisics :: IntrinsicsTable
fortran90intrinisics :: IntrinsicsTable
fortran90intrinisics = IntrinsicsTable
fortran77intrinsics IntrinsicsTable -> IntrinsicsTable -> IntrinsicsTable
forall k a. Ord k => Map k a -> Map k a -> Map k a
`M.union` [(String, IntrinsicsEntry)] -> IntrinsicsTable
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
  [ (String
"present" , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical     ([Int], [Int])
func1)
  , (String
"modulo"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func2)
  , (String
"ceiling" , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func1)
  , (String
"iand"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ior"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ieor"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"iany"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ibclr"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ibits"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func3)
  , (String
"ibset"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ishftc"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func3)
  , (String
"btest"   , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"not"     , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func1)
  , (String
"dot_product"  , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func2)
  , (String
"matmul"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func2)
  , (String
"all"          , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical     ([Int], [Int])
func2)
  , (String
"any"          , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical     ([Int], [Int])
func2)
  , (String
"count"        , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"maxval"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func3)
  , (String
"minval"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func3)
  , (String
"product"      , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func3)
  , (String
"sum"          , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func3)
  , (String
"allocated"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITLogical     ([Int], [Int])
func1)
  , (String
"lbound"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"ubound"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"shape"        , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func1)
  , (String
"size"         , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func2)
  , (String
"merge"        , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry IntrinsicType
ITInteger     ([Int], [Int])
func3)
  , (String
"pack"         , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
3)   ([Int], [Int])
func3)
  , (String
"spread"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func3)
  , (String
"unpack"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
3)   ([Int], [Int])
func3)
  , (String
"reshape"      , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func4)
  , (String
"eoshift"      , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func4)
  , (String
"transpose"    , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func1)
  , (String
"maxloc"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func2)
  , (String
"minloc"       , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (Int -> IntrinsicType
ITParam Int
1)   ([Int], [Int])
func2)
  , (String
"epsilon"      , IntrinsicType -> ([Int], [Int]) -> IntrinsicsEntry
mkIEntry (IntrinsicType
ITReal)      ([Int], [Int])
func1)
  ]