{-# LANGUAGE FlexibleContexts #-}

module Futhark.Pass.Simplify
  ( simplify,
    simplifySOACS,
    simplifySeq,
    simplifyMC,
    simplifyKernels,
    simplifyKernelsMem,
    simplifySeqMem,
    simplifyMCMem,
  )
where

import qualified Futhark.IR.Kernels.Simplify as Kernels
import qualified Futhark.IR.KernelsMem as KernelsMem
import qualified Futhark.IR.MC as MC
import qualified Futhark.IR.MCMem as MCMem
import qualified Futhark.IR.SOACS.Simplify as SOACS
import qualified Futhark.IR.Seq as Seq
import qualified Futhark.IR.SeqMem as SeqMem
import Futhark.IR.Syntax
import Futhark.Pass

simplify ::
  (Prog lore -> PassM (Prog lore)) ->
  Pass lore lore
simplify :: (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify = String
-> String -> (Prog lore -> PassM (Prog lore)) -> Pass lore lore
forall fromlore tolore.
String
-> String
-> (Prog fromlore -> PassM (Prog tolore))
-> Pass fromlore tolore
Pass String
"simplify" String
"Perform simple enabling optimisations."

simplifySOACS :: Pass SOACS.SOACS SOACS.SOACS
simplifySOACS :: Pass SOACS SOACS
simplifySOACS = (Prog SOACS -> PassM (Prog SOACS)) -> Pass SOACS SOACS
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog SOACS -> PassM (Prog SOACS)
SOACS.simplifySOACS

simplifyKernels :: Pass Kernels.Kernels Kernels.Kernels
simplifyKernels :: Pass Kernels Kernels
simplifyKernels = (Prog Kernels -> PassM (Prog Kernels)) -> Pass Kernels Kernels
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog Kernels -> PassM (Prog Kernels)
Kernels.simplifyKernels

simplifySeq :: Pass Seq.Seq Seq.Seq
simplifySeq :: Pass Seq Seq
simplifySeq = (Prog Seq -> PassM (Prog Seq)) -> Pass Seq Seq
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog Seq -> PassM (Prog Seq)
Seq.simplifyProg

simplifyMC :: Pass MC.MC MC.MC
simplifyMC :: Pass MC MC
simplifyMC = (Prog MC -> PassM (Prog MC)) -> Pass MC MC
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog MC -> PassM (Prog MC)
MC.simplifyProg

simplifyKernelsMem :: Pass KernelsMem.KernelsMem KernelsMem.KernelsMem
simplifyKernelsMem :: Pass KernelsMem KernelsMem
simplifyKernelsMem = (Prog KernelsMem -> PassM (Prog KernelsMem))
-> Pass KernelsMem KernelsMem
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog KernelsMem -> PassM (Prog KernelsMem)
KernelsMem.simplifyProg

simplifySeqMem :: Pass SeqMem.SeqMem SeqMem.SeqMem
simplifySeqMem :: Pass SeqMem SeqMem
simplifySeqMem = (Prog SeqMem -> PassM (Prog SeqMem)) -> Pass SeqMem SeqMem
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog SeqMem -> PassM (Prog SeqMem)
SeqMem.simplifyProg

simplifyMCMem :: Pass MCMem.MCMem MCMem.MCMem
simplifyMCMem :: Pass MCMem MCMem
simplifyMCMem = (Prog MCMem -> PassM (Prog MCMem)) -> Pass MCMem MCMem
forall lore. (Prog lore -> PassM (Prog lore)) -> Pass lore lore
simplify Prog MCMem -> PassM (Prog MCMem)
MCMem.simplifyProg