Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- compileProg :: (ExplicitMemorish lore, MonadFreshNames m) => Operations lore op -> Space -> Prog lore -> m (Either InternalError (Functions op))
- type OpCompiler lore op = Destination -> Op lore -> ImpM lore op ()
- type ExpCompiler lore op = Destination -> Exp lore -> ImpM lore op ()
- type CopyCompiler lore op = PrimType -> MemLocation -> MemLocation -> Count Elements -> ImpM lore op ()
- type BodyCompiler lore op = Destination -> Body lore -> ImpM lore op ()
- data Operations lore op = Operations {
- opsExpCompiler :: ExpCompiler lore op
- opsOpCompiler :: OpCompiler lore op
- opsBodyCompiler :: BodyCompiler lore op
- opsCopyCompiler :: CopyCompiler lore op
- defaultOperations :: (ExplicitMemorish lore, FreeIn op) => OpCompiler lore op -> Operations lore op
- data Destination = Destination {}
- data ValueDestination
- data MemLocation = MemLocation {}
- data MemEntry = MemEntry {}
- newtype ScalarEntry = ScalarEntry {}
- data ImpM lore op a
- data Env lore op
- subImpM :: Operations lore' op' -> ImpM lore' op' a -> ImpM lore op (a, Code op')
- subImpM_ :: Operations lore' op' -> ImpM lore' op' a -> ImpM lore op (Code op')
- emit :: Code op -> ImpM lore op ()
- collect :: ImpM lore op () -> ImpM lore op (Code op)
- comment :: String -> ImpM lore op () -> ImpM lore op ()
- data VarEntry lore
- data ArrayEntry = ArrayEntry {}
- lookupVar :: VName -> ImpM lore op (VarEntry lore)
- lookupArray :: VName -> ImpM lore op ArrayEntry
- arrayLocation :: VName -> ImpM lore op MemLocation
- lookupMemory :: VName -> ImpM lore op MemEntry
- compileSubExp :: SubExp -> ImpM lore op Exp
- compileSubExpOfType :: PrimType -> SubExp -> Exp
- compileSubExpTo :: ValueDestination -> SubExp -> ImpM lore op ()
- compilePrimExp :: PrimExp VName -> Exp
- compileAlloc :: Destination -> SubExp -> Space -> ImpM lore op ()
- subExpToDimSize :: SubExp -> ImpM lore op DimSize
- declaringLParams :: ExplicitMemorish lore => [LParam lore] -> ImpM lore op a -> ImpM lore op a
- declaringFParams :: ExplicitMemorish lore => [FParam lore] -> ImpM lore op a -> ImpM lore op a
- declaringVarEntry :: VName -> VarEntry lore -> ImpM lore op a -> ImpM lore op a
- declaringScope :: Maybe (Exp lore) -> Scope ExplicitMemory -> ImpM lore op a -> ImpM lore op a
- declaringScopes :: [(Maybe (Exp lore), Scope ExplicitMemory)] -> ImpM lore op a -> ImpM lore op a
- declaringPrimVar :: VName -> PrimType -> ImpM lore op a -> ImpM lore op a
- declaringPrimVars :: [(VName, PrimType)] -> ImpM lore op a -> ImpM lore op a
- withPrimVar :: VName -> PrimType -> ImpM lore op a -> ImpM lore op a
- everythingVolatile :: ImpM lore op a -> ImpM lore op a
- compileBody :: Destination -> Body lore -> ImpM lore op ()
- compileLoopBody :: (ExplicitMemorish lore, FreeIn op) => [VName] -> Body lore -> ImpM lore op (Code op)
- defCompileBody :: (ExplicitMemorish lore, FreeIn op) => Destination -> Body lore -> ImpM lore op ()
- compileStms :: (ExplicitMemorish lore, FreeIn op) => Names -> [Stm lore] -> ImpM lore op () -> ImpM lore op ()
- compileExp :: Destination -> Exp lore -> ImpM lore op ()
- defCompileExp :: (ExplicitMemorish lore, FreeIn op) => Destination -> Exp lore -> ImpM lore op ()
- sliceArray :: MemLocation -> Slice Exp -> MemLocation
- offsetArray :: MemLocation -> Exp -> MemLocation
- strideArray :: MemLocation -> Exp -> MemLocation
- fullyIndexArray :: VName -> [Exp] -> ImpM lore op (VName, Space, Count Bytes)
- fullyIndexArray' :: MemLocation -> [Exp] -> PrimType -> ImpM lore op (VName, Space, Count Bytes)
- varIndex :: VName -> Exp
- dimSizeToExp :: DimSize -> Count Elements
- dimSizeToSubExp :: Size -> SubExp
- destinationFromParam :: Param (MemBound u) -> ImpM lore op ValueDestination
- destinationFromParams :: [Param (MemBound u)] -> ImpM lore op Destination
- destinationFromPattern :: ExplicitMemorish lore => Pattern lore -> ImpM lore op Destination
- funcallTargets :: Destination -> ImpM lore op [VName]
- copy :: CopyCompiler lore op
- copyDWIM :: VName -> [Exp] -> SubExp -> [Exp] -> ImpM lore op ()
- copyDWIMDest :: ValueDestination -> [Exp] -> SubExp -> [Exp] -> ImpM lore op ()
- copyElementWise :: CopyCompiler lore op
Entry Points
compileProg :: (ExplicitMemorish lore, MonadFreshNames m) => Operations lore op -> Space -> Prog lore -> m (Either InternalError (Functions op)) Source #
Pluggable Compiler
type OpCompiler lore op = Destination -> Op lore -> ImpM lore op () Source #
How to compile an ExpT
.
type ExpCompiler lore op = Destination -> Exp lore -> ImpM lore op () Source #
How to compile an Exp
.
type CopyCompiler lore op Source #
= PrimType | |
-> MemLocation | |
-> MemLocation | |
-> Count Elements | Number of row elements of the source. |
-> ImpM lore op () |
type BodyCompiler lore op = Destination -> Body lore -> ImpM lore op () Source #
How to compile a BodyT
.
data Operations lore op Source #
Operations | |
|
defaultOperations :: (ExplicitMemorish lore, FreeIn op) => OpCompiler lore op -> Operations lore op Source #
An operations set for which the expression compiler always
returns CompileExp
.
data Destination Source #
When compiling an expression, this is a description of where the result should end up. The integer is a reference to the construct that gave rise to this destination (for patterns, this will be the tag of the first name in the pattern). This can be used to make the generated code easier to relate to the original code.
Instances
Show Destination Source # | |
Defined in Futhark.CodeGen.ImpGen showsPrec :: Int -> Destination -> ShowS # show :: Destination -> String # showList :: [Destination] -> ShowS # |
data ValueDestination Source #
ScalarDestination VName | |
ArrayElemDestination VName PrimType Space (Count Bytes) | |
MemoryDestination VName | |
ArrayDestination (Maybe MemLocation) | The |
Instances
Show ValueDestination Source # | |
Defined in Futhark.CodeGen.ImpGen showsPrec :: Int -> ValueDestination -> ShowS # show :: ValueDestination -> String # showList :: [ValueDestination] -> ShowS # |
data MemLocation Source #
When an array is declared, this is where it is stored.
Instances
Eq MemLocation Source # | |
Defined in Futhark.CodeGen.ImpGen (==) :: MemLocation -> MemLocation -> Bool # (/=) :: MemLocation -> MemLocation -> Bool # | |
Show MemLocation Source # | |
Defined in Futhark.CodeGen.ImpGen showsPrec :: Int -> MemLocation -> ShowS # show :: MemLocation -> String # showList :: [MemLocation] -> ShowS # |
newtype ScalarEntry Source #
Monadic Compiler Interface
Instances
MonadState VNameSource (ImpM lore op) Source # | |
Defined in Futhark.CodeGen.ImpGen get :: ImpM lore op VNameSource # put :: VNameSource -> ImpM lore op () # state :: (VNameSource -> (a, VNameSource)) -> ImpM lore op a # | |
MonadError InternalError (ImpM lore op) Source # | |
Defined in Futhark.CodeGen.ImpGen throwError :: InternalError -> ImpM lore op a # catchError :: ImpM lore op a -> (InternalError -> ImpM lore op a) -> ImpM lore op a # | |
HasScope SOACS (ImpM lore op) Source # | |
MonadWriter (Code op) (ImpM lore op) Source # | |
Monad (ImpM lore op) Source # | |
Functor (ImpM lore op) Source # | |
MonadFail (ImpM lore op) Source # | |
Defined in Futhark.CodeGen.ImpGen | |
Applicative (ImpM lore op) Source # | |
Defined in Futhark.CodeGen.ImpGen | |
MonadFreshNames (ImpM lore op) Source # | |
Defined in Futhark.CodeGen.ImpGen getNameSource :: ImpM lore op VNameSource Source # putNameSource :: VNameSource -> ImpM lore op () Source # | |
MonadReader (Env lore op) (ImpM lore op) Source # | |
collect :: ImpM lore op () -> ImpM lore op (Code op) Source #
Execute a code generation action, returning the code that was emitted.
comment :: String -> ImpM lore op () -> ImpM lore op () Source #
Execute a code generation action, wrapping the generated code
within a Comment
with the given description.
Every non-scalar variable must be associated with an entry.
Lookups
lookupArray :: VName -> ImpM lore op ArrayEntry Source #
arrayLocation :: VName -> ImpM lore op MemLocation Source #
Building Blocks
compileSubExpTo :: ValueDestination -> SubExp -> ImpM lore op () Source #
compileAlloc :: Destination -> SubExp -> Space -> ImpM lore op () Source #
compileAlloc dest size space
allocates n
bytes of memory in space
,
writing the result to dest
, which must be a single
MemoryDestination
,
declaringLParams :: ExplicitMemorish lore => [LParam lore] -> ImpM lore op a -> ImpM lore op a Source #
declaringFParams :: ExplicitMemorish lore => [FParam lore] -> ImpM lore op a -> ImpM lore op a Source #
declaringScope :: Maybe (Exp lore) -> Scope ExplicitMemory -> ImpM lore op a -> ImpM lore op a Source #
declaringScopes :: [(Maybe (Exp lore), Scope ExplicitMemory)] -> ImpM lore op a -> ImpM lore op a Source #
everythingVolatile :: ImpM lore op a -> ImpM lore op a Source #
compileBody :: Destination -> Body lore -> ImpM lore op () Source #
compileLoopBody :: (ExplicitMemorish lore, FreeIn op) => [VName] -> Body lore -> ImpM lore op (Code op) Source #
defCompileBody :: (ExplicitMemorish lore, FreeIn op) => Destination -> Body lore -> ImpM lore op () Source #
compileStms :: (ExplicitMemorish lore, FreeIn op) => Names -> [Stm lore] -> ImpM lore op () -> ImpM lore op () Source #
compileExp :: Destination -> Exp lore -> ImpM lore op () Source #
defCompileExp :: (ExplicitMemorish lore, FreeIn op) => Destination -> Exp lore -> ImpM lore op () Source #
sliceArray :: MemLocation -> Slice Exp -> MemLocation Source #
offsetArray :: MemLocation -> Exp -> MemLocation Source #
strideArray :: MemLocation -> Exp -> MemLocation Source #
fullyIndexArray' :: MemLocation -> [Exp] -> PrimType -> ImpM lore op (VName, Space, Count Bytes) Source #
dimSizeToSubExp :: Size -> SubExp Source #
destinationFromParam :: Param (MemBound u) -> ImpM lore op ValueDestination Source #
destinationFromParams :: [Param (MemBound u)] -> ImpM lore op Destination Source #
destinationFromPattern :: ExplicitMemorish lore => Pattern lore -> ImpM lore op Destination Source #
funcallTargets :: Destination -> ImpM lore op [VName] Source #
Remove the array targets.
copy :: CopyCompiler lore op Source #
copyDWIM :: VName -> [Exp] -> SubExp -> [Exp] -> ImpM lore op () Source #
Copy from here to there; both destination and source be indexeded. If so, they better be arrays of enough dimensions. This function will generally just Do What I Mean, and Do The Right Thing. Both destination and source must be in scope.
copyDWIMDest :: ValueDestination -> [Exp] -> SubExp -> [Exp] -> ImpM lore op () Source #
Like copyDWIM
, but the target is a ValueDestination
instead of a variable name.
copyElementWise :: CopyCompiler lore op Source #