module Camfort.Analysis.Annotations where
import Data.Data
import Data.Generics.Uniplate.Operations
import Data.Maybe (isJust)
import Data.Map.Lazy hiding (map)
import Debug.Trace
import Language.Haskell.ParseMonad
import Language.Fortran
import Camfort.Analysis.IntermediateReps
import Camfort.Specification.Units.Environment
import qualified Camfort.Specification.Stencils.Syntax as StencilSpec
import qualified Camfort.Specification.Stencils.Grammar as StencilComment
import qualified Language.Fortran.AST as F
import qualified Language.Fortran.Analysis as FA
type Report = String
data ReduceType = Reduce | NoReduce
data AccessPatternType = Regular | RegularAndConstants | Irregular | Undecidable
data LoopType = Functor ReduceType
| Gather ReduceType ReduceType AccessPatternType
| Scatter ReduceType AccessPatternType
type A = Annotation
data Annotation = A { indices :: [Variable],
lives :: ([Access],[Access]),
arrsRead :: Map Variable [[Expr ()]],
arrsWrite :: Map Variable [[Expr ()]],
unitVar :: Int,
number :: Int,
refactored :: Maybe SrcLoc,
successorStmts :: [Int],
newNode :: Bool,
stencilSpec :: Maybe
(Either StencilComment.Specification
(Either StencilSpec.RegionEnv StencilSpec.SpecDecls)),
stencilBlock ::
Maybe (F.Block (FA.Analysis Annotation))
}
deriving (Eq, Show, Typeable, Data)
liveOut = snd . lives
liveIn = fst . lives
pRefactored :: Annotation -> Bool
pRefactored = isJust . refactored
unitAnnotation = A
{ indices = []
, lives = ([], [])
, arrsRead = empty
, arrsWrite = empty
, unitVar = 0
, number = 0
, refactored = Nothing
, successorStmts = []
, newNode = False
, stencilSpec = Nothing
, stencilBlock = Nothing
}