{-# LANGUAGE FlexibleContexts #-}

-- | @futhark c@
module Futhark.CLI.C (main) where

import Futhark.Actions (compileCAction)
import Futhark.Compiler.CLI
import Futhark.Passes (sequentialCpuPipeline)

-- | Run @futhark c@
main :: String -> [String] -> IO ()
main :: String -> [String] -> IO ()
main = ()
-> [CompilerOption ()]
-> String
-> String
-> Pipeline SOACS SeqMem
-> (FutharkConfig
    -> () -> CompilerMode -> String -> Prog SeqMem -> FutharkM ())
-> String
-> [String]
-> IO ()
forall cfg rep.
cfg
-> [CompilerOption cfg]
-> String
-> String
-> Pipeline SOACS rep
-> (FutharkConfig
    -> cfg -> CompilerMode -> String -> Prog rep -> FutharkM ())
-> String
-> [String]
-> IO ()
compilerMain
  ()
  []
  String
"Compile sequential C"
  String
"Generate sequential C code from optimised Futhark program."
  Pipeline SOACS SeqMem
sequentialCpuPipeline
  ((FutharkConfig
  -> () -> CompilerMode -> String -> Prog SeqMem -> FutharkM ())
 -> String -> [String] -> IO ())
-> (FutharkConfig
    -> () -> CompilerMode -> String -> Prog SeqMem -> FutharkM ())
-> String
-> [String]
-> IO ()
forall a b. (a -> b) -> a -> b
$ \FutharkConfig
fcfg () CompilerMode
mode String
outpath Prog SeqMem
prog ->
    Action SeqMem -> Prog SeqMem -> FutharkM ()
forall rep. Action rep -> Prog rep -> FutharkM ()
actionProcedure (FutharkConfig -> CompilerMode -> String -> Action SeqMem
compileCAction FutharkConfig
fcfg CompilerMode
mode String
outpath) Prog SeqMem
prog