module Feldspar.Compiler.Options where
import Feldspar.Compiler.Imperative.Representation
import Feldspar.Compiler.Imperative.Semantics(IsRestrict, PrettyPrintSemanticInfo)
data Options =
Options
{ platform :: Platform
, unroll :: UnrollStrategy
, debug :: DebugOption
, defaultArraySize :: Int
} deriving (Eq, Show)
data UnrollStrategy = NoUnroll | Unroll Int
deriving (Eq, Show)
data DebugOption = NoDebug | NoSimplification | NoPrimitiveInstructionHandling
deriving (Eq, Show)
data Platform = Platform {
name :: String,
types :: [(Type, String, String)],
values :: [(Type, ShowValue)],
primitives :: [(FeldPrimDesc, Either CPrimDesc TransformPrim)],
includes :: [String],
isRestrict :: IsRestrict
} deriving (Eq, Show)
data FeldPrimDesc = FeldPrimDesc {
fName :: String,
inputs :: [TypeDesc]
} deriving (Eq, Show)
data CPrimDesc = Op1 {
cOp :: String
} | Op2 {
cOp :: String
} | Fun {
cName :: String,
funPf :: FunPostfixDescr
} | Proc {
cName :: String,
funPf :: FunPostfixDescr
} | Assig
| InvalidDesc
deriving (Eq, Show)
data TypeDesc
= AllT
| BoolT
| FloatT
| IntT | IntTS | IntTU | IntTS_ Size | IntTU_ Size | IntT_ Size
| UserT String
deriving (Eq, Show)
data FunPostfixDescr = FunPostfixDescr {
useInputs :: Int,
useOutputs :: Int
} deriving (Eq, Show)
noneFP = FunPostfixDescr 0 0
firstInFP = FunPostfixDescr 1 0
firstOutFP = FunPostfixDescr 0 1
type ShowValue = (ConstantData PrettyPrintSemanticInfo -> String)
instance Eq ShowValue where
(==) _ _ = True
instance Show ShowValue where
show _ = "<<ShowValue>>"
type TransformPrim
= FeldPrimDesc
-> [Expression ()]
-> [LeftValue ()]
-> [(CPrimDesc, [Expression ()], [LeftValue ()])]
instance Eq TransformPrim where
(==) _ _ = True
instance Show TransformPrim where
show _ = "<<TransformPrim>>"
machTypes :: TypeDesc -> Type -> Bool
machTypes AllT _ = True
machTypes BoolT BoolType = True
machTypes FloatT FloatType = True
machTypes IntT (Numeric _ _) = True
machTypes IntTS (Numeric ImpSigned _) = True
machTypes IntTU (Numeric ImpUnsigned _) = True
machTypes (IntTS_ s) (Numeric ImpSigned s') = s == s'
machTypes (IntTU_ s) (Numeric ImpUnsigned s') = s == s'
machTypes (IntT_ s) (Numeric _ s') = s == s'
machTypes (UserT s) (UserType s') = s == s'
machTypes _ _ = False