Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
An intermediate language which makes cursors explicit
Synopsis
- data E3Ext loc dec
- = ReadScalar Scalar Var
- | WriteScalar Scalar Var (PreExp E3Ext loc dec)
- | ReadTag Var
- | WriteTag DataCon Var
- | TagCursor Var Var
- | WriteTaggedCursor Var (PreExp E3Ext loc dec)
- | ReadTaggedCursor Var
- | ReadCursor Var
- | WriteCursor Var (PreExp E3Ext loc dec)
- | ReadList Var dec
- | WriteList Var (PreExp E3Ext loc dec) dec
- | ReadVector Var dec
- | WriteVector Var (PreExp E3Ext loc dec) dec
- | AddCursor Var (PreExp E3Ext loc dec)
- | SubPtr Var Var
- | NewBuffer Multiplicity
- | ScopedBuffer Multiplicity
- | NewParBuffer Multiplicity
- | ScopedParBuffer Multiplicity
- | EndOfBuffer Multiplicity
- | MMapFileSize Var
- | SizeOfPacked Var Var
- | SizeOfScalar Var
- | BoundsCheck Int Var Var
- | IndirectionBarrier TyCon (Var, Var, Var, Var)
- | BumpArenaRefCount Var Var
- | NullCursor
- | RetE [PreExp E3Ext loc dec]
- | GetCilkWorkerNum
- | LetAvail [Var] (PreExp E3Ext loc dec)
- | AllocateTagHere Var TyCon
- | AllocateScalarsHere Var
- | StartTagAllocation Var
- | EndTagAllocation Var
- | StartScalarsAllocation Var
- | EndScalarsAllocation Var
- | SSPush SSModality Var Var TyCon
- | SSPop SSModality Var Var
- | Assert (PreExp E3Ext loc dec)
- type Prog3 = Prog Exp3
- type DDef3 = DDef Ty3
- type DDefs3 = DDefs Ty3
- type FunDef3 = FunDef Exp3
- type FunDefs3 = FunDefs Exp3
- type Exp3 = PreExp E3Ext () Ty3
- type Ty3 = UrTy ()
- data Scalar
- mkScalar :: Out a => UrTy a -> Scalar
- scalarToTy :: Scalar -> UrTy a
- eraseLocMarkers :: DDef Ty2 -> DDef Ty3
- mapMExprs :: Monad m => (Env2 Ty3 -> Exp3 -> m Exp3) -> Prog3 -> m Prog3
- cursorizeTy :: UrTy a -> UrTy b
- toL3Prim :: Prim Ty2 -> Prim Ty3
- updateAvailVars :: [Var] -> [Var] -> Exp3 -> Exp3
- type TyCon = String
- class Expression e => Typeable e where
- type Binds e = (Var, [LocOf e], TyOf e, e)
- type Tag = Word8
- data Prim ty
- = AddP
- | SubP
- | MulP
- | DivP
- | ModP
- | ExpP
- | RandP
- | EqIntP
- | LtP
- | GtP
- | LtEqP
- | GtEqP
- | FAddP
- | FSubP
- | FMulP
- | FDivP
- | FExpP
- | FRandP
- | EqFloatP
- | EqCharP
- | FLtP
- | FGtP
- | FLtEqP
- | FGtEqP
- | FSqrtP
- | IntToFloatP
- | FloatToIntP
- | FTanP
- | EqSymP
- | EqBenchProgP String
- | OrP
- | AndP
- | MkTrue
- | MkFalse
- | ErrorP String ty
- | SizeParam
- | IsBig
- | GetNumProcessors
- | PrintInt
- | PrintChar
- | PrintFloat
- | PrintBool
- | PrintSym
- | ReadInt
- | DictInsertP ty
- | DictLookupP ty
- | DictEmptyP ty
- | DictHasKeyP ty
- | SymSetEmpty
- | SymSetInsert
- | SymSetContains
- | SymHashEmpty
- | SymHashInsert
- | SymHashLookup
- | SymHashContains
- | IntHashEmpty
- | IntHashInsert
- | IntHashLookup
- | PDictAllocP ty ty
- | PDictInsertP ty ty
- | PDictLookupP ty ty
- | PDictHasKeyP ty ty
- | PDictForkP ty ty
- | PDictJoinP ty ty
- | LLAllocP ty
- | LLIsEmptyP ty
- | LLConsP ty
- | LLHeadP ty
- | LLTailP ty
- | LLFreeP ty
- | LLFree2P ty
- | LLCopyP ty
- | VAllocP ty
- | VFreeP ty
- | VFree2P ty
- | VLengthP ty
- | VNthP ty
- | VSliceP ty
- | InplaceVUpdateP ty
- | VConcatP ty
- | VSortP ty
- | InplaceVSortP ty
- | VMergeP ty
- | Write3dPpmFile FilePath
- | ReadPackedFile (Maybe FilePath) TyCon (Maybe Var) ty
- | WritePackedFile FilePath ty
- | ReadArrayFile (Maybe (FilePath, Int)) ty
- | RequestEndOf
- | RequestSizeOf
- | Gensym
- class Expression e => Interp s e where
- class (Show e, Out e, FreeVars e) => Expression e where
- type DDefs a = Map Var (DDef a)
- type DataCon = String
- type IsBoxed = Bool
- data DDef a = DDef {}
- class (Out (ArrowTy ty), Show (ArrowTy ty)) => FunctionTy ty where
- type FunDefs ex = Map Var (FunDef ex)
- data FunDef ex = FunDef {}
- data FunMeta = FunMeta {}
- data FunRec
- data FunInline
- = Inline
- | NoInline
- | Inlineable
- data Prog ex = Prog {}
- type TyEnv a = Map Var a
- data Env2 a = Env2 {}
- data PreExp (ext :: Type -> Type -> Type) loc dec
- = VarE Var
- | LitE Int
- | CharE Char
- | FloatE Double
- | LitSymE Var
- | AppE Var [loc] [PreExp ext loc dec]
- | PrimAppE (Prim dec) [PreExp ext loc dec]
- | LetE (Var, [loc], dec, PreExp ext loc dec) (PreExp ext loc dec)
- | IfE (PreExp ext loc dec) (PreExp ext loc dec) (PreExp ext loc dec)
- | MkProdE [PreExp ext loc dec]
- | ProjE Int (PreExp ext loc dec)
- | CaseE (PreExp ext loc dec) [(DataCon, [(Var, loc)], PreExp ext loc dec)]
- | DataConE loc DataCon [PreExp ext loc dec]
- | TimeIt (PreExp ext loc dec) dec Bool
- | WithArenaE Var (PreExp ext loc dec)
- | SpawnE Var [loc] [PreExp ext loc dec]
- | SyncE
- | MapE (Var, dec, PreExp ext loc dec) (PreExp ext loc dec)
- | FoldE { }
- | Ext (ext loc dec)
- data UrTy loc
- data PreExpF (ext :: Type -> Type -> Type) (loc :: Type) (dec :: Type) r
- = VarEF Var
- | LitEF Int
- | CharEF Char
- | FloatEF Double
- | LitSymEF Var
- | AppEF Var [loc] [r]
- | PrimAppEF (Prim dec) [r]
- | LetEF (Var, [loc], dec, r) r
- | IfEF r r r
- | MkProdEF [r]
- | ProjEF Int r
- | CaseEF r [([Char], [(Var, loc)], r)]
- | DataConEF loc [Char] [r]
- | TimeItF r dec Bool
- | WithArenaEF Var r
- | SpawnEF Var [loc] [r]
- | SyncEF
- | MapEF (Var, dec, r) r
- | FoldEF { }
- | ExtF (ext loc dec)
- data PrimF (ty :: Type) r
- = AddPF
- | SubPF
- | MulPF
- | DivPF
- | ModPF
- | ExpPF
- | RandPF
- | EqIntPF
- | LtPF
- | GtPF
- | LtEqPF
- | GtEqPF
- | FAddPF
- | FSubPF
- | FMulPF
- | FDivPF
- | FExpPF
- | FRandPF
- | EqFloatPF
- | EqCharPF
- | FLtPF
- | FGtPF
- | FLtEqPF
- | FGtEqPF
- | FSqrtPF
- | IntToFloatPF
- | FloatToIntPF
- | FTanPF
- | EqSymPF
- | EqBenchProgPF [Char]
- | OrPF
- | AndPF
- | MkTrueF
- | MkFalseF
- | ErrorPF [Char] ty
- | SizeParamF
- | IsBigF
- | GetNumProcessorsF
- | PrintIntF
- | PrintCharF
- | PrintFloatF
- | PrintBoolF
- | PrintSymF
- | ReadIntF
- | DictInsertPF ty
- | DictLookupPF ty
- | DictEmptyPF ty
- | DictHasKeyPF ty
- | SymSetEmptyF
- | SymSetInsertF
- | SymSetContainsF
- | SymHashEmptyF
- | SymHashInsertF
- | SymHashLookupF
- | SymHashContainsF
- | IntHashEmptyF
- | IntHashInsertF
- | IntHashLookupF
- | PDictAllocPF ty ty
- | PDictInsertPF ty ty
- | PDictLookupPF ty ty
- | PDictHasKeyPF ty ty
- | PDictForkPF ty ty
- | PDictJoinPF ty ty
- | LLAllocPF ty
- | LLIsEmptyPF ty
- | LLConsPF ty
- | LLHeadPF ty
- | LLTailPF ty
- | LLFreePF ty
- | LLFree2PF ty
- | LLCopyPF ty
- | VAllocPF ty
- | VFreePF ty
- | VFree2PF ty
- | VLengthPF ty
- | VNthPF ty
- | VSlicePF ty
- | InplaceVUpdatePF ty
- | VConcatPF ty
- | VSortPF ty
- | InplaceVSortPF ty
- | VMergePF ty
- | Write3dPpmFileF [Char]
- | ReadPackedFileF (Maybe [Char]) [Char] (Maybe Var) ty
- | WritePackedFileF [Char] ty
- | ReadArrayFileF (Maybe ([Char], Int)) ty
- | RequestEndOfF
- | RequestSizeOfF
- | GensymF
- data UrTyF (loc :: Type) r
- class FreeVars a where
- class Expression e => Flattenable e where
- class Expression e => Simplifiable e where
- gInlineTrivExp :: Map Var e -> e -> e
- class Expression e => SimplifiableExt e ext where
- gInlineTrivExt :: Map Var e -> ext -> ext
- class Expression e => Substitutable e where
- class Expression e => SubstitutableExt e ext where
- gSubstExt :: Var -> e -> ext -> ext
- gSubstEExt :: e -> e -> ext -> ext
- class Renamable e where
- type HasSimplifiable e l d = (Show l, Out l, Show d, Out d, Expression (e l d), SimplifiableExt (PreExp e l d) (e l d))
- type HasSimplifiableExt e l d = (Show l, Out l, Show d, Out d, Simplifiable (PreExp e l d))
- type HasSubstitutable e l d = (Expression (e l d), SubstitutableExt (PreExp e l d) (e l d), Eq d, Show d, Out d, Eq l, Show l, Out l, Eq (e l d))
- type HasSubstitutableExt e l d = (Eq d, Show d, Out d, Eq l, Show l, Out l, Substitutable (PreExp e l d))
- type HasRenamable e l d = (Renamable l, Renamable d, Renamable (e l d))
- type HasOut ex = (Out ex, Out (TyOf ex), Out (ArrowTy (TyOf ex)))
- type HasShow ex = (Show ex, Show (TyOf ex), Show (ArrowTy (TyOf ex)))
- type HasEq ex = (Eq ex, Eq (TyOf ex), Eq (ArrowTy (TyOf ex)))
- type HasGeneric ex = (Generic ex, Generic (TyOf ex), Generic (ArrowTy (TyOf ex)))
- type HasNFData ex = (NFData ex, NFData (TyOf ex), NFData (ArrowTy (TyOf ex)))
- class (Expression e, Expression ext) => InterpExt s e ext where
- class Interp s e => InterpProg s e where
- gInterpProg :: s -> RunConfig -> Prog e -> IO (s, Value e, ByteString)
- gInterpNoLogs :: s -> RunConfig -> Prog e -> String
- gInterpWithStdout :: s -> RunConfig -> Prog e -> IO (String, [String])
- data Value e
- type ValEnv e = Map Var (Value e)
- type InterpLog = Builder
- data InterpM s e a
- mapExt :: (e1 l d -> e2 l d) -> PreExp e1 l d -> PreExp e2 l d
- mapLocs :: (e l2 d -> e l2 d) -> PreExp e l2 d -> PreExp e l2 d
- mapExprs :: (e -> e) -> Prog e -> Prog e
- visitExp :: forall l1 l2 e1 e2 d1 d2. (l1 -> l2) -> (e1 l1 d1 -> e2 l2 d2) -> (d1 -> d2) -> PreExp e1 l1 d1 -> PreExp e2 l2 d2
- subst :: HasSubstitutable e l d => Var -> PreExp e l d -> PreExp e l d -> PreExp e l d
- substE :: HasSubstitutable e l d => PreExp e l d -> PreExp e l d -> PreExp e l d -> PreExp e l d
- hasTimeIt :: PreExp e l d -> Bool
- hasSpawns :: PreExp e l d -> Bool
- hasSpawnsProg :: Prog (PreExp e l d) -> Bool
- projNonFirst :: (Out l, Out d, Out (e l d)) => Int -> PreExp e l d -> PreExp e l d
- mkProj :: Int -> PreExp e l d -> PreExp e l d
- mkProd :: [PreExp e l d] -> PreExp e l d
- mkLets :: [(Var, [loc], dec, PreExp ext loc dec)] -> PreExp ext loc dec -> PreExp ext loc dec
- flatLets :: [(Var, [l], d, PreExp e l d)] -> PreExp e l d -> PreExp e l d
- tuplizeRefs :: Var -> [Var] -> [d] -> PreExp e l d -> PreExp e l d
- mkProdTy :: [UrTy a] -> UrTy a
- projTy :: Out a => Int -> UrTy a -> UrTy a
- voidTy :: UrTy a
- isProdTy :: UrTy a -> Bool
- isNestedProdTy :: UrTy a -> Bool
- isPackedTy :: UrTy a -> Bool
- isScalarTy :: UrTy a -> Bool
- hasPacked :: Show a => UrTy a -> Bool
- sizeOfTy :: UrTy a -> Maybe Int
- primArgsTy :: Prim (UrTy a) -> [UrTy a]
- primRetTy :: Prim (UrTy a) -> UrTy a
- tyToDataCon :: Show a => UrTy a -> DataCon
- stripTyLocs :: UrTy a -> UrTy ()
- isValidListElemTy :: UrTy a -> Bool
- getPackedTys :: Show a => UrTy a -> [UrTy a]
- assertTriv :: (HasCallStack, Expression e) => e -> a -> a
- assertTrivs :: (HasCallStack, Expression e) => [e] -> a -> a
- lookupDDef :: Out a => DDefs a -> TyCon -> DDef a
- getConOrdering :: Out a => DDefs a -> TyCon -> [DataCon]
- getTyOfDataCon :: Out a => DDefs a -> DataCon -> TyCon
- lookupDataCon :: Out a => DDefs a -> DataCon -> [a]
- lkp :: Out a => DDefs a -> DataCon -> (Var, (DataCon, [(IsBoxed, a)]))
- lookupDataCon' :: Out a => DDef a -> DataCon -> [a]
- insertDD :: DDef a -> DDefs a -> DDefs a
- emptyDD :: DDefs a
- fromListDD :: [DDef a] -> DDefs a
- isVoidDDef :: DDef a -> Bool
- insertFD :: FunDef ex -> FunDefs ex -> FunDefs ex
- fromListFD :: [FunDef ex] -> FunDefs ex
- initFunEnv :: FunDefs a -> TyEnv (ArrowTy (TyOf a))
- progToEnv :: Prog a -> Env2 (TyOf a)
- getFunTy :: Var -> Prog ex -> ArrowTy (TyOf ex)
- emptyEnv2 :: Env2 a
- extendVEnv :: Var -> a -> Env2 a -> Env2 a
- extendsVEnv :: Map Var a -> Env2 a -> Env2 a
- lookupVEnv :: Out a => Var -> Env2 a -> a
- extendFEnv :: Var -> ArrowTy a -> Env2 a -> Env2 a
- lookupFEnv :: Out (ArrowTy a) => Var -> Env2 a -> ArrowTy a
- runInterpM :: InterpM s e a -> s -> IO (a, InterpLog, s)
- execAndPrint :: InterpProg s ex => s -> RunConfig -> Prog ex -> IO ()
- redirectionSize :: Int
- redirectionTag :: DataCon
- isRedirectionTag :: DataCon -> Bool
- redirectionAlt :: Num a => a
- indirectionTag :: DataCon
- isIndirectionTag :: DataCon -> Bool
- indirectionAlt :: Num a => a
- toAbsRANDataCon :: DataCon -> DataCon
- isAbsRANDataCon :: DataCon -> Bool
- toRelRANDataCon :: DataCon -> DataCon
- isRelRANDataCon :: DataCon -> Bool
- fromRANDataCon :: DataCon -> DataCon
- mkUnpackerName :: TyCon -> Var
- isUnpackerName :: Var -> Bool
- mkPrinterName :: TyCon -> Var
- isPrinterName :: Var -> Bool
- mkCopyFunName :: TyCon -> Var
- isCopyFunName :: Var -> Bool
- mkCopySansPtrsFunName :: TyCon -> Var
- isCopySansPtrsFunName :: Var -> Bool
- mkTravFunName :: TyCon -> Var
- isTravFunName :: Var -> Bool
- mkRelOffsetsFunName :: DataCon -> Var
- isRelOffsetsFunName :: Var -> Bool
Extended language
The extension that turns L1 into L3.
ReadScalar Scalar Var | One cursor in, (int, cursor') out |
WriteScalar Scalar Var (PreExp E3Ext loc dec) | Write int at cursor, and return a cursor |
ReadTag Var | One cursor in, (tag,cursor) out |
WriteTag DataCon Var | Write Tag at Cursor, and return a cursor |
TagCursor Var Var | Create a tagged cursor |
WriteTaggedCursor Var (PreExp E3Ext loc dec) | Write a tagged cursor |
ReadTaggedCursor Var | Reads and returns a tagged cursor at Var |
ReadCursor Var | Reads and returns the cursor at Var |
WriteCursor Var (PreExp E3Ext loc dec) | Write a cursor, and return a cursor |
ReadList Var dec | Read a pointer to a linked list |
WriteList Var (PreExp E3Ext loc dec) dec | Write a pointer to a linked list |
ReadVector Var dec | Read a pointer to a vector |
WriteVector Var (PreExp E3Ext loc dec) dec | Write a pointer to a vector |
AddCursor Var (PreExp E3Ext loc dec) | Add a constant offset to a cursor variable |
SubPtr Var Var | Pointer subtraction |
NewBuffer Multiplicity | Create a new buffer, and return a cursor |
ScopedBuffer Multiplicity | Create a temporary scoped buffer, and return a cursor |
NewParBuffer Multiplicity | Create a new buffer for parallel allocations, and return a cursor |
ScopedParBuffer Multiplicity | Create a temporary scoped buffer for parallel allocations, and return a cursor |
EndOfBuffer Multiplicity | |
MMapFileSize Var | |
SizeOfPacked Var Var | Takes in start and end cursors, and returns an Int we'll probably represent (sizeof x) as (end_x - start_x) / INT |
SizeOfScalar Var | sizeof(var) |
BoundsCheck Int Var Var | Bytes required, region, write cursor |
IndirectionBarrier TyCon (Var, Var, Var, Var) | Do one of the following: (1) If it's a old-to-young indirection, record it in the remembered set. (2) Otherwise, bump the refcount and update the outset. |
BumpArenaRefCount Var Var | Given an arena and end-of-region ptr, add a reference from the arena to the region |
NullCursor | Constant null cursor value (hack?). Used for dict lookup, which returns a packed value but no end witness. |
RetE [PreExp E3Ext loc dec] | Analogous to L2's RetE. |
GetCilkWorkerNum | Translates to __cilkrts_get_worker_number(). |
LetAvail [Var] (PreExp E3Ext loc dec) | These variables are available to use before the join point |
AllocateTagHere Var TyCon | Analogous to L2's extension. |
AllocateScalarsHere Var | Analogous to L2's extension. |
StartTagAllocation Var | Marks the beginning of tag allocation. |
EndTagAllocation Var | Marks the end of tag allocation. |
StartScalarsAllocation Var | Marks the beginning of scalar allocation. |
EndScalarsAllocation Var | Marks the end of scalar allocation. |
SSPush SSModality Var Var TyCon | |
SSPop SSModality Var Var | |
Assert (PreExp E3Ext loc dec) | Translates to assert statements in C. ^ Analogous to L2's extensions. |
Instances
Instances
Out Scalar Source # | |
Generic Scalar Source # | |
Read Scalar Source # | |
Show Scalar Source # | |
NFData Scalar Source # | |
Defined in Gibbon.L3.Syntax | |
Eq Scalar Source # | |
Ord Scalar Source # | |
Defined in Gibbon.L3.Syntax | |
type Rep Scalar Source # | |
Defined in Gibbon.L3.Syntax type Rep Scalar = D1 ('MetaData "Scalar" "Gibbon.L3.Syntax" "gibbon-0.3-inplace" 'False) ((C1 ('MetaCons "IntS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CharS" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FloatS" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SymS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BoolS" 'PrefixI 'False) (U1 :: Type -> Type)))) |
scalarToTy :: Scalar -> UrTy a Source #
Functions
mapMExprs :: Monad m => (Env2 Ty3 -> Exp3 -> m Exp3) -> Prog3 -> m Prog3 Source #
Map exprs with an initial type environment: Exactly the same function that was in L2 before
cursorizeTy :: UrTy a -> UrTy b Source #
class Expression e => Typeable e where Source #
This is NOT a replacement for any typechecker. This only recover type of an expression given a type-environment. Without this, we cannot have truly generic Flattenable, b/c we need to know the type of an expression before we bind it with a LetE.
Instances
Typeable (E1Ext () (UrTy ())) Source # | |
Typeable (E2Ext LocArg Ty2) Source # | |
(Out l, Show l, Typeable (E2 l (UrTy l))) => Typeable (E2Ext l (UrTy l)) Source # | |
(Out l, Show l, Typeable (PreExp E3Ext l (UrTy l))) => Typeable (E3Ext l (UrTy l)) Source # | |
Typeable (PreExp E2Ext LocVar (UrTy LocVar)) Source # | The add1 :: Tree ... (add1 [loc1, loc2] tr1) .. in this case, we want the type of (add1 tr1) to be (Tree |
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 |
(Show (), Out (), TyOf (e () (UrTy ())) ~ TyOf (PreExp e () (UrTy ())), FunctionTy (UrTy ()), Typeable (e () (UrTy ()))) => Typeable (PreExp e () (UrTy ())) Source # | A Typeable instance for L1 and L3 (L2 defines it's own) |
Some of these primitives are (temporarily) tagged directly with their return types.
AddP | |
SubP | |
MulP | May need more numeric primitives... |
DivP | |
ModP | Integer division and modulus |
ExpP | Exponentiation |
RandP | Generate a random number. Translates to 'rand()' in C. |
EqIntP | Equality on Int |
LtP | |
GtP | (and () for Int's |
LtEqP | |
GtEqP | and= |
FAddP | |
FSubP | |
FMulP | |
FDivP | |
FExpP | |
FRandP | |
EqFloatP | |
EqCharP | |
FLtP | |
FGtP | |
FLtEqP | |
FGtEqP | |
FSqrtP | |
IntToFloatP | |
FloatToIntP | |
FTanP | Translates to 'tan()' in C. |
EqSymP | Equality on Sym |
EqBenchProgP String | |
OrP | |
AndP | |
MkTrue | Zero argument constructor. |
MkFalse | Zero argument constructor. |
ErrorP String ty | crash and issue a static error message. To avoid needing inference, this is labeled with a return type. |
SizeParam | |
IsBig | Check the size of constructors with size. |
GetNumProcessors | Return the number of processors |
PrintInt | Print an integer to standard out |
PrintChar | Print a character to standard out |
PrintFloat | Print a floating point number to standard out |
PrintBool | Print a boolean to standard out |
PrintSym | Print a symbol to standard out |
ReadInt | Read an int from standard in |
DictInsertP ty | takes dict, k,v; annotated with element type |
DictLookupP ty | takes dict,k errors if absent; annotated with element type |
DictEmptyP ty | annotated with element type to avoid ambiguity |
DictHasKeyP ty | takes dict,k; returns a Bool, annotated with element type |
SymSetEmpty | Creates an empty set |
SymSetInsert | Inserts a symbol into a set of symbols |
SymSetContains | Queries if a symbol is in a set |
SymHashEmpty | Create empty hash table of symbols |
SymHashInsert | Insert a symbol into a hash table |
SymHashLookup | Look up a symbol in a hash table (takes default symbol) |
SymHashContains | Queries if a symbol is in a hash |
IntHashEmpty | Create empty hash table of integers |
IntHashInsert | Insert an integer into a hash table |
IntHashLookup | Look up a integer in a hash table (takes default integer) |
PDictAllocP ty ty | annotated with element type to avoid ambiguity |
PDictInsertP ty ty | takes dict, k, v; annotated with element type |
PDictLookupP ty ty | takes dict, k. errors if absent; annotated with element type |
PDictHasKeyP ty ty | takes dict,k; returns a Bool, annotated with element type |
PDictForkP ty ty | takes dict; returns thread safe safe dicts. |
PDictJoinP ty ty | takes 2 dicts; returns a merged dict. |
LLAllocP ty | |
LLIsEmptyP ty | |
LLConsP ty | |
LLHeadP ty | |
LLTailP ty | |
LLFreeP ty | Free the list, and it's data. |
LLFree2P ty | Free list struct, but not it's data. |
LLCopyP ty | Copy the list node. |
VAllocP ty | Allocate a vector |
VFreeP ty | Free a vector, and it's data. |
VFree2P ty | Free the vector struct, but not it's data. |
VLengthP ty | Length of the vector |
VNthP ty | Fetch the nth element |
VSliceP ty | An efficient slice operation |
InplaceVUpdateP ty | Update ith element of the vector |
VConcatP ty | Flatten a vector |
VSortP ty | A sort primop that accepts a function pointer |
InplaceVSortP ty | A sort primop that sorts the array in place |
VMergeP ty | ASSUMPTION: the vectors being merged have the same underlying mutable array. This assumption is checked at the type level with a Rank-2 type variable. But this evidence is erased (by the desugarer) by the time we get to L0. |
Write3dPpmFile FilePath | |
ReadPackedFile (Maybe FilePath) TyCon (Maybe Var) ty | Read (mmap) a binary file containing packed data. This must be annotated with the
type of the file being read. The |
WritePackedFile FilePath ty | Write a packed value to a file. To enable re-reading this packed value with Gibbon, this primitive gets rid of any absolute pointers in the value. First, it inlines (by copying) any regions pointed to by the packed value. Next, random access nodes are eliminated. We could change them to relative pointers (numeric offsets), but for a first version we can simplify things by getting rid of them completely. |
ReadArrayFile (Maybe (FilePath, Int)) ty | Parse a file into a Vector. This is decorated with the element type. If the element type is a struct, like (Int, Int) for example, each line must contain 2 numbers separated by a space. The Int is the number of lines in the file. |
RequestEndOf | Conveys a demand for the "end of" some packed value, which is fulfilled by Cursorize. N.B. the argument must be a VarE that refers to a packed value. |
RequestSizeOf | Like |
Gensym |
Instances
class Expression e => Interp s e where Source #
Pure Gibbon programs, at any stage of compilation, should always be evaluatable to a unique value. The only side effects are timing.
gInterpExp :: RunConfig -> ValEnv e -> DDefs (TyOf e) -> FunDefs e -> e -> InterpM s e (Value e) Source #
class (Show e, Out e, FreeVars e) => Expression e where Source #
A generic interface to expressions found in different phases of the compiler.
The type representation used in this expression.
The location (variable) representation used in this expression.
Instances
(Out l, Out d, Show l, Show d) => Expression (E0Ext l d) Source # | |
(Out l, Out d, Show l, Show d) => Expression (LinearExt l d) Source # | |
(Show l, Show d, Out l, Out d) => Expression (E1Ext l d) Source # | |
(Out l, Out d, Show l, Show d) => Expression (E2Ext l d) Source # | |
(Out l, Out d, Show l, Show d) => Expression (E3Ext l d) Source # | |
(Out l, Show l, Show d, Out d, Expression (e l d)) => Expression (PreExp e l d) Source # | |
Data type definitions.
Monomorphism: In the extreme case we can strip packed datatypes of all type parameters, or we can allow them to retain type params but require that they always be fully instantiated to monomorphic types in the context of our monomorphic programs.
Here we allow individual to be marked with whether or not they should be boxed. We say that a regular, pointer-based datatype has all-boxed fields, whereas a fully serialized datatype has no boxed fields.
Instances
Functor DDef Source # | |
Out a => Out (DDef a) Source # | |
Generic (DDef a) Source # | |
Read a => Read (DDef a) Source # | |
Show a => Show (DDef a) Source # | |
NFData a => NFData (DDef a) Source # | |
Defined in Gibbon.Language.Syntax | |
Eq a => Eq (DDef a) Source # | |
Ord a => Ord (DDef a) Source # | |
Defined in Gibbon.Language.Syntax | |
Pretty ex => Pretty (DDef ex) Source # | |
type Rep (DDef a) Source # | |
Defined in Gibbon.Language.Syntax type Rep (DDef a) = D1 ('MetaData "DDef" "Gibbon.Language.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "DDef" 'PrefixI 'True) (S1 ('MetaSel ('Just "tyName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Var) :*: (S1 ('MetaSel ('Just "tyArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TyVar]) :*: S1 ('MetaSel ('Just "dataCons") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(DataCon, [(IsBoxed, a)])])))) |
class (Out (ArrowTy ty), Show (ArrowTy ty)) => FunctionTy ty where Source #
A type family describing function types.
Instances
FunctionTy Ty0 Source # | |
FunctionTy Ty1 Source # | |
FunctionTy Ty2 Source # | Function types know about locations and traversal effects. |
FunctionTy Ty2 Source # | Function types know about locations and traversal effects. |
A function definiton indexed by a type and expression.
Instances
Instances
Out FunMeta Source # | |
Generic FunMeta Source # | |
Read FunMeta Source # | |
Show FunMeta Source # | |
NFData FunMeta Source # | |
Defined in Gibbon.Language.Syntax | |
Eq FunMeta Source # | |
Ord FunMeta Source # | |
Pretty FunMeta Source # | |
type Rep FunMeta Source # | |
Defined in Gibbon.Language.Syntax type Rep FunMeta = D1 ('MetaData "FunMeta" "Gibbon.Language.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "FunMeta" 'PrefixI 'True) (S1 ('MetaSel ('Just "funRec") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FunRec) :*: (S1 ('MetaSel ('Just "funInline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FunInline) :*: S1 ('MetaSel ('Just "funCanTriggerGC") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))) |
Instances
Instances
Out FunInline Source # | |
Generic FunInline Source # | |
Read FunInline Source # | |
Show FunInline Source # | |
NFData FunInline Source # | |
Defined in Gibbon.Language.Syntax | |
Eq FunInline Source # | |
Ord FunInline Source # | |
Defined in Gibbon.Language.Syntax | |
Pretty FunInline Source # | |
type Rep FunInline Source # | |
Defined in Gibbon.Language.Syntax type Rep FunInline = D1 ('MetaData "FunInline" "Gibbon.Language.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "Inline" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoInline" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Inlineable" 'PrefixI 'False) (U1 :: Type -> Type))) |
Complete programs include datatype definitions:
For evaluating a complete program, main's type will be an Int or a datatype. For running a pass benchmark, main will be Nothing and we will expect a "benchmark" function definition which consumes an appropriate packed AST datatype.
Instances
A common currency for a two part environment consisting of function bindings and regular value bindings.
Instances
(Out a, Out (ArrowTy a)) => Out (Env2 a) Source # | |
Generic (Env2 a) Source # | |
(Read (TyOf a), Read a, Read (ArrowTy a)) => Read (Env2 a) Source # | |
(Show (TyOf a), Show a, Show (ArrowTy a)) => Show (Env2 a) Source # | |
(Eq (TyOf a), Eq a, Eq (ArrowTy a)) => Eq (Env2 a) Source # | |
type Rep (Env2 a) Source # | |
Defined in Gibbon.Language.Syntax type Rep (Env2 a) = D1 ('MetaData "Env2" "Gibbon.Language.Syntax" "gibbon-0.3-inplace" 'False) (C1 ('MetaCons "Env2" 'PrefixI 'True) (S1 ('MetaSel ('Just "vEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TyEnv a)) :*: S1 ('MetaSel ('Just "fEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TyEnv (ArrowTy a))))) |
data PreExp (ext :: Type -> Type -> Type) loc dec Source #
The source language. It has pointer-based sums and products, as well as packed algebraic datatypes.
- It is parameterized by an a potential extension point.
- It is parameterized by
loc
, the type of locations. - It is parameterized by a decoration, d, attached to every binder.
VarE Var | Variable reference |
LitE Int | Numeric literal |
CharE Char | A character literal |
FloatE Double | Floating point literal |
LitSymE Var | A quoted symbol literal |
AppE Var [loc] [PreExp ext loc dec] | Apply a top-level / first-order function. Instantiate its type schema by providing location-variable arguments, if applicable. |
PrimAppE (Prim dec) [PreExp ext loc dec] | Primitive applications don't manipulate locations. |
LetE (Var, [loc], dec, PreExp ext loc dec) (PreExp ext loc dec) | One binding at a time. Allows binding a list of implicit *location* return vales from the RHS, plus a single "real" value. This list of implicit returnsb |
IfE (PreExp ext loc dec) (PreExp ext loc dec) (PreExp ext loc dec) | |
MkProdE [PreExp ext loc dec] | Tuple construction |
ProjE Int (PreExp ext loc dec) | Tuple projection. |
CaseE (PreExp ext loc dec) [(DataCon, [(Var, loc)], PreExp ext loc dec)] | Case on a datatype. Each bound, unpacked variable lives at a fixed, read-only location. |
DataConE loc DataCon [PreExp ext loc dec] | Construct data that may unpack some fields. The location argument, if applicable, is the byte location at which to write the tag for the sum type. |
TimeIt (PreExp ext loc dec) dec Bool | The boolean being true indicates this TimeIt is really (iterate _) This iterate form is used for criterion-style benchmarking. |
WithArenaE Var (PreExp ext loc dec) | |
SpawnE Var [loc] [PreExp ext loc dec] | |
SyncE | |
MapE (Var, dec, PreExp ext loc dec) (PreExp ext loc dec) | |
FoldE | |
Ext (ext loc dec) | Extension point for downstream language extensions. |
Instances
Types include boxed/pointer-based products as well as unpacked algebraic datatypes. This data is parameterized to allow annotation on Packed types later on.
IntTy | |
CharTy | |
FloatTy | |
SymTy | Symbols used in writing compiler passes. |
BoolTy | |
ProdTy [UrTy loc] | An N-ary tuple |
SymDictTy (Maybe Var) (UrTy ()) | A map from SymTy to Ty ^ We allow built-in dictionaries from symbols to a value type. |
PackedTy TyCon loc | No type arguments to TyCons for now. (No polymorphism.) |
VectorTy (UrTy loc) | Vectors are decorated with the types of their elements; which can only include scalars or flat products of scalars. |
PDictTy (UrTy loc) (UrTy loc) | Thread safe dictionaries decorated with key and value type. |
ListTy (UrTy loc) | Linked lists are decorated with the types of their elements; which can only include scalars or flat products of scalars. |
ArenaTy | Collection of allocated, non-packed values |
SymSetTy | Set of symbols |
SymHashTy | Hash table of symbols |
IntHashTy | Hash table of integers |
PtrTy | A machine pointer tvo a complete value in memory. This is decorated with the region it points into, which may affect the memory layout. |
CursorTy | A cursor for reading or writing, which may point to an unkwown type or to a fraction of a complete value. It is a machine pointer that can point to any byte. |
Instances
data PreExpF (ext :: Type -> Type -> Type) (loc :: Type) (dec :: Type) r Source #
VarEF Var | |
LitEF Int | |
CharEF Char | |
FloatEF Double | |
LitSymEF Var | |
AppEF Var [loc] [r] | |
PrimAppEF (Prim dec) [r] | |
LetEF (Var, [loc], dec, r) r | |
IfEF r r r | |
MkProdEF [r] | |
ProjEF Int r | |
CaseEF r [([Char], [(Var, loc)], r)] | |
DataConEF loc [Char] [r] | |
TimeItF r dec Bool | |
WithArenaEF Var r | |
SpawnEF Var [loc] [r] | |
SyncEF | |
MapEF (Var, dec, r) r | |
FoldEF | |
ExtF (ext loc dec) |
Instances
Foldable (PreExpF ext loc dec) Source # | |
Defined in Gibbon.Language.Syntax fold :: Monoid m => PreExpF ext loc dec m -> m Source # foldMap :: Monoid m => (a -> m) -> PreExpF ext loc dec a -> m Source # foldMap' :: Monoid m => (a -> m) -> PreExpF ext loc dec a -> m Source # foldr :: (a -> b -> b) -> b -> PreExpF ext loc dec a -> b Source # foldr' :: (a -> b -> b) -> b -> PreExpF ext loc dec a -> b Source # foldl :: (b -> a -> b) -> b -> PreExpF ext loc dec a -> b Source # foldl' :: (b -> a -> b) -> b -> PreExpF ext loc dec a -> b Source # foldr1 :: (a -> a -> a) -> PreExpF ext loc dec a -> a Source # foldl1 :: (a -> a -> a) -> PreExpF ext loc dec a -> a Source # toList :: PreExpF ext loc dec a -> [a] Source # null :: PreExpF ext loc dec a -> Bool Source # length :: PreExpF ext loc dec a -> Int Source # elem :: Eq a => a -> PreExpF ext loc dec a -> Bool Source # maximum :: Ord a => PreExpF ext loc dec a -> a Source # minimum :: Ord a => PreExpF ext loc dec a -> a Source # | |
Traversable (PreExpF ext loc dec) Source # | |
Defined in Gibbon.Language.Syntax traverse :: Applicative f => (a -> f b) -> PreExpF ext loc dec a -> f (PreExpF ext loc dec b) Source # sequenceA :: Applicative f => PreExpF ext loc dec (f a) -> f (PreExpF ext loc dec a) Source # mapM :: Monad m => (a -> m b) -> PreExpF ext loc dec a -> m (PreExpF ext loc dec b) Source # sequence :: Monad m => PreExpF ext loc dec (m a) -> m (PreExpF ext loc dec a) Source # | |
Functor (PreExpF ext loc dec) Source # | |
data PrimF (ty :: Type) r Source #
Instances
Foldable (PrimF ty) Source # | |
Defined in Gibbon.Language.Syntax fold :: Monoid m => PrimF ty m -> m Source # foldMap :: Monoid m => (a -> m) -> PrimF ty a -> m Source # foldMap' :: Monoid m => (a -> m) -> PrimF ty a -> m Source # foldr :: (a -> b -> b) -> b -> PrimF ty a -> b Source # foldr' :: (a -> b -> b) -> b -> PrimF ty a -> b Source # foldl :: (b -> a -> b) -> b -> PrimF ty a -> b Source # foldl' :: (b -> a -> b) -> b -> PrimF ty a -> b Source # foldr1 :: (a -> a -> a) -> PrimF ty a -> a Source # foldl1 :: (a -> a -> a) -> PrimF ty a -> a Source # toList :: PrimF ty a -> [a] Source # null :: PrimF ty a -> Bool Source # length :: PrimF ty a -> Int Source # elem :: Eq a => a -> PrimF ty a -> Bool Source # maximum :: Ord a => PrimF ty a -> a Source # minimum :: Ord a => PrimF ty a -> a Source # | |
Traversable (PrimF ty) Source # | |
Defined in Gibbon.Language.Syntax | |
Functor (PrimF ty) Source # | |
data UrTyF (loc :: Type) r Source #
IntTyF | |
CharTyF | |
FloatTyF | |
SymTyF | |
BoolTyF | |
ProdTyF [r] | |
SymDictTyF (Maybe Var) (UrTy ()) | |
PackedTyF [Char] loc | |
VectorTyF r | |
PDictTyF r r | |
ListTyF r | |
ArenaTyF | |
SymSetTyF | |
SymHashTyF | |
IntHashTyF | |
PtrTyF | |
CursorTyF |
Instances
Foldable (UrTyF loc) Source # | |
Defined in Gibbon.Language.Syntax fold :: Monoid m => UrTyF loc m -> m Source # foldMap :: Monoid m => (a -> m) -> UrTyF loc a -> m Source # foldMap' :: Monoid m => (a -> m) -> UrTyF loc a -> m Source # foldr :: (a -> b -> b) -> b -> UrTyF loc a -> b Source # foldr' :: (a -> b -> b) -> b -> UrTyF loc a -> b Source # foldl :: (b -> a -> b) -> b -> UrTyF loc a -> b Source # foldl' :: (b -> a -> b) -> b -> UrTyF loc a -> b Source # foldr1 :: (a -> a -> a) -> UrTyF loc a -> a Source # foldl1 :: (a -> a -> a) -> UrTyF loc a -> a Source # toList :: UrTyF loc a -> [a] Source # null :: UrTyF loc a -> Bool Source # length :: UrTyF loc a -> Int Source # elem :: Eq a => a -> UrTyF loc a -> Bool Source # maximum :: Ord a => UrTyF loc a -> a Source # minimum :: Ord a => UrTyF loc a -> a Source # | |
Traversable (UrTyF loc) Source # | |
Defined in Gibbon.Language.Syntax | |
Functor (UrTyF loc) Source # | |
class FreeVars a where Source #
Expression and program types which support a notion of free variables.
gFreeVars :: a -> Set Var Source #
Return a set of free TERM variables. Does not return location variables.
Instances
FreeVars LocExp Source # | |
FreeVars LocExp Source # | |
FreeVars a => FreeVars (TyEnv a) Source # | |
FreeVars (E0Ext l d) Source # | |
FreeVars (LinearExt l d) Source # | |
FreeVars (E1Ext l d) Source # | |
FreeVars (E2Ext l d) Source # | |
FreeVars (E3Ext l d) Source # | |
FreeVars (e l d) => FreeVars (PreExp e l d) Source # | Free data variables. Does not include function variables, which currently occupy a different namespace. Does not include location/region variables. |
class Expression e => Flattenable e where Source #
IRs amenable to flattening
gFlattenExp :: DDefs (TyOf e) -> Env2 (TyOf e) -> e -> PassM e Source #
Process an expression into a fully-flattened expression which typically includes a larger number of temporary, local variable bindings.
gFlattenGatherBinds :: DDefs (TyOf e) -> Env2 (TyOf e) -> e -> PassM ([Binds e], e) Source #
A private method. Gather the bindings from a subexpression, but do not "discharge" them by creating a let expression. They are in order, so later may depend on earlier.
Instances
class Expression e => Simplifiable e where Source #
IRs amenable to simplification/inlineTrivs. Note that there's a
separate SimplifiableExt
for simplifying extensions. Simplifiable
is
the only class which makes such a distinction -- b/c when it's simplifying
an extension point, the type of the environment would still be 'M.Map Var e',
where e is a top-level IR. Right now we don't have a class (and probably
don't want to have one as well) which ties an extension point with an IR.
Keeping these classes separate works out nicely.
gInlineTrivExp :: Map Var e -> e -> e Source #
Instances
HasSimplifiable e l d => Simplifiable (PreExp e l d) Source # | |
Defined in Gibbon.Passes.InlineTriv |
class Expression e => SimplifiableExt e ext where Source #
gInlineTrivExt :: Map Var e -> ext -> ext Source #
Instances
HasSimplifiableExt E1Ext l d => SimplifiableExt (PreExp E1Ext l d) (E1Ext l d) Source # | |
Defined in Gibbon.L1.Syntax | |
HasSimplifiableExt E2Ext l d => SimplifiableExt (PreExp E2Ext l d) (E2Ext l d) Source # | |
Defined in Gibbon.L2.Syntax | |
HasSimplifiableExt E3Ext l d => SimplifiableExt (PreExp E3Ext l d) (E3Ext l d) Source # | |
Defined in Gibbon.L3.Syntax |
class Expression e => Substitutable e where Source #
Generic substitution over expressions.
class Expression e => SubstitutableExt e ext where Source #
Instances
HasSubstitutableExt E0Ext l d => SubstitutableExt (PreExp E0Ext l d) (E0Ext l d) Source # | |
HasSubstitutableExt E0Ext l d => SubstitutableExt (PreExp E0Ext l d) (LinearExt l d) Source # | |
HasSubstitutableExt E1Ext l d => SubstitutableExt (PreExp E1Ext l d) (E1Ext l d) Source # | |
HasSubstitutableExt E2Ext l d => SubstitutableExt (PreExp E2Ext l d) (E2Ext l d) Source # | |
HasSubstitutableExt E3Ext l d => SubstitutableExt (PreExp E3Ext l d) (E3Ext l d) Source # | |
class Renamable e where Source #
Alpha renaming, without worrying about name capture -- assuming that Freshen has run before!
Instances
Renamable TyVar Source # | |
Renamable Var Source # | |
Renamable Ty0 Source # | |
Renamable () Source # | |
Renamable a => Renamable (UrTy a) Source # | |
HasRenamable E0Ext l d => Renamable (E0Ext l d) Source # | |
HasRenamable E0Ext l d => Renamable (LinearExt l d) Source # | |
HasRenamable E1Ext l d => Renamable (E1Ext l d) Source # | |
HasRenamable E2Ext l d => Renamable (E2Ext l d) Source # | |
HasRenamable E3Ext l d => Renamable (E3Ext l d) Source # | |
HasRenamable e l d => Renamable (PreExp e l d) Source # | |
type HasSimplifiable e l d = (Show l, Out l, Show d, Out d, Expression (e l d), SimplifiableExt (PreExp e l d) (e l d)) Source #
type HasSimplifiableExt e l d = (Show l, Out l, Show d, Out d, Simplifiable (PreExp e l d)) Source #
type HasSubstitutable e l d = (Expression (e l d), SubstitutableExt (PreExp e l d) (e l d), Eq d, Show d, Out d, Eq l, Show l, Out l, Eq (e l d)) Source #
type HasSubstitutableExt e l d = (Eq d, Show d, Out d, Eq l, Show l, Out l, Substitutable (PreExp e l d)) Source #
class (Expression e, Expression ext) => InterpExt s e ext where Source #
gInterpExt :: RunConfig -> ValEnv e -> DDefs (TyOf e) -> FunDefs e -> ext -> InterpM s e (Value e) Source #
class Interp s e => InterpProg s e where Source #
gInterpProg :: s -> RunConfig -> Prog e -> IO (s, Value e, ByteString) Source #
gInterpNoLogs :: s -> RunConfig -> Prog e -> String Source #
Interpret while ignoring timing constructs, and dropping the corresponding output to stdout.
gInterpWithStdout :: s -> RunConfig -> Prog e -> IO (String, [String]) Source #
Interpret and produce a "log" of output lines, as well as a final, printed result. The output lines include timing information.
Instances
InterpProg Store Exp2 Source # | |
InterpProg () Exp0 Source # | |
InterpProg () Exp1 Source # | |
It's a first order language with simple values.
VInt Int | |
VChar Char | |
VFloat Double | |
VSym String | |
VBool Bool | |
VDict (Map (Value e) (Value e)) | |
VProd [Value e] | |
VList [Value e] | |
VPacked DataCon [Value e] | |
VLoc | |
VCursor | |
VPtr | Cursor are a pointer into the Store plus an offset into the Buffer. |
VLam [Var] e (ValEnv e) | |
VWrapId Int (Value e) | A wrapper for vectors that wraps the value with an "id".
All Inplace* operations use this "id" to update the value
in |
Instances
Instances
MonadState s (InterpM s e) Source # | |
MonadWriter InterpLog (InterpM s e) Source # | |
MonadFail (InterpM a b) Source # | |
MonadIO (InterpM s e) Source # | |
Applicative (InterpM s e) Source # | |
Defined in Gibbon.Language.Syntax pure :: a -> InterpM s e a Source # (<*>) :: InterpM s e (a -> b) -> InterpM s e a -> InterpM s e b Source # liftA2 :: (a -> b -> c) -> InterpM s e a -> InterpM s e b -> InterpM s e c Source # (*>) :: InterpM s e a -> InterpM s e b -> InterpM s e b Source # (<*) :: InterpM s e a -> InterpM s e b -> InterpM s e a Source # | |
Functor (InterpM s e) Source # | |
Monad (InterpM s e) Source # | |
mapExt :: (e1 l d -> e2 l d) -> PreExp e1 l d -> PreExp e2 l d Source #
Apply a function to the extension points only.
mapLocs :: (e l2 d -> e l2 d) -> PreExp e l2 d -> PreExp e l2 d Source #
Apply a function to the locations only.
visitExp :: forall l1 l2 e1 e2 d1 d2. (l1 -> l2) -> (e1 l1 d1 -> e2 l2 d2) -> (d1 -> d2) -> PreExp e1 l1 d1 -> PreExp e2 l2 d2 Source #
Apply a function to the locations, extensions, and binder-decorations, respectively.
subst :: HasSubstitutable e l d => Var -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #
Substitute an expression in place of a variable.
substE :: HasSubstitutable e l d => PreExp e l d -> PreExp e l d -> PreExp e l d -> PreExp e l d Source #
Expensive subst
that looks for a whole matching sub-EXPRESSION.
If the old expression is a variable, this still avoids going under binder.
projNonFirst :: (Out l, Out d, Out (e l d)) => Int -> PreExp e l d -> PreExp e l d Source #
Project something which had better not be the first thing in a tuple.
mkProj :: Int -> PreExp e l d -> PreExp e l d Source #
Smart constructor that immediately destroys products if it can: Does NOT avoid single-element tuples.
mkLets :: [(Var, [loc], dec, PreExp ext loc dec)] -> PreExp ext loc dec -> PreExp ext loc dec Source #
Make a nested series of lets.
flatLets :: [(Var, [l], d, PreExp e l d)] -> PreExp e l d -> PreExp e l d Source #
Alternative version of L1.mkLets that also flattens
isNestedProdTy :: UrTy a -> Bool Source #
Do values of this type contain nested tuples ?
isPackedTy :: UrTy a -> Bool Source #
Are values of this type Packed ?
isScalarTy :: UrTy a -> Bool Source #
tyToDataCon :: Show a => UrTy a -> DataCon Source #
Get the data constructor type from a type, failing if it's not packed
stripTyLocs :: UrTy a -> UrTy () Source #
isValidListElemTy :: UrTy a -> Bool Source #
Lists of scalars or flat products of scalars are allowed.
assertTriv :: (HasCallStack, Expression e) => e -> a -> a Source #
Ensure that an expression is trivial.
assertTrivs :: (HasCallStack, Expression e) => [e] -> a -> a Source #
List version of assertTriv
.
getConOrdering :: Out a => DDefs a -> TyCon -> [DataCon] Source #
Get the canonical ordering for data constructors, currently based on ordering in the original source code. Takes a TyCon as argument.
getTyOfDataCon :: Out a => DDefs a -> DataCon -> TyCon Source #
Lookup the name of the TyCon that goes with a given DataCon. Must be unique!
lookupDataCon :: Out a => DDefs a -> DataCon -> [a] Source #
Lookup the arguments to a data contstructor.
lkp :: Out a => DDefs a -> DataCon -> (Var, (DataCon, [(IsBoxed, a)])) Source #
Lookup a Datacon. Return (TyCon, (DataCon, [flds]))
lookupDataCon' :: Out a => DDef a -> DataCon -> [a] Source #
Like lookupDataCon
but lookup arguments to a data contstructor for a
specific instance of a datatype.
lookupDataCon' (Maybe Int) Just = [Int]
fromListDD :: [DDef a] -> DDefs a Source #
isVoidDDef :: DDef a -> Bool Source #
Is this an empty type (like 'data Void' in Haskell) ?
fromListFD :: [FunDef ex] -> FunDefs ex Source #
progToEnv :: Prog a -> Env2 (TyOf a) Source #
Abstract some of the differences of top level program types, by having a common way to extract an initial environment. The initial environment has types only for functions.
getFunTy :: Var -> Prog ex -> ArrowTy (TyOf ex) Source #
Look up the input/output type of a top-level function binding.
execAndPrint :: InterpProg s ex => s -> RunConfig -> Prog ex -> IO () Source #
isRedirectionTag :: DataCon -> Bool Source #
redirectionAlt :: Num a => a Source #
isIndirectionTag :: DataCon -> Bool Source #
indirectionAlt :: Num a => a Source #
toAbsRANDataCon :: DataCon -> DataCon Source #
isAbsRANDataCon :: DataCon -> Bool Source #
toRelRANDataCon :: DataCon -> DataCon Source #
isRelRANDataCon :: DataCon -> Bool Source #
fromRANDataCon :: DataCon -> DataCon Source #
mkUnpackerName :: TyCon -> Var Source #
Map a DataCon onto the name of the generated unpack function.
isUnpackerName :: Var -> Bool Source #
mkPrinterName :: TyCon -> Var Source #
Map a DataCon onto the name of the generated print function.
isPrinterName :: Var -> Bool Source #
mkCopyFunName :: TyCon -> Var Source #
isCopyFunName :: Var -> Bool Source #
mkCopySansPtrsFunName :: TyCon -> Var Source #
isCopySansPtrsFunName :: Var -> Bool Source #
mkTravFunName :: TyCon -> Var Source #
isTravFunName :: Var -> Bool Source #
mkRelOffsetsFunName :: DataCon -> Var Source #
isRelOffsetsFunName :: Var -> Bool Source #