Copyright | (C) 2012-2016 University of Twente 2017 Google Inc. 2021 QBayLogic B.V. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
Term representation in the CoreHW language: System F + LetRec + Case
Synopsis
- data Term where
- mkAbstraction :: Term -> [Either Id TyVar] -> Term
- mkTyLams :: Term -> [TyVar] -> Term
- mkLams :: Term -> [Id] -> Term
- mkApps :: Term -> [Either Term Type] -> Term
- mkTyApps :: Term -> [Type] -> Term
- mkTmApps :: Term -> [Term] -> Term
- mkTicks :: Term -> [TickInfo] -> Term
- type TmName = Name Term
- varToId :: Term -> Id
- data Bind a
- type LetBinding = (Id, Term)
- data Pat
- patIds :: Pat -> ([TyVar], [Id])
- patVars :: Pat -> [Var a]
- type Alt = (Pat, Term)
- data TickInfo
- stripTicks :: Term -> Term
- stripAllTicks :: Term -> Term
- partitionTicks :: [TickInfo] -> ([TickInfo], [TickInfo])
- data NameMod
- data PrimInfo = PrimInfo {
- primName :: !Text
- primType :: !Type
- primWorkInfo :: !WorkInfo
- primMultiResult :: !IsMultiPrim
- primUnfolding :: !PrimUnfolding
- data PrimUnfolding
- = NoUnfolding
- | Unfolding !Id
- data IsMultiPrim
- data MultiPrimInfo = MultiPrimInfo {}
- data WorkInfo
- data CoreContext
- type Context = [CoreContext]
- isLambdaBodyCtx :: CoreContext -> Bool
- isTickCtx :: CoreContext -> Bool
- walkTerm :: forall a. (Term -> Maybe a) -> Term -> [a]
- collectArgs :: Term -> (Term, [Either Term Type])
- collectArgsTicks :: Term -> (Term, [Either Term Type], [TickInfo])
- collectTicks :: Term -> (Term, [TickInfo])
- collectTermIds :: Term -> [Id]
- collectBndrs :: Term -> ([Either Id TyVar], Term)
- primArg :: Term -> Maybe (Text, Int, Int)
Documentation
Term representation in the CoreHW language: System F + LetRec + Case
Var !Id | Variable reference |
Data !DataCon | Datatype constructor |
Literal !Literal | Literal |
Prim !PrimInfo | Primitive |
Lam !Id Term | Term-abstraction |
TyLam !TyVar Term | Type-abstraction |
App !Term !Term | Application |
TyApp !Term !Type | Type-application |
Let !(Bind Term) Term | Recursive let-binding |
Case !Term !Type [Alt] | Case-expression: subject, type of alternatives, list of alternatives |
Cast !Term !Type !Type | Cast a term from one type to another |
Tick !TickInfo !Term | Annotated term |
pattern Letrec :: [LetBinding] -> Term -> Term |
Instances
mkAbstraction :: Term -> [Either Id TyVar] -> Term Source #
Abstract a term over a list of term and type variables
varToId :: Term -> Id Source #
Make a term variable out of a variable reference or ticked variable reference
Instances
Functor Bind Source # | |
Eq a => Eq (Bind a) Source # | |
Show a => Show (Bind a) Source # | |
Generic (Bind a) Source # | |
Hashable a => Hashable (Bind a) Source # | |
Binary a => Binary (Bind a) Source # | |
NFData a => NFData (Bind a) Source # | |
Defined in Clash.Core.Term | |
type Rep (Bind a) Source # | |
Defined in Clash.Core.Term type Rep (Bind a) = D1 ('MetaData "Bind" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (C1 ('MetaCons "NonRec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Rec" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Id, a)]))) |
type LetBinding = (Id, Term) Source #
Binding in a LetRec construct
Patterns in the LHS of a case-decomposition
DataPat !DataCon [TyVar] [Id] | Datatype pattern, '[TyVar]' bind existentially-quantified type-variables of a DataCon |
LitPat !Literal | Literal pattern |
DefaultPat | Default pattern |
Instances
Eq Pat Source # | |
Ord Pat Source # | |
Show Pat Source # | |
Generic Pat Source # | |
Binary Pat Source # | |
NFData Pat Source # | |
Defined in Clash.Core.Term | |
PrettyPrec Pat Source # | |
type Rep Pat Source # | |
Defined in Clash.Core.Term type Rep Pat = D1 ('MetaData "Pat" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (C1 ('MetaCons "DataPat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataCon) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TyVar]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Id]))) :+: (C1 ('MetaCons "LitPat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Literal)) :+: C1 ('MetaCons "DefaultPat" 'PrefixI 'False) (U1 :: Type -> Type))) |
SrcSpan !SrcSpan | Source tick, will get added by GHC by running clash with `-g` |
NameMod !NameMod !Type | Modifier for naming module instantiations and registers, are added by
the user by using the functions |
DeDup | Deduplicate, i.e. try to share expressions between multiple branches. |
NoDeDup | Do not deduplicate, i.e. keep, an expression inside a case-alternative; do not try to share expressions between multiple branches. |
Instances
Eq TickInfo Source # | |
Ord TickInfo Source # | |
Defined in Clash.Core.Term | |
Show TickInfo Source # | |
Generic TickInfo Source # | |
Binary TickInfo Source # | |
NFData TickInfo Source # | |
Defined in Clash.Core.Term | |
PrettyPrec TickInfo Source # | |
type Rep TickInfo Source # | |
Defined in Clash.Core.Term type Rep TickInfo = D1 ('MetaData "TickInfo" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) ((C1 ('MetaCons "SrcSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SrcSpan)) :+: C1 ('MetaCons "NameMod" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NameMod) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type))) :+: (C1 ('MetaCons "DeDup" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoDeDup" 'PrefixI 'False) (U1 :: Type -> Type))) |
stripTicks :: Term -> Term Source #
stripAllTicks :: Term -> Term Source #
Like stripTicks
but removes all ticks from subexpressions.
Partition ticks in source ticks and nameMod ticks
Tag to indicate which instance/register name modifier was used
PrefixName | Clash.Magic.prefixName |
SuffixName | Clash.Magic.suffixName |
SuffixNameP | Clash.Magic.suffixNameP |
SetName | Clash.Magic.setName |
Instances
Eq NameMod Source # | |
Ord NameMod Source # | |
Show NameMod Source # | |
Generic NameMod Source # | |
Hashable NameMod Source # | |
Binary NameMod Source # | |
NFData NameMod Source # | |
Defined in Clash.Core.Term | |
type Rep NameMod Source # | |
Defined in Clash.Core.Term type Rep NameMod = D1 ('MetaData "NameMod" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) ((C1 ('MetaCons "PrefixName" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SuffixName" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SuffixNameP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SetName" 'PrefixI 'False) (U1 :: Type -> Type))) |
PrimInfo | |
|
Instances
Show PrimInfo Source # | |
Generic PrimInfo Source # | |
Binary PrimInfo Source # | |
NFData PrimInfo Source # | |
Defined in Clash.Core.Term | |
HasType PrimInfo Source # | |
Defined in Clash.Core.HasType coreTypeOf :: PrimInfo -> Type Source # | |
type Rep PrimInfo Source # | |
Defined in Clash.Core.Term type Rep PrimInfo = D1 ('MetaData "PrimInfo" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) (C1 ('MetaCons "PrimInfo" 'PrefixI 'True) ((S1 ('MetaSel ('Just "primName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "primType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type)) :*: (S1 ('MetaSel ('Just "primWorkInfo") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 WorkInfo) :*: (S1 ('MetaSel ('Just "primMultiResult") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 IsMultiPrim) :*: S1 ('MetaSel ('Just "primUnfolding") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrimUnfolding))))) |
data PrimUnfolding Source #
Instances
data IsMultiPrim Source #
Instances
Eq IsMultiPrim Source # | |
Defined in Clash.Core.Term (==) :: IsMultiPrim -> IsMultiPrim -> Bool Source # (/=) :: IsMultiPrim -> IsMultiPrim -> Bool Source # | |
Show IsMultiPrim Source # | |
Defined in Clash.Core.Term | |
Generic IsMultiPrim Source # | |
Defined in Clash.Core.Term from :: IsMultiPrim -> Rep IsMultiPrim x Source # to :: Rep IsMultiPrim x -> IsMultiPrim Source # | |
Hashable IsMultiPrim Source # | |
Defined in Clash.Core.Term hashWithSalt :: Int -> IsMultiPrim -> Int Source # hash :: IsMultiPrim -> Int Source # | |
Binary IsMultiPrim Source # | |
Defined in Clash.Core.Term put :: IsMultiPrim -> Put Source # get :: Get IsMultiPrim Source # putList :: [IsMultiPrim] -> Put Source # | |
NFData IsMultiPrim Source # | |
Defined in Clash.Core.Term rnf :: IsMultiPrim -> () Source # | |
type Rep IsMultiPrim Source # | |
data MultiPrimInfo Source #
WorkConstant | Ignores its arguments, and outputs a constant |
WorkNever | Never adds any work |
WorkVariable | Does work when the arguments are variable |
WorkAlways | Performs work regardless of whether the variables are constant or variable; these are things like clock or reset generators |
WorkIdentity Int [Int] | A more restrictive version of |
Instances
Eq WorkInfo Source # | |
Show WorkInfo Source # | |
Generic WorkInfo Source # | |
Hashable WorkInfo Source # | |
Binary WorkInfo Source # | |
NFData WorkInfo Source # | |
Defined in Clash.Core.Term | |
type Rep WorkInfo Source # | |
Defined in Clash.Core.Term type Rep WorkInfo = D1 ('MetaData "WorkInfo" "Clash.Core.Term" "clash-lib-1.8.1-inplace" 'False) ((C1 ('MetaCons "WorkConstant" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WorkNever" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "WorkVariable" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WorkAlways" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WorkIdentity" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int]))))) |
data CoreContext Source #
Context in which a term appears
AppFun | Function position of an application |
AppArg (Maybe (Text, Int, Int)) | Argument position of an application. If this is an argument applied to a primitive, a tuple is defined containing (name of the primitive, #type args, #term args) |
TyAppC | Function position of a type application |
LetBinding Id [Id] | RHS of a Let-binder with the sibling LHS' |
LetBody [LetBinding] | Body of a Let-binding with the bound LHS' |
LamBody Id | Body of a lambda-term with the abstracted variable |
TyLamBody TyVar | Body of a TyLambda-term with the abstracted type-variable |
CaseAlt Pat | RHS of a case-alternative with the bound pattern on the LHS |
CaseScrut | Subject of a case-decomposition |
CastBody | Body of a Cast |
TickC TickInfo | Body of a Tick |
Instances
type Context = [CoreContext] Source #
A list of CoreContext
describes the complete navigation path from the
top-level to a specific sub-expression.
isLambdaBodyCtx :: CoreContext -> Bool Source #
Is the Context a Lambda/Term-abstraction context?
isTickCtx :: CoreContext -> Bool Source #
Is the Context a Tick context?
walkTerm :: forall a. (Term -> Maybe a) -> Term -> [a] Source #
Visit all terms in a term, testing it with a predicate, and returning a list of predicate yields.
collectArgs :: Term -> (Term, [Either Term Type]) Source #
Split a (Type)Application in the applied term and it arguments
collectTermIds :: Term -> [Id] Source #