summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2010-10-21 14:28:24 +0000
committerIan Lynagh <igloo@earth.li>2010-10-21 14:28:24 +0000
commit14a496fd0b3aa821b69eb02736d5f41086576761 (patch)
treeea4fd69e6840f9070dbc429e5dd6b28f17e52b80
parent00a05a5c09b097e3afa8d21058a3a4d8ed410ad4 (diff)
downloadhaskell-14a496fd0b3aa821b69eb02736d5f41086576761.tar.gz
Switch more uniqFromSupply+splitUniqSupply's to takeUniqFromSupply
-rw-r--r--compiler/coreSyn/MkCore.lhs6
-rw-r--r--compiler/iface/BinIface.hs12
-rw-r--r--compiler/main/TidyPgm.lhs5
-rw-r--r--compiler/nativeGen/NCGMonad.hs4
-rw-r--r--compiler/nativeGen/RegAlloc/Graph/Spill.hs7
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/State.hs4
-rw-r--r--compiler/typecheck/TcRnMonad.lhs6
7 files changed, 20 insertions, 24 deletions
diff --git a/compiler/coreSyn/MkCore.lhs b/compiler/coreSyn/MkCore.lhs
index a497747431..f345b89c88 100644
--- a/compiler/coreSyn/MkCore.lhs
+++ b/compiler/coreSyn/MkCore.lhs
@@ -478,11 +478,11 @@ mkTupleCase uniqs vars body scrut_var scrut
in mk_tuple_case us' (chunkify vars') body'
one_tuple_case chunk_vars (us, vs, body)
- = let (us1, us2) = splitUniqSupply us
- scrut_var = mkSysLocal (fsLit "ds") (uniqFromSupply us1)
+ = let (uniq, us') = takeUniqFromSupply us
+ scrut_var = mkSysLocal (fsLit "ds") uniq
(mkBoxedTupleTy (map idType chunk_vars))
body' = mkSmallTupleCase chunk_vars body scrut_var (Var scrut_var)
- in (us2, scrut_var:vs, body')
+ in (us', scrut_var:vs, body')
\end{code}
\begin{code}
diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs
index 211e8a7cf4..f7a9aa297a 100644
--- a/compiler/iface/BinIface.hs
+++ b/compiler/iface/BinIface.hs
@@ -263,15 +263,13 @@ fromOnDiskName _ nc (pid, mod_name, occ) =
case lookupOrigNameCache cache mod occ of
Just name -> (nc, name)
Nothing ->
- let
- us = nsUniqs nc
- uniq = uniqFromSupply us
+ case takeUniqFromSupply (nsUniqs nc) of
+ (uniq, us) ->
+ let
name = mkExternalName uniq mod occ noSrcSpan
new_cache = extendNameCache cache mod occ name
- in
- case splitUniqSupply us of { (us',_) ->
- ( nc{ nsUniqs = us', nsNames = new_cache }, name )
- }
+ in
+ ( nc{ nsUniqs = us, nsNames = new_cache }, name )
serialiseName :: BinHandle -> Name -> UniqFM (Int,Name) -> IO ()
serialiseName bh name _ = do
diff --git a/compiler/main/TidyPgm.lhs b/compiler/main/TidyPgm.lhs
index a03098322b..8025f20bf1 100644
--- a/compiler/main/TidyPgm.lhs
+++ b/compiler/main/TidyPgm.lhs
@@ -854,10 +854,9 @@ tidyTopName mod nc_var maybe_ref occ_env id
(occ_env', occ') = tidyOccName occ_env new_occ
- mk_new_local nc = (nc { nsUniqs = us2 }, mkInternalName uniq occ' loc)
+ mk_new_local nc = (nc { nsUniqs = us }, mkInternalName uniq occ' loc)
where
- (us1, us2) = splitUniqSupply (nsUniqs nc)
- uniq = uniqFromSupply us1
+ (uniq, us) = takeUniqFromSupply (nsUniqs nc)
mk_new_external nc = allocateGlobalBinder nc mod occ' loc
-- If we want to externalise a currently-local name, check
diff --git a/compiler/nativeGen/NCGMonad.hs b/compiler/nativeGen/NCGMonad.hs
index 409d0c42cf..8b9629b1d8 100644
--- a/compiler/nativeGen/NCGMonad.hs
+++ b/compiler/nativeGen/NCGMonad.hs
@@ -90,8 +90,8 @@ mapAccumLNat f b (x:xs)
getUniqueNat :: NatM Unique
getUniqueNat = NatM $ \ (NatM_State us delta imports pic dflags) ->
- case splitUniqSupply us of
- (us1,us2) -> (uniqFromSupply us1, (NatM_State us2 delta imports pic dflags))
+ case takeUniqFromSupply us of
+ (uniq, us') -> (uniq, (NatM_State us' delta imports pic dflags))
getDynFlagsNat :: NatM DynFlags
diff --git a/compiler/nativeGen/RegAlloc/Graph/Spill.hs b/compiler/nativeGen/RegAlloc/Graph/Spill.hs
index 2ce028f185..7e744e6337 100644
--- a/compiler/nativeGen/RegAlloc/Graph/Spill.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/Spill.hs
@@ -293,10 +293,9 @@ type SpillM a = State SpillS a
newUnique :: SpillM Unique
newUnique
= do us <- gets stateUS
- case splitUniqSupply us of
- (us1, us2)
- -> do let uniq = uniqFromSupply us1
- modify $ \s -> s { stateUS = us2 }
+ case takeUniqFromSupply us of
+ (uniq, us')
+ -> do modify $ \s -> s { stateUS = us' }
return uniq
accSpillSL (r1, s1, l1) (_, s2, l2)
diff --git a/compiler/nativeGen/RegAlloc/Linear/State.hs b/compiler/nativeGen/RegAlloc/Linear/State.hs
index b9f7049844..234701c60e 100644
--- a/compiler/nativeGen/RegAlloc/Linear/State.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/State.hs
@@ -131,8 +131,8 @@ getDeltaR = RegM $ \s -> (# s, ra_delta s #)
getUniqueR :: RegM Unique
getUniqueR = RegM $ \s ->
- case splitUniqSupply (ra_us s) of
- (us1, us2) -> (# s{ra_us = us2}, uniqFromSupply us1 #)
+ case takeUniqFromSupply (ra_us s) of
+ (uniq, us) -> (# s{ra_us = us}, uniq #)
-- | Record that a spill instruction was inserted, for profiling.
diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs
index e3633ec922..646abca0c2 100644
--- a/compiler/typecheck/TcRnMonad.lhs
+++ b/compiler/typecheck/TcRnMonad.lhs
@@ -332,9 +332,9 @@ newUnique
= do { env <- getEnv ;
let { u_var = env_us env } ;
us <- readMutVar u_var ;
- case splitUniqSupply us of { (us1,_) -> do {
- writeMutVar u_var us1 ;
- return $! uniqFromSupply us }}}
+ case takeUniqFromSupply us of { (uniq, us') -> do {
+ writeMutVar u_var us' ;
+ return $! uniq }}}
-- NOTE 1: we strictly split the supply, to avoid the possibility of leaving
-- a chain of unevaluated supplies behind.
-- NOTE 2: we use the uniq in the supply from the MutVar directly, and