+preludeDataCons :: Modules -> [(DataCon, Module, FastString)]
+preludeDataCons (Modules { dph_Prelude_Tuple = dph_Prelude_Tuple })
+ = [mk_tup n dph_Prelude_Tuple (mkFastString $ "tup" ++ show n) | n <- [2..3]]
+ where
+ mk_tup n mod name = (tupleCon Boxed n, mod, name)
+
+
+-- | Mapping of prelude functions to vectorised versions.
+-- Functions like filterP currently have a working but naive version in GHC.PArr
+-- During vectorisation we replace these by calls to filterPA, which are
+-- defined in dph-common Data.Array.Parallel.Lifted.Combinators
+--
+-- As renamer only sees the GHC.PArr functions, if you want to add a new function
+-- to the vectoriser there has to be a definition for it in GHC.PArr, even though
+-- it will never be used at runtime.
+--
+preludeVars :: Modules -> [(Module, FastString, Module, FastString)]
+preludeVars (Modules { dph_Combinators = dph_Combinators
+ , dph_PArray = dph_PArray
+ , dph_Prelude_Int = dph_Prelude_Int
+ , dph_Prelude_Word8 = dph_Prelude_Word8
+ , dph_Prelude_Double = dph_Prelude_Double
+ , dph_Prelude_Bool = dph_Prelude_Bool
+ , dph_Prelude_PArr = dph_Prelude_PArr
+ })
+
+ -- Functions that work on whole PArrays, defined in GHC.PArr
+ = [ mk gHC_PARR (fsLit "mapP") dph_Combinators (fsLit "mapPA")
+ , mk gHC_PARR (fsLit "zipWithP") dph_Combinators (fsLit "zipWithPA")
+ , mk gHC_PARR (fsLit "zipP") dph_Combinators (fsLit "zipPA")
+ , mk gHC_PARR (fsLit "unzipP") dph_Combinators (fsLit "unzipPA")
+ , mk gHC_PARR (fsLit "filterP") dph_Combinators (fsLit "filterPA")
+ , mk gHC_PARR (fsLit "lengthP") dph_Combinators (fsLit "lengthPA")
+ , mk gHC_PARR (fsLit "replicateP") dph_Combinators (fsLit "replicatePA")
+ , mk gHC_PARR (fsLit "!:") dph_Combinators (fsLit "indexPA")
+ , mk gHC_PARR (fsLit "sliceP") dph_Combinators (fsLit "slicePA")
+ , mk gHC_PARR (fsLit "crossMapP") dph_Combinators (fsLit "crossMapPA")
+ , mk gHC_PARR (fsLit "singletonP") dph_Combinators (fsLit "singletonPA")
+ , mk gHC_PARR (fsLit "concatP") dph_Combinators (fsLit "concatPA")
+ , mk gHC_PARR (fsLit "+:+") dph_Combinators (fsLit "appPA")
+ , mk gHC_PARR (fsLit "emptyP") dph_PArray (fsLit "emptyPA")
+
+ -- Map scalar functions to versions using closures.
+ , mk' dph_Prelude_Int "div" "divV"
+ , mk' dph_Prelude_Int "mod" "modV"
+ , mk' dph_Prelude_Int "sqrt" "sqrtV"
+ , mk' dph_Prelude_Int "enumFromToP" "enumFromToPA"
+ -- , mk' dph_Prelude_Int "upToP" "upToPA"
+ ]
+ ++ vars_Ord dph_Prelude_Int
+ ++ vars_Num dph_Prelude_Int
+
+ ++ vars_Ord dph_Prelude_Word8
+ ++ vars_Num dph_Prelude_Word8
+ ++
+ [ mk' dph_Prelude_Word8 "div" "divV"
+ , mk' dph_Prelude_Word8 "mod" "modV"
+ , mk' dph_Prelude_Word8 "fromInt" "fromIntV"
+ , mk' dph_Prelude_Word8 "toInt" "toIntV"
+ ]