futhark
Safe HaskellNone
LanguageGHC2021

Futhark.Internalise.Monomorphise

Description

This monomorphization module converts a well-typed, polymorphic, module-free Futhark program into an equivalent monomorphic program.

This pass also does a few other simplifications to make the job of subsequent passes easier. Specifically, it does the following:

  • Turn operator sections into explicit lambdas.
  • Converts applications of intrinsic SOACs into SOAC AST nodes (Map, Reduce, etc).
  • Elide functions that are not reachable from an entry point (this is a side effect of the monomorphisation algorithm, which uses the entry points as roots).
  • Rewrite BinOp nodes to Apply nodes.
  • Replace all size expressions by constants or variables, complex expressions replaced by variables are calculated in let binding or replaced by size parameters if in argument.

Note that these changes are unfortunately not visible in the AST representation.

Synopsis

Documentation

transformProg :: MonadFreshNames m => [ValBind] -> m ([ValBind], MonoStats) Source #

Monomorphise a list of top-level value bindings.

type MonoType = TypeBase MonoSize NoMode Source #

The kind of type relative to which we monomorphise. What is most important to us is not the specific dimensions, but merely whether they are known or anonymous/local.

data MonoStats Source #

Statistics about which functions were monomorphised.

Instances

Instances details
Pretty MonoStats Source # 
Instance details

Defined in Futhark.Internalise.Monomorphise

Methods

pretty :: MonoStats -> Doc ann #

prettyList :: [MonoStats] -> Doc ann #