atom-1.0.9: A DSL for embedded hard realtime applications.

Safe Haskell | None

Language.Atom.UeMap

Description

Sharing for UEs, based on IntMaps. The idea is to share subexpressions of `UE`s.

Synopsis

- data UeElem
  - = MUVRef !MUV
  - | MUConst !Const
  - | MUCast !Type !Hash
  - | MUAdd !Hash !Hash
  - | MUSub !Hash !Hash
  - | MUMul !Hash !Hash
  - | MUDiv !Hash !Hash
  - | MUMod !Hash !Hash
  - | MUNot !Hash
  - | MUAnd [Hash]
  - | MUBWNot !Hash
  - | MUBWAnd !Hash !Hash
  - | MUBWOr !Hash !Hash
  - | MUShift !Hash !Int
  - | MUEq !Hash !Hash
  - | MULt !Hash !Hash
  - | MUMux !Hash !Hash !Hash
  - | MUF2B !Hash
  - | MUD2B !Hash
  - | MUB2F !Hash
  - | MUB2D !Hash
  - | MUPi
  - | MUExp !Hash
  - | MULog !Hash
  - | MUSqrt !Hash
  - | MUPow !Hash !Hash
  - | MUSin !Hash
  - | MUAsin !Hash
  - | MUCos !Hash
  - | MUAcos !Hash
  - | MUSinh !Hash
  - | MUCosh !Hash
  - | MUAsinh !Hash
  - | MUAcosh !Hash
  - | MUAtan !Hash
  - | MUAtanh !Hash
- data MUV
  - = MUV Int String Const
  - | MUVArray UA Hash
  - | MUVExtern String Type
- type UeMap = (Hash, Bimap Int UeElem)
- emptyMap :: UeMap
- type Hash = Int
- typeOf :: Hash -> UeMap -> Type
- type UeState a = State UeMap a
- recoverUE :: UeMap -> Hash -> UE
- getUE :: Hash -> UeMap -> UeElem
- newUE :: UE -> UeMap -> (Hash, UeMap)
- newUV :: UV -> UeMap -> (MUV, UeMap)
- maybeUpdate :: UeElem -> UeState Hash
- ueUpstream :: Hash -> UeMap -> [Hash]
- nearestUVs :: Hash -> UeMap -> [MUV]
- arrayIndices :: Hash -> UeMap -> [(UA, Hash)]
- isMathHCall :: UeElem -> Bool

# Documentation

data UeElem

Corresponds to `UE`s --- the elements in the sharing structure.

Constructors

MUVRef !MUV |
MUConst !Const |
MUCast !Type !Hash |
MUAdd !Hash !Hash |
MUSub !Hash !Hash |
MUMul !Hash !Hash |
MUDiv !Hash !Hash |
MUMod !Hash !Hash |
MUNot !Hash |
MUAnd [Hash] |
MUBWNot !Hash |
MUBWAnd !Hash !Hash |
MUBWOr !Hash !Hash |
MUShift !Hash !Int |
MUEq !Hash !Hash |
MULt !Hash !Hash |
MUMux !Hash !Hash !Hash |
MUF2B !Hash |
MUD2B !Hash |
MUB2F !Hash |
MUB2D !Hash |
MUPi |
MUExp !Hash |
MULog !Hash |
MUSqrt !Hash |
MUPow !Hash !Hash |
MUSin !Hash |
MUAsin !Hash |
MUCos !Hash |
MUAcos !Hash |
MUSinh !Hash |
MUCosh !Hash |
MUAsinh !Hash |
MUAcosh !Hash |
MUAtan !Hash |
MUAtanh !Hash |

Instances

Eq UeElem |
Ord UeElem |
Show UeElem |

data MUV

Untyped variables map.

Constructors

MUV Int String Const |
MUVArray UA Hash |
MUVExtern String Type |

Instances

Eq MUV |
Ord MUV |
Show MUV |

type UeMap = (Hash, Bimap Int UeElem)

An entry in the Map.

emptyMap :: UeMap

type Hash = Int

typeOf :: Hash -> UeMap -> Type

type UeState a = State UeMap a

Wrapped in the State Monad.

recoverUE :: UeMap -> Hash -> UE

Get a `UE` back out of the `UeMap`.

getUE :: Hash -> UeMap -> UeElem

Get the element associated with a `Hash` value. It's an error if the element is not in the map.

newUE :: UE -> UeMap -> (Hash, UeMap)

Put a new `UE` in the map, unless it's already in there, and return the hash pointing to the `UE` and a new map.

newUV :: UV -> UeMap -> (MUV, UeMap)

Transforms a `UV` into a `MUV`, returning the possibly updated map.

maybeUpdate :: UeElem -> UeState Hash

Lookup an element in the map, and if it's in there, do nothing, but return its hash value. Otherwise, update the map and return the new hash value for the inserted element.

ueUpstream :: Hash -> UeMap -> [Hash]

The list of Hashes to adjacent upstream of a UE.

nearestUVs :: Hash -> UeMap -> [MUV]

The list of all UVs that directly control the value of an expression.

arrayIndices :: Hash -> UeMap -> [(UA, Hash)]

All array indexing subexpressions.

isMathHCall :: UeElem -> Bool