clash-lib-1.8.1: Clash: a functional hardware description language - As a library

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 | Safe-Inferred
Language | Haskell2010

Clash.Core.Term

Description

Term representation in the CoreHW language: System F + LetRec + Case

Synopsis

- data Term where
  - Var !Id
  - Data !DataCon
  - Literal !Literal
  - Prim !PrimInfo
  - Lam !Id Term
  - TyLam !TyVar Term
  - App !Term !Term
  - TyApp !Term !Type
  - Let !(Bind Term) Term
  - Case !Term !Type [Alt]
  - Cast !Term !Type !Type
  - Tick !TickInfo !Term
  - pattern Letrec :: [LetBinding] -> Term -> 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
- varToId :: Term -> Id
- data Bind a
  - = NonRec Id a
  - | Rec [(Id, a)]
- type LetBinding = (Id, Term)
- data Pat
  - = DataPat !DataCon [TyVar] [Id]
  - | LitPat !Literal
  - | DefaultPat
- patIds :: Pat -> ([TyVar], [Id])
- patVars :: Pat -> [Var a]
- type Alt = (Pat, Term)
- data TickInfo
  - = SrcSpan !SrcSpan
  - | NameMod !NameMod !Type
  - | DeDup
  - | NoDeDup
- stripTicks :: Term -> Term
- stripAllTicks :: Term -> Term
- partitionTicks :: [TickInfo] -> ([TickInfo], [TickInfo])
- data NameMod
  - = PrefixName
  - | SuffixName
  - | SuffixNameP
  - | SetName
- data PrimInfo = PrimInfo {
  - primName :: !Text
  - primType :: !Type
  - primWorkInfo :: !WorkInfo
  - primMultiResult :: !IsMultiPrim
  - primUnfolding :: !PrimUnfolding
  }
- data PrimUnfolding
  - = NoUnfolding
  - | Unfolding !Id
- data IsMultiPrim
  - = SingleResult
  - | MultiResult
- data MultiPrimInfo = MultiPrimInfo {
  - mpi_primInfo :: PrimInfo
  - mpi_resultDc :: DataCon
  - mpi_resultTypes :: [Type]
  }
- data WorkInfo
  - = WorkConstant
  - | WorkNever
  - | WorkVariable
  - | WorkAlways
  - | WorkIdentity Int [Int]
- data CoreContext
  - = AppFun
  - | AppArg (Maybe (Text, Int, Int))
  - | TyAppC
  - | LetBinding Id [Id]
  - | LetBody [LetBinding]
  - | LamBody Id
  - | TyLamBody TyVar
  - | CaseAlt Pat
  - | CaseScrut
  - | CastBody
  - | TickC TickInfo
- 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

data Term Source #

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
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

Bundled Patterns

pattern Letrec :: [LetBinding] -> Term -> Term |

#### Instances

Instances details

Generic Term Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep Term :: Type -> Type Source # Methods from :: Term -> Rep Term x Source # to :: Rep Term x -> Term Source #
Show Term Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> Term -> ShowS Source # show :: Term -> String Source # showList :: [Term] -> ShowS Source #
Binary Term Source # |
Instance details Defined in Clash.Core.Term Methods put :: Term -> Put Source # get :: Get Term Source # putList :: [Term] -> Put Source #
HasFreeVars Term Source # |
Instance details Defined in Clash.Core.HasFreeVars Methods freeVarsOf :: Term -> VarSet Source # isClosed :: Term -> Bool Source # elemFreeVars :: Var Term -> Term -> Bool Source # notElemFreeVars :: Var Term -> Term -> Bool Source # subsetFreeVars :: VarSet -> Term -> Bool Source # disjointFreeVars :: VarSet -> Term -> Bool Source #
InferType Term Source # |
Instance details Defined in Clash.Core.HasType Methods inferCoreTypeOf :: TyConMap -> Term -> Type Source #
PrettyPrec Term Source # |
Instance details Defined in Clash.Core.Pretty Methods pprPrec :: Monad m => Rational -> Term -> m ClashDoc Source # pprPrec' :: Monad m => PrettyOptions -> Rational -> Term -> m ClashDoc Source #
TermLiteral Term Source # |
Instance details Defined in Clash.Core.TermLiteral Methods termToData :: Term -> Either Term Term Source # showsTypePrec :: Int -> Proxy Term -> ShowS Source #
ClashPretty Term Source # |
Instance details Defined in Clash.Core.Pretty Methods clashPretty :: Term -> Doc () Source #
NFData Term Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: Term -> () Source #
Eq Term Source # |
Instance details Defined in Clash.Core.Subst Methods (==) :: Term -> Term -> Bool Source # (/=) :: Term -> Term -> Bool Source #
Ord Term Source # |
Instance details Defined in Clash.Core.Subst Methods compare :: Term -> Term -> Ordering Source # (<) :: Term -> Term -> Bool Source # (<=) :: Term -> Term -> Bool Source # (>) :: Term -> Term -> Bool Source # (>=) :: Term -> Term -> Bool Source # max :: Term -> Term -> Term Source # min :: Term -> Term -> Term Source #
(TypeError (('Text "A broken implementation of Hashable Term has been " ':<>: 'Text "removed in Clash 1.4.7. If this is an issue for you, please submit ") ':<>: 'Text "an issue report at https://github.com/clash-lang/clash-compiler/issues.") :: Constraint) => Hashable Term Source # |
Instance details Defined in Clash.Core.Subst Methods hashWithSalt :: Int -> Term -> Int Source # hash :: Term -> Int Source #
PrettyPrec (Id, Term) Source # |
Instance details Defined in Clash.Core.Pretty Methods pprPrec :: Monad m => Rational -> (Id, Term) -> m ClashDoc Source # pprPrec' :: Monad m => PrettyOptions -> Rational -> (Id, Term) -> m ClashDoc Source #
type Rep Term Source # |

Instance details

Defined in Clash.Core.Term

type Rep Term = D1 ('MetaData "Term" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" 'False) (((C1 ('MetaCons "Var" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id)) :+: (C1 ('MetaCons "Data" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DataCon)) :+: C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Literal)))) :+: (C1 ('MetaCons "Prim" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PrimInfo)) :+: (C1 ('MetaCons "Lam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term)) :+: C1 ('MetaCons "TyLam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TyVar) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term))))) :+: ((C1 ('MetaCons "App" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term)) :+: (C1 ('MetaCons "TyApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type)) :+: C1 ('MetaCons "Let" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Bind Term)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Term)))) :+: (C1 ('MetaCons "Case" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Alt]))) :+: (C1 ('MetaCons "Cast" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Type))) :+: C1 ('MetaCons "Tick" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TickInfo) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Term))))))

mkAbstraction :: Term -> [Either Id TyVar] -> Term Source #

Abstract a term over a list of term and type variables

mkTyLams :: Term -> [TyVar] -> Term Source #

Abstract a term over a list of type variables

mkLams :: Term -> [Id] -> Term Source #

Abstract a term over a list of variables

mkApps :: Term -> [Either Term Type] -> Term Source #

Apply a list of types and terms to a term

mkTyApps :: Term -> [Type] -> Term Source #

Apply a list of types to a term

mkTmApps :: Term -> [Term] -> Term Source #

Apply a list of terms to a term

mkTicks :: Term -> [TickInfo] -> Term Source #

type TmName = Name Term Source #

Term reference

varToId :: Term -> Id Source #

Make a term variable out of a variable reference or ticked variable reference

data Bind a Source #

Constructors

NonRec Id a |
Rec [(Id, a)] |

#### Instances

Instances details

Functor Bind Source # |
Instance details Defined in Clash.Core.Term Methods fmap :: (a -> b) -> Bind a -> Bind b Source # (<$) :: a -> Bind b -> Bind a Source #
Generic (Bind a) Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep (Bind a) :: Type -> Type Source # Methods from :: Bind a -> Rep (Bind a) x Source # to :: Rep (Bind a) x -> Bind a Source #
Show a => Show (Bind a) Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> Bind a -> ShowS Source # show :: Bind a -> String Source # showList :: [Bind a] -> ShowS Source #
Binary a => Binary (Bind a) Source # |
Instance details Defined in Clash.Core.Term Methods put :: Bind a -> Put Source # get :: Get (Bind a) Source # putList :: [Bind a] -> Put Source #
NFData a => NFData (Bind a) Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: Bind a -> () Source #
Eq a => Eq (Bind a) Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: Bind a -> Bind a -> Bool Source # (/=) :: Bind a -> Bind a -> Bool Source #
Hashable a => Hashable (Bind a) Source # |
Instance details Defined in Clash.Core.Term Methods hashWithSalt :: Int -> Bind a -> Int Source # hash :: Bind a -> Int Source #
type Rep (Bind a) Source # |

Instance details

Defined in Clash.Core.Term

type Rep (Bind a) = D1 ('MetaData "Bind" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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

data Pat Source #

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

Instances details

Generic Pat Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep Pat :: Type -> Type Source # Methods from :: Pat -> Rep Pat x Source # to :: Rep Pat x -> Pat Source #
Show Pat Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> Pat -> ShowS Source # show :: Pat -> String Source # showList :: [Pat] -> ShowS Source #
Binary Pat Source # |
Instance details Defined in Clash.Core.Term Methods put :: Pat -> Put Source # get :: Get Pat Source # putList :: [Pat] -> Put Source #
PrettyPrec Pat Source # |
Instance details Defined in Clash.Core.Pretty Methods pprPrec :: Monad m => Rational -> Pat -> m ClashDoc Source # pprPrec' :: Monad m => PrettyOptions -> Rational -> Pat -> m ClashDoc Source #
NFData Pat Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: Pat -> () Source #
Eq Pat Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: Pat -> Pat -> Bool Source # (/=) :: Pat -> Pat -> Bool Source #
Ord Pat Source # |
Instance details Defined in Clash.Core.Term Methods compare :: Pat -> Pat -> Ordering Source # (<) :: Pat -> Pat -> Bool Source # (<=) :: Pat -> Pat -> Bool Source # (>) :: Pat -> Pat -> Bool Source # (>=) :: Pat -> Pat -> Bool Source # max :: Pat -> Pat -> Pat Source # min :: Pat -> Pat -> Pat Source #
type Rep Pat Source # |

Instance details

Defined in Clash.Core.Term

type Rep Pat = D1 ('MetaData "Pat" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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)))

patIds :: Pat -> ([TyVar], [Id]) Source #

Get the list of term-binders out of a DataType pattern

patVars :: Pat -> [Var a] Source #

type Alt = (Pat, Term) Source #

data TickInfo Source #

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 `Clash.Magic.[prefixName,suffixName,setName]`
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

Instances details

Generic TickInfo Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep TickInfo :: Type -> Type Source # Methods from :: TickInfo -> Rep TickInfo x Source # to :: Rep TickInfo x -> TickInfo Source #
Show TickInfo Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> TickInfo -> ShowS Source # show :: TickInfo -> String Source # showList :: [TickInfo] -> ShowS Source #
Binary TickInfo Source # |
Instance details Defined in Clash.Core.Term Methods put :: TickInfo -> Put Source # get :: Get TickInfo Source # putList :: [TickInfo] -> Put Source #
PrettyPrec TickInfo Source # |
Instance details Defined in Clash.Core.Pretty Methods pprPrec :: Monad m => Rational -> TickInfo -> m ClashDoc Source # pprPrec' :: Monad m => PrettyOptions -> Rational -> TickInfo -> m ClashDoc Source #
NFData TickInfo Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: TickInfo -> () Source #
Eq TickInfo Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: TickInfo -> TickInfo -> Bool Source # (/=) :: TickInfo -> TickInfo -> Bool Source #
Ord TickInfo Source # |
Instance details Defined in Clash.Core.Term Methods compare :: TickInfo -> TickInfo -> Ordering Source # (<) :: TickInfo -> TickInfo -> Bool Source # (<=) :: TickInfo -> TickInfo -> Bool Source # (>) :: TickInfo -> TickInfo -> Bool Source # (>=) :: TickInfo -> TickInfo -> Bool Source # max :: TickInfo -> TickInfo -> TickInfo Source # min :: TickInfo -> TickInfo -> TickInfo Source #
type Rep TickInfo Source # |

Instance details

Defined in Clash.Core.Term

type Rep TickInfo = D1 ('MetaData "TickInfo" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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.

partitionTicks Source #

Arguments

:: [TickInfo] |
-> ([TickInfo], [TickInfo]) | (source ticks, nameMod ticks)

Partition ticks in source ticks and nameMod ticks

data NameMod Source #

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

Instances details

Generic NameMod Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep NameMod :: Type -> Type Source # Methods from :: NameMod -> Rep NameMod x Source # to :: Rep NameMod x -> NameMod Source #
Show NameMod Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> NameMod -> ShowS Source # show :: NameMod -> String Source # showList :: [NameMod] -> ShowS Source #
Binary NameMod Source # |
Instance details Defined in Clash.Core.Term Methods put :: NameMod -> Put Source # get :: Get NameMod Source # putList :: [NameMod] -> Put Source #
NFData NameMod Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: NameMod -> () Source #
Eq NameMod Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: NameMod -> NameMod -> Bool Source # (/=) :: NameMod -> NameMod -> Bool Source #
Ord NameMod Source # |
Instance details Defined in Clash.Core.Term Methods compare :: NameMod -> NameMod -> Ordering Source # (<) :: NameMod -> NameMod -> Bool Source # (<=) :: NameMod -> NameMod -> Bool Source # (>) :: NameMod -> NameMod -> Bool Source # (>=) :: NameMod -> NameMod -> Bool Source # max :: NameMod -> NameMod -> NameMod Source # min :: NameMod -> NameMod -> NameMod Source #
Hashable NameMod Source # |
Instance details Defined in Clash.Core.Term Methods hashWithSalt :: Int -> NameMod -> Int Source # hash :: NameMod -> Int Source #
type Rep NameMod Source # |

Instance details

Defined in Clash.Core.Term

type Rep NameMod = D1 ('MetaData "NameMod" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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)))

data PrimInfo Source #

Constructors

PrimInfo |

Fields

- primName :: !Text
- primType :: !Type
- primWorkInfo :: !WorkInfo
- primMultiResult :: !IsMultiPrim

  Primitive with multiple return values. Useful for primitives that cannot return their results as a single product type, due to limitation of synthesis tooling. It will be applied to its normal arguments, followed by the variables it should assign its results to.

  See: `setupMultiResultPrim`

- primUnfolding :: !PrimUnfolding

#### Instances

Instances details

Generic PrimInfo Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep PrimInfo :: Type -> Type Source # Methods from :: PrimInfo -> Rep PrimInfo x Source # to :: Rep PrimInfo x -> PrimInfo Source #
Show PrimInfo Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> PrimInfo -> ShowS Source # show :: PrimInfo -> String Source # showList :: [PrimInfo] -> ShowS Source #
Binary PrimInfo Source # |
Instance details Defined in Clash.Core.Term Methods put :: PrimInfo -> Put Source # get :: Get PrimInfo Source # putList :: [PrimInfo] -> Put Source #
HasType PrimInfo Source # |
Instance details Defined in Clash.Core.HasType Methods coreTypeOf :: PrimInfo -> Type Source #
NFData PrimInfo Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: PrimInfo -> () Source #
type Rep PrimInfo Source # |

Instance details

Defined in Clash.Core.Term

type Rep PrimInfo = D1 ('MetaData "PrimInfo" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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 #

Constructors

NoUnfolding |
Unfolding !Id |

#### Instances

Instances details

Generic PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep PrimUnfolding :: Type -> Type Source # Methods from :: PrimUnfolding -> Rep PrimUnfolding x Source # to :: Rep PrimUnfolding x -> PrimUnfolding Source #
Show PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> PrimUnfolding -> ShowS Source # show :: PrimUnfolding -> String Source # showList :: [PrimUnfolding] -> ShowS Source #
Binary PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Methods put :: PrimUnfolding -> Put Source # get :: Get PrimUnfolding Source # putList :: [PrimUnfolding] -> Put Source #
NFData PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: PrimUnfolding -> () Source #
Eq PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: PrimUnfolding -> PrimUnfolding -> Bool Source # (/=) :: PrimUnfolding -> PrimUnfolding -> Bool Source #
Hashable PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term Methods hashWithSalt :: Int -> PrimUnfolding -> Int Source # hash :: PrimUnfolding -> Int Source #
type Rep PrimUnfolding Source # |
Instance details Defined in Clash.Core.Term type Rep PrimUnfolding = D1 ('MetaData "PrimUnfolding" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" 'False) (C1 ('MetaCons "NoUnfolding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Unfolding" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Id)))

data IsMultiPrim Source #

Constructors

SingleResult |
MultiResult |

#### Instances

Instances details

Generic IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep IsMultiPrim :: Type -> Type Source # Methods from :: IsMultiPrim -> Rep IsMultiPrim x Source # to :: Rep IsMultiPrim x -> IsMultiPrim Source #
Show IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> IsMultiPrim -> ShowS Source # show :: IsMultiPrim -> String Source # showList :: [IsMultiPrim] -> ShowS Source #
Binary IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Methods put :: IsMultiPrim -> Put Source # get :: Get IsMultiPrim Source # putList :: [IsMultiPrim] -> Put Source #
NFData IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: IsMultiPrim -> () Source #
Eq IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: IsMultiPrim -> IsMultiPrim -> Bool Source # (/=) :: IsMultiPrim -> IsMultiPrim -> Bool Source #
Hashable IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term Methods hashWithSalt :: Int -> IsMultiPrim -> Int Source # hash :: IsMultiPrim -> Int Source #
type Rep IsMultiPrim Source # |
Instance details Defined in Clash.Core.Term type Rep IsMultiPrim = D1 ('MetaData "IsMultiPrim" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" 'False) (C1 ('MetaCons "SingleResult" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MultiResult" 'PrefixI 'False) (U1 :: Type -> Type))

data MultiPrimInfo Source #

Constructors

MultiPrimInfo |

Fields

- mpi_primInfo :: PrimInfo
- mpi_resultDc :: DataCon
- mpi_resultTypes :: [Type]

data WorkInfo Source #

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
WorkIdentity Int [Int] | A more restrictive version of `WorkNever`, where the value is the argument at the given position if all arguments for the given list of positions are also `WorkIdentity`

#### Instances

Instances details

Generic WorkInfo Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep WorkInfo :: Type -> Type Source # Methods from :: WorkInfo -> Rep WorkInfo x Source # to :: Rep WorkInfo x -> WorkInfo Source #
Show WorkInfo Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> WorkInfo -> ShowS Source # show :: WorkInfo -> String Source # showList :: [WorkInfo] -> ShowS Source #
Binary WorkInfo Source # |
Instance details Defined in Clash.Core.Term Methods put :: WorkInfo -> Put Source # get :: Get WorkInfo Source # putList :: [WorkInfo] -> Put Source #
NFData WorkInfo Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: WorkInfo -> () Source #
Eq WorkInfo Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: WorkInfo -> WorkInfo -> Bool Source # (/=) :: WorkInfo -> WorkInfo -> Bool Source #
Hashable WorkInfo Source # |
Instance details Defined in Clash.Core.Term Methods hashWithSalt :: Int -> WorkInfo -> Int Source # hash :: WorkInfo -> Int Source #
type Rep WorkInfo Source # |

Instance details

Defined in Clash.Core.Term

type Rep WorkInfo = D1 ('MetaData "WorkInfo" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" '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

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 [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

Instances details

Generic CoreContext Source # |
Instance details Defined in Clash.Core.Term Associated Types type Rep CoreContext :: Type -> Type Source # Methods from :: CoreContext -> Rep CoreContext x Source # to :: Rep CoreContext x -> CoreContext Source #
Show CoreContext Source # |
Instance details Defined in Clash.Core.Term Methods showsPrec :: Int -> CoreContext -> ShowS Source # show :: CoreContext -> String Source # showList :: [CoreContext] -> ShowS Source #
Binary CoreContext Source # |
Instance details Defined in Clash.Core.Term Methods put :: CoreContext -> Put Source # get :: Get CoreContext Source # putList :: [CoreContext] -> Put Source #
NFData CoreContext Source # |
Instance details Defined in Clash.Core.Term Methods rnf :: CoreContext -> () Source #
Eq CoreContext Source # |
Instance details Defined in Clash.Core.Term Methods (==) :: CoreContext -> CoreContext -> Bool Source # (/=) :: CoreContext -> CoreContext -> Bool Source #
type Rep CoreContext Source # |

Instance details

Defined in Clash.Core.Term

type Rep CoreContext = D1 ('MetaData "CoreContext" "Clash.Core.Term" "clash-lib-1.8.1-2YrsOtauO5B4MB9KvGiYOL" 'False) (((C1 ('MetaCons "AppFun" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AppArg" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Text, Int, Int))))) :+: (C1 ('MetaCons "TyAppC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LetBinding" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Id])) :+: C1 ('MetaCons "LetBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LetBinding]))))) :+: ((C1 ('MetaCons "LamBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Id)) :+: (C1 ('MetaCons "TyLamBody" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TyVar)) :+: C1 ('MetaCons "CaseAlt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pat)))) :+: (C1 ('MetaCons "CaseScrut" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CastBody" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TickC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TickInfo))))))

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

collectArgsTicks :: Term -> (Term, [Either Term Type], [TickInfo]) Source #

collectTicks :: Term -> (Term, [TickInfo]) Source #

collectTermIds :: Term -> [Id] Source #

collectBndrs :: Term -> ([Either Id TyVar], Term) Source #

Split a (Type)Abstraction in the bound variables and the abstracted term

primArg Source #

Arguments

:: Term | Function application
-> Maybe (Text, Int, Int) | If `Term` was a primitive: (name of primitive, #type args, #term args)

Given a function application, find the primitive it's applied. Yields Nothing if given term is not an application or if it is not a primitive.