futhark-0.16.1: An optimising compiler for a functional, array-oriented language.
Safe HaskellTrustworthy
LanguageHaskell2010

Futhark.Transform.Rename

Description

This module provides facilities for transforming Futhark programs such that names are unique, via the renameProg function.

Synopsis

Renaming programs

renameProg :: (Renameable lore, MonadFreshNames m) => Prog lore -> m (Prog lore) Source #

Rename variables such that each is unique. The semantics of the program are unaffected, under the assumption that the program was correct to begin with. In particular, the renaming may make an invalid program valid.

Renaming parts of a program.

renameExp :: (Renameable lore, MonadFreshNames m) => Exp lore -> m (Exp lore) Source #

Rename bound variables such that each is unique. The semantics of the expression is unaffected, under the assumption that the expression was correct to begin with. Any free variables are left untouched.

renameStm :: (Renameable lore, MonadFreshNames m) => Stm lore -> m (Stm lore) Source #

Rename bound variables such that each is unique. The semantics of the binding is unaffected, under the assumption that the binding was correct to begin with. Any free variables are left untouched, as are the names in the pattern of the binding.

renameBody :: (Renameable lore, MonadFreshNames m) => Body lore -> m (Body lore) Source #

Rename bound variables such that each is unique. The semantics of the body is unaffected, under the assumption that the body was correct to begin with. Any free variables are left untouched.

renameLambda :: (Renameable lore, MonadFreshNames m) => Lambda lore -> m (Lambda lore) Source #

Rename bound variables such that each is unique. The semantics of the lambda is unaffected, under the assumption that the body was correct to begin with. Any free variables are left untouched. Note in particular that the parameters of the lambda are renamed.

renamePattern :: (Rename dec, MonadFreshNames m) => PatternT dec -> m (PatternT dec) Source #

Produce an equivalent pattern but with each pattern element given a new name.

Renaming annotations

data RenameM a Source #

The monad in which renaming is performed.

Instances

Instances details
Monad RenameM Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

(>>=) :: RenameM a -> (a -> RenameM b) -> RenameM b #

(>>) :: RenameM a -> RenameM b -> RenameM b #

return :: a -> RenameM a #

Functor RenameM Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

fmap :: (a -> b) -> RenameM a -> RenameM b #

(<$) :: a -> RenameM b -> RenameM a #

Applicative RenameM Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

pure :: a -> RenameM a #

(<*>) :: RenameM (a -> b) -> RenameM a -> RenameM b #

liftA2 :: (a -> b -> c) -> RenameM a -> RenameM b -> RenameM c #

(*>) :: RenameM a -> RenameM b -> RenameM b #

(<*) :: RenameM a -> RenameM b -> RenameM a #

MonadFreshNames RenameM Source # 
Instance details

Defined in Futhark.Transform.Rename

substituteRename :: Substitute a => a -> RenameM a Source #

Perform a renaming using the Substitute instance. This only works if the argument does not itself perform any name binding, but it can save on boilerplate for simple types.

renamingStms :: Renameable lore => Stms lore -> (Stms lore -> RenameM a) -> RenameM a Source #

Rename some statements, then execute an action with the name substitutions induced by the statements active.

class Rename a where Source #

Members of class Rename can be uniquely renamed.

Methods

rename :: a -> RenameM a Source #

Rename the given value such that it does not contain shadowing, and has incorporated any substitutions present in the RenameM environment.

Instances

Instances details
Rename Bool Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename () Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: () -> RenameM () Source #

Rename VName Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename SubExp Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename Certificates Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename Ident Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename Rank Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename ExtSize Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename Attrs Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename Names Source # 
Instance details

Defined in Futhark.Transform.Rename

Rename AliasDec Source # 
Instance details

Defined in Futhark.IR.Aliases

Rename ExpWisdom Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Lore

Rename VarWisdom Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Lore

Rename MemReturn Source # 
Instance details

Defined in Futhark.IR.Mem

Rename MemBind Source # 
Instance details

