module Futhark.CodeGen.Backends.SequentialCSharp ( compileProg ) where import Control.Monad import Futhark.Representation.ExplicitMemory import qualified Futhark.CodeGen.ImpCode.Sequential as Imp import qualified Futhark.CodeGen.ImpGen.Sequential as ImpGen import qualified Futhark.CodeGen.Backends.GenericCSharp as CS import Futhark.CodeGen.Backends.GenericCSharp.AST () import Futhark.MonadFreshNames compileProg :: MonadFreshNames m => Maybe String -> Prog ExplicitMemory -> m String compileProg :: Maybe String -> Prog ExplicitMemory -> m String compileProg Maybe String module_name = Prog ExplicitMemory -> m Program forall (m :: * -> *). MonadFreshNames m => Prog ExplicitMemory -> m Program ImpGen.compileProg (Prog ExplicitMemory -> m Program) -> (Program -> m String) -> Prog ExplicitMemory -> m String forall (m :: * -> *) a b c. Monad m => (a -> m b) -> (b -> m c) -> a -> m c >=> Maybe String -> Constructor -> [CSStmt] -> [CSStmt] -> Operations Sequential () -> () -> CompilerM Sequential () () -> [CSStmt] -> [Space] -> [Option] -> Program -> m String forall (m :: * -> *) op s. MonadFreshNames m => Maybe String -> Constructor -> [CSStmt] -> [CSStmt] -> Operations op s -> s -> CompilerM op s () -> [CSStmt] -> [Space] -> [Option] -> Definitions op -> m String CS.compileProg Maybe String module_name Constructor CS.emptyConstructor [] [] Operations Sequential () operations () CompilerM Sequential () () empty [] [] [] where operations :: CS.Operations Imp.Sequential () operations :: Operations Sequential () operations = Operations Sequential () forall op s. Operations op s CS.defaultOperations { opsCompiler :: OpCompiler Sequential () CS.opsCompiler = CompilerM Sequential () () -> OpCompiler Sequential () forall a b. a -> b -> a const (CompilerM Sequential () () -> OpCompiler Sequential ()) -> CompilerM Sequential () () -> OpCompiler Sequential () forall a b. (a -> b) -> a -> b $ () -> CompilerM Sequential () () forall (m :: * -> *) a. Monad m => a -> m a return () , opsCopy :: Copy Sequential () CS.opsCopy = Copy Sequential () copySequentialMemory } empty :: CompilerM Sequential () () empty = () -> CompilerM Sequential () () forall (m :: * -> *) a. Monad m => a -> m a return () copySequentialMemory :: CS.Copy Imp.Sequential () copySequentialMemory :: Copy Sequential () copySequentialMemory CSExp destmem CSExp destidx Space DefaultSpace CSExp srcmem CSExp srcidx Space DefaultSpace CSExp nbytes PrimType _bt = CSExp -> CSExp -> CSExp -> CSExp -> CSExp -> CompilerM Sequential () () forall op s. CSExp -> CSExp -> CSExp -> CSExp -> CSExp -> CompilerM op s () CS.copyMemoryDefaultSpace CSExp destmem CSExp destidx CSExp srcmem CSExp srcidx CSExp nbytes copySequentialMemory CSExp _ CSExp _ Space destspace CSExp _ CSExp _ Space srcspace CSExp _ PrimType _ = String -> CompilerM Sequential () () forall a. HasCallStack => String -> a error (String -> CompilerM Sequential () ()) -> String -> CompilerM Sequential () () forall a b. (a -> b) -> a -> b $ String "Cannot copy to " String -> String -> String forall a. [a] -> [a] -> [a] ++ Space -> String forall a. Show a => a -> String show Space destspace String -> String -> String forall a. [a] -> [a] -> [a] ++ String " from " String -> String -> String forall a. [a] -> [a] -> [a] ++ Space -> String forall a. Show a => a -> String show Space srcspace