Skip to content

Commit

Permalink
Add support for GHC 9.8.4
Browse files Browse the repository at this point in the history
Fixes #2852
  • Loading branch information
christiaanb committed Dec 31, 2024
1 parent e1235bd commit d2097b3
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 32 deletions.
1 change: 1 addition & 0 deletions changelog/2024-12-31T16_09_30+01_00_ghc_984_support
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ADDED: Support for GHC 9.8.4 [#2852](https://github.com/clash-lang/clash-compiler/issues/2852)
1 change: 1 addition & 0 deletions clash-lib-hedgehog/clash-lib-hedgehog.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ library
primitive >= 0.5.0.1 && < 1.0,
text >= 1.2.2 && < 2.2,
transformers >= 0.5.2.0 && < 0.7,
ghc >= 8.10.0 && < 9.11,

clash-lib == 1.9.0,
2 changes: 1 addition & 1 deletion clash-lib-hedgehog/src/Clash/Hedgehog/Unique.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Clash.Hedgehog.Internal.Bias

genUnique :: forall m. MonadGen m => m Unique
genUnique =
#if __GLASGOW_HASKELL__ >= 910
#if MIN_VERSION_ghc(9,8,4)
Gen.word64
#else
Gen.int
Expand Down
4 changes: 2 additions & 2 deletions clash-lib/src/Clash/Core/FreeVars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import qualified Control.Lens as Lens
import Control.Lens.Fold (Fold)
import Control.Lens.Getter (Contravariant)
import Data.Coerce
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
import qualified GHC.Data.Word64Set as IntSet
#else
import qualified Data.IntSet as IntSet
Expand Down Expand Up @@ -86,7 +86,7 @@ typeFreeVars'
:: (Contravariant f, Applicative f)
=> (forall b . Var b -> Bool)
-- ^ Predicate telling whether a variable is interesting
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
-> IntSet.Word64Set
#else
-> IntSet.IntSet
Expand Down
4 changes: 2 additions & 2 deletions clash-lib/src/Clash/Core/VarEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import Data.Coerce (coerce)
import qualified Data.List as List
import qualified Data.List.Extra as List
import Data.Maybe (fromMaybe)
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
import Data.Word (Word64)
#endif

Expand Down Expand Up @@ -389,7 +389,7 @@ eltsVarSet = UniqMap.elems
-- * InScopeSet

type Seed
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
= Word64
#else
= Int
Expand Down
6 changes: 3 additions & 3 deletions clash-lib/src/Clash/Data/UniqMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import Control.DeepSeq (NFData)
import Data.Binary (Binary (..))
import Data.Bifunctor (first)
import Data.Function (on)
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
import GHC.Data.Word64Map.Strict (Word64Map)
import qualified GHC.Data.Word64Map.Strict as IntMap
#else
Expand All @@ -71,7 +71,7 @@ import Clash.Unique (Unique, Uniquable(getUnique))
-- uniqueable and provide their own key, however a unique can be associated
-- with any value.
newtype UniqMap a
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
= UniqMap { uniqMapToIntMap :: Word64Map a }
#else
= UniqMap { uniqMapToIntMap :: IntMap a }
Expand All @@ -85,7 +85,7 @@ newtype UniqMap a
, Semigroup
, Show
)
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
instance Binary a => Binary (UniqMap a) where
put (UniqMap m) = put (IntMap.size m) <> mapM_ put (IntMap.toAscList m)
get = fmap (UniqMap . IntMap.fromDistinctAscList) get
Expand Down
9 changes: 2 additions & 7 deletions clash-lib/src/Clash/Netlist/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ import Data.Functor (($>))
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
#if MIN_VERSION_ghc(9,10,0)
import qualified GHC.Data.Word64Set as IntSet
#else
import qualified Data.IntSet as IntSet
#endif
import Data.Primitive.ByteArray (ByteArray (..))
import Control.Applicative (Alternative((<|>)))
import Data.List (unzip4, partition)
Expand Down Expand Up @@ -573,10 +568,10 @@ hasUnconstrainedExistential tcm dc =
let -- Free FVs in the LHS and RHS of the constraint that are not the
-- in the set of universal type variables of the constructor.
ty1FEVs = Lens.toListOf (typeFreeVars' ((`notElem` uTVs) . coerce)
IntSet.empty)
mempty)
ty1
ty2FEVs = Lens.toListOf (typeFreeVars' ((`notElem` uTVs) . coerce)
IntSet.empty)
mempty)
ty2

-- Determine whether `eTV` can be generated from one side of a
Expand Down
7 changes: 1 addition & 6 deletions clash-lib/src/Clash/Normalize/Transformations/DEC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ import qualified Data.Foldable as Foldable
import qualified Data.Graph as Graph
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
#if MIN_VERSION_ghc(9,10,0)
import qualified GHC.Data.Word64Set as IntSet
#else
import qualified Data.IntSet as IntSet
#endif
import qualified Data.List as List
import qualified Data.List.Extra as List
import qualified Data.Map.Strict as Map
Expand Down Expand Up @@ -599,7 +594,7 @@ areShared _ _ [] = True
areShared tcm inScope xs@(x:_) = noFV1 && (isProof x || allEqual xs)
where
noFV1 = case x of
Right ty -> getAll (Lens.foldMapOf (typeFreeVars' isLocallyBound IntSet.empty)
Right ty -> getAll (Lens.foldMapOf (typeFreeVars' isLocallyBound mempty)
(const (All False)) ty)
Left tm -> getAll (Lens.foldMapOf (termFreeVars' isLocallyBound)
(const (All False)) tm)
Expand Down
13 changes: 4 additions & 9 deletions clash-lib/src/Clash/Unique.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Clash.Unique
) where

import Data.Word (Word64)
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
import GHC.Word (Word64(W64#))
import GHC.Exts (Word64#)
#else
Expand All @@ -31,7 +31,7 @@ import qualified GHC.Types.Unique as GHC
import qualified Unique as GHC
#endif

#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
type Unique = Word64
type Unique# = Word64#

Expand Down Expand Up @@ -63,16 +63,11 @@ instance Uniquable Unique where
getUnique = id
setUnique = flip const

#if !MIN_VERSION_ghc(9,10,0)
#if !MIN_VERSION_ghc(9,8,4)
instance Uniquable Word64 where
getUnique = fromIntegral
setUnique _ = fromIntegral
#endif

#if MIN_VERSION_ghc(9,10,0)
fromGhcUnique :: GHC.Unique -> Unique
fromGhcUnique = fromIntegral . GHC.getKey
#else
fromGhcUnique :: GHC.Unique -> Unique
fromGhcUnique = id . GHC.getKey
#endif
fromGhcUnique = GHC.getKey
4 changes: 2 additions & 2 deletions clash-lib/src/Clash/Util/Graph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Clash.Util.Graph

import Data.Tuple (swap)
import Data.Foldable (foldlM)
#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
import qualified GHC.Data.Word64Map.Strict as IntMap
import qualified GHC.Data.Word64Set as IntSet
#else
Expand All @@ -33,7 +33,7 @@ import Clash.Driver.Types (BindingMap, Binding (bindingTerm))
import Clash.Normalize.Util (callGraph)
import Clash.Unique (Unique)

#if MIN_VERSION_ghc(9,10,0)
#if MIN_VERSION_ghc(9,8,4)
type IntMap = IntMap.Word64Map
type IntSet = IntSet.Word64Set
#endif
Expand Down

0 comments on commit d2097b3

Please sign in to comment.