futhark-0.9.1: An optimising compiler for a functional, array-oriented language.

Safe HaskellNone
LanguageHaskell2010

Futhark.Transform.Rename

Contents

Description

This module provides facilities for transforming Futhark programs such that names are unique, via the renameProg function. Additionally, the module also supports adding integral "tags" to names (incarnated as the ID type), in order to support more efficient comparisons and renamings. This is done by tagProg. The intent is that you call tagProg once at some early stage, then use renameProg from then on. Functions are also provided for removing the tags again from expressions, patterns and typs.

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.

renameFun :: (Renameable lore, MonadFreshNames m) => FunDef lore -> m (FunDef lore) Source #

Rename bound variables such that each is unique. The semantics of the function 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 attr, MonadFreshNames m) => PatternT attr -> m (PatternT attr) Source #

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

Renaming annotations

type RenameM = StateT VNameSource (Reader RenameEnv) Source #

The monad in which renaming is performed.

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.

bindingForRename :: [VName] -> RenameM a -> RenameM a Source #

Create a bunch of new names and bind them for substitution.

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
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 Names 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 ScalExp Source # 
Instance details

Defined in Futhark.Analysis.ScalExp

Rename KnownBound Source # 
Instance details

Defined in Futhark.Representation.AST.Attributes.Ranges

Rename Names' Source # 
Instance details

Defined in Futhark.Representation.Aliases

Rename ExpWisdom Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Lore

Rename VarWisdom Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Lore

Rename CombineSpace Source # 
Instance details

Defined in Futhark.Representation.Kernels.KernelExp

Rename SplitOrdering Source # 
Instance details

Defined in Futhark.Representation.Kernels.KernelExp

Rename WhichThreads Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Rename KernelResult Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Rename MemReturn Source # 
Instance details

Defined in Futhark.Representation.ExplicitMemory

Rename MemBind Source # 
Instance details

Defined in Futhark.Representation.ExplicitMemory

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 attr => Rename (PatElemT attr) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

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

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

Defined in Futhark.Transform.Rename

Methods

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

Rename attr => Rename (ParamT attr) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

rename :: ParamT attr -> RenameM (ParamT attr) 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 attr => Rename (StmAux attr) Source # 
Instance details

Defined in Futhark.Transform.Rename

Methods

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

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

Defined in Futhark.Transform.Rename

Methods

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

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

Defined in Futhark.Representation.ExplicitMemory.Lmad

Methods

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

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

Defined in Futhark.Representation.ExplicitMemory.IndexFunction

Methods

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

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

Defined in Futhark.Representation.SOACS.SOAC

Methods

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

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

Defined in Futhark.Representation.Kernels.KernelExp

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

Defined in Futhark.Representation.Kernels.KernelExp

Methods

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

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

Defined in Futhark.Representation.Kernels.Kernel

Methods

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

Attributes lore => Rename (Kernel lore) Source # 
Instance details

Defined in Futhark.Representation.Kernels.Kernel

Methods

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

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

Defined in Futhark.Representation.ExplicitMemory

Methods

rename :: MemOp inner -> RenameM (MemOp inner) 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 #

(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.Representation.ExplicitMemory

Methods

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

type Renameable lore = (Rename (LetAttr lore), Rename (ExpAttr lore), Rename (BodyAttr lore), Rename (FParamAttr lore), Rename (LParamAttr lore), Rename (RetType lore), Rename (BranchType lore), Rename (Op lore)) Source #

Lores in which all annotations are renameable.