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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Transform.Rename

Contents

- Renaming programs
- Renaming parts of a program.
- Renaming annotations

Description

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

Synopsis

- renameProg :: (Renameable rep, MonadFreshNames m) => Prog rep -> m (Prog rep)
- renameExp :: (Renameable rep, MonadFreshNames m) => Exp rep -> m (Exp rep)
- renameStm :: (Renameable rep, MonadFreshNames m) => Stm rep -> m (Stm rep)
- renameBody :: (Renameable rep, MonadFreshNames m) => Body rep -> m (Body rep)
- renameLambda :: (Renameable rep, MonadFreshNames m) => Lambda rep -> m (Lambda rep)
- renamePat :: (Rename dec, MonadFreshNames m) => Pat dec -> m (Pat dec)
- renameSomething :: (Rename a, MonadFreshNames m) => a -> m a
- renameBound :: [VName] -> RenameM a -> RenameM a
- renameStmsWith :: (MonadFreshNames m, Renameable rep, Rename a) => Stms rep -> a -> m (Stms rep, a)
- data RenameM a
- substituteRename :: Substitute a => a -> RenameM a
- renamingStms :: Renameable rep => Stms rep -> (Stms rep -> RenameM a) -> RenameM a
- class Rename a where
  - rename :: a -> RenameM a
- type Renameable rep = (Rename (LetDec rep), Rename (ExpDec rep), Rename (BodyDec rep), Rename (FParamInfo rep), Rename (LParamInfo rep), Rename (RetType rep), Rename (BranchType rep), Rename (Op rep))

# Renaming programs

renameProg :: (Renameable rep, MonadFreshNames m) => Prog rep -> m (Prog rep) 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 rep, MonadFreshNames m) => Exp rep -> m (Exp rep) 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 rep, MonadFreshNames m) => Stm rep -> m (Stm rep) 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 rep, MonadFreshNames m) => Body rep -> m (Body rep) 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 rep, MonadFreshNames m) => Lambda rep -> m (Lambda rep) 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.

renamePat :: (Rename dec, MonadFreshNames m) => Pat dec -> m (Pat dec) Source #

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

renameSomething :: (Rename a, MonadFreshNames m) => a -> m a Source #

Rename the bound variables in something (does not affect free variables).

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

Rename variables in binding position. The provided VNames are associated with new, fresh names in the renaming environment.

renameStmsWith :: (MonadFreshNames m, Renameable rep, Rename a) => Stms rep -> a -> m (Stms rep, a) Source #

Rename statements, then rename something within the scope of those statements.

# Renaming annotations

data RenameM a Source #

The monad in which renaming is performed.

#### Instances

Instances details

