Luite Stegeman pushed to branch wip/ubxsumtag at Glasgow Haskell Compiler / GHC Commits: 0b20ae55 by Luite Stegeman at 2025-08-13T19:06:18+02:00 Support larger unboxed sums - - - - - 1 changed file: - compiler/GHC/Builtin/Uniques.hs Changes: ===================================== compiler/GHC/Builtin/Uniques.hs ===================================== @@ -104,30 +104,30 @@ This layout is chosen to remain compatible with the usual unique allocation for wired-in data constructors described in GHC.Types.Unique TyCon for sum of arity k: - 00000000 kkkkkkkk 11111100 + 00kkkkkk kkkkkkkk 11111111 11111100 TypeRep of TyCon for sum of arity k: - 00000000 kkkkkkkk 11111101 + 00kkkkkk kkkkkkkk 11111111 11111101 DataCon for sum of arity k and alternative n (zero-based): - 00000000 kkkkkkkk nnnnnn00 + 00kkkkkk kkkkkkkk nnnnnnnn nnnnnn00 TypeRep for sum DataCon of arity k and alternative n (zero-based): - 00000000 kkkkkkkk nnnnnn10 + 00kkkkkk kkkkkkkk nnnnnnnn nnnnnn10 -} mkSumTyConUnique :: Arity -> Unique mkSumTyConUnique arity = - assertPpr (arity <= 0x3f) (ppr arity) $ - -- 0x3f since we only have 6 bits to encode the + assertPpr (arity <= 0x3fff) (ppr arity) $ + -- 0x3fff since we only have 14 bits to encode the -- alternative - mkUniqueInt 'z' (arity `shiftL` 8 .|. 0xfc) + mkUniqueInt 'z' (arity `shiftL` 16 .|. 0xfffc) -- | Inverse of 'mkSumTyConUnique' isSumTyConUnique :: Unique -> Maybe Arity isSumTyConUnique u = - case (tag, n .&. 0xfc) of - ('z', 0xfc) -> Just (word64ToInt n `shiftR` 8) + case (tag, n .&. 0xfffc) of + ('z', 0xfffc) -> Just (word64ToInt n `shiftR` 16) _ -> Nothing where (tag, n) = unpkUnique u @@ -137,11 +137,11 @@ mkSumDataConUnique alt arity | alt >= arity = panic ("mkSumDataConUnique: " ++ show alt ++ " >= " ++ show arity) | otherwise - = mkUniqueInt 'z' (arity `shiftL` 8 + alt `shiftL` 2) {- skip the tycon -} + = mkUniqueInt 'z' (arity `shiftL` 16 + alt `shiftL` 2) {- skip the tycon -} getUnboxedSumName :: Int -> Name getUnboxedSumName n - | n .&. 0xfc == 0xfc + | n .&. 0xfffc == 0xfffc = case tag of 0x0 -> tyConName $ sumTyCon arity 0x1 -> getRep $ sumTyCon arity @@ -155,7 +155,7 @@ getUnboxedSumName n | otherwise = pprPanic "getUnboxedSumName" (ppr n) where - arity = n `shiftR` 8 + arity = n `shiftR` 16 alt = (n .&. 0xfc) `shiftR` 2 tag = 0x3 .&. n getRep tycon = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b20ae55ce712687a24984b33d661683... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b20ae55ce712687a24984b33d661683... You're receiving this email because of your account on gitlab.haskell.org.