X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FUnique.lhs;h=1ef0ca85909fab053fdf9328cc38f8f6343a4396;hp=d8f244e7ea10d4bc5226f797578aa8467a559975;hb=388e3356f71daffa62f1d4157e1e07e4c68f218a;hpb=3d9d59ff6b7f41a90f1325046d3d2bd09b9450b9 diff --git a/compiler/basicTypes/Unique.lhs b/compiler/basicTypes/Unique.lhs index d8f244e..1ef0ca8 100644 --- a/compiler/basicTypes/Unique.lhs +++ b/compiler/basicTypes/Unique.lhs @@ -25,7 +25,6 @@ module Unique ( pprUnique, - mkUnique, -- Used in UniqSupply mkUniqueGrimily, -- Used in UniqSupply only! getKey, getKeyFastInt, -- Used in Var, UniqFM, Name only! @@ -47,6 +46,9 @@ module Unique ( mkPreludeTyConUnique, mkPreludeClassUnique, mkPArrDataConUnique, + mkVarOccUnique, mkDataOccUnique, mkTvOccUnique, mkTcOccUnique, + mkRegSingleUnique, mkRegPairUnique, mkRegClassUnique, mkRegSubUnique, + mkBuiltinUnique, mkPseudoUniqueC, mkPseudoUniqueD, @@ -61,7 +63,6 @@ import FastTypes import FastString import Outputable import StaticFlags -import Util #if defined(__GLASGOW_HASKELL__) --just for implementing a fast [0,61) -> Char function @@ -94,7 +95,6 @@ Now come the functions which construct uniques from their pieces, and vice versa The stuff about unique *supplies* is handled further down this module. \begin{code} -mkUnique :: Char -> Int -> Unique -- Builds a unique from pieces unpkUnique :: Unique -> (Char, Int) -- The reverse mkUniqueGrimily :: Int -> Unique -- A trap-door for UniqSupply @@ -132,11 +132,14 @@ newTagUnique u c = mkUnique c i where (_,i) = unpkUnique u -- and as long as the Char fits in 8 bits, which we assume anyway! +mkUnique :: Char -> Int -> Unique -- Builds a unique from pieces +-- NOT EXPORTED, so that we can see all the Chars that +-- are used in this one module mkUnique c i = MkUnique (tag `bitOrFastInt` bits) where - tag = fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) - bits = iUnbox i `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-} + !tag = fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) + !bits = iUnbox i `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-} unpkUnique (MkUnique u) = let @@ -212,7 +215,7 @@ We do sometimes make strings with @Uniques@ in them: \begin{code} pprUnique :: Unique -> SDoc pprUnique uniq - | debugIsOn || opt_SuppressUniques + | opt_SuppressUniques = empty -- Used exclusively to suppress uniques so you | otherwise -- can compare output easily = case unpkUnique uniq of @@ -267,7 +270,7 @@ iToBase62 n_ #if defined(__GLASGOW_HASKELL__) --then FastInt == Int# chooseChar62 n = C# (indexCharOffAddr# chars62 n) - chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"# + !chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"# #else --Haskell98 arrays are portable chooseChar62 n = (!) chars62 n @@ -341,8 +344,7 @@ isTupleKey u = case unpkUnique u of mkPrimOpIdUnique op = mkUnique '9' op mkPreludeMiscIdUnique i = mkUnique '0' i --- No numbers left anymore, so I pick something different for the character --- tag +-- No numbers left anymore, so I pick something different for the character tag mkPArrDataConUnique a = mkUnique ':' (2*a) -- The "tyvar uniques" print specially nicely: a, b, c, etc. @@ -359,5 +361,18 @@ mkPseudoUniqueC i = mkUnique 'C' i -- used for getUnique on Regs mkPseudoUniqueD i = mkUnique 'D' i -- used in NCG for getUnique on RealRegs mkPseudoUniqueE i = mkUnique 'E' i -- used in NCG spiller to create spill VirtualRegs mkPseudoUniqueH i = mkUnique 'H' i -- used in NCG spiller to create spill VirtualRegs + +mkRegSingleUnique, mkRegPairUnique, mkRegSubUnique, mkRegClassUnique :: Int -> Unique +mkRegSingleUnique = mkUnique 'R' +mkRegSubUnique = mkUnique 'S' +mkRegPairUnique = mkUnique 'P' +mkRegClassUnique = mkUnique 'L' + +mkVarOccUnique, mkDataOccUnique, mkTvOccUnique, mkTcOccUnique :: FastString -> Unique +-- See Note [The Unique of an OccName] in OccName +mkVarOccUnique fs = mkUnique 'i' (iBox (uniqueOfFS fs)) +mkDataOccUnique fs = mkUnique 'd' (iBox (uniqueOfFS fs)) +mkTvOccUnique fs = mkUnique 'v' (iBox (uniqueOfFS fs)) +mkTcOccUnique fs = mkUnique 'c' (iBox (uniqueOfFS fs)) \end{code}