Added a VECTORISE pragma
[ghc-hetmet.git] / compiler / vectorise / Vectorise / Monad / Global.hs
index 4bd6c77..ae68ffb 100644 (file)
@@ -4,11 +4,14 @@ module Vectorise.Monad.Global (
        setGEnv,
        updGEnv,
        
-       -- * Vars
-       defGlobalVar,
-       
-       -- * Scalars
-       globalScalars,
+  -- * Vars
+  defGlobalVar,
+  
+  -- * Vectorisation declarations
+  lookupVectDecl,
+  
+  -- * Scalars
+  globalScalars, isGlobalScalar,
        
        -- * TyCons
        lookupTyCon,
@@ -27,8 +30,12 @@ module Vectorise.Monad.Global (
        -- * PR Dictionaries
        lookupTyConPR
 ) where
+
 import Vectorise.Monad.Base
 import Vectorise.Env
+
+import CoreSyn
+import Type
 import TyCon
 import DataCon
 import NameEnv
@@ -65,11 +72,20 @@ defGlobalVar v v' = updGEnv $ \env ->
             | otherwise      = env
 
 
+-- Vectorisation declarations -------------------------------------------------
+-- | Check whether a variable has a (non-scalar) vectorisation declaration.
+lookupVectDecl :: Var -> VM (Maybe (Type, CoreExpr))
+lookupVectDecl var = readGEnv $ \env -> lookupVarEnv (global_vect_decls env) var
+
+
 -- Scalars --------------------------------------------------------------------
 -- | Get the set of global scalar variables.
 globalScalars :: VM VarSet
-globalScalars 
-       = readGEnv global_scalars
+globalScalars = readGEnv global_scalars
+
+-- | Check whether a given variable is in the set of global scalar variables.
+isGlobalScalar :: Var -> VM Bool
+isGlobalScalar var = readGEnv $ \env -> elemVarSet var (global_scalars env)
 
 
 -- TyCons ---------------------------------------------------------------------