diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-10-19 21:45:10 +0200 |
---|---|---|
committer | Andreas Klebinger <klebinger.andreas@gmx.at> | 2022-10-19 21:45:10 +0200 |
commit | 71044d6b5fd8ac43c5532420adf6a397e63e949f (patch) | |
tree | 927a8c310f3b2350b98b50156b8b31a131d259a7 | |
parent | 8e558717285d306442c2464421ecfaf42354e946 (diff) | |
download | haskell-71044d6b5fd8ac43c5532420adf6a397e63e949f.tar.gz |
Revert "Adds data instances, and denesting for ByteArray#"
This reverts commit 8e558717285d306442c2464421ecfaf42354e946.
-rw-r--r-- | compiler/GHC/Builtin/PrimOps.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Builtin/Types.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Cmm/CLabel.hs | 24 | ||||
-rw-r--r-- | compiler/GHC/Cmm/Dataflow/Label.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Cmm/Expr.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Cmm/MachOp.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Cmm/Reg.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Cmm/Type.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/CodeGen.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/CoreToStg.hs | 15 | ||||
-rw-r--r-- | compiler/GHC/Stg/InferTags.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Stg/InferTags/Rewrite.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm.hs-boot | 49 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Bind.hs | 19 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Closure.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/DataCon.hs | 54 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Env.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/StgToCmm/Expr.hs | 25 | ||||
-rw-r--r-- | compiler/GHC/Types/CostCentre.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Types/Id/Info.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Types/Rep/Virtual.hs | 120 | ||||
-rw-r--r-- | compiler/GHC/Types/RepType.hs | 66 | ||||
-rw-r--r-- | compiler/GHC/Types/Unique.hs | 4 | ||||
-rw-r--r-- | compiler/ghc.cabal.in | 1 |
24 files changed, 185 insertions, 263 deletions
diff --git a/compiler/GHC/Builtin/PrimOps.hs b/compiler/GHC/Builtin/PrimOps.hs index 5766caa998..ecd9da0ac2 100644 --- a/compiler/GHC/Builtin/PrimOps.hs +++ b/compiler/GHC/Builtin/PrimOps.hs @@ -5,8 +5,6 @@ -} {-# LANGUAGE CPP #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Builtin.PrimOps ( PrimOp(..), PrimOpVecCat(..), allThePrimOps, @@ -55,7 +53,6 @@ import GHC.Unit.Types ( Unit ) import GHC.Utils.Outputable import GHC.Data.FastString -import Data.Data (Data) {- ************************************************************************ @@ -76,8 +73,7 @@ These are in \tr{state-interface.verb} order. #include "primop-tag.hs-incl" primOpTag _ = error "primOpTag: unknown primop" -deriving instance Data PrimOp -deriving instance Data PrimOpVecCat + instance Eq PrimOp where op1 == op2 = primOpTag op1 == primOpTag op2 diff --git a/compiler/GHC/Builtin/Types.hs b/compiler/GHC/Builtin/Types.hs index bbabc6e241..21c579460a 100644 --- a/compiler/GHC/Builtin/Types.hs +++ b/compiler/GHC/Builtin/Types.hs @@ -180,7 +180,7 @@ import GHC.Unit.Module ( Module ) import GHC.Core.Type import qualified GHC.Core.TyCo.Rep as TyCoRep (Type(TyConApp)) import GHC.Core.TyCo.Rep (RuntimeRepType) -import GHC.Types.RepType (runtimeRepPrimRep, slotPrimRep, ubxSumRepType) +import GHC.Types.RepType () import GHC.Core.DataCon import GHC.Core.ConLike import GHC.Core.TyCon diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs index 2e9c283241..b718b73f30 100644 --- a/compiler/GHC/Cmm/CLabel.hs +++ b/compiler/GHC/Cmm/CLabel.hs @@ -9,7 +9,6 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.CLabel ( @@ -157,7 +156,6 @@ import GHC.Types.Unique.Set import GHC.Utils.Misc import GHC.Core.Ppr ( {- instances -} ) import GHC.Types.SrcLoc -import Data.Data (Data) -- ----------------------------------------------------------------------------- -- The CLabel type @@ -292,7 +290,7 @@ data CLabel | LargeBitmapLabel {-# UNPACK #-} !Unique - deriving (Eq,Data) + deriving Eq instance Show CLabel where show = showPprUnsafe . pprDebugCLabel genericPlatform @@ -302,7 +300,7 @@ data ModuleLabelKind | MLK_InitializerArray | MLK_Finalizer String | MLK_FinalizerArray - deriving (Eq, Ord, Data) + deriving (Eq, Ord) instance Outputable ModuleLabelKind where ppr MLK_InitializerArray = text "init_arr" @@ -336,7 +334,7 @@ isTickyLabel _ = False -- for why extern declaration are needed at all. newtype NeedExternDecl = NeedExternDecl Bool - deriving (Ord,Eq, Data) + deriving (Ord,Eq) -- This is laborious, but necessary. We can't derive Ord because -- Unique doesn't have an Ord instance. Note nonDetCmpUnique in the @@ -443,7 +441,7 @@ data ForeignLabelSource -- destination module. | ForeignLabelInThisPackage - deriving (Eq, Ord, Data) + deriving (Eq, Ord) -- | For debugging problems with the CLabel representation. @@ -472,7 +470,7 @@ pprDebugCLabel platform lbl = pprCLabel platform AsmStyle lbl <> parens extra data TickyIdInfo = TickyRednCounts -- ^ Used for dynamic allocations | TickyInferedTag !Unique -- ^ Used to track dynamic hits of tag inference. - deriving (Eq,Show, Data) + deriving (Eq,Show) instance Outputable TickyIdInfo where ppr TickyRednCounts = text "ct_rdn" @@ -521,12 +519,12 @@ data IdLabelInfo -- instead of a closure entry-point. -- See Note [Proc-point local block entry-points]. - deriving (Eq, Ord, Data) + deriving (Eq, Ord) -- | Which module is the info table from, and which number was it. data ConInfoTableLocation = UsageSite Module Int | DefinitionSite - deriving (Eq, Ord, Data) + deriving (Eq, Ord) instance Outputable ConInfoTableLocation where ppr (UsageSite m n) = text "Loc(" <> ppr n <> text "):" <+> ppr m @@ -564,7 +562,7 @@ data RtsLabelInfo | RtsApFast NonDetFastString -- ^ _fast versions of generic apply | RtsSlowFastTickyCtr String - deriving (Eq,Ord, Data) + deriving (Eq,Ord) -- | What type of Cmm label we're dealing with. @@ -579,7 +577,7 @@ data CmmLabelInfo | CmmCode -- ^ misc rts code | CmmClosure -- ^ closures eg CHARLIKE_closure | CmmPrimCall -- ^ a prim call to some hand written Cmm code - deriving (Eq, Ord, Data) + deriving (Eq, Ord) data DynamicLinkerLabelInfo = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt @@ -587,7 +585,7 @@ data DynamicLinkerLabelInfo | GotSymbolPtr -- ELF: foo@got | GotSymbolOffset -- ELF: foo@gotoff - deriving (Eq, Ord, Data) + deriving (Eq, Ord) -- ----------------------------------------------------------------------------- @@ -825,7 +823,7 @@ data InfoProvEnt = InfoProvEnt -- Origin module , infoTableProv :: !(Maybe (RealSrcSpan, String)) } -- Position and information about the info table - deriving (Eq, Ord, Data) + deriving (Eq, Ord) instance OutputableP Platform InfoProvEnt where pdoc platform (InfoProvEnt clabel _ _ _ _) = pdoc platform clabel diff --git a/compiler/GHC/Cmm/Dataflow/Label.hs b/compiler/GHC/Cmm/Dataflow/Label.hs index d5c4270a81..a9a74fd50e 100644 --- a/compiler/GHC/Cmm/Dataflow/Label.hs +++ b/compiler/GHC/Cmm/Dataflow/Label.hs @@ -3,8 +3,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.Dataflow.Label ( Label @@ -24,7 +22,6 @@ import GHC.Cmm.Dataflow.Collections import GHC.Types.Unique (Uniquable(..)) import GHC.Data.TrieMap -import Data.Data (Data) ----------------------------------------------------------------------------- @@ -32,7 +29,7 @@ import Data.Data (Data) ----------------------------------------------------------------------------- newtype Label = Label { lblToUnique :: Int } - deriving (Eq, Ord, Data) + deriving (Eq, Ord) mkHooplLabel :: Int -> Label mkHooplLabel = Label diff --git a/compiler/GHC/Cmm/Expr.hs b/compiler/GHC/Cmm/Expr.hs index 449f28d82e..212316b68d 100644 --- a/compiler/GHC/Cmm/Expr.hs +++ b/compiler/GHC/Cmm/Expr.hs @@ -4,7 +4,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.Expr ( CmmExpr(..), cmmExprType, cmmExprWidth, cmmExprAlignment, maybeInvertCmmExpr @@ -57,7 +56,6 @@ import qualified Data.Set as Set import Numeric ( fromRat ) import GHC.Types.Basic (Alignment, mkAlignment, alignmentOf) -import Data.Data ----------------------------------------------------------------------------- -- CmmExpr @@ -78,7 +76,7 @@ data CmmExpr -- ** is shorthand only, meaning ** -- CmmMachOp (MO_Add rep) [x, CmmLit (CmmInt (fromIntegral i) rep)] -- where rep = typeWidth (cmmRegType reg) - deriving (Show, Data) + deriving Show instance Eq CmmExpr where -- Equality ignores the types CmmLit l1 == CmmLit l2 = l1==l2 @@ -93,7 +91,7 @@ instance OutputableP Platform CmmExpr where pdoc = pprExpr data AlignmentSpec = NaturallyAligned | Unaligned - deriving (Eq, Ord, Show, Data) + deriving (Eq, Ord, Show) -- | A stack area is either the stack slot where a variable is spilled -- or the stack space where function arguments and results are passed. @@ -101,7 +99,7 @@ data Area = Old -- See Note [Old Area] | Young {-# UNPACK #-} !BlockId -- Invariant: must be a continuation BlockId -- See Note [Continuation BlockIds] in GHC.Cmm.Node. - deriving (Eq, Ord, Show, Data) + deriving (Eq, Ord, Show) instance Outputable Area where ppr e = pprArea e @@ -232,7 +230,7 @@ data CmmLit -- During the stack-layout pass, CmmHighStackMark -- is replaced by a CmmInt for the actual number -- of bytes used - deriving (Eq, Show,Data) + deriving (Eq, Show) instance OutputableP Platform CmmLit where pdoc = pprLit diff --git a/compiler/GHC/Cmm/MachOp.hs b/compiler/GHC/Cmm/MachOp.hs index f4be3ef1bf..0bd3ac1111 100644 --- a/compiler/GHC/Cmm/MachOp.hs +++ b/compiler/GHC/Cmm/MachOp.hs @@ -1,5 +1,4 @@ {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.MachOp ( MachOp(..) @@ -34,7 +33,6 @@ import GHC.Prelude import GHC.Platform import GHC.Cmm.Type import GHC.Utils.Outputable -import Data.Data (Data) ----------------------------------------------------------------------------- -- MachOp @@ -157,7 +155,7 @@ data MachOp -- Alignment check (for -falignment-sanitisation) | MO_AlignmentCheck Int Width - deriving (Eq, Show, Data) + deriving (Eq, Show) pprMachOp :: MachOp -> SDoc pprMachOp mo = text (show mo) diff --git a/compiler/GHC/Cmm/Reg.hs b/compiler/GHC/Cmm/Reg.hs index 720b978b7d..6c94ecb2eb 100644 --- a/compiler/GHC/Cmm/Reg.hs +++ b/compiler/GHC/Cmm/Reg.hs @@ -1,7 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.Reg ( -- * Cmm Registers @@ -25,7 +24,6 @@ import GHC.Platform import GHC.Utils.Outputable import GHC.Types.Unique import GHC.Cmm.Type -import Data.Data (Data) ----------------------------------------------------------------------------- -- Cmm registers @@ -34,7 +32,7 @@ import Data.Data (Data) data CmmReg = CmmLocal {-# UNPACK #-} !LocalReg | CmmGlobal GlobalReg - deriving( Eq, Ord, Show, Data ) + deriving( Eq, Ord, Show ) instance Outputable CmmReg where ppr e = pprReg e @@ -62,7 +60,7 @@ data LocalReg -- ^ Parameters: -- 1. Identifier -- 2. Type - deriving (Show, Data) + deriving Show instance Eq LocalReg where (LocalReg u1 _) == (LocalReg u2 _) = u1 == u2 @@ -130,7 +128,7 @@ account. However it is still used in UserOfRegs/DefinerOfRegs and there are likely still bugs there, beware! -} -data VGcPtr = VGcPtr | VNonGcPtr deriving( Eq, Show, Data ) +data VGcPtr = VGcPtr | VNonGcPtr deriving( Eq, Show ) data GlobalReg -- Argument and return registers @@ -193,7 +191,7 @@ data GlobalReg -- from platform to platform (see module PositionIndependentCode). | PicBaseReg - deriving( Show, Data ) + deriving( Show ) instance Eq GlobalReg where VanillaReg i _ == VanillaReg j _ = i==j -- Ignore type when seeking clashes diff --git a/compiler/GHC/Cmm/Type.hs b/compiler/GHC/Cmm/Type.hs index 52308bdde6..ec000a3c47 100644 --- a/compiler/GHC/Cmm/Type.hs +++ b/compiler/GHC/Cmm/Type.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Cmm.Type ( CmmType -- Abstract , b8, b16, b32, b64, b128, b256, b512, f32, f64, bWord, bHalfWord, gcWord @@ -41,7 +40,6 @@ import GHC.Utils.Panic import Data.Word import Data.Int -import Data.Data (Data) ----------------------------------------------------------------------------- -- CmmType @@ -55,14 +53,14 @@ import Data.Data (Data) data CmmType -- The important one! = CmmType CmmCat !Width - deriving (Show,Data) + deriving Show data CmmCat -- "Category" (not exported) = GcPtrCat -- GC pointer | BitsCat -- Non-pointer | FloatCat -- Float | VecCat Length CmmCat -- Vector - deriving( Eq, Show, Data) + deriving( Eq, Show ) -- See Note [Signed vs unsigned] at the end instance Outputable CmmType where @@ -184,7 +182,7 @@ data Width | W128 | W256 | W512 - deriving (Eq, Ord, Show, Data) + deriving (Eq, Ord, Show) instance Outputable Width where ppr rep = text (show rep) diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs index ac285f864c..9861177c3a 100644 --- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs @@ -92,7 +92,6 @@ import Data.Maybe import Data.Word import qualified Data.Map as M -import GHC.Hs.Dump (showAstDataFull) is32BitPlatform :: NatM Bool is32BitPlatform = do @@ -1238,7 +1237,7 @@ getRegister' platform _ (CmmLit lit) getRegister' platform _ other | isVecExpr other = needLlvm - | otherwise = pprPanic "getRegister'(x86)" (pdoc platform other $$ text (show other)) + | otherwise = pprPanic "getRegister(x86)" (pdoc platform other) intLoadCode :: (Operand -> Operand -> Instr) -> CmmExpr diff --git a/compiler/GHC/CoreToStg.hs b/compiler/GHC/CoreToStg.hs index 51fc887d8d..6dd7a25f06 100644 --- a/compiler/GHC/CoreToStg.hs +++ b/compiler/GHC/CoreToStg.hs @@ -34,7 +34,6 @@ import GHC.Stg.Debug import GHC.Stg.Utils import GHC.Types.RepType -import GHC.Types.Rep.Virtual (isVirtualTyCon, isVirtualDataCon) import GHC.Types.Id.Make ( coercionTokenId ) import GHC.Types.Id import GHC.Types.Id.Info @@ -729,13 +728,13 @@ mkTopStgRhs dflags this_mod ccs bndr (PreStgRhs bndrs rhs) = -- CorePrep does this right, but just to make sure assertPpr (not (isUnboxedTupleDataCon con || isUnboxedSumDataCon con)) (ppr bndr $$ ppr con $$ ppr args) $ - -- if isVirtualDataCon con - -- then - -- ( StgRhsClosure noExtFieldSilent - -- all_cafs_ccs - -- upd_flag [] (virtual_arg args) - -- , ccs ) - -- else + if isVirtualDataCon con + then + ( StgRhsClosure noExtFieldSilent + all_cafs_ccs + upd_flag [] (virtual_arg args) + , ccs ) + else ( StgRhsCon dontCareCCS con mn ticks args, ccs ) -- Otherwise it's a CAF, see Note [Cost-centre initialization plan]. diff --git a/compiler/GHC/Stg/InferTags.hs b/compiler/GHC/Stg/InferTags.hs index eb2c777c30..3b160f7c38 100644 --- a/compiler/GHC/Stg/InferTags.hs +++ b/compiler/GHC/Stg/InferTags.hs @@ -17,8 +17,7 @@ import GHC.Types.Name import GHC.Stg.Syntax import GHC.Types.Basic ( CbvMark (..) ) import GHC.Types.Unique.Supply (mkSplitUniqSupply) -import GHC.Types.RepType (dataConRuntimeRepStrictness) -import GHC.Types.Rep.Virtual (isVirtualDataCon) +import GHC.Types.RepType (dataConRuntimeRepStrictness, isVirtualTyCon, isVirtualDataCon) import GHC.Core (AltCon(..)) import Data.List (mapAccumL) import GHC.Utils.Outputable diff --git a/compiler/GHC/Stg/InferTags/Rewrite.hs b/compiler/GHC/Stg/InferTags/Rewrite.hs index d2d0bbeb2f..2b78089a88 100644 --- a/compiler/GHC/Stg/InferTags/Rewrite.hs +++ b/compiler/GHC/Stg/InferTags/Rewrite.hs @@ -425,6 +425,7 @@ rewriteApp :: InferStgExpr -> RM TgStgExpr rewriteApp (StgApp f []) = do f' <- rewriteId f return $! StgApp f' [] + rewriteApp (StgApp f args) -- pprTrace "rewriteAppOther" (ppr f <+> ppr args) False -- = undefined diff --git a/compiler/GHC/StgToCmm.hs-boot b/compiler/GHC/StgToCmm.hs-boot index 023c94f48b..7e7473b18f 100644 --- a/compiler/GHC/StgToCmm.hs-boot +++ b/compiler/GHC/StgToCmm.hs-boot @@ -13,14 +13,61 @@ module GHC.StgToCmm ( cgTopRhs ) where -import GHC.Prelude as Prelude () +import GHC.Prelude as Prelude +import GHC.StgToCmm.Prof (initCostCentres, ldvEnter) import GHC.StgToCmm.Monad +import GHC.StgToCmm.Env +import GHC.StgToCmm.Bind +import GHC.StgToCmm.Layout +import GHC.StgToCmm.Utils +import GHC.StgToCmm.Closure +import GHC.StgToCmm.Config +import GHC.StgToCmm.Hpc +import GHC.StgToCmm.Ticky +import GHC.StgToCmm.Types (ModuleLFInfos) + +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Graph import GHC.Stg.Syntax +import GHC.Types.CostCentre +import GHC.Types.IPE +import GHC.Types.HpcInfo import GHC.Types.Id +import GHC.Types.Id.Info +import GHC.Types.RepType import GHC.Types.Basic +import GHC.Types.Var.Set ( isEmptyDVarSet ) +import GHC.Types.Unique.FM +import GHC.Types.Name.Env + +import GHC.Core.DataCon +import GHC.Core.TyCon +import GHC.Core.Multiplicity + +import GHC.Unit.Module + +import GHC.Utils.Error +import GHC.Utils.Outputable +import GHC.Utils.Panic.Plain +import GHC.Utils.Logger + +import GHC.Utils.TmpFs + +import GHC.Data.Stream +import GHC.Data.OrdList +import GHC.Types.Unique.Map + +import Control.Monad (when,void, forM_) +import GHC.Utils.Misc +import System.IO.Unsafe +import qualified Data.ByteString as BS +import Data.IORef +import GHC.Utils.Panic (assertPpr) cgTopRhs :: StgToCmmConfig -> RecFlag -> Id -> CgStgRhs -> (CgIdInfo, FCode ()) -- The Id is passed along for setting up a binding... diff --git a/compiler/GHC/StgToCmm/Bind.hs b/compiler/GHC/StgToCmm/Bind.hs index 033fa9387f..a97ae084c0 100644 --- a/compiler/GHC/StgToCmm/Bind.hs +++ b/compiler/GHC/StgToCmm/Bind.hs @@ -65,7 +65,7 @@ import GHC.Data.List.SetOps import Control.Monad import GHC.Utils.Trace -import GHC.Types.Rep.Virtual (isVirtualDataCon, virtualDataConType, VirtualConType (..)) +import GHC.Types.RepType (isVirtualDataCon) ------------------------------------------------------------------------ -- Top-level bindings @@ -108,21 +108,6 @@ cgTopRhsClosure platform rec id ccs upd_flag args body = = do cg_info <- getCgIdInfo f emitDataCon closure_label indStaticInfoTable ccs [unLit (idInfoToAmode cg_info)] - | StgConApp con _ [StgVarArg x] _ <- body - , null args - , vcon <- virtualDataConType con - -- Boxed types we can just compile to a indirection - , vcon /= NonVirtual - = do - cg_info <- getCgIdInfo x - let !payload = case vcon of - VirtualBoxed -> unLit (idInfoToAmode cg_info) - VirtualUnboxedHeap -> - pprPanic "top level unboxed thing" empty $ - cmmOffsetLit (unLit (idInfoToAmode cg_info)) 1 - NonVirtual -> panic "impossible" -- checked in the guard - - emitDataCon closure_label indStaticInfoTable ccs [payload] gen_code lf_info _closure_label = do { profile <- getProfile @@ -309,7 +294,7 @@ mkRhsClosure profile _ _check_tags bndr _cc , StgApp selectee [{-no args-}] <- strip sel_expr , the_fv == scrutinee -- Scrutinee is the only free variable - -- Virtual data cons look like selectors but shouldn't be evaluated by the RTS. + -- Virtual data cons just return themselves. , not $ isVirtualDataCon con , let (_, _, params_w_offsets) = mkVirtConstrOffsets profile (addIdReps (assertNonVoidIds params)) diff --git a/compiler/GHC/StgToCmm/Closure.hs b/compiler/GHC/StgToCmm/Closure.hs index 77c3e6a70f..87d242138d 100644 --- a/compiler/GHC/StgToCmm/Closure.hs +++ b/compiler/GHC/StgToCmm/Closure.hs @@ -112,12 +112,10 @@ import GHC.Utils.Trace (pprTrace) -- module need to have access to them as well data CgLoc - = CmmLoc { cgl_cmm :: CmmExpr } -- A stable CmmExpr; that is, one not mentioning + = CmmLoc CmmExpr -- A stable CmmExpr; that is, one not mentioning -- Hp, so that it remains valid across calls - | LneLoc { cgl_lne_block :: BlockId - , cgl_lne_regs :: [LocalReg] } - -- A join point + | LneLoc BlockId [LocalReg] -- A join point -- A join point (= let-no-escape) should only -- be tail-called, and in a saturated way. -- To tail-call it, assign to these locals, diff --git a/compiler/GHC/StgToCmm/DataCon.hs b/compiler/GHC/StgToCmm/DataCon.hs index 2c9071129d..199cfe0ba4 100644 --- a/compiler/GHC/StgToCmm/DataCon.hs +++ b/compiler/GHC/StgToCmm/DataCon.hs @@ -10,7 +10,6 @@ -- (c) The University of Glasgow 2004-2006 -- ----------------------------------------------------------------------------- -{-# LANGUAGE NamedFieldPuns #-} module GHC.StgToCmm.DataCon ( cgTopRhsCon, buildDynCon, bindConArgs @@ -44,8 +43,7 @@ import GHC.Types.Id import {-# SOURCE #-} GHC.StgToCmm.Bind import GHC.Types.Id.Info( CafInfo( NoCafRefs ) ) import GHC.Types.Name (isInternalName) -import GHC.Types.RepType (countConRepArgs) -import GHC.Types.Rep.Virtual (isVirtualDataCon, VirtualConType(..), virtualDataConType) +import GHC.Types.RepType (countConRepArgs, isVirtualTyCon, virtualDataConType, VirtualConType(..), isVirtualDataCon) import GHC.Types.Literal import GHC.Builtin.Utils import GHC.Utils.Panic @@ -56,9 +54,10 @@ import GHC.Utils.Monad (mapMaybeM) import Control.Monad import Data.Char import GHC.StgToCmm.Config (stgToCmmPlatform) -import GHC.StgToCmm.TagCheck (checkConArgsStatic, checkConArgsDyn, emitTagAssertionId) +import GHC.StgToCmm.TagCheck (checkConArgsStatic, checkConArgsDyn, emitTagAssertion, emitTagAssertionId) import GHC.Utils.Outputable import GHC.Utils.Trace +import Data.Maybe --------------------------------------------------------------- -- Top-level constructors @@ -82,12 +81,10 @@ cgTopRhsCon cfg id con mn args -- See Note [About the NameSorts] in "GHC.Types.Name" for Internal/External (static_info, static_code) - -- Virtual constructor, just return the argument, behaves more like an closure - | virtualDataConType con /= NonVirtual + -- Virtual constructor, just return the argument. + | virtualDataConType con == VirtualBoxed , [NonVoid (StgVarArg x)] <- args - -- It could only be unboxed if we implemented top level unlifted boxy data types. - = assert (virtualDataConType con == VirtualBoxed) $ - let fake_rhs = StgConApp con {-unused-}NoNumber [StgVarArg x] [idType x] :: CgStgExpr + = panic "topRhsCon" $ let fake_rhs = StgApp x [] in pprTrace "cgTopRhsCon" (ppr id $$ ppr con $$ ppr args) $ cgTopRhsClosure platform NonRecursive id dontCareCCS Updatable [] fake_rhs @@ -207,32 +204,22 @@ the addr modes of the args is that we may be in a "knot", and premature looking at the args will cause the compiler to black-hole! -} -------- buildDynCon': Virtual constructor ----------- -buildDynCon' binder _mn _actually_bound _ccs con args - | vcon <- virtualDataConType con - , vcon /= NonVirtual +buildDynCon' binder mn actually_bound ccs con args + | virtualDataConType con == VirtualBoxed , [NonVoid (StgVarArg arg)] <- assert (length args == 1) args = do - pprTraceM "buildDynCon" (ppr con) cfg <- getStgToCmmConfig let platform = stgToCmmPlatform cfg m_arg_cg_info <- (getCgInfo_maybe $ idName arg) case m_arg_cg_info of - Just arg_info@CgIdInfo{ cg_loc, cg_id } -> do - case vcon of - -- A virtual con for regular boxed things is just the argument info under another name. - VirtualBoxed -> do - emitTagAssertionId "buildDynConVirt:" arg - let virt_con_info = arg_info { cg_id = binder } - return (virt_con_info, return mempty) - -- These things usually don't have a pointer tag. But here we attach one to avoid these values from being entered. - VirtualUnboxedHeap - | CmmLoc{ cgl_cmm } <- cg_loc -> do - let virt_con_info = arg_info { cg_id = binder, cg_loc = cg_loc { cgl_cmm = cmmOffset platform cgl_cmm 1 } } - return (virt_con_info, return mempty) - | otherwise -> panic "VirtualCon with LNE value as argument" - NonVirtual -> panic "impossible" -- handled by guard on buildDynCon'/CmmLoc + Just arg_info -> do + emitTagAssertionId "buildDynConVirt:" arg + + -- A virtual con is just the arguments info under another name. + let fake_con_info = arg_info { cg_id = binder } + return (fake_con_info, return mempty) Nothing -> panic "buildDynCon': LFInfo for VCon args unknown" (ppr binder <> text " = " <> ppr con <+> ppr args) -- let !lf_info = mkLFArgument arg @@ -435,16 +422,9 @@ bindConArgs :: AltCon -> LocalReg -> [NonVoid Id] -> FCode [LocalReg] bindConArgs (DataAlt con) base args | isVirtualDataCon con , [NonVoid arg] <- assert (length args == 1) args - = case virtualDataConType con of - NonVirtual -> panic "Impossible" -- checked by guard above - VirtualBoxed -> do - bindArgToGivenReg (NonVoid arg) base - return [base] - VirtualUnboxedHeap -> do - pprTraceM "BindOffset" (ppr con) - bindArgToGivenRegOffset (NonVoid arg) base (-1) - return [base] - + = do + bindArgToGivenReg (NonVoid arg) base + return [base] | otherwise = assert (not (isUnboxedTupleDataCon con)) $ do profile <- getProfile diff --git a/compiler/GHC/StgToCmm/Env.hs b/compiler/GHC/StgToCmm/Env.hs index 2d9c83ba0e..824d47d398 100644 --- a/compiler/GHC/StgToCmm/Env.hs +++ b/compiler/GHC/StgToCmm/Env.hs @@ -18,7 +18,7 @@ module GHC.StgToCmm.Env ( bindArgsToRegs, bindToReg, rebindToReg, bindArgToReg, bindArgToGivenReg, idToReg, getCgIdInfo, getCgInfo_maybe, - maybeLetNoEscape, bindArgToGivenRegOffset, + maybeLetNoEscape, ) where import GHC.Prelude @@ -191,11 +191,6 @@ bindArgToGivenReg (NonVoid id) reg = do let !lf_info = mkLFArgument id addBindC (mkCgIdInfo id lf_info (CmmReg (CmmLocal reg))) -bindArgToGivenRegOffset :: NonVoid Id -> LocalReg -> Int -> FCode () --- Records that an arg is already present in the given reg -bindArgToGivenRegOffset (NonVoid id) reg offset - = do let !lf_info = mkLFArgument id - addBindC (mkCgIdInfo id lf_info (CmmRegOff (CmmLocal reg) offset)) rebindToReg :: NonVoid Id -> FCode LocalReg -- Like bindToReg, but the Id is already in scope, so diff --git a/compiler/GHC/StgToCmm/Expr.hs b/compiler/GHC/StgToCmm/Expr.hs index 0a77859210..e0b5a9dfa2 100644 --- a/compiler/GHC/StgToCmm/Expr.hs +++ b/compiler/GHC/StgToCmm/Expr.hs @@ -37,7 +37,7 @@ import GHC.Cmm.Graph import GHC.Cmm.BlockId import GHC.Cmm hiding ( succ ) import GHC.Cmm.Info -import GHC.Cmm.Utils ( zeroExpr, cmmTagMask, mkWordCLit, mAX_PTR_TAG, cmmOffset ) +import GHC.Cmm.Utils ( zeroExpr, cmmTagMask, mkWordCLit, mAX_PTR_TAG ) import GHC.Core import GHC.Core.DataCon import GHC.Types.ForeignCall @@ -45,7 +45,7 @@ import GHC.Types.Id import GHC.Builtin.PrimOps import GHC.Core.TyCon import GHC.Core.Type ( isUnliftedType ) -import GHC.Types.RepType ( isZeroBitTy, countConRepArgs, mightBeFunTy ) +import GHC.Types.RepType ( isZeroBitTy, countConRepArgs, mightBeFunTy, isVirtualTyCon ) import GHC.Types.CostCentre ( CostCentreStack, currentCCS ) import GHC.Types.Tickish import GHC.Data.Maybe @@ -60,7 +60,6 @@ import Control.Arrow ( first ) import Data.List ( partition ) import GHC.Stg.InferTags.TagSig (isTaggedSig) import GHC.Platform.Profile (profileIsProfiling) -import GHC.Types.Rep.Virtual ------------------------------------------------------------------------ -- cgExpr: the main function @@ -131,11 +130,16 @@ cgExpr (StgOpApp op args ty) = cgOpApp op args ty cgExpr (StgConApp con mn args _) -- Unlike for a regular con for a virtual con we -- might have to evaluate the argument here! - -- | isVirtualDataCon con - -- , arg <- getArg args - -- = cgExpr (StgApp arg []) + | isVirtualTyCon (dataConTyCon con) + , arg <- getArg args + = cgExpr (StgApp arg []) | otherwise = cgConApp con mn args + where + getArg args + | [StgVarArg arg] <- args + = arg + | otherwise = pprPanic "Very odd virtalCon" (ppr con <> ppr args) cgExpr (StgTick t e) = cgTick t >> cgExpr e cgExpr (StgLit lit) = do cmm_expr <- cgLit lit emitReturn [cmm_expr] @@ -985,16 +989,11 @@ cgConApp con mn stg_args ; emitReturn arg_exprs } -- Virtual constructor, just return the argument. - | isVirtualDataCon con + | isVirtualTyCon (dataConTyCon con) , [StgVarArg arg] <- assert (length stg_args == 1) stg_args = do info <- getCgIdInfo arg - platform <- getPlatform - let !arg_cmm = idInfoToAmode info - if virtualDataConType con == VirtualBoxed - then emitReturn [arg_cmm] - -- "Unboxed" heap object without a tag, make one up. - else emitReturn [cmmOffset platform arg_cmm 1] + emitReturn [idInfoToAmode info] | otherwise -- Boxed constructors; allocate and return = assertPpr (stg_args `lengthIs` countConRepArgs con) diff --git a/compiler/GHC/Types/CostCentre.hs b/compiler/GHC/Types/CostCentre.hs index 1d5cec6c94..092b727d8d 100644 --- a/compiler/GHC/Types/CostCentre.hs +++ b/compiler/GHC/Types/CostCentre.hs @@ -189,7 +189,7 @@ data CostCentreStack | SingletonCCS CostCentre - deriving (Eq, Ord, Data) -- needed for Ord on CLabel + deriving (Eq, Ord) -- needed for Ord on CLabel -- synonym for triple which describes the cost centre info in the generated diff --git a/compiler/GHC/Types/Id/Info.hs b/compiler/GHC/Types/Id/Info.hs index 743eb7bf86..edd1ba0da0 100644 --- a/compiler/GHC/Types/Id/Info.hs +++ b/compiler/GHC/Types/Id/Info.hs @@ -13,7 +13,6 @@ Haskell. [WDP 94/11]) {-# LANGUAGE BinaryLiterals #-} {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Types.Id.Info ( -- * The IdDetails type @@ -110,7 +109,6 @@ import GHC.Stg.InferTags.TagSig import Data.Word import GHC.StgToCmm.Types (LambdaFormInfo) -import Data.Data (Data) -- infixl so you can say (id `set` a `set` b) infixl 1 `setRuleInfo`, @@ -721,7 +719,7 @@ data CafInfo | NoCafRefs -- ^ A function or static constructor -- that refers to no CAFs. - deriving (Eq, Ord, Data) + deriving (Eq, Ord) -- | Assumes that the 'Id' has CAF references: definitely safe vanillaCafInfo :: CafInfo diff --git a/compiler/GHC/Types/Rep/Virtual.hs b/compiler/GHC/Types/Rep/Virtual.hs deleted file mode 100644 index d86c8444de..0000000000 --- a/compiler/GHC/Types/Rep/Virtual.hs +++ /dev/null @@ -1,120 +0,0 @@ - -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE InstanceSigs #-} - -module GHC.Types.Rep.Virtual - ( - isVirtualTyCon, isVirtualDataCon, virtualDataConType, VirtualConType(..) - ) where - -import GHC.Prelude - -import GHC.Types.RepType -import GHC.Core.DataCon -import GHC.Core.TyCon -import GHC.Core.TyCo.Rep -import GHC.Core.Type - -import GHC.Utils.Misc -import GHC.Utils.Outputable - -import GHC.Utils.Trace -import GHC.Builtin.Types.Prim - -{- ********************************************************************** -* * - Virtual Data Con stuff -* * -********************************************************************** -} - -data VirtualConType = VirtualBoxed -- ^ These have a regular pointer tag - | VirtualUnboxedHeap -- ^ ByteArray# and friends. These don't usually have pointers. - | NonVirtual -- ^ Can't be shorted out. - deriving (Eq,Show) - -instance Outputable VirtualConType where - ppr :: VirtualConType -> SDoc - ppr = text . show - -isVirtualDataCon :: DataCon -> Bool -isVirtualDataCon con = virtualDataConType con /= NonVirtual - -virtualDataConType :: DataCon -> VirtualConType -virtualDataConType = isVirtualTyCon . dataConTyCon - --- Is this unlifted type a fixed unboxed heap object type -isUnboxedVirtualTyCon :: TyCon -> Bool -isUnboxedVirtualTyCon tc - | tc `elem` - -- These are heap objects who naturally have pointer tag zero. - [ arrayPrimTyCon - , byteArrayPrimTyCon - , smallArrayPrimTyCon - , mutableArrayPrimTyCon - , mutableByteArrayPrimTyCon - , smallMutableArrayPrimTyCon - , mVarPrimTyCon - , ioPortPrimTyCon - , tVarPrimTyCon - , mutVarPrimTyCon - - -- For these below I'm not sure about - -- their representation. - -- , weakPrimTyCon - -- , stablePtrPrimTyCon - -- , stableNamePrimTyCon - -- , compactPrimTyCon - -- , stackSnapshotPrimTyCon - -- , promptTagPrimTyCon - - -- , tYPETyCon - -- , funTyCon - ] - = True - | otherwise = False - -isVirtualTyCon :: HasDebugCallStack => TyCon -> VirtualConType -isVirtualTyCon tc - -- Exactly one constructor - | [dc] <- tyConDataCons tc - -- No (runtime) constraints - , [] <- filter (not . isZeroBitTy) (dataConOtherTheta dc) - -- , pprTrace "isV.2" (ppr dc <> text ":" <> ppr tc) True - --Exactly one non-void field argument - , rep_bangs <- dataConRepStrictness dc - , rep_tys <- dataConRepArgTys dc - , all (tyHasFixedRuntimeRep) $ map scaledThing rep_tys - -- , pprTrace "args,bangs" (ppr rep_bangs <> ppr rep_tys) True - , [(field :: Type, strictness)] <- filter (not . isZeroBitTy . fst) $ - zipWithEqual "isVirtualTyCon" (\a b -> (scaledThing a, b)) - (rep_tys) (rep_bangs) - , pprTrace "isV.3" empty True - -- That field is boxed - , isBoxedType field - , pprTrace "isV.4" empty True - -- And it's a boxed ADT! - , isBoxedType (dataConOrigResTy dc) - -- The field is either unlifted boxed or strict - = if (isUnliftedType field) - then - isSafeUnlifted field - else - isSafeLifted strictness - -- , pprTrace "isV.7" empty True - -- -- Result is boxed - -- = pprTrace "foundVirtualCon:" (ppr dc <> text ":" <> ppr tc <> text "@" <> ppr field) True - | otherwise = NonVirtual - where - isSafeLifted strictness = case strictness of MarkedStrict -> pprTrace "safeBoxed" (ppr tc) VirtualBoxed; _ -> NonVirtual - - isSafeUnlifted field - | Just field_tc <- tyConAppTyCon_maybe field - -- , pprTrace "ftc" (ppr field_tc) True - , isDataTyCon field_tc - = pprTrace "safeBoxedU" (ppr tc) VirtualBoxed - | Just field_tc <- tyConAppTyCon_maybe field - , isUnboxedVirtualTyCon field_tc - = pprTrace "safeUnboxed" (ppr tc) VirtualUnboxedHeap - -- = NonVirtual - -- TODO: Hashmaps etc. - | otherwise = NonVirtual diff --git a/compiler/GHC/Types/RepType.hs b/compiler/GHC/Types/RepType.hs index 4d4a797380..c5c92fefb9 100644 --- a/compiler/GHC/Types/RepType.hs +++ b/compiler/GHC/Types/RepType.hs @@ -23,11 +23,10 @@ module GHC.Types.RepType ubxSumRepType, layoutUbxSum, typeSlotTy, SlotTy (..), slotPrimRep, primRepSlot, - tyHasFixedRuntimeRep, - -- * Is this type known to be data? mightBeFunTy, + isVirtualTyCon, isVirtualDataCon, virtualDataConType, VirtualConType(..) ) where import GHC.Prelude @@ -62,6 +61,7 @@ import GHC.Utils.Panic import GHC.Utils.Panic.Plain import Data.List (sort) +import GHC.Utils.Trace import qualified Data.IntSet as IS {- ********************************************************************** @@ -700,3 +700,65 @@ mightBeFunTy ty | otherwise = True +------------------------------------------ +-- Virtual Data Con stuff +------------------------------------------ + +data VirtualConType = VirtualBoxed -- ^ These have a regular pointer tag + | VirtualUnboxed -- ^ ByteArray# and friends. These don't usually have pointers. + | NonVirtual -- ^ Can't be shorted out. + deriving (Eq,Show) + +instance Outputable VirtualConType where + ppr :: VirtualConType -> SDoc + ppr = text . show + +isVirtualDataCon :: DataCon -> Bool +isVirtualDataCon con = virtualDataConType con /= NonVirtual + +virtualDataConType :: DataCon -> VirtualConType +virtualDataConType = isVirtualTyCon . dataConTyCon + +isVirtualTyCon :: HasDebugCallStack => TyCon -> VirtualConType +isVirtualTyCon tc + -- Exactly one constructor + | [dc] <- tyConDataCons tc + -- No (runtime) constraints + , [] <- filter (not . isZeroBitTy) (dataConOtherTheta dc) + -- , pprTrace "isV.2" (ppr dc <> text ":" <> ppr tc) True + --Exactly one non-void field argument + , rep_bangs <- dataConRepStrictness dc + , rep_tys <- dataConRepArgTys dc + , all (tyHasFixedRuntimeRep) $ map scaledThing rep_tys + -- , pprTrace "args,bangs" (ppr rep_bangs <> ppr rep_tys) True + , [(field :: Type, strictness)] <- filter (not . isZeroBitTy . fst) $ + zipWithEqual "isVirtualTyCon" (\a b -> (scaledThing a, b)) + (rep_tys) (rep_bangs) + , pprTrace "isV.3" empty True + -- That field is boxed + , isBoxedType field + , pprTrace "isV.4" empty True + -- And it's a boxed ADT! + -- , pprTrace "isV.5" empty True + -- , pprTrace "isV.6" empty True + -- That field is either unlifted or strict + , isBoxedType (dataConOrigResTy dc) + = if (isUnliftedType field) + then + (\r -> pprTrace "safeUnlifted " (ppr tc <+> ppr r) r) (isSafeUnlifted field) + else + isSafeLifted strictness + -- , pprTrace "isV.7" empty True + -- -- Result is boxed + -- = pprTrace "foundVirtualCon:" (ppr dc <> text ":" <> ppr tc <> text "@" <> ppr field) True + | otherwise = NonVirtual + where + isSafeLifted strictness = case strictness of MarkedStrict -> VirtualBoxed; _ -> NonVirtual + + isSafeUnlifted field + | Just field_tc <- tyConAppTyCon_maybe field + -- , pprTrace "ftc" (ppr field_tc) True + , isDataTyCon field_tc + = VirtualBoxed + -- TODO: Hashmaps etc. + | otherwise = NonVirtual diff --git a/compiler/GHC/Types/Unique.hs b/compiler/GHC/Types/Unique.hs index e86139c9d5..60d1c452e2 100644 --- a/compiler/GHC/Types/Unique.hs +++ b/compiler/GHC/Types/Unique.hs @@ -19,7 +19,6 @@ Haskell). {-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns, MagicHash #-} -{-# LANGUAGE DeriveDataTypeable #-} module GHC.Types.Unique ( -- * Main data types @@ -61,7 +60,6 @@ import GHC.Exts (indexCharOffAddr#, Char(..), Int(..)) import Data.Char ( chr, ord ) import Language.Haskell.Syntax.Module.Name -import Data.Data (Data) {- ************************************************************************ @@ -93,7 +91,7 @@ GHC.Builtin.Uniques. See Note [Uniques for wired-in prelude things and known mas -- the functions from the 'UniqSupply' module -- -- These are sometimes also referred to as \"keys\" in comments in GHC. -newtype Unique = MkUnique Int deriving Data +newtype Unique = MkUnique Int {-# INLINE uNIQUE_BITS #-} uNIQUE_BITS :: Int diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index 5a2e93ec91..0ac1080c65 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -732,7 +732,6 @@ Library GHC.Types.PkgQual GHC.Types.ProfAuto GHC.Types.RepType - GHC.Types.Rep.Virtual GHC.Types.SafeHaskell GHC.Types.SourceError GHC.Types.SourceFile |