Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
86a646a6
by Andreas Klebinger at 2026-04-22T13:00:05-04:00
10 changed files:
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Types/Unique/DSet.hs
- compiler/GHC/Utils/Ppr/Colour.hs
Changes:
| ... | ... | @@ -2,8 +2,6 @@ |
| 2 | 2 | {-# LANGUAGE MultiWayIf #-}
|
| 3 | 3 | {-# LANGUAGE ParallelListComp #-}
|
| 4 | 4 | {-# LANGUAGE NondecreasingIndentation #-}
|
| 5 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 6 | -{-# LANGUAGE DerivingVia #-}
|
|
| 7 | 5 | |
| 8 | 6 | -----------------------------------------------------------------------------
|
| 9 | 7 | --
|
| ... | ... | @@ -74,8 +72,6 @@ import GHC.Cmm.CLabel |
| 74 | 72 | import GHC.Types.Tickish ( GenTickish(..) )
|
| 75 | 73 | import GHC.Types.SrcLoc ( srcSpanFile, srcSpanStartLine, srcSpanStartCol )
|
| 76 | 74 | |
| 77 | -import GHC.Generics (Generic, Generically(..))
|
|
| 78 | - |
|
| 79 | 75 | -- The rest:
|
| 80 | 76 | import GHC.Data.Maybe ( expectJust )
|
| 81 | 77 | import GHC.Types.ForeignCall ( CCallConv(..) )
|
| ... | ... | @@ -440,7 +436,7 @@ getRegisterReg _ (CmmLocal lreg) = getLocalRegReg lreg |
| 440 | 436 | |
| 441 | 437 | getRegisterReg platform (CmmGlobal mid)
|
| 442 | 438 | = case globalRegMaybe platform $ globalRegUse_reg mid of
|
| 443 | - Just reg -> RegReal reg
|
|
| 439 | + Just reg -> RegReal $ reg
|
|
| 444 | 440 | Nothing -> pprPanic "getRegisterReg-memory" (ppr $ CmmGlobal mid)
|
| 445 | 441 | -- By this stage, the only MagicIds remaining should be the
|
| 446 | 442 | -- ones which map to a real machine register on this
|
| ... | ... | @@ -4936,8 +4932,11 @@ data LoadArgs |
| 4936 | 4932 | -- | The code to assign arguments to registers used for argument passing.
|
| 4937 | 4933 | , assignArgsCode :: InstrBlock
|
| 4938 | 4934 | }
|
| 4939 | - deriving (Generic)
|
|
| 4940 | - deriving (Semigroup, Monoid) via Generically LoadArgs
|
|
| 4935 | +instance Semigroup LoadArgs where
|
|
| 4936 | + LoadArgs a1 d1 r1 j1 <> LoadArgs a2 d2 r2 j2
|
|
| 4937 | + = LoadArgs (a1 ++ a2) (d1 ++ d2) (r1 ++ r2) (j1 S.<> j2)
|
|
| 4938 | +instance Monoid LoadArgs where
|
|
| 4939 | + mempty = LoadArgs [] [] [] nilOL
|
|
| 4941 | 4940 | |
| 4942 | 4941 | -- | An argument passed on the stack, either directly or by reference.
|
| 4943 | 4942 | --
|
| 1 | 1 | {-# LANGUAGE CPP #-}
|
| 2 | 2 | {-# LANGUAGE MultiWayIf #-}
|
| 3 | 3 | {-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
| 4 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 5 | -{-# LANGUAGE DerivingVia #-}
|
|
| 6 | 4 | |
| 7 | 5 | -- | Handle conversion of CmmProc to LLVM code.
|
| 8 | 6 | module GHC.CmmToLlvm.CodeGen ( genLlvmProc ) where
|
| ... | ... | @@ -31,8 +29,6 @@ import GHC.Data.FastString |
| 31 | 29 | import GHC.Data.Maybe (expectJust)
|
| 32 | 30 | import GHC.Data.OrdList
|
| 33 | 31 | |
| 34 | -import GHC.Generics (Generic, Generically(..))
|
|
| 35 | - |
|
| 36 | 32 | import GHC.Types.ForeignCall
|
| 37 | 33 | import GHC.Types.Unique.DSM
|
| 38 | 34 | import GHC.Types.Unique
|
| ... | ... | @@ -52,6 +48,7 @@ import Data.List ( nub ) |
| 52 | 48 | import qualified Data.List as List
|
| 53 | 49 | import Data.List.NonEmpty ( NonEmpty (..), nonEmpty )
|
| 54 | 50 | import Data.Maybe ( catMaybes )
|
| 51 | +import qualified Data.Semigroup as Semigroup
|
|
| 55 | 52 | |
| 56 | 53 | type Atomic = Maybe MemoryOrdering
|
| 57 | 54 | type LlvmStatements = OrdList LlvmStatement
|
| ... | ... | @@ -2478,8 +2475,14 @@ getTBAARegMeta = getTBAAMeta . getTBAA |
| 2478 | 2475 | |
| 2479 | 2476 | -- | A more convenient way of accumulating LLVM statements and declarations.
|
| 2480 | 2477 | data LlvmAccum = LlvmAccum LlvmStatements [LlvmCmmDecl]
|
| 2481 | - deriving (Generic)
|
|
| 2482 | - deriving (Monoid, Semigroup) via Generically LlvmAccum
|
|
| 2478 | + |
|
| 2479 | +instance Semigroup LlvmAccum where
|
|
| 2480 | + LlvmAccum stmtsA declsA <> LlvmAccum stmtsB declsB =
|
|
| 2481 | + LlvmAccum (stmtsA Semigroup.<> stmtsB) (declsA Semigroup.<> declsB)
|
|
| 2482 | + |
|
| 2483 | +instance Monoid LlvmAccum where
|
|
| 2484 | + mempty = LlvmAccum nilOL []
|
|
| 2485 | + mappend = (Semigroup.<>)
|
|
| 2483 | 2486 | |
| 2484 | 2487 | liftExprData :: LlvmM ExprData -> WriterT LlvmAccum LlvmM LlvmVar
|
| 2485 | 2488 | liftExprData action = do
|
| 1 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 2 | -{-# LANGUAGE DerivingVia #-}
|
|
| 3 | - |
|
| 4 | 1 | {-
|
| 5 | 2 | A simple homogeneous pair type with useful Functor, Applicative, and
|
| 6 | 3 | Traversable instances.
|
| ... | ... | @@ -23,12 +20,8 @@ import GHC.Prelude |
| 23 | 20 | import GHC.Utils.Outputable
|
| 24 | 21 | import qualified Data.Semigroup as Semi
|
| 25 | 22 | |
| 26 | -import GHC.Generics (Generic, Generically(..))
|
|
| 27 | - |
|
| 28 | 23 | data Pair a = Pair { pFst :: a, pSnd :: a }
|
| 29 | - deriving (Foldable, Functor, Traversable, Generic)
|
|
| 30 | - deriving (Semigroup, Monoid) via Generically (Pair a)
|
|
| 31 | - |
|
| 24 | + deriving (Foldable, Functor, Traversable)
|
|
| 32 | 25 | -- Note that Pair is a *unary* type constructor
|
| 33 | 26 | -- whereas (,) is binary
|
| 34 | 27 | |
| ... | ... | @@ -40,6 +33,13 @@ instance Applicative Pair where |
| 40 | 33 | pure x = Pair x x
|
| 41 | 34 | (Pair f g) <*> (Pair x y) = Pair (f x) (g y)
|
| 42 | 35 | |
| 36 | +instance Semi.Semigroup a => Semi.Semigroup (Pair a) where
|
|
| 37 | + Pair a1 b1 <> Pair a2 b2 = Pair (a1 Semi.<> a2) (b1 Semi.<> b2)
|
|
| 38 | + |
|
| 39 | +instance (Semi.Semigroup a, Monoid a) => Monoid (Pair a) where
|
|
| 40 | + mempty = Pair mempty mempty
|
|
| 41 | + mappend = (Semi.<>)
|
|
| 42 | + |
|
| 43 | 43 | instance Outputable a => Outputable (Pair a) where
|
| 44 | 44 | ppr (Pair a b) = ppr a <+> char '~' <+> ppr b
|
| 45 | 45 |
| 1 | 1 | {-# LANGUAGE TypeFamilies #-}
|
| 2 | +{-# LANGUAGE ViewPatterns #-}
|
|
| 2 | 3 | {-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow]
|
| 3 | 4 | -- in module Language.Haskell.Syntax.Extension
|
| 4 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 5 | -{-# LANGUAGE DerivingVia #-}
|
|
| 5 | + |
|
| 6 | 6 | {-# OPTIONS_GHC -Wno-orphans #-} -- NamedThing, Outputable, OutputableBndrId
|
| 7 | 7 | |
| 8 | 8 | {-
|
| ... | ... | @@ -117,7 +117,6 @@ import GHC.Core.Ppr ( pprOccWithTick) |
| 117 | 117 | import GHC.Core.Type
|
| 118 | 118 | import GHC.Core.Multiplicity( pprArrowWithModifiers )
|
| 119 | 119 | import GHC.Hs.Doc
|
| 120 | -import GHC.Generics (Generic, Generically(..))
|
|
| 121 | 120 | import GHC.Types.Basic
|
| 122 | 121 | import GHC.Types.SrcLoc
|
| 123 | 122 | import GHC.Utils.Outputable
|
| ... | ... | @@ -233,8 +232,6 @@ data HsTyPatRnBuilder = |
| 233 | 232 | hstpb_imp_tvs :: Bag Name,
|
| 234 | 233 | hstpb_exp_tvs :: Bag Name
|
| 235 | 234 | }
|
| 236 | - deriving (Generic)
|
|
| 237 | - deriving (Semigroup, Monoid) via Generically HsTyPatRnBuilder
|
|
| 238 | 235 | |
| 239 | 236 | tpBuilderExplicitTV :: Name -> HsTyPatRnBuilder
|
| 240 | 237 | tpBuilderExplicitTV name = mempty {hstpb_exp_tvs = unitBag name}
|
| ... | ... | @@ -246,6 +243,16 @@ tpBuilderPatSig HsPSRn {hsps_nwcs, hsps_imp_tvs} = |
| 246 | 243 | hstpb_imp_tvs = listToBag hsps_imp_tvs
|
| 247 | 244 | }
|
| 248 | 245 | |
| 246 | +instance Semigroup HsTyPatRnBuilder where
|
|
| 247 | + HsTPRnB nwcs1 imp_tvs1 exptvs1 <> HsTPRnB nwcs2 imp_tvs2 exptvs2 =
|
|
| 248 | + HsTPRnB
|
|
| 249 | + (nwcs1 `unionBags` nwcs2)
|
|
| 250 | + (imp_tvs1 `unionBags` imp_tvs2)
|
|
| 251 | + (exptvs1 `unionBags` exptvs2)
|
|
| 252 | + |
|
| 253 | +instance Monoid HsTyPatRnBuilder where
|
|
| 254 | + mempty = HsTPRnB emptyBag emptyBag emptyBag
|
|
| 255 | + |
|
| 249 | 256 | buildHsTyPatRn :: HsTyPatRnBuilder -> HsTyPatRn
|
| 250 | 257 | buildHsTyPatRn HsTPRnB {hstpb_nwcs, hstpb_imp_tvs, hstpb_exp_tvs} =
|
| 251 | 258 | HsTPRn {
|
| 1 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 2 | -{-# LANGUAGE DerivingVia #-}
|
|
| 3 | - |
|
| 4 | 1 | -- | This module coverage checks pattern matches. It finds
|
| 5 | 2 | --
|
| 6 | 3 | -- * Uncovered patterns, certifying non-exhaustivity
|
| ... | ... | @@ -66,7 +63,6 @@ import {-# SOURCE #-} GHC.HsToCore.Expr (dsLExpr) |
| 66 | 63 | import GHC.HsToCore.Monad
|
| 67 | 64 | import GHC.Data.Bag
|
| 68 | 65 | import GHC.Data.OrdList
|
| 69 | -import GHC.Generics (Generic, Generically(..))
|
|
| 70 | 66 | |
| 71 | 67 | import Control.Monad (when, forM_)
|
| 72 | 68 | import qualified Data.Semigroup as Semi
|
| ... | ... | @@ -468,8 +464,13 @@ data CIRB |
| 468 | 464 | , cirb_red :: !(OrdList SrcInfo) -- ^ Redundant clauses
|
| 469 | 465 | , cirb_bangs :: !(OrdList SrcInfo) -- ^ Redundant bang patterns
|
| 470 | 466 | }
|
| 471 | - deriving (Generic)
|
|
| 472 | - deriving (Semigroup, Monoid) via Generically CIRB
|
|
| 467 | + |
|
| 468 | +instance Semigroup CIRB where
|
|
| 469 | + CIRB a b c d <> CIRB e f g h = CIRB (a <> e) (b <> f) (c <> g) (d <> h)
|
|
| 470 | + where (<>) = (Semi.<>)
|
|
| 471 | + |
|
| 472 | +instance Monoid CIRB where
|
|
| 473 | + mempty = CIRB mempty mempty mempty mempty
|
|
| 473 | 474 | |
| 474 | 475 | -- See Note [Determining inaccessible clauses]
|
| 475 | 476 | ensureOneNotRedundant :: CIRB -> CIRB
|
| ... | ... | @@ -2,8 +2,6 @@ |
| 2 | 2 | {-# LANGUAGE ViewPatterns #-}
|
| 3 | 3 | {-# LANGUAGE MultiWayIf #-}
|
| 4 | 4 | {-# LANGUAGE TypeFamilies #-}
|
| 5 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 6 | -{-# LANGUAGE DerivingVia #-}
|
|
| 7 | 5 | |
| 8 | 6 | -- | Domain types used in "GHC.HsToCore.Pmc.Solver".
|
| 9 | 7 | -- The ultimate goal is to define 'Nabla', which models normalised refinement
|
| ... | ... | @@ -71,7 +69,6 @@ import GHC.Types.CompleteMatch |
| 71 | 69 | import GHC.Types.SourceText (SourceText(..), mkFractionalLit, FractionalLit
|
| 72 | 70 | , fractionalLitFromRational
|
| 73 | 71 | , FractionalExponentBase(..))
|
| 74 | -import GHC.Generics (Generic, Generically(..))
|
|
| 75 | 72 | |
| 76 | 73 | import Numeric (fromRat)
|
| 77 | 74 | import Data.Ratio
|
| ... | ... | @@ -108,13 +105,19 @@ instance Outputable Nabla where |
| 108 | 105 | |
| 109 | 106 | -- | A disjunctive bag of 'Nabla's, representing a refinement type.
|
| 110 | 107 | newtype Nablas = MkNablas (Bag Nabla)
|
| 111 | - -- deriving 'Outputable' removes `MkNablas` label
|
|
| 112 | - deriving (Generic, Outputable)
|
|
| 113 | - deriving (Semigroup, Monoid) via Generically Nablas
|
|
| 114 | 108 | |
| 115 | 109 | initNablas :: Nablas
|
| 116 | 110 | initNablas = MkNablas (unitBag initNabla)
|
| 117 | 111 | |
| 112 | +instance Outputable Nablas where
|
|
| 113 | + ppr (MkNablas nablas) = ppr nablas
|
|
| 114 | + |
|
| 115 | +instance Semigroup Nablas where
|
|
| 116 | + MkNablas l <> MkNablas r = MkNablas (l `unionBags` r)
|
|
| 117 | + |
|
| 118 | +instance Monoid Nablas where
|
|
| 119 | + mempty = MkNablas emptyBag
|
|
| 120 | + |
|
| 118 | 121 | -- | The type oracle state. An 'GHC.Tc.Solver.Monad.InertSet' that we
|
| 119 | 122 | -- incrementally add local type constraints to, together with a sequence
|
| 120 | 123 | -- number that counts the number of times we extended it with new facts.
|
| 1 | 1 | {-# LANGUAGE ApplicativeDo #-}
|
| 2 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 3 | 2 | {-# LANGUAGE DerivingVia #-}
|
| 4 | 3 | {-# LANGUAGE TypeFamilies #-}
|
| 5 | 4 | |
| ... | ... | @@ -62,7 +61,6 @@ import {-# SOURCE #-} GHC.Parser (parseIdentifier) |
| 62 | 61 | import GHC.Parser.Lexer
|
| 63 | 62 | import GHC.Parser.HaddockLex
|
| 64 | 63 | import GHC.Parser.Errors.Types
|
| 65 | -import GHC.Generics (Generic, Generically(..))
|
|
| 66 | 64 | import GHC.Utils.Misc (mergeListsBy, filterOut, (<&&>))
|
| 67 | 65 | import qualified GHC.Data.Strict as Strict
|
| 68 | 66 | |
| ... | ... | @@ -1349,8 +1347,13 @@ data LocRange = |
| 1349 | 1347 | { loc_range_from :: !LowerLocBound,
|
| 1350 | 1348 | loc_range_to :: !UpperLocBound,
|
| 1351 | 1349 | loc_range_col :: !ColumnBound }
|
| 1352 | - deriving (Generic)
|
|
| 1353 | - deriving (Semigroup, Monoid) via Generically LocRange
|
|
| 1350 | + |
|
| 1351 | +instance Semigroup LocRange where
|
|
| 1352 | + LocRange from1 to1 col1 <> LocRange from2 to2 col2 =
|
|
| 1353 | + LocRange (from1 <> from2) (to1 <> to2) (col1 <> col2)
|
|
| 1354 | + |
|
| 1355 | +instance Monoid LocRange where
|
|
| 1356 | + mempty = LocRange mempty mempty mempty
|
|
| 1354 | 1357 | |
| 1355 | 1358 | -- The location range from the specified position to the end of the file.
|
| 1356 | 1359 | locRangeFrom :: Strict.Maybe BufPos -> LocRange
|
| 1 | 1 | {-# LANGUAGE DuplicateRecordFields #-}
|
| 2 | 2 | {-# LANGUAGE MultiWayIf #-}
|
| 3 | 3 | {-# LANGUAGE RecursiveDo #-}
|
| 4 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 5 | -{-# LANGUAGE DerivingVia #-}
|
|
| 6 | 4 | |
| 7 | 5 | {-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
|
| 8 | 6 | {-
|
| ... | ... | @@ -147,13 +145,13 @@ import GHC.Utils.Outputable |
| 147 | 145 | import GHC.Utils.Panic
|
| 148 | 146 | import GHC.Utils.Constants (debugIsOn)
|
| 149 | 147 | |
| 150 | -import GHC.Generics (Generic, Generically(..))
|
|
| 151 | - |
|
| 152 | 148 | import Control.Monad
|
| 153 | 149 | import Data.IORef
|
| 154 | 150 | import GHC.Data.Maybe
|
| 155 | 151 | import GHC.Types.Name.Reader
|
| 156 | 152 | |
| 153 | +import qualified Data.Semigroup as Semi
|
|
| 154 | + |
|
| 157 | 155 | {-
|
| 158 | 156 | ************************************************************************
|
| 159 | 157 | * *
|
| ... | ... | @@ -1281,8 +1279,17 @@ data CandidatesQTvs |
| 1281 | 1279 | -- These are covars. Included only so that we don't repeatedly
|
| 1282 | 1280 | -- look at covars' kinds in accumulator. Not used by quantifyTyVars.
|
| 1283 | 1281 | }
|
| 1284 | - deriving (Generic)
|
|
| 1285 | - deriving (Semigroup, Monoid) via Generically CandidatesQTvs
|
|
| 1282 | + |
|
| 1283 | +instance Semi.Semigroup CandidatesQTvs where
|
|
| 1284 | + (DV { dv_kvs = kv1, dv_tvs = tv1, dv_cvs = cv1 })
|
|
| 1285 | + <> (DV { dv_kvs = kv2, dv_tvs = tv2, dv_cvs = cv2 })
|
|
| 1286 | + = DV { dv_kvs = kv1 `unionDVarSet` kv2
|
|
| 1287 | + , dv_tvs = tv1 `unionDVarSet` tv2
|
|
| 1288 | + , dv_cvs = cv1 `unionVarSet` cv2 }
|
|
| 1289 | + |
|
| 1290 | +instance Monoid CandidatesQTvs where
|
|
| 1291 | + mempty = DV { dv_kvs = emptyDVarSet, dv_tvs = emptyDVarSet, dv_cvs = emptyVarSet }
|
|
| 1292 | + mappend = (Semi.<>)
|
|
| 1286 | 1293 | |
| 1287 | 1294 | instance Outputable CandidatesQTvs where
|
| 1288 | 1295 | ppr (DV {dv_kvs = kvs, dv_tvs = tvs, dv_cvs = cvs })
|
| ... | ... | @@ -44,7 +44,6 @@ import GHC.Types.Unique |
| 44 | 44 | |
| 45 | 45 | import Data.Coerce
|
| 46 | 46 | import Data.Data
|
| 47 | -import Data.Semigroup
|
|
| 48 | 47 | |
| 49 | 48 | -- See Note [UniqSet invariant] in GHC.Types.Unique.Set for why we want a newtype here.
|
| 50 | 49 | -- Beyond preserving invariants, we may also want to 'override' typeclass
|
| ... | ... | @@ -155,9 +154,3 @@ instance Outputable a => Outputable (UniqDSet a) where |
| 155 | 154 | |
| 156 | 155 | pprUniqDSet :: (a -> SDoc) -> UniqDSet a -> SDoc
|
| 157 | 156 | pprUniqDSet f = braces . pprWithCommas f . uniqDSetToList |
| 158 | - |
|
| 159 | -instance Semigroup (UniqDSet a) where
|
|
| 160 | - (<>) = unionUniqDSets
|
|
| 161 | - |
|
| 162 | -instance Monoid (UniqDSet a) where
|
|
| 163 | - mempty = emptyUniqDSet |
| 1 | -{-# LANGUAGE DeriveGeneric #-}
|
|
| 2 | -{-# LANGUAGE DerivingVia #-}
|
|
| 3 | - |
|
| 4 | 1 | module GHC.Utils.Ppr.Colour where
|
| 5 | 2 | import GHC.Prelude.Basic
|
| 6 | 3 | |
| 7 | 4 | import Data.Maybe (fromMaybe)
|
| 8 | 5 | import GHC.Data.Bool
|
| 9 | -import GHC.Generics (Generic, Generically(..))
|
|
| 6 | +import Data.Semigroup as Semi
|
|
| 10 | 7 | |
| 11 | 8 | -- | A colour\/style for use with 'coloured'.
|
| 12 | 9 | newtype PprColour = PprColour { renderColour :: String }
|
| 13 | - deriving (Generic)
|
|
| 14 | - deriving (Semigroup, Monoid) via Generically PprColour
|
|
| 10 | + |
|
| 11 | +instance Semi.Semigroup PprColour where
|
|
| 12 | + PprColour s1 <> PprColour s2 = PprColour (s1 <> s2)
|
|
| 13 | + |
|
| 14 | +-- | Allow colours to be combined (e.g. bold + red);
|
|
| 15 | +-- In case of conflict, right side takes precedence.
|
|
| 16 | +instance Monoid PprColour where
|
|
| 17 | + mempty = PprColour mempty
|
|
| 18 | + mappend = (<>)
|
|
| 15 | 19 | |
| 16 | 20 | renderColourAfresh :: PprColour -> String
|
| 17 | 21 | renderColourAfresh c = renderColour (colReset `mappend` c)
|