Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Utility declarations for performing range analysis. The ranges computed here are local (does not take range of subexpressions into account), which is probably not very interesting. See Futhark.Analysis.Range for a more comprehensive analysis built on these building blocks.
Synopsis
- type Bound = Maybe KnownBound
- data KnownBound
- boundToScalExp :: KnownBound -> Maybe ScalExp
- minimumBound :: Bound -> Bound -> Bound
- maximumBound :: Bound -> Bound -> Bound
- type Range = (Bound, Bound)
- unknownRange :: Range
- type ScalExpRange = (Maybe ScalExp, Maybe ScalExp)
- type Ranged lore = (ASTLore lore, RangedOp (Op lore), RangeOf (LetDec lore), RangesOf (BodyDec lore))
- class RangeOf a where
- class RangesOf a where
- expRanges :: Ranged lore => Exp lore -> [Range]
- class IsOp op => RangedOp op where
- class RangedOp (OpWithRanges op) => CanBeRanged op where
- type OpWithRanges op :: Type
- removeOpRanges :: OpWithRanges op -> op
- addOpRanges :: op -> OpWithRanges op
Documentation
type Bound = Maybe KnownBound Source #
A possibly undefined bound on a value.
data KnownBound Source #
A known bound on a value.
VarBound VName | Has the same bounds as this variable. VERY
IMPORTANT: this variable may be an array, so it
cannot be immediately translated to a |
MinimumBound KnownBound KnownBound | Bounded by the minimum of these two bounds. |
MaximumBound KnownBound KnownBound | Bounded by the maximum of these two bounds. |
ScalarBound ScalExp | Bounded by this scalar expression. |
Instances
boundToScalExp :: KnownBound -> Maybe ScalExp Source #
Convert the bound to a scalar expression if possible. This is
possible for all bounds that do not contain VarBound
s.
minimumBound :: Bound -> Bound -> Bound Source #
Construct a MinimumBound
from two possibly known bounds. The
resulting bound will be unknown unless both of the given Bound
s
are known. This may seem counterintuitive, but it actually makes
sense when you consider the task of combining the lower bounds for
two different flows of execution (like an if
expression). If we
only have knowledge about one of the branches, this means that we
have no useful information about the combined lower bound, as the
other branch may take any value.
maximumBound :: Bound -> Bound -> Bound Source #
Like minimumBound
, but constructs a MaximumBound
.
unknownRange :: Range Source #
A range in which both upper and lower bounds are 'Nothing.
type ScalExpRange = (Maybe ScalExp, Maybe ScalExp) Source #
The range as a pair of scalar expressions.
type Ranged lore = (ASTLore lore, RangedOp (Op lore), RangeOf (LetDec lore), RangesOf (BodyDec lore)) Source #
The lore has embedded range information. Note that it may not be up to date, unless whatever maintains the syntax tree is careful.
class RangeOf a where Source #
Something that contains range information.
expRanges :: Ranged lore => Exp lore -> [Range] Source #
Ranges of the value parts of the expression.
class IsOp op => RangedOp op where Source #
The class of operations that can produce range information.
Instances
RangedOp () Source # | |
Defined in Futhark.IR.Prop.Ranges | |
RangedOp SizeOp Source # | |
Ranged inner => RangedOp (SOAC inner) Source # | |
RangedOp inner => RangedOp (MemOp inner) Source # | |
(ASTLore inner, ASTConstraints lvl) => RangedOp (SegOp lvl inner) Source # | |
(ASTLore lore, RangedOp op) => RangedOp (HostOp lore op) Source # | |
class RangedOp (OpWithRanges op) => CanBeRanged op where Source #
The class of operations that can be given ranging information. This is a somewhat subtle concept that is only used in the simplifier and when using "lore adapters".
type OpWithRanges op :: Type Source #
removeOpRanges :: OpWithRanges op -> op Source #
addOpRanges :: op -> OpWithRanges op Source #