{-# LANGUAGE TypeFamilies #-}
module Futhark.CodeGen.ImpGen.Sequential
  ( compileProg
  )
  where

import qualified Futhark.CodeGen.ImpCode.Sequential as Imp
import qualified Futhark.CodeGen.ImpGen as ImpGen
import Futhark.Representation.ExplicitMemory
import Futhark.MonadFreshNames

compileProg :: MonadFreshNames m => Prog ExplicitMemory -> m Imp.Program
compileProg :: Prog ExplicitMemory -> m Program
compileProg = ()
-> Operations ExplicitMemory () Sequential
-> Space
-> Prog ExplicitMemory
-> m Program
forall lore op (m :: * -> *) r.
(ExplicitMemorish lore, FreeIn op, MonadFreshNames m) =>
r
-> Operations lore r op -> Space -> Prog lore -> m (Definitions op)
ImpGen.compileProg () Operations ExplicitMemory () Sequential
ops Space
Imp.DefaultSpace
  where ops :: Operations ExplicitMemory () Sequential
ops = OpCompiler ExplicitMemory () Sequential
-> Operations ExplicitMemory () Sequential
forall lore op r.
(ExplicitMemorish lore, FreeIn op) =>
OpCompiler lore r op -> Operations lore r op
ImpGen.defaultOperations OpCompiler ExplicitMemory () Sequential
opCompiler
        opCompiler :: ImpGen.OpCompiler ExplicitMemory () Imp.Sequential
        opCompiler :: OpCompiler ExplicitMemory () Sequential
opCompiler Pattern ExplicitMemory
dest (Alloc e space) =
          Pattern ExplicitMemory
-> SubExp -> Space -> ImpM ExplicitMemory () Sequential ()
forall lore r op.
ExplicitMemorish lore =>
Pattern lore -> SubExp -> Space -> ImpM lore r op ()
ImpGen.compileAlloc Pattern ExplicitMemory
dest SubExp
e Space
space
        opCompiler Pattern ExplicitMemory
_ (Inner _) =
          [Char] -> ImpM ExplicitMemory () Sequential ()
forall a. HasCallStack => [Char] -> a
error [Char]
"Cannot handle kernels in sequential code generator."