Defined in Futhark.IR.Mem

Rename KernelResult Source # 
Instance details

Defined in Futhark.IR.SegOp

Rename SplitOrdering Source # 
Instance details

Defined in Futhark.IR.SegOp

Rename SizeOp Source # 
Instance details

Defined in Futhark.IR.Kernels.Kernel

Rename SegLevel Source # 
Instance details

Defined in Futhark.IR.Kernels.Kernel

Rename a => Rename [a] Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: [a] -> RenameM [a] Source #

Rename a => Rename (Maybe a) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Maybe a -> RenameM (Maybe a) Source #

Rename dec => Rename (PatElemT dec) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: PatElemT dec -> RenameM (PatElemT dec) Source #

Rename d => Rename (DimIndex d) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: DimIndex d -> RenameM (DimIndex d) Source #

Rename dec => Rename (Param dec) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Param dec -> RenameM (Param dec) Source #

Rename d => Rename (ShapeBase d) Source # 
Instance details

Defined in Futhark.Transform.Rename

Renameable lore => Rename (FunDef lore) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: FunDef lore -> RenameM (FunDef lore) Source #

Renameable lore => Rename (Lambda lore) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Lambda lore -> RenameM (Lambda lore) Source #

Renameable lore => Rename (Exp lore) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Exp lore -> RenameM (Exp lore) Source #

Renameable lore => Rename (Body lore) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Body lore -> RenameM (Body lore) Source #

Renameable lore => Rename (Stm lore) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: Stm lore -> RenameM (Stm lore) Source #

Rename dec => Rename (StmAux dec) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: StmAux dec -> RenameM (StmAux dec) Source #

Rename dec => Rename (PatternT dec) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: PatternT dec -> RenameM (PatternT dec) Source #

Substitute num => Rename (IxFun num) Source # 
Instance details

Defined in Futhark.IR.Mem.IxFun

Methods

rename :: IxFun num -> RenameM (IxFun num) Source #

ASTLore lore => Rename (SOAC lore) Source # 
Instance details

Defined in Futhark.IR.SOACS.SOAC

Methods

rename :: SOAC lore -> RenameM (SOAC lore) Source #

Rename inner => Rename (MemOp inner) Source # 
Instance details

Defined in Futhark.IR.Mem

Methods

rename :: MemOp inner -> RenameM (MemOp inner) Source #

ASTLore lore => Rename (KernelBody lore) Source # 
Instance details

Defined in Futhark.IR.SegOp

Methods

rename :: KernelBody lore -> RenameM (KernelBody lore) Source #

(Rename a, Rename b) => Rename (a, b) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: (a, b) -> RenameM (a, b) Source #

Rename shape => Rename (TypeBase shape u) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: TypeBase shape u -> RenameM (TypeBase shape u) Source #

(ASTLore lore, ASTConstraints lvl) => Rename (SegOp lvl lore) Source # 
Instance details

Defined in Futhark.IR.SegOp

Methods

rename :: SegOp lvl lore -> RenameM (SegOp lvl lore) Source #

(ASTLore lore, Rename op) => Rename (HostOp lore op) Source # 
Instance details

Defined in Futhark.IR.Kernels.Kernel

Methods

rename :: HostOp lore op -> RenameM (HostOp lore op) Source #

(Rename a, Rename b, Rename c) => Rename (a, b, c) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: (a, b, c) -> RenameM (a, b, c) Source #

(Substitute d, Substitute ret) => Rename (MemInfo d u ret) Source # 
Instance details

Defined in Futhark.IR.Mem

Methods

rename :: MemInfo d u ret -> RenameM (MemInfo d u ret) Source #

type Renameable lore = (Rename (LetDec lore), Rename (ExpDec lore), Rename (BodyDec lore), Rename (FParamInfo lore), Rename (LParamInfo lore), Rename (RetType lore), Rename (BranchType lore), Rename (Op lore)) Source #

Lores in which all annotations are renameable.