| Copyright | (C) 2012-2016 University of Twente 2017 Google Inc. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Clash.Core.Term
Description
Term representation in the CoreHW language: System F + LetRec + Case
Synopsis
- data Term
- 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
- idToVar :: Id -> Term
- varToId :: Term -> Id
- type LetBinding = (Id, Term)
- data Pat
- patIds :: Pat -> ([TyVar], [Id])
- patVars :: Pat -> [Var a]
- type Alt = (Pat, Term)
- data TickInfo
- stripTicks :: Term -> Term
- partitionTicks :: [TickInfo] -> ([TickInfo], [TickInfo])
- data NameMod
- data PrimInfo = PrimInfo {}
- 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
Constructors
| 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 |
| Letrec [LetBinding] 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 |
Instances
mkAbstraction :: Term -> [Either Id TyVar] -> Term Source #
Abstract a term over a list of term and type variables
type LetBinding = (Id, Term) Source #
Binding in a LetRec construct
Patterns in the LHS of a case-decomposition
Constructors
| 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 # | |
| Hashable Pat Source # | |
Defined in Clash.Core.Term | |
| 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.2.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))) | |
Constructors
| 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 # | |
| Show TickInfo Source # | |
| Generic TickInfo Source # | |
| Hashable TickInfo Source # | |
Defined in Clash.Core.Term | |
| 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.2.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 #
Partition ticks in source ticks and nameMod ticks
Tag to indicate which instance/register name modifier was used
Constructors
| PrefixName | Clash.Magic.prefixName |
| SuffixName | Clash.Magic.suffixName |
| SuffixNameP | Clash.Magic.suffixNameP |
| SetName | Clash.Magic.setName |
Instances
| Eq NameMod Source # | |
| Show NameMod Source # | |
| Generic NameMod Source # | |
| Hashable NameMod Source # | |
Defined in Clash.Core.Term | |
| 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.2.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))) | |
Instances
| Show PrimInfo Source # | |
| Generic PrimInfo Source # | |
| Hashable PrimInfo Source # | |
Defined in Clash.Core.Term | |
| Binary PrimInfo Source # | |
| NFData PrimInfo Source # | |
Defined in Clash.Core.Term | |
| type Rep PrimInfo Source # | |
Defined in Clash.Core.Term type Rep PrimInfo = D1 (MetaData "PrimInfo" "Clash.Core.Term" "clash-lib-1.2.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)))) | |
Constructors
| 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 |
Instances
| Show WorkInfo Source # | |
| Generic WorkInfo Source # | |
| Hashable WorkInfo Source # | |
Defined in Clash.Core.Term | |
| 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.2.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))) | |
data CoreContext Source #
Context in which a term appears
Constructors
| 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 [Id] | 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 #