Applicative RenameM Source # |
Instance details Defined in Futhark.Transform.Rename Methods pure :: a -> RenameM a Source # (<*>) :: RenameM (a -> b) -> RenameM a -> RenameM b Source # liftA2 :: (a -> b -> c) -> RenameM a -> RenameM b -> RenameM c Source # (*>) :: RenameM a -> RenameM b -> RenameM b Source # (<*) :: RenameM a -> RenameM b -> RenameM a Source #
Functor RenameM Source # |
Instance details Defined in Futhark.Transform.Rename Methods fmap :: (a -> b) -> RenameM a -> RenameM b Source # (<$) :: a -> RenameM b -> RenameM a Source #
Monad RenameM Source # |
Instance details Defined in Futhark.Transform.Rename Methods (>>=) :: RenameM a -> (a -> RenameM b) -> RenameM b Source # (>>) :: RenameM a -> RenameM b -> RenameM b Source # return :: a -> RenameM a Source #
MonadFreshNames RenameM Source # |
Instance details Defined in Futhark.Transform.Rename Methods getNameSource :: RenameM VNameSource Source # putNameSource :: VNameSource -> RenameM () Source #

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 rep => Stms rep -> (Stms rep -> 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 AliasDec Source # |
Instance details Defined in Futhark.IR.Aliases Methods rename :: AliasDec -> RenameM AliasDec Source #
Rename SegLevel Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: SegLevel -> RenameM SegLevel Source #
Rename SizeOp Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: SizeOp -> RenameM SizeOp Source #
Rename MemBind Source # |
Instance details Defined in Futhark.IR.Mem Methods rename :: MemBind -> RenameM MemBind Source #
Rename MemReturn Source # |
Instance details Defined in Futhark.IR.Mem Methods rename :: MemReturn -> RenameM MemReturn Source #
Rename Names Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Names -> RenameM Names Source #
Rename KernelResult Source # |
Instance details Defined in Futhark.IR.SegOp Methods rename :: KernelResult -> RenameM KernelResult Source #
Rename SubExpRes Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: SubExpRes -> RenameM SubExpRes Source #
Rename Attrs Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Attrs -> RenameM Attrs Source #
Rename Certs Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Certs -> RenameM Certs Source #
Rename ExtSize Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: ExtSize -> RenameM ExtSize Source #
Rename Ident Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Ident -> RenameM Ident Source #
Rename Rank Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Rank -> RenameM Rank Source #
Rename SubExp Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: SubExp -> RenameM SubExp Source #
Rename ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods rename :: ExpWisdom -> RenameM ExpWisdom Source #
Rename VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods rename :: VarWisdom -> RenameM VarWisdom Source #
Rename VName Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: VName -> RenameM VName Source #
Rename PrimType Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: PrimType -> RenameM PrimType Source #
Rename () Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: () -> RenameM () Source #
Rename Bool Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Bool -> RenameM Bool Source #
Substitute num => Rename (LMAD num) Source # |
Instance details Defined in Futhark.IR.Mem.LMAD Methods rename :: LMAD num -> RenameM (LMAD num) Source #
ASTRep rep => Rename (SOAC rep) Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods rename :: SOAC rep -> RenameM (SOAC rep) Source #
ASTRep rep => Rename (KernelBody rep) Source # |
Instance details Defined in Futhark.IR.SegOp Methods rename :: KernelBody rep -> RenameM (KernelBody rep) Source #
Renameable rep => Rename (Body rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Body rep -> RenameM (Body rep) Source #
Renameable rep => Rename (Exp rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Exp rep -> RenameM (Exp rep) Source #
Renameable rep => Rename (FunDef rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: FunDef rep -> RenameM (FunDef rep) Source #
Renameable rep => Rename (Lambda rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Lambda rep -> RenameM (Lambda rep) Source #
Rename dec => Rename (Pat dec) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Pat dec -> RenameM (Pat dec) Source #
Renameable rep => Rename (Stm rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Stm rep -> RenameM (Stm rep) Source #
Rename dec => Rename (StmAux dec) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: StmAux dec -> RenameM (StmAux 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 dec => Rename (PatElem dec) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: PatElem dec -> RenameM (PatElem dec) Source #
Rename d => Rename (ShapeBase d) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: ShapeBase d -> RenameM (ShapeBase d) Source #
Rename a => Rename (Maybe a) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: Maybe a -> RenameM (Maybe a) Source #
Rename a => Rename [a] Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: [a] -> RenameM [a] Source #
(ASTRep rep, Rename (op rep)) => Rename (HostOp op rep) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods rename :: HostOp op rep -> RenameM (HostOp op rep) Source #
(ASTRep rep, Rename (op rep)) => Rename (MCOp op rep) Source # |
Instance details Defined in Futhark.IR.MC.Op Methods rename :: MCOp op rep -> RenameM (MCOp op rep) Source #
Rename (inner rep) => Rename (MemOp inner rep) Source # |
Instance details Defined in Futhark.IR.Mem Methods rename :: MemOp inner rep -> RenameM (MemOp inner rep) Source #
Rename (NoOp rep) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: NoOp rep -> RenameM (NoOp rep) Source #
(ASTRep rep, ASTConstraints lvl) => Rename (SegOp lvl rep) Source # |
Instance details Defined in Futhark.IR.SegOp Methods rename :: SegOp lvl rep -> RenameM (SegOp lvl rep) 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 (a, b) Source # |
Instance details Defined in Futhark.Transform.Rename Methods rename :: (a, b) -> RenameM (a, b) 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 #
(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 #

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

Representations in which all decorations are renameable.