Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
An intermediate language with an effect system that captures traversals.
Synopsis
- data E2Ext loc dec
- = LetRegionE Region RegionSize (Maybe RegionType) (E2 loc dec)
- | LetParRegionE Region RegionSize (Maybe RegionType) (E2 loc dec)
- | LetLocE LocVar (PreLocExp loc) (E2 loc dec)
- | RetE [loc] Var
- | FromEndE loc
- | BoundsCheck Int loc loc
- | AddFixed Var Int
- | IndirectionE TyCon DataCon (loc, loc) (loc, loc) (E2 loc dec)
- | StartOfPkdCursor Var
- | TagCursor Var Var
- | GetCilkWorkerNum
- | LetAvail [Var] (E2 loc dec)
- | AllocateTagHere LocVar TyCon
- | AllocateScalarsHere LocVar
- | SSPush SSModality LocVar LocVar TyCon
- | SSPop SSModality LocVar LocVar
- type Prog2 = Prog Exp2
- type DDefs2 = DDefs Ty2
- type DDef2 = DDef Ty2
- type FunDef2 = FunDef Exp2
- type FunDefs2 = FunDefs Exp2
- type Exp2 = PreExp E2Ext LocArg Ty2
- newtype Ty2 = MkTy2 {}
- data Effect = Traverse LocVar
- data ArrowTy2 ty2 = ArrowTy2 {}
- data LocRet = EndOf LRM
- data LocArg
- type LocExp = PreLocExp LocArg
- data PreLocExp loc
- = StartOfRegionLE Region
- | AfterConstantLE Int loc
- | AfterVariableLE Var loc Bool
- | InRegionLE Region
- | FreeLE
- | FromEndLE loc
- type LocVar = Var
- data Region
- = GlobR Var Multiplicity
- | DynR Var Multiplicity
- | VarR Var
- | MMapR Var
- data Modality
- data LRM = LRM {}
- data LREM = LREM {}
- data Multiplicity
- data RegionSize
- data RegionType
- regionToVar :: Region -> Var
- allLocVars :: ArrowTy2 ty2 -> [LocVar]
- inLocVars :: ArrowTy2 ty2 -> [LocVar]
- outLocVars :: ArrowTy2 ty2 -> [LocVar]
- outRegVars :: ArrowTy2 ty2 -> [LocVar]
- inRegVars :: ArrowTy2 ty2 -> [LocVar]
- allRegVars :: ArrowTy2 ty2 -> [LocVar]
- substLoc :: Map LocVar LocVar -> Ty2 -> Ty2
- substLocs :: Map LocVar LocVar -> [Ty2] -> [Ty2]
- substEff :: Map LocVar LocVar -> Effect -> Effect
- substEffs :: Map LocVar LocVar -> Set Effect -> Set Effect
- extendPatternMatchEnv :: HasCallStack => DataCon -> DDefs Ty2 -> [Var] -> [LocVar] -> Env2 Ty2 -> Env2 Ty2
- locsInTy :: Ty2 -> [LocVar]
- dummyTyLocs :: Applicative f => UrTy () -> f (UrTy LocVar)
- allFreeVars :: Exp2 -> Set Var
- freeLocVars :: Exp2 -> [Var]
- toLocVar :: LocArg -> LocVar
- fromLRM :: LRM -> LREM
- revertToL1 :: Prog2 -> Prog1
- occurs :: Set Var -> Exp2 -> Bool
- mapPacked :: (Var -> l -> UrTy l) -> UrTy l -> UrTy l
- constPacked :: UrTy a1 -> UrTy a2 -> UrTy a1
- depList :: Exp2 -> [(Var, Var, [Var])]
- changeAppToSpawn :: (Eq loc, Eq dec) => Var -> [PreExp E2Ext loc dec] -> PreExp E2Ext loc dec -> PreExp E2Ext loc dec
- toEndFromTaggedV :: Var -> Var
- toTagV :: Var -> Var
- module Gibbon.Language
Extended language L2 with location types.
The extension that turns L1 into L2.
LetRegionE Region RegionSize (Maybe RegionType) (E2 loc dec) | Allocate a new region. |
LetParRegionE Region RegionSize (Maybe RegionType) (E2 loc dec) | Allocate a new region for parallel allocations. |
LetLocE LocVar (PreLocExp loc) (E2 loc dec) | Bind a new location. |
RetE [loc] Var | Return a value together with extra loc values. |
FromEndE loc | Bind a location from an EndOf location (for RouteEnds and after). |
BoundsCheck Int loc loc | |
AddFixed Var Int | |
IndirectionE TyCon DataCon (loc, loc) (loc, loc) (E2 loc dec) | A indirection node. |
StartOfPkdCursor Var | |
TagCursor Var Var | |
GetCilkWorkerNum | Translates to __cilkrts_get_worker_number(). |
LetAvail [Var] (E2 loc dec) | These variables are available to use before the join point. |
AllocateTagHere LocVar TyCon | |
AllocateScalarsHere LocVar | A marker which tells subsequent a compiler pass where to move the tag and scalar field allocations so that they happen before any of the subsequent packed fields. |
SSPush SSModality LocVar LocVar TyCon | |
SSPop SSModality LocVar LocVar | Spill and restore from the shadow-stack. |
Instances
type Exp2 = PreExp E2Ext LocArg Ty2 Source #
Extended expressions, L2.
By adding a LocVar
decoration, all data constructors,
applications, and bindings gain a location annotation.
L1 Types extended with abstract Locations.
Instances
Out Ty2 Source # | |
Generic Ty2 Source # | |
Read Ty2 Source # | |
Show Ty2 Source # | |
NFData Ty2 Source # | |
Defined in Gibbon.NewL2.Syntax | |
Eq Ty2 Source # | |
Ord Ty2 Source # | |
FunctionTy Ty2 Source # | Function types know about locations and traversal effects. |
Pretty Ty2 Source # | |
Out (ArrowTy2 Ty2) Source # | |
Typeable (E2Ext LocArg Ty2) Source # | |
Out (E2Ext LocArg Ty2) => Typeable (PreExp E2Ext LocArg Ty2) Source # | The add1 :: Tree ... (add1 [loc1, loc2] tr1) .. in this case, we want the type of (add1 tr1) to be (Tree |
type Rep Ty2 Source # | |
Defined in Gibbon.NewL2.Syntax | |
type ArrowTy Ty2 Source # | |
Defined in Gibbon.NewL2.Syntax |
The side-effect of evaluating a function.
Traverse LocVar | The function, during its execution, traverses all of the value living at this location. |
Our type for functions grows to include effects, and explicit universal quantification over location/region variables.
ArrowTy2 | |
|
Instances
Locations (end-witnesses) returned from functions after RouteEnds.
Loc LREM | |
EndWitness LREM Var | |
Reg RegVar Modality | |
EndOfReg RegVar Modality RegVar | |
EndOfReg_Tagged RegVar |
Instances
Define a location in terms of a different location.
StartOfRegionLE Region | |
AfterConstantLE Int loc | |
AfterVariableLE Var loc Bool | |
InRegionLE Region | |
FreeLE | |
FromEndLE loc |
Instances
Regions and locations
An abstract region identifier. This is used inside type signatures and elsewhere.
GlobR Var Multiplicity | A global region with lifetime equal to the whole program. |
DynR Var Multiplicity | A dynamic region that may be created or destroyed, tagged by an identifier. |
VarR Var | A region metavariable that can range over either global or dynamic regions. |
MMapR Var | A region that doesn't result in an (explicit) memory allocation. It merely ensures that there are no free locations in the program. |
Instances
The modality of locations and cursors: input/output, for reading and writing, respectively.
Instances
Out Modality Source # | |
Generic Modality Source # | |
Read Modality Source # | |
Show Modality Source # | |
NFData Modality Source # | |
Defined in Gibbon.L2.Syntax | |
Eq Modality Source # | |
Ord Modality Source # | |
Defined in Gibbon.L2.Syntax | |
Pretty Modality Source # | |
type Rep Modality Source # | |
A location and region, together with modality.
Instances
Out LRM Source # | |
Generic LRM Source # | |
Read LRM Source # | |
Show LRM Source # | |
NFData LRM Source # | |
Defined in Gibbon.L2.Syntax | |
Eq LRM Source # | |
Ord LRM Source # | |
Pretty LRM Source # | |
type Rep LRM Source # | |
Defined in Gibbon.L2.Syntax type Rep LRM = D1 ('MetaData "LRM" "Gibbon.L2.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "LRM" 'PrefixI 'True) (S1 ('MetaSel ('Just "lrmLoc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocVar) :*: (S1 ('MetaSel ('Just "lrmReg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Region) :*: S1 ('MetaSel ('Just "lrmMode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Modality)))) |
Instances
Out LREM Source # | |
Generic LREM Source # | |
Read LREM Source # | |
Show LREM Source # | |
NFData LREM Source # | |
Defined in Gibbon.NewL2.Syntax | |
Eq LREM Source # | |
Ord LREM Source # | |
Pretty LREM Source # | |
type Rep LREM Source # | |
Defined in Gibbon.NewL2.Syntax type Rep LREM = D1 ('MetaData "LREM" "Gibbon.NewL2.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "LREM" 'PrefixI 'True) ((S1 ('MetaSel ('Just "lremLoc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 LocVar) :*: S1 ('MetaSel ('Just "lremReg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RegVar)) :*: (S1 ('MetaSel ('Just "lremEndReg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RegVar) :*: S1 ('MetaSel ('Just "lremMode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Modality)))) |
data Multiplicity Source #
Region variants (multiplicities)
Bounded Int | Contain a finite number of values and can be stack-allocated. |
Infinite | Consist of a linked list of buffers, spread throughout memory (though possible constrained to 4GB regions). Writing into these regions requires bounds-checking. The buffers can start very small at the head of the list, but probably grow geometrically in size, making the cost of traversing all of them logarithmic. |
BigInfinite | These regions are infinite, but also have the expectation of containing many values. Thus we give them large initial page sizes. This is also could be the appropriate place to use mmap to grow the region and to establish guard places. |
Instances
data RegionSize Source #
Instances
data RegionType Source #
Instances
regionToVar :: Region -> Var Source #
Operations on types
allLocVars :: ArrowTy2 ty2 -> [LocVar] Source #
Retrieve all LocVars from a fn type (Arrow)
outLocVars :: ArrowTy2 ty2 -> [LocVar] Source #
outRegVars :: ArrowTy2 ty2 -> [LocVar] Source #
allRegVars :: ArrowTy2 ty2 -> [LocVar] Source #
substEffs :: Map LocVar LocVar -> Set Effect -> Set Effect Source #
Apply a substitution to an effect set.
extendPatternMatchEnv :: HasCallStack => DataCon -> DDefs Ty2 -> [Var] -> [LocVar] -> Env2 Ty2 -> Env2 Ty2 Source #
Extend an environment for a pattern match. E.g.
data Foo = MkFoo Int Foo | ...
case foo1 of MkFoo (i:loc1) (f:loc2) -> new_env2 = extendPatternMatchEnv [loc1,loc2] old_env2
dummyTyLocs :: Applicative f => UrTy () -> f (UrTy LocVar) Source #
freeLocVars :: Exp2 -> [Var] Source #
Other helpers
revertToL1 :: Prog2 -> Prog1 Source #
occurs :: Set Var -> Exp2 -> Bool Source #
Does a variable occur in an expression ?
N.B. it only looks for actual variables, not LocVar's or RegionVar's.
depList :: Exp2 -> [(Var, Var, [Var])] Source #
Build a dependency list which can be later converted to a graph
changeAppToSpawn :: (Eq loc, Eq dec) => Var -> [PreExp E2Ext loc dec] -> PreExp E2Ext loc dec -> PreExp E2Ext loc dec Source #
toEndFromTaggedV :: Var -> Var Source #
module Gibbon.Language