Implicitly import NDP stuff when vectorising
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Tue, 7 Aug 2007 04:39:07 +0000 (04:39 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Tue, 7 Aug 2007 04:39:07 +0000 (04:39 +0000)
We add the following declaration to all vectorised modules:

  import qualified <NDP interface module> as :NDP

This allows us to refer to NDP stuff by RdrName later on but does not expose
NDP names to the user's code.

compiler/prelude/PrelNames.lhs
compiler/rename/RnNames.lhs

index 282765b..c09d73d 100644 (file)
@@ -274,6 +274,8 @@ gLA_EXTS    = mkBaseModule FSLIT("GHC.Exts")
 
 nDP_PARRAY      = mkNDPModule FSLIT("Data.Array.Parallel.Lifted.PArray")
 nDP_CLOSURE     = mkNDPModule FSLIT("Data.Array.Parallel.Lifted.Closure")
 
 nDP_PARRAY      = mkNDPModule FSLIT("Data.Array.Parallel.Lifted.PArray")
 nDP_CLOSURE     = mkNDPModule FSLIT("Data.Array.Parallel.Lifted.Closure")
+nDP_INTERFACE_NAME = mkModuleNameFS FSLIT("Data.Array.Parallel.Lifted")
+nDP_BUILTIN     = mkModuleNameFS FSLIT(":NDP")
 
 mAIN           = mkMainModule_ mAIN_NAME
 rOOT_MAIN      = mkMainModule FSLIT(":Main") -- Root module for initialisation 
 
 mAIN           = mkMainModule_ mAIN_NAME
 rOOT_MAIN      = mkMainModule FSLIT(":Main") -- Root module for initialisation 
index 8b09f52..39b43ac 100644 (file)
@@ -65,7 +65,9 @@ rnImports imports
          -- warning for {- SOURCE -} ones that are unnecessary
     = do this_mod <- getModule
          implicit_prelude <- doptM Opt_ImplicitPrelude
          -- warning for {- SOURCE -} ones that are unnecessary
     = do this_mod <- getModule
          implicit_prelude <- doptM Opt_ImplicitPrelude
+         implicit_ndp     <- doptM Opt_Vectorise
          let prel_imports      = mkPrelImports this_mod implicit_prelude imports
          let prel_imports      = mkPrelImports this_mod implicit_prelude imports
+             ndp_imports        = mkNDPImports implicit_ndp
              (source, ordinary) = partition is_source_import imports
              is_source_import (L _ (ImportDecl _ is_boot _ _ _)) = is_boot
 
              (source, ordinary) = partition is_source_import imports
              is_source_import (L _ (ImportDecl _ is_boot _ _ _)) = is_boot
 
@@ -73,7 +75,9 @@ rnImports imports
             when (notNull prel_imports) $ addWarn (implicitPreludeWarn)
           )
 
             when (notNull prel_imports) $ addWarn (implicitPreludeWarn)
           )
 
-         stuff1 <- mapM (rnImportDecl this_mod) (prel_imports ++ ordinary)
+         stuff1 <- mapM (rnImportDecl this_mod) (prel_imports
+                                                 ++ ndp_imports
+                                                 ++ ordinary)
          stuff2 <- mapM (rnImportDecl this_mod) source
          let (decls, rdr_env, imp_avails,hpc_usage) = combine (stuff1 ++ stuff2)
          return (decls, rdr_env, imp_avails,hpc_usage) 
          stuff2 <- mapM (rnImportDecl this_mod) source
          let (decls, rdr_env, imp_avails,hpc_usage) = combine (stuff1 ++ stuff2)
          return (decls, rdr_env, imp_avails,hpc_usage) 
@@ -117,6 +121,20 @@ mkPrelImports this_mod implicit_prelude import_decls
 
       loc = mkGeneralSrcSpan FSLIT("Implicit import declaration")         
 
 
       loc = mkGeneralSrcSpan FSLIT("Implicit import declaration")         
 
+mkNDPImports :: Bool -> [LImportDecl RdrName]
+mkNDPImports False = []
+mkNDPImports True  = [ndpImportDecl]
+  where
+    ndpImportDecl
+      = L loc $
+        ImportDecl (L loc nDP_INTERFACE_NAME)
+             False                -- not a boot interface
+             True                 -- qualified
+             (Just nDP_BUILTIN)   -- "as"
+             Nothing              -- no import list
+
+    loc = mkGeneralSrcSpan FSLIT("Implicit import declaration")
+
 
 rnImportDecl  :: Module
              -> LImportDecl RdrName
 
 rnImportDecl  :: Module
              -> LImportDecl RdrName