gibbon-0.3: A compiler for operating on serialized data
Safe HaskellSafe-Inferred
LanguageHaskell2010

Gibbon.Passes.InferLocations

Description

Convert from L1 to L2, adding region constructs.

Synopsis

Documentation

data FullEnv Source #

Combine the different kinds of contextual information in-scope.

Instances

Instances details
Show FullEnv Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

type TiM a = ExceptT Failure (StateT InferState PassM) a Source #

The location inference monad is a stack of ExceptT and StateT.

type InferState = Map LocVar UnifyLoc Source #

The state of the inference procedure is a map from location variable to UnifyLoc, which is explained below. This is a bit awkward, since after inference is done we have to make another pass over the AST to update all the LocVars. One refactoring that would make this less awkward would be to make a type-level distinction between LocVars that occur before and after this pass. Also, it would be more efficient to use mutable state directly for this, or possibly some more sophisticated union find thing.

type Result = (Exp2, Ty2, [Constraint]) Source #

The result type for this pass. Return a new expression and its type, which includes/implies its location.

data UnifyLoc Source #

A location is either fixed or fresh. Two fixed locations cannot unify.

Instances

Instances details
Show UnifyLoc Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

Eq UnifyLoc Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

data Failure Source #

Instances

Instances details
Show Failure Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

Eq Failure Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

data Dest Source #

Destination can be a single location var, a tuple of destinations, or nothing (for scalar values)

Instances

Instances details
Out Dest Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

Methods

docPrec :: Int -> Dest -> Doc Source #

doc :: Dest -> Doc Source #

docList :: [Dest] -> Doc Source #

Generic Dest Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

Associated Types

type Rep Dest :: Type -> Type Source #

Methods

from :: Dest -> Rep Dest x Source #

to :: Rep Dest x -> Dest Source #

Show Dest Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

type Rep Dest Source # 
Instance details

Defined in Gibbon.Passes.InferLocations

type Rep Dest = D1 ('MetaData "Dest" "Gibbon.Passes.InferLocations" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "SingleDest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocVar)) :+: (C1 ('MetaCons "TupleDest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Dest])) :+: C1 ('MetaCons "NoDest" 'PrefixI 'False) (U1 :: Type -> Type)))

finishExp :: Exp2 -> TiM Exp2 Source #

Transforms an expression by updating all locations to their final mapping as a result of unification.

prim :: Prim Ty1 -> PassM (Prim Ty2) Source #

Convert a prim from L1 to L2

unify :: LocVar -> LocVar -> TiM a -> TiM a -> TiM a Source #

Unify is a conditional form that takes a "success branch" and "failure branch". In the case of failure, it makes no change to the store. In the case of success, the new equalities are placed in the store before executing the success branch.

inferExp :: FullEnv -> Exp1 -> Dest -> TiM Result Source #

We proceed in a destination-passing style given the target region into which we must produce the resulting value.

inferExp' :: FullEnv -> Exp1 -> [LocVar] -> Dest -> TiM (Exp2, Ty2) Source #

Wrap the inferExp procedure, and consume all remaining constraints

convertFunTy :: ([Ty1], Ty1, Bool) -> PassM (ArrowTy2 Ty2) Source #

This helper exemplifies the simplicity of our current approach. If we assume output regions are disjoint from input ones, then we can instantiate an L1 function type into a polymorphic L2 one, mechanically.

copyOutOfOrderPacked :: Prog1 -> PassM Prog1 Source #

Adds copyPacked calls in certain places that inferLocs is not able to.