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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Analysis.UsageTable

Description

A usage-table is sort of a bottom-up symbol table, describing how (and if) a variable is used.

Synopsis

- data UsageTable
- without :: UsageTable -> [VName] -> UsageTable
- lookup :: VName -> UsageTable -> Maybe Usages
- used :: VName -> UsageTable -> Bool
- expand :: (VName -> Names) -> UsageTable -> UsageTable
- isConsumed :: VName -> UsageTable -> Bool
- isInResult :: VName -> UsageTable -> Bool
- isUsedDirectly :: VName -> UsageTable -> Bool
- isSize :: VName -> UsageTable -> Bool
- usages :: Names -> UsageTable
- usage :: VName -> Usages -> UsageTable
- consumedUsage :: VName -> UsageTable
- inResultUsage :: VName -> UsageTable
- sizeUsage :: VName -> UsageTable
- sizeUsages :: Names -> UsageTable
- withoutU :: Usages -> Usages -> Usages
- data Usages
- consumedU :: Usages
- presentU :: Usages
- usageInStm :: Aliased rep => Stm rep -> UsageTable
- usageInPat :: FreeIn t => Pat t -> UsageTable

# Documentation

data UsageTable Source #

A usage table.

#### Instances

Instances details

Monoid UsageTable Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods mempty :: UsageTable Source # mappend :: UsageTable -> UsageTable -> UsageTable Source # mconcat :: [UsageTable] -> UsageTable Source #
Semigroup UsageTable Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods (<>) :: UsageTable -> UsageTable -> UsageTable Source # sconcat :: NonEmpty UsageTable -> UsageTable Source # stimes :: Integral b => b -> UsageTable -> UsageTable Source #
Show UsageTable Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods showsPrec :: Int -> UsageTable -> ShowS Source # show :: UsageTable -> String Source # showList :: [UsageTable] -> ShowS Source #
Eq UsageTable Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods (==) :: UsageTable -> UsageTable -> Bool Source # (/=) :: UsageTable -> UsageTable -> Bool Source #

without :: UsageTable -> [VName] -> UsageTable Source #

Remove these entries from the usage table.

lookup :: VName -> UsageTable -> Maybe Usages Source #

Look up a variable in the usage table.

used :: VName -> UsageTable -> Bool Source #

Is the variable present in the usage table? That is, has it been used?

expand :: (VName -> Names) -> UsageTable -> UsageTable Source #

Expand the usage table based on aliasing information.

isConsumed :: VName -> UsageTable -> Bool Source #

Has the variable been consumed?

isInResult :: VName -> UsageTable -> Bool Source #

Has the variable been used in the `Result` of a body?

isUsedDirectly :: VName -> UsageTable -> Bool Source #

Has the given name been used directly (i.e. could we rename it or remove it without anyone noticing?)

isSize :: VName -> UsageTable -> Bool Source #

Is this name used as the size of something (array or memory block)?

usages :: Names -> UsageTable Source #

Construct a usage table reflecting that these variables have been used.

usage :: VName -> Usages -> UsageTable Source #

Construct a usage table where the given variable has been used in this specific way.

consumedUsage :: VName -> UsageTable Source #

Construct a usage table where the given variable has been consumed.

inResultUsage :: VName -> UsageTable Source #

Construct a usage table where the given variable has been used in the `Result` of a body.

sizeUsage :: VName -> UsageTable Source #

Construct a usage table where the given variable has been used as an array or memory size.

sizeUsages :: Names -> UsageTable Source #

Construct a usage table where the given names have been used as an array or memory size.

withoutU :: Usages -> Usages -> Usages Source #

x - y, but for `Usages`.

data Usages Source #

A description of how a single variable has been used.

#### Instances

Instances details

Monoid Usages Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods mempty :: Usages Source # mappend :: Usages -> Usages -> Usages Source # mconcat :: [Usages] -> Usages Source #
Semigroup Usages Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods (<>) :: Usages -> Usages -> Usages Source # sconcat :: NonEmpty Usages -> Usages Source # stimes :: Integral b => b -> Usages -> Usages Source #
Show Usages Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods showsPrec :: Int -> Usages -> ShowS Source # show :: Usages -> String Source # showList :: [Usages] -> ShowS Source #
Eq Usages Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods (==) :: Usages -> Usages -> Bool Source # (/=) :: Usages -> Usages -> Bool Source #
Ord Usages Source # |
Instance details Defined in Futhark.Analysis.UsageTable Methods compare :: Usages -> Usages -> Ordering Source # (<) :: Usages -> Usages -> Bool Source # (<=) :: Usages -> Usages -> Bool Source # (>) :: Usages -> Usages -> Bool Source # (>=) :: Usages -> Usages -> Bool Source # max :: Usages -> Usages -> Usages Source # min :: Usages -> Usages -> Usages Source #

consumedU :: Usages Source #

A kind of usage.

presentU :: Usages Source #

A kind of usage.

usageInStm :: Aliased rep => Stm rep -> UsageTable Source #

Produce a usage table reflecting the use of the free variables in a single statement.

usageInPat :: FreeIn t => Pat t -> UsageTable Source #

Usage table reflecting use in pattern. In particular, free variables in the decorations are considered used as sizes, even if they are also bound in this pattern.