futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Futhark.CodeGen.Backends.GenericC

Description

C code generation for whole programs, built on Futhark.CodeGen.Backends.GenericC.Monad. Most of this module is concerned with constructing the C API.

Synopsis

- compileProg :: MonadFreshNames m => Text -> Text -> ParamMap -> Operations op () -> CompilerM op () () -> Text -> (Space, [Space]) -> [Option] -> Definitions op -> m CParts
- compileProg' :: MonadFreshNames m => Text -> Text -> ParamMap -> Operations op s -> s -> CompilerM op s () -> Text -> (Space, [Space]) -> [Option] -> Definitions op -> m (CParts, CompilerState s)
- defaultOperations :: Operations op s
- type ParamMap = Map Name (SizeClass, Set Name)
- data CParts = CParts {
  - cHeader :: Text
  - cUtils :: Text
  - cCLI :: Text
  - cServer :: Text
  - cLib :: Text
  - cJsonManifest :: Text
  }
- asLibrary :: CParts -> (Text, Text, Text)
- asExecutable :: CParts -> Text
- asServer :: CParts -> Text
- module Futhark.CodeGen.Backends.GenericC.Monad
- module Futhark.CodeGen.Backends.GenericC.Code

# Documentation

compileProg :: MonadFreshNames m => Text -> Text -> ParamMap -> Operations op () -> CompilerM op () () -> Text -> (Space, [Space]) -> [Option] -> Definitions op -> m CParts Source #

Compile imperative program to a C program. Always uses the function named "main" as entry point, so make sure it is defined.

compileProg' :: MonadFreshNames m => Text -> Text -> ParamMap -> Operations op s -> s -> CompilerM op s () -> Text -> (Space, [Space]) -> [Option] -> Definitions op -> m (CParts, CompilerState s) Source #

defaultOperations :: Operations op s Source #

A set of operations that fail for every operation involving non-default memory spaces. Uses plain pointers and `malloc` for memory management.

type ParamMap = Map Name (SizeClass, Set Name) Source #

A mapping from names of tuning parameters to their class, as well as which functions make use of them (including transitively).

data CParts Source #

The result of compilation to C is multiple parts, which can be put together in various ways. The obvious way is to concatenate all of them, which yields a CLI program. Another is to compile the library part by itself, and use the header file to call into it.

Constructors

CParts |

Fields

- cHeader :: Text
- cUtils :: Text

  Utility definitions that must be visible to both CLI and library parts.

- cCLI :: Text
- cServer :: Text
- cLib :: Text
- cJsonManifest :: Text

  The manifest, in JSON format.

asLibrary :: CParts -> (Text, Text, Text) Source #

Produce header, implementation, and manifest files.

asExecutable :: CParts -> Text Source #

As executable with command-line interface.

asServer :: CParts -> Text Source #

As server executable.

module Futhark.CodeGen.Backends.GenericC.Monad

module Futhark.CodeGen.Backends.GenericC.Code