-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The GHC API, decoupled from GHC versions -- -- A package equivalent to the ghc package, but which can be -- loaded on many compiler versions. @package ghc-lib @version 0.20220401 module GHC.Builtin.Names.TH templateHaskellNames :: [Name] thSyn :: Module thLib :: Module qqLib :: Module mkTHModule :: FastString -> Module libFun :: FastString -> Unique -> Name libTc :: FastString -> Unique -> Name thFun :: FastString -> Unique -> Name thTc :: FastString -> Unique -> Name thCls :: FastString -> Unique -> Name thCon :: FastString -> Unique -> Name qqFun :: FastString -> Unique -> Name liftClassName :: Name quoteClassName :: Name qTyConName :: Name nameTyConName :: Name fieldExpTyConName :: Name patTyConName :: Name fieldPatTyConName :: Name expTyConName :: Name decTyConName :: Name typeTyConName :: Name matchTyConName :: Name clauseTyConName :: Name funDepTyConName :: Name predTyConName :: Name codeTyConName :: Name injAnnTyConName :: Name overlapTyConName :: Name decsTyConName :: Name modNameTyConName :: Name returnQName :: Name bindQName :: Name sequenceQName :: Name newNameName :: Name liftName :: Name mkNameName :: Name mkNameG_vName :: Name mkNameG_dName :: Name mkNameG_tcName :: Name mkNameLName :: Name mkNameSName :: Name liftStringName :: Name unTypeName :: Name unTypeCodeName :: Name unsafeCodeCoerceName :: Name liftTypedName :: Name mkModNameName :: Name charLName :: Name stringLName :: Name integerLName :: Name intPrimLName :: Name wordPrimLName :: Name floatPrimLName :: Name doublePrimLName :: Name rationalLName :: Name stringPrimLName :: Name charPrimLName :: Name litPName :: Name varPName :: Name tupPName :: Name unboxedTupPName :: Name unboxedSumPName :: Name conPName :: Name infixPName :: Name tildePName :: Name bangPName :: Name asPName :: Name wildPName :: Name recPName :: Name listPName :: Name sigPName :: Name viewPName :: Name fieldPatName :: Name matchName :: Name clauseName :: Name varEName :: Name conEName :: Name litEName :: Name appEName :: Name appTypeEName :: Name infixEName :: Name infixAppName :: Name sectionLName :: Name sectionRName :: Name lamEName :: Name lamCaseEName :: Name tupEName :: Name unboxedTupEName :: Name unboxedSumEName :: Name condEName :: Name multiIfEName :: Name letEName :: Name caseEName :: Name doEName :: Name mdoEName :: Name compEName :: Name staticEName :: Name unboundVarEName :: Name labelEName :: Name implicitParamVarEName :: Name getFieldEName :: Name projectionEName :: Name fromEName :: Name fromThenEName :: Name fromToEName :: Name fromThenToEName :: Name listEName :: Name sigEName :: Name recConEName :: Name recUpdEName :: Name fieldExpName :: Name guardedBName :: Name normalBName :: Name normalGEName :: Name patGEName :: Name bindSName :: Name letSName :: Name noBindSName :: Name parSName :: Name recSName :: Name funDName :: Name valDName :: Name dataDName :: Name newtypeDName :: Name tySynDName :: Name classDName :: Name instanceWithOverlapDName :: Name sigDName :: Name kiSigDName :: Name forImpDName :: Name pragInlDName :: Name pragSpecDName :: Name pragSpecInlDName :: Name pragSpecInstDName :: Name pragRuleDName :: Name pragAnnDName :: Name standaloneDerivWithStrategyDName :: Name defaultSigDName :: Name defaultDName :: Name dataInstDName :: Name newtypeInstDName :: Name tySynInstDName :: Name dataFamilyDName :: Name openTypeFamilyDName :: Name closedTypeFamilyDName :: Name infixLDName :: Name infixRDName :: Name infixNDName :: Name roleAnnotDName :: Name patSynDName :: Name patSynSigDName :: Name pragCompleteDName :: Name implicitParamBindDName :: Name cxtName :: Name noSourceUnpackednessName :: Name sourceNoUnpackName :: Name sourceUnpackName :: Name noSourceStrictnessName :: Name sourceLazyName :: Name sourceStrictName :: Name normalCName :: Name recCName :: Name infixCName :: Name forallCName :: Name gadtCName :: Name recGadtCName :: Name bangName :: Name bangTypeName :: Name varBangTypeName :: Name unidirPatSynName :: Name implBidirPatSynName :: Name explBidirPatSynName :: Name prefixPatSynName :: Name infixPatSynName :: Name recordPatSynName :: Name forallTName :: Name forallVisTName :: Name varTName :: Name conTName :: Name infixTName :: Name tupleTName :: Name unboxedTupleTName :: Name unboxedSumTName :: Name arrowTName :: Name mulArrowTName :: Name listTName :: Name appTName :: Name appKindTName :: Name sigTName :: Name equalityTName :: Name litTName :: Name promotedTName :: Name promotedTupleTName :: Name promotedNilTName :: Name promotedConsTName :: Name wildCardTName :: Name implicitParamTName :: Name numTyLitName :: Name strTyLitName :: Name charTyLitName :: Name plainTVName :: Name kindedTVName :: Name plainInvisTVName :: Name kindedInvisTVName :: Name specifiedSpecName :: Name inferredSpecName :: Name nominalRName :: Name representationalRName :: Name phantomRName :: Name inferRName :: Name starKName :: Name constraintKName :: Name noSigName :: Name kindSigName :: Name tyVarSigName :: Name injectivityAnnName :: Name cCallName :: Name stdCallName :: Name cApiCallName :: Name primCallName :: Name javaScriptCallName :: Name unsafeName :: Name safeName :: Name interruptibleName :: Name ruleVarName :: Name typedRuleVarName :: Name funDepName :: Name tySynEqnName :: Name valueAnnotationName :: Name typeAnnotationName :: Name moduleAnnotationName :: Name derivClauseName :: Name stockStrategyName :: Name anyclassStrategyName :: Name newtypeStrategyName :: Name viaStrategyName :: Name patQTyConName :: Name expQTyConName :: Name stmtTyConName :: Name conTyConName :: Name bangTypeTyConName :: Name varBangTypeTyConName :: Name typeQTyConName :: Name decsQTyConName :: Name ruleBndrTyConName :: Name tySynEqnTyConName :: Name roleTyConName :: Name derivClauseTyConName :: Name kindTyConName :: Name tyVarBndrUnitTyConName :: Name tyVarBndrSpecTyConName :: Name derivStrategyTyConName :: Name quoteExpName :: Name quotePatName :: Name quoteDecName :: Name quoteTypeName :: Name noInlineDataConName :: Name inlineDataConName :: Name inlinableDataConName :: Name opaqueDataConName :: Name conLikeDataConName :: Name funLikeDataConName :: Name allPhasesDataConName :: Name fromPhaseDataConName :: Name beforePhaseDataConName :: Name overlappableDataConName :: Name overlappingDataConName :: Name overlapsDataConName :: Name incoherentDataConName :: Name liftClassKey :: Unique quoteClassKey :: Unique expTyConKey :: Unique matchTyConKey :: Unique clauseTyConKey :: Unique qTyConKey :: Unique expQTyConKey :: Unique patTyConKey :: Unique stmtTyConKey :: Unique conTyConKey :: Unique typeQTyConKey :: Unique typeTyConKey :: Unique tyVarBndrUnitTyConKey :: Unique tyVarBndrSpecTyConKey :: Unique decTyConKey :: Unique bangTypeTyConKey :: Unique varBangTypeTyConKey :: Unique fieldExpTyConKey :: Unique fieldPatTyConKey :: Unique nameTyConKey :: Unique patQTyConKey :: Unique funDepTyConKey :: Unique predTyConKey :: Unique predQTyConKey :: Unique decsQTyConKey :: Unique ruleBndrTyConKey :: Unique tySynEqnTyConKey :: Unique roleTyConKey :: Unique codeTyConKey :: Unique injAnnTyConKey :: Unique kindTyConKey :: Unique overlapTyConKey :: Unique derivClauseTyConKey :: Unique derivStrategyTyConKey :: Unique decsTyConKey :: Unique modNameTyConKey :: Unique noInlineDataConKey :: Unique inlineDataConKey :: Unique inlinableDataConKey :: Unique opaqueDataConKey :: Unique conLikeDataConKey :: Unique funLikeDataConKey :: Unique allPhasesDataConKey :: Unique fromPhaseDataConKey :: Unique beforePhaseDataConKey :: Unique overlappableDataConKey :: Unique overlappingDataConKey :: Unique overlapsDataConKey :: Unique incoherentDataConKey :: Unique returnQIdKey :: Unique bindQIdKey :: Unique sequenceQIdKey :: Unique liftIdKey :: Unique newNameIdKey :: Unique mkNameIdKey :: Unique mkNameG_vIdKey :: Unique mkNameG_dIdKey :: Unique mkNameG_tcIdKey :: Unique mkNameLIdKey :: Unique mkNameSIdKey :: Unique unTypeIdKey :: Unique unTypeCodeIdKey :: Unique unsafeCodeCoerceIdKey :: Unique liftTypedIdKey :: Unique mkModNameIdKey :: Unique charLIdKey :: Unique stringLIdKey :: Unique integerLIdKey :: Unique intPrimLIdKey :: Unique wordPrimLIdKey :: Unique floatPrimLIdKey :: Unique doublePrimLIdKey :: Unique rationalLIdKey :: Unique stringPrimLIdKey :: Unique charPrimLIdKey :: Unique liftStringIdKey :: Unique litPIdKey :: Unique varPIdKey :: Unique tupPIdKey :: Unique unboxedTupPIdKey :: Unique unboxedSumPIdKey :: Unique conPIdKey :: Unique infixPIdKey :: Unique tildePIdKey :: Unique bangPIdKey :: Unique asPIdKey :: Unique wildPIdKey :: Unique recPIdKey :: Unique listPIdKey :: Unique sigPIdKey :: Unique viewPIdKey :: Unique fieldPatIdKey :: Unique matchIdKey :: Unique clauseIdKey :: Unique varEIdKey :: Unique conEIdKey :: Unique litEIdKey :: Unique appEIdKey :: Unique appTypeEIdKey :: Unique infixEIdKey :: Unique infixAppIdKey :: Unique sectionLIdKey :: Unique sectionRIdKey :: Unique lamEIdKey :: Unique lamCaseEIdKey :: Unique tupEIdKey :: Unique unboxedTupEIdKey :: Unique unboxedSumEIdKey :: Unique condEIdKey :: Unique multiIfEIdKey :: Unique letEIdKey :: Unique caseEIdKey :: Unique doEIdKey :: Unique compEIdKey :: Unique fromEIdKey :: Unique fromThenEIdKey :: Unique fromToEIdKey :: Unique fromThenToEIdKey :: Unique listEIdKey :: Unique sigEIdKey :: Unique recConEIdKey :: Unique recUpdEIdKey :: Unique staticEIdKey :: Unique unboundVarEIdKey :: Unique labelEIdKey :: Unique implicitParamVarEIdKey :: Unique mdoEIdKey :: Unique getFieldEIdKey :: Unique projectionEIdKey :: Unique fieldExpIdKey :: Unique guardedBIdKey :: Unique normalBIdKey :: Unique normalGEIdKey :: Unique patGEIdKey :: Unique bindSIdKey :: Unique letSIdKey :: Unique noBindSIdKey :: Unique parSIdKey :: Unique recSIdKey :: Unique funDIdKey :: Unique valDIdKey :: Unique dataDIdKey :: Unique newtypeDIdKey :: Unique tySynDIdKey :: Unique classDIdKey :: Unique instanceWithOverlapDIdKey :: Unique instanceDIdKey :: Unique sigDIdKey :: Unique forImpDIdKey :: Unique pragInlDIdKey :: Unique pragSpecDIdKey :: Unique pragSpecInlDIdKey :: Unique pragSpecInstDIdKey :: Unique pragRuleDIdKey :: Unique pragAnnDIdKey :: Unique defaultSigDIdKey :: Unique dataFamilyDIdKey :: Unique openTypeFamilyDIdKey :: Unique closedTypeFamilyDIdKey :: Unique dataInstDIdKey :: Unique newtypeInstDIdKey :: Unique tySynInstDIdKey :: Unique standaloneDerivWithStrategyDIdKey :: Unique infixLDIdKey :: Unique infixRDIdKey :: Unique infixNDIdKey :: Unique roleAnnotDIdKey :: Unique patSynDIdKey :: Unique patSynSigDIdKey :: Unique pragCompleteDIdKey :: Unique implicitParamBindDIdKey :: Unique kiSigDIdKey :: Unique defaultDIdKey :: Unique cxtIdKey :: Unique noSourceUnpackednessKey :: Unique sourceNoUnpackKey :: Unique sourceUnpackKey :: Unique noSourceStrictnessKey :: Unique sourceLazyKey :: Unique sourceStrictKey :: Unique normalCIdKey :: Unique recCIdKey :: Unique infixCIdKey :: Unique forallCIdKey :: Unique gadtCIdKey :: Unique recGadtCIdKey :: Unique bangIdKey :: Unique bangTKey :: Unique varBangTKey :: Unique unidirPatSynIdKey :: Unique implBidirPatSynIdKey :: Unique explBidirPatSynIdKey :: Unique prefixPatSynIdKey :: Unique infixPatSynIdKey :: Unique recordPatSynIdKey :: Unique forallTIdKey :: Unique forallVisTIdKey :: Unique varTIdKey :: Unique conTIdKey :: Unique tupleTIdKey :: Unique unboxedTupleTIdKey :: Unique unboxedSumTIdKey :: Unique arrowTIdKey :: Unique listTIdKey :: Unique appTIdKey :: Unique appKindTIdKey :: Unique sigTIdKey :: Unique equalityTIdKey :: Unique litTIdKey :: Unique promotedTIdKey :: Unique promotedTupleTIdKey :: Unique promotedNilTIdKey :: Unique promotedConsTIdKey :: Unique wildCardTIdKey :: Unique implicitParamTIdKey :: Unique infixTIdKey :: Unique numTyLitIdKey :: Unique strTyLitIdKey :: Unique charTyLitIdKey :: Unique plainTVIdKey :: Unique kindedTVIdKey :: Unique plainInvisTVIdKey :: Unique kindedInvisTVIdKey :: Unique nominalRIdKey :: Unique representationalRIdKey :: Unique phantomRIdKey :: Unique inferRIdKey :: Unique starKIdKey :: Unique constraintKIdKey :: Unique noSigIdKey :: Unique kindSigIdKey :: Unique tyVarSigIdKey :: Unique injectivityAnnIdKey :: Unique cCallIdKey :: Unique stdCallIdKey :: Unique cApiCallIdKey :: Unique primCallIdKey :: Unique javaScriptCallIdKey :: Unique unsafeIdKey :: Unique safeIdKey :: Unique interruptibleIdKey :: Unique funDepIdKey :: Unique mulArrowTIdKey :: Unique tySynEqnIdKey :: Unique quoteExpKey :: Unique quotePatKey :: Unique quoteDecKey :: Unique quoteTypeKey :: Unique ruleVarIdKey :: Unique typedRuleVarIdKey :: Unique valueAnnotationIdKey :: Unique typeAnnotationIdKey :: Unique moduleAnnotationIdKey :: Unique derivClauseIdKey :: Unique stockStrategyIdKey :: Unique anyclassStrategyIdKey :: Unique newtypeStrategyIdKey :: Unique viaStrategyIdKey :: Unique specifiedSpecKey :: Unique inferredSpecKey :: Unique lift_RDR :: RdrName liftTyped_RDR :: RdrName mkNameG_dRDR :: RdrName mkNameG_vRDR :: RdrName unsafeCodeCoerce_RDR :: RdrName conE_RDR :: RdrName litE_RDR :: RdrName appE_RDR :: RdrName infixApp_RDR :: RdrName stringL_RDR :: RdrName intPrimL_RDR :: RdrName wordPrimL_RDR :: RdrName floatPrimL_RDR :: RdrName doublePrimL_RDR :: RdrName stringPrimL_RDR :: RdrName charPrimL_RDR :: RdrName module GHC.Builtin.Types.Literals typeNatTyCons :: [TyCon] typeNatCoAxiomRules :: UniqFM FastString CoAxiomRule data BuiltInSynFamily BuiltInSynFamily :: ([Type] -> Maybe (CoAxiomRule, [Type], Type)) -> ([Type] -> Type -> [TypeEqn]) -> ([Type] -> Type -> [Type] -> Type -> [TypeEqn]) -> BuiltInSynFamily [sfMatchFam] :: BuiltInSynFamily -> [Type] -> Maybe (CoAxiomRule, [Type], Type) [sfInteractTop] :: BuiltInSynFamily -> [Type] -> Type -> [TypeEqn] [sfInteractInert] :: BuiltInSynFamily -> [Type] -> Type -> [Type] -> Type -> [TypeEqn] typeNatAddTyCon :: TyCon typeNatMulTyCon :: TyCon typeNatExpTyCon :: TyCon typeNatSubTyCon :: TyCon typeNatDivTyCon :: TyCon typeNatModTyCon :: TyCon typeNatLogTyCon :: TyCon typeNatCmpTyCon :: TyCon typeSymbolCmpTyCon :: TyCon typeSymbolAppendTyCon :: TyCon typeCharCmpTyCon :: TyCon typeConsSymbolTyCon :: TyCon typeUnconsSymbolTyCon :: TyCon typeCharToNatTyCon :: TyCon typeNatToCharTyCon :: TyCon -- | The GHC.Builtin.Utils interface to the compiler's prelude -- knowledge. -- -- This module serves as the central gathering point for names which the -- compiler knows something about. This includes functions for, -- -- -- -- See Note [Known-key names] and Note [About wired-in things] for -- information about the two types of prelude things in GHC. module GHC.Builtin.Utils -- | Is a Name known-key? isKnownKeyName :: Name -> Bool -- | Given a Unique lookup its associated Name if it -- corresponds to a known-key thing. lookupKnownKeyName :: Unique -> Maybe Name -- | Given a Unique lookup any associated arbitrary SDoc's to be -- displayed by GHCi's ':info' command. lookupKnownNameInfo :: Name -> SDoc -- | This list is used to ensure that when you say "Prelude.map" in your -- source code, or in an interface file, you get a Name with the correct -- known key (See Note [Known-key names] in GHC.Builtin.Names) knownKeyNames :: [Name] wiredInIds :: [Id] ghcPrimIds :: [Id] ghcPrimExports :: [IfaceExport] ghcPrimDeclDocs :: Docs maybeCharLikeCon :: DataCon -> Bool maybeIntLikeCon :: DataCon -> Bool isNumericClass :: Class -> Bool isStandardClass :: Class -> Bool -- | Bytecode assembler and linker module GHC.ByteCode.Linker type ClosureEnv = NameEnv (Name, ForeignHValue) emptyClosureEnv :: ClosureEnv extendClosureEnv :: ClosureEnv -> [(Name, ForeignHValue)] -> ClosureEnv linkBCO :: Interp -> ItblEnv -> ClosureEnv -> NameEnv Int -> RemoteRef BreakArray -> UnlinkedBCO -> IO ResolvedBCO lookupStaticPtr :: Interp -> FastString -> IO (Ptr ()) lookupIE :: Interp -> ItblEnv -> Name -> IO (Ptr ()) nameToCLabel :: Name -> String -> FastString linkFail :: String -> String -> IO a -- | Cmm compilation configuration module GHC.Cmm.Config data CmmConfig CmmConfig :: !Profile -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> CmmConfig -- | Target Profile [cmmProfile] :: CmmConfig -> !Profile -- | Optimize Cmm Control Flow or not [cmmOptControlFlow] :: CmmConfig -> !Bool -- | Do Cmm Linting Optimization or not [cmmDoLinting] :: CmmConfig -> !Bool -- | Eliminate common blocks or not [cmmOptElimCommonBlks] :: CmmConfig -> !Bool -- | Perform sink after stack layout or not [cmmOptSink] :: CmmConfig -> !Bool -- | Generate stack unwinding instructions (for debugging) [cmmGenStackUnwindInstr] :: CmmConfig -> !Bool -- | Generate code to link against dynamic libraries [cmmExternalDynamicRefs] :: CmmConfig -> !Bool -- | Should the Cmm pass replace Stg switch statements [cmmDoCmmSwitchPlans] :: CmmConfig -> !Bool -- | Should Cmm split proc points or not [cmmSplitProcPoints] :: CmmConfig -> !Bool -- | retrieve the target Cmm platform cmmPlatform :: CmmConfig -> Platform module GHC.Cmm.Dataflow type C = 'Closed type O = 'Open -- | A sequence of nodes. May be any of four shapes (OO, OC, CO, -- CC). Open at the entry means single entry, mutatis mutandis for -- exit. A closedclosed block is a basic/ block and can't be -- extended further. Clients should avoid manipulating blocks and should -- stick to either nodes or graphs. data Block (n :: Extensibility -> Extensibility -> Type) (e :: Extensibility) (x :: Extensibility) lastNode :: forall n (x :: Extensibility). Block n x C -> n O C entryLabel :: forall (x :: Extensibility). NonLocal thing => thing C x -> Label -- | Folds backward over all nodes of an open-open block. Strict in the -- accumulator. foldNodesBwdOO :: (node O O -> f -> f) -> Block node O O -> f -> f -- | Folds backward over all the nodes of an open-open block and allows -- rewriting them. The accumulator is both the block of nodes and -- f (usually dataflow facts). Strict in both accumulated parts. foldRewriteNodesBwdOO :: forall f node. (node O O -> f -> UniqSM (Block node O O, f)) -> Block node O O -> f -> UniqSM (Block node O O, f) data DataflowLattice a DataflowLattice :: a -> JoinFun a -> DataflowLattice a [fact_bot] :: DataflowLattice a -> a [fact_join] :: DataflowLattice a -> JoinFun a newtype OldFact a OldFact :: a -> OldFact a newtype NewFact a NewFact :: a -> NewFact a -- | The result of joining OldFact and NewFact. data JoinedFact a -- | Result is different than OldFact. Changed :: !a -> JoinedFact a -- | Result is the same as OldFact. NotChanged :: !a -> JoinedFact a type TransferFun f = CmmBlock -> FactBase f -> FactBase f -- | Function for rewrtiting and analysis combined. To be used with -- rewriteCmm. -- -- Currently set to work with UniqSM monad, but we could -- probably abstract that away (if we do that, we might want to -- specialize the fixpoint algorithms to the particular monads through -- SPECIALIZE). type RewriteFun f = CmmBlock -> FactBase f -> UniqSM (CmmBlock, FactBase f) type family Fact (x :: Extensibility) f :: Type type FactBase f = LabelMap f getFact :: DataflowLattice f -> Label -> FactBase f -> f -- | Returns the joined facts for each label. mkFactBase :: DataflowLattice f -> [(Label, f)] -> FactBase f analyzeCmmFwd :: NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f analyzeCmmBwd :: NonLocal node => DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f rewriteCmmBwd :: NonLocal node => DataflowLattice f -> RewriteFun' node f -> GenCmmGraph node -> FactBase f -> UniqSM (GenCmmGraph node, FactBase f) changedIf :: Bool -> a -> JoinedFact a -- | Returns the result of joining the facts from all the successors of the -- provided node or block. joinOutFacts :: NonLocal n => DataflowLattice f -> n e C -> FactBase f -> f joinFacts :: DataflowLattice f -> [f] -> f -- | Utilities for dealing with constructors/destructors. module GHC.Cmm.InitFini data InitOrFini IsInitArray :: InitOrFini IsFiniArray :: InitOrFini isInitOrFiniArray :: RawCmmDecl -> Maybe (InitOrFini, [CLabel]) module GHC.Cmm.LRegSet type LRegSet = IntSet type LRegKey = Int emptyLRegSet :: LRegSet nullLRegSet :: LRegSet -> Bool insertLRegSet :: LocalReg -> LRegSet -> LRegSet elemLRegSet :: LocalReg -> LRegSet -> Bool deleteFromLRegSet :: LRegSet -> LocalReg -> LRegSet sizeLRegSet :: IntSet -> Int plusLRegSet :: IntSet -> IntSet -> IntSet elemsLRegSet :: IntSet -> [Int] module GHC.Cmm.Parser.Monad newtype PD a PD :: (DynFlags -> HomeUnit -> PState -> ParseResult a) -> PD a [unPD] :: PD a -> DynFlags -> HomeUnit -> PState -> ParseResult a liftP :: P a -> PD a failMsgPD :: (SrcSpan -> MsgEnvelope PsMessage) -> PD a getProfile :: PD Profile getPlatform :: PD Platform -- | Return the UnitId of the home-unit. This is used to create labels. getHomeUnitId :: PD UnitId instance GHC.Base.Functor GHC.Cmm.Parser.Monad.PD instance GHC.Base.Applicative GHC.Cmm.Parser.Monad.PD instance GHC.Base.Monad GHC.Cmm.Parser.Monad.PD instance GHC.Driver.Session.HasDynFlags GHC.Cmm.Parser.Monad.PD module GHC.Cmm.Lexer data CmmToken CmmT_SpecChar :: Char -> CmmToken CmmT_DotDot :: CmmToken CmmT_DoubleColon :: CmmToken CmmT_Shr :: CmmToken CmmT_Shl :: CmmToken CmmT_Ge :: CmmToken CmmT_Le :: CmmToken CmmT_Eq :: CmmToken CmmT_Ne :: CmmToken CmmT_BoolAnd :: CmmToken CmmT_BoolOr :: CmmToken CmmT_CLOSURE :: CmmToken CmmT_INFO_TABLE :: CmmToken CmmT_INFO_TABLE_RET :: CmmToken CmmT_INFO_TABLE_FUN :: CmmToken CmmT_INFO_TABLE_CONSTR :: CmmToken CmmT_INFO_TABLE_SELECTOR :: CmmToken CmmT_else :: CmmToken CmmT_export :: CmmToken CmmT_section :: CmmToken CmmT_goto :: CmmToken CmmT_if :: CmmToken CmmT_call :: CmmToken CmmT_jump :: CmmToken CmmT_foreign :: CmmToken CmmT_never :: CmmToken CmmT_prim :: CmmToken CmmT_reserve :: CmmToken CmmT_return :: CmmToken CmmT_returns :: CmmToken CmmT_import :: CmmToken CmmT_switch :: CmmToken CmmT_case :: CmmToken CmmT_default :: CmmToken CmmT_push :: CmmToken CmmT_unwind :: CmmToken CmmT_bits8 :: CmmToken CmmT_bits16 :: CmmToken CmmT_bits32 :: CmmToken CmmT_bits64 :: CmmToken CmmT_bits128 :: CmmToken CmmT_bits256 :: CmmToken CmmT_bits512 :: CmmToken CmmT_float32 :: CmmToken CmmT_float64 :: CmmToken CmmT_gcptr :: CmmToken CmmT_GlobalReg :: GlobalReg -> CmmToken CmmT_Name :: FastString -> CmmToken CmmT_String :: String -> CmmToken CmmT_Int :: Integer -> CmmToken CmmT_Float :: Rational -> CmmToken CmmT_EOF :: CmmToken CmmT_False :: CmmToken CmmT_True :: CmmToken CmmT_likely :: CmmToken cmmlex :: (Located CmmToken -> PD a) -> PD a instance GHC.Show.Show GHC.Cmm.Lexer.CmmToken module GHC.Cmm.Ppr.Expr pprExpr :: Platform -> CmmExpr -> SDoc pprLit :: Platform -> CmmLit -> SDoc instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Expr.CmmExpr instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.CmmReg instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Expr.CmmLit instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.LocalReg instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.Area instance GHC.Utils.Outputable.Outputable GHC.Cmm.Expr.GlobalReg instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.Expr.GlobalReg module GHC.Cmm.Ppr.Decl pprCmms :: (OutputableP Platform info, OutputableP Platform g) => Platform -> [GenCmmGroup RawCmmStatics info g] -> SDoc pprCmmGroup :: (OutputableP Platform d, OutputableP Platform info, OutputableP Platform g) => Platform -> GenCmmGroup d info g -> SDoc pprSection :: Platform -> Section -> SDoc pprStatic :: Platform -> CmmStatic -> SDoc instance (GHC.Utils.Outputable.OutputableP GHC.Platform.Platform d, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform info, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform i) => GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.GenCmmDecl d info i) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.GenCmmStatics a) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmStatic instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmInfoTable instance GHC.Utils.Outputable.Outputable GHC.Cmm.Type.ForeignHint module GHC.Cmm.Liveness type CmmLocalLive = CmmLive LocalReg -- | Calculated liveness info for a CmmGraph cmmLocalLiveness :: Platform -> CmmGraph -> BlockEntryLiveness LocalReg cmmLocalLivenessL :: Platform -> CmmGraph -> BlockEntryLivenessL cmmGlobalLiveness :: Platform -> CmmGraph -> BlockEntryLiveness GlobalReg -- | The dataflow lattice liveLattice :: Ord r => DataflowLattice (CmmLive r) -- | The dataflow lattice liveLatticeL :: DataflowLattice LRegSet gen_kill :: (DefinerOfRegs r n, UserOfRegs r n) => Platform -> n -> CmmLive r -> CmmLive r gen_killL :: (DefinerOfRegs LocalReg n, UserOfRegs LocalReg n) => Platform -> n -> LRegSet -> LRegSet module GHC.Cmm.Utils primRepCmmType :: Platform -> PrimRep -> CmmType slotCmmType :: Platform -> SlotTy -> CmmType typeCmmType :: Platform -> UnaryType -> CmmType typeForeignHint :: UnaryType -> ForeignHint primRepForeignHint :: PrimRep -> ForeignHint zeroCLit :: Platform -> CmmLit mkIntCLit :: Platform -> Int -> CmmLit mkWordCLit :: Platform -> Integer -> CmmLit packHalfWordsCLit :: Platform -> StgHalfWord -> StgHalfWord -> CmmLit -- | We make a top-level decl for the string, and return a label pointing -- to it mkByteStringCLit :: CLabel -> ByteString -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) -- | We make a top-level decl for the embedded binary file, and return a -- label pointing to it mkFileEmbedLit :: CLabel -> FilePath -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) -- | Build a data-segment data block mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt mkStgWordCLit :: Platform -> StgWord -> CmmLit mkIntExpr :: Platform -> Int -> CmmExpr zeroExpr :: Platform -> CmmExpr mkLblExpr :: CLabel -> CmmExpr cmmRegOff :: CmmReg -> Int -> CmmExpr cmmOffset :: Platform -> CmmExpr -> Int -> CmmExpr cmmLabelOff :: CLabel -> Int -> CmmLit cmmOffsetLit :: CmmLit -> Int -> CmmLit cmmOffsetExpr :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr cmmOffsetB :: Platform -> CmmExpr -> ByteOff -> CmmExpr cmmLabelOffB :: CLabel -> ByteOff -> CmmLit cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit cmmOffsetExprB :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmRegOffW :: Platform -> CmmReg -> WordOff -> CmmExpr cmmOffsetW :: Platform -> CmmExpr -> WordOff -> CmmExpr cmmLabelOffW :: Platform -> CLabel -> WordOff -> CmmLit cmmOffsetLitW :: Platform -> CmmLit -> WordOff -> CmmLit cmmOffsetExprW :: Platform -> CmmExpr -> CmmExpr -> CmmExpr -- | Useful for creating an index into an array, with a statically known -- offset. The type is the element type; used for making the multiplier cmmIndex :: Platform -> Width -> CmmExpr -> Int -> CmmExpr -- | Useful for creating an index into an array, with an unknown offset. cmmIndexExpr :: Platform -> Width -> CmmExpr -> CmmExpr -> CmmExpr cmmLoadIndex :: Platform -> CmmType -> CmmExpr -> Int -> CmmExpr cmmLoadIndexW :: Platform -> CmmExpr -> Int -> CmmType -> CmmExpr -- | Load a naturally-aligned non-pointer word. cmmLoadBWord :: Platform -> CmmExpr -> CmmExpr -- | Load a naturally-aligned GC pointer. cmmLoadGCWord :: Platform -> CmmExpr -> CmmExpr cmmNegate :: Platform -> CmmExpr -> CmmExpr cmmULtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUGeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUGtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUShrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmSLtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmNeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmEqWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmOrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmAndWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmSubWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmAddWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmMulWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmQuotWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmToWord :: Platform -> CmmExpr -> CmmExpr cmmMkAssign :: Platform -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr) isTrivialCmmExpr :: CmmExpr -> Bool hasNoGlobalRegs :: CmmExpr -> Bool isLit :: CmmExpr -> Bool isComparisonExpr :: CmmExpr -> Bool baseExpr :: CmmExpr spExpr :: CmmExpr hpExpr :: CmmExpr spLimExpr :: CmmExpr hpLimExpr :: CmmExpr currentTSOExpr :: CmmExpr currentNurseryExpr :: CmmExpr cccsExpr :: CmmExpr cmmTagMask :: Platform -> CmmExpr cmmPointerMask :: Platform -> CmmExpr cmmUntag :: Platform -> CmmExpr -> CmmExpr cmmIsTagged :: Platform -> CmmExpr -> CmmExpr cmmIsNotTagged :: Platform -> CmmExpr -> CmmExpr cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr mAX_PTR_TAG :: Platform -> Int tAG_MASK :: Platform -> Int -- | Returns True if the two STG registers overlap on the specified -- platform, in the sense that writing to one will clobber the other. -- This includes the case that the two registers are the same STG -- register. See Note [Overlapping global registers] for details. regsOverlap :: Platform -> CmmReg -> CmmReg -> Bool -- | Returns True if the STG register is used by the expression, in the -- sense that a store to the register might affect the value of the -- expression. -- -- We must check for overlapping registers and not just equal registers -- here, otherwise CmmSink may incorrectly reorder assignments that -- conflict due to overlap. See #10521 and Note [Overlapping global -- registers]. regUsedIn :: Platform -> CmmReg -> CmmExpr -> Bool mkLiveness :: Platform -> [LocalReg] -> Liveness modifyGraph :: (Graph n C C -> Graph n' C C) -> GenCmmGraph n -> GenCmmGraph n' ofBlockMap :: BlockId -> LabelMap CmmBlock -> CmmGraph toBlockMap :: CmmGraph -> LabelMap CmmBlock ofBlockList :: BlockId -> [CmmBlock] -> CmmGraph toBlockList :: CmmGraph -> [CmmBlock] bodyToBlockList :: Body CmmNode -> [CmmBlock] -- | like toBlockList, but the entry block always comes first toBlockListEntryFirst :: CmmGraph -> [CmmBlock] -- | Like toBlockListEntryFirst, but we strive to ensure that we -- order blocks so that the false case of a conditional jumps to the next -- block in the output list of blocks. This matches the way OldCmm blocks -- were output since in OldCmm the false case was a fallthrough, whereas -- in Cmm conditional branches have both true and false successors. Block -- ordering can make a big difference in performance in the LLVM backend. -- Note that we rely crucially on the order of successors returned for -- CmmCondBranch by the NonLocal instance for CmmNode defined in -- GHC.Cmm.Node. -GBM toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock] foldlGraphBlocks :: (a -> CmmBlock -> a) -> a -> CmmGraph -> a mapGraphNodes :: (CmmNode C O -> CmmNode C O, CmmNode O O -> CmmNode O O, CmmNode O C -> CmmNode O C) -> CmmGraph -> CmmGraph revPostorder :: CmmGraph -> [CmmBlock] mapGraphNodes1 :: (forall e x. CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph -- | Extract all tick annotations from the given block blockTicks :: Block CmmNode C C -> [CmmTickish] module GHC.Cmm.Switch.Implement -- | Traverses the CmmGraph, making sure that CmmSwitch are -- suitable for code generation. cmmImplementSwitchPlans :: Platform -> CmmGraph -> UniqSM CmmGraph module GHC.Cmm.Ppr instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CLabel.InfoProvEnt instance GHC.Utils.Outputable.Outputable GHC.Cmm.CmmStackInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmTopInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Node.CmmNode e x) instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.Convention instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.ForeignConvention instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.Node.ForeignTarget instance GHC.Utils.Outputable.Outputable GHC.Cmm.Node.CmmReturnInfo instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.C GHC.Cmm.Dataflow.Block.C) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.C GHC.Cmm.Dataflow.Block.O) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.O GHC.Cmm.Dataflow.Block.C) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Block.Block GHC.Cmm.Node.CmmNode GHC.Cmm.Dataflow.Block.O GHC.Cmm.Dataflow.Block.O) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform (GHC.Cmm.Dataflow.Graph.Graph GHC.Cmm.Node.CmmNode e x) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.Cmm.CmmGraph module GHC.Cmm.CallConv data ParamLocation RegisterParam :: GlobalReg -> ParamLocation StackParam :: ByteOff -> ParamLocation -- | Given a list of arguments, and a function that tells their types, -- return a list showing where each argument is passed assignArgumentsPos :: Profile -> ByteOff -> Convention -> (a -> CmmType) -> [a] -> (ByteOff, [(a, ParamLocation)]) assignStack :: Platform -> ByteOff -> (a -> CmmType) -> [a] -> (ByteOff, [(a, ParamLocation)]) realArgRegsCover :: Platform -> [GlobalReg] tupleRegsCover :: Platform -> [GlobalReg] instance GHC.Utils.Outputable.Outputable GHC.Cmm.CallConv.ParamLocation module GHC.Cmm.Graph -- | CmmAGraph is a chunk of code consisting of: -- -- -- -- The semantics is that control falls through labels and out-of-line -- blocks. Everything after a jump up to the next label is by definition -- unreachable code, and will be discarded. -- -- Two CmmAGraphs can be stuck together with *, with the meaning -- that control flows from the first to the second. -- -- A CmmAGraph can be turned into a CmmGraph (closed at -- both ends) by providing a label for the entry point and a tick scope; -- see labelAGraph. type CmmAGraph = OrdList CgStmt -- | Unlabeled graph with tick scope type CmmAGraphScoped = (CmmAGraph, CmmTickScope) data CgStmt CgLabel :: BlockId -> CmmTickScope -> CgStmt CgStmt :: CmmNode O O -> CgStmt CgLast :: CmmNode O C -> CgStmt CgFork :: BlockId -> CmmAGraph -> CmmTickScope -> CgStmt (<*>) :: CmmAGraph -> CmmAGraph -> CmmAGraph catAGraphs :: [CmmAGraph] -> CmmAGraph -- | creates a sequence "goto id; id:" as an AGraph mkLabel :: BlockId -> CmmTickScope -> CmmAGraph -- | creates an open AGraph from a given node mkMiddle :: CmmNode O O -> CmmAGraph -- | creates a closed AGraph from a given node mkLast :: CmmNode O C -> CmmAGraph -- | A labelled code block; should end in a last node outOfLine :: BlockId -> CmmAGraphScoped -> CmmAGraph -- | allocate a fresh label for the entry point lgraphOfAGraph :: CmmAGraphScoped -> UniqSM CmmGraph -- | use the given BlockId as the label of the entry point labelAGraph :: BlockId -> CmmAGraphScoped -> CmmGraph stackStubExpr :: Width -> CmmExpr mkNop :: CmmAGraph mkAssign :: CmmReg -> CmmExpr -> CmmAGraph -- | Assumes natural alignment mkStore :: CmmExpr -> CmmExpr -> CmmAGraph mkUnsafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmAGraph mkFinalCall :: Profile -> CmmExpr -> CCallConv -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph mkCallReturnsTo :: Profile -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph mkJumpReturnsTo :: Profile -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> CmmAGraph mkJump :: Profile -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph mkJumpExtra :: Profile -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph -- | A jump where the caller says what the live GlobalRegs are. Used for -- low-level hand-written Cmm. mkRawJump :: Profile -> CmmExpr -> UpdFrameOffset -> [GlobalReg] -> CmmAGraph mkCbranch :: CmmExpr -> BlockId -> BlockId -> Maybe Bool -> CmmAGraph mkSwitch :: CmmExpr -> SwitchTargets -> CmmAGraph mkReturn :: Profile -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph mkComment :: FastString -> CmmAGraph mkCallEntry :: Profile -> Convention -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) mkBranch :: BlockId -> CmmAGraph -- | Construct a CmmUnwind node for the given register and unwinding -- expression. mkUnwind :: GlobalReg -> CmmExpr -> CmmAGraph copyInOflow :: Profile -> Convention -> Area -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) copyOutOflow :: Profile -> Convention -> Transfer -> Area -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> (Int, [GlobalReg], CmmAGraph) noExtraStack :: [CmmExpr] toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff -> ByteOff -> [GlobalReg] -> CmmAGraph data Transfer Call :: Transfer JumpRet :: Transfer Jump :: Transfer Ret :: Transfer instance GHC.Classes.Eq GHC.Cmm.Graph.Transfer module GHC.Cmm.Opt constantFoldNode :: Platform -> CmmNode e x -> CmmNode e x constantFoldExpr :: Platform -> CmmExpr -> CmmExpr cmmMachOpFold :: Platform -> MachOp -> [CmmExpr] -> CmmExpr cmmMachOpFoldM :: Platform -> MachOp -> [CmmExpr] -> Maybe CmmExpr module GHC.Cmm.Sink cmmSink :: Platform -> CmmGraph -> CmmGraph module GHC.Cmm.Lint cmmLint :: (OutputableP Platform d, OutputableP Platform h) => Platform -> GenCmmGroup d h CmmGraph -> Maybe SDoc cmmLintGraph :: Platform -> CmmGraph -> Maybe SDoc instance GHC.Base.Functor GHC.Cmm.Lint.CmmLint instance GHC.Base.Applicative GHC.Cmm.Lint.CmmLint instance GHC.Base.Monad GHC.Cmm.Lint.CmmLint module GHC.Cmm.DebugBlock -- | Debug information about a block of code. Ticks scope over nested -- blocks. data DebugBlock DebugBlock :: !Label -> !Label -> !CLabel -> !Bool -> !Maybe DebugBlock -> ![CmmTickish] -> !Maybe CmmTickish -> !Maybe Int -> [UnwindPoint] -> ![DebugBlock] -> DebugBlock -- | Entry label of containing proc [dblProcedure] :: DebugBlock -> !Label -- | Hoopl label [dblLabel] :: DebugBlock -> !Label -- | Output label [dblCLabel] :: DebugBlock -> !CLabel -- | Has an info table? [dblHasInfoTbl] :: DebugBlock -> !Bool -- | The parent of this proc. See Note [Splitting DebugBlocks] [dblParent] :: DebugBlock -> !Maybe DebugBlock -- | Ticks defined in this block [dblTicks] :: DebugBlock -> ![CmmTickish] -- | Best source tick covering block [dblSourceTick] :: DebugBlock -> !Maybe CmmTickish -- | Output position relative to other blocks. Nothing means the -- block was optimized out [dblPosition] :: DebugBlock -> !Maybe Int [dblUnwind] :: DebugBlock -> [UnwindPoint] -- | Nested blocks [dblBlocks] :: DebugBlock -> ![DebugBlock] -- | Extract debug data from a group of procedures. We will prefer source -- notes that come from the given module (presumably the module that we -- are currently compiling). cmmDebugGen :: ModLocation -> RawCmmGroup -> [DebugBlock] cmmDebugLabels :: (i -> Bool) -> GenCmmGroup d g (ListGraph i) -> [Label] -- | Sets position and unwind table fields in the debug block tree -- according to native generated code. cmmDebugLink :: [Label] -> LabelMap [UnwindPoint] -> [DebugBlock] -> [DebugBlock] -- | Converts debug blocks into a label map for easier lookups debugToMap :: [DebugBlock] -> LabelMap DebugBlock -- | Maps registers to expressions that yield their "old" values further up -- the stack. Most interesting for the stack pointer Sp, but -- might be useful to document saved registers, too. Note that a -- register's value will be Nothing when the register's previous -- value cannot be reconstructed. type UnwindTable = Map GlobalReg (Maybe UnwindExpr) -- | A label associated with an UnwindTable data UnwindPoint UnwindPoint :: !CLabel -> !UnwindTable -> UnwindPoint -- | Expressions, used for unwind information data UnwindExpr -- | literal value UwConst :: !Int -> UnwindExpr -- | register plus offset UwReg :: !GlobalReg -> !Int -> UnwindExpr -- | pointer dereferencing UwDeref :: UnwindExpr -> UnwindExpr UwLabel :: CLabel -> UnwindExpr UwPlus :: UnwindExpr -> UnwindExpr -> UnwindExpr UwMinus :: UnwindExpr -> UnwindExpr -> UnwindExpr UwTimes :: UnwindExpr -> UnwindExpr -> UnwindExpr -- | Conversion of Cmm expressions to unwind expressions. We check for -- unsupported operator usages and simplify the expression as far as -- possible. toUnwindExpr :: Platform -> CmmExpr -> UnwindExpr instance GHC.Classes.Eq GHC.Cmm.DebugBlock.UnwindExpr instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.DebugBlock instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.UnwindPoint instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.DebugBlock.UnwindExpr module GHC.Cmm.ContFlowOpt cmmCfgOpts :: Bool -> CmmGraph -> CmmGraph cmmCfgOptsProc :: Bool -> CmmDecl -> CmmDecl removeUnreachableBlocksProc :: CmmDecl -> CmmDecl replaceLabels :: LabelMap BlockId -> CmmGraph -> CmmGraph module GHC.Cmm.CommonBlockElim elimCommonBlocks :: CmmGraph -> CmmGraph module GHC.CmmToAsm.AArch64.Cond data Cond ALWAYS :: Cond EQ :: Cond NE :: Cond SLT :: Cond SLE :: Cond SGE :: Cond SGT :: Cond ULT :: Cond ULE :: Cond UGE :: Cond UGT :: Cond OLT :: Cond OLE :: Cond OGE :: Cond OGT :: Cond UOLT :: Cond UOLE :: Cond UOGE :: Cond UOGT :: Cond NEVER :: Cond VS :: Cond VC :: Cond instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Cond.Cond -- | The Lengauer-Tarjan graph dominators algorithm. -- -- <math> Lengauer, Tarjan, A Fast Algorithm for Finding -- Dominators in a Flowgraph, 1979. -- -- <math> Muchnick, Advanced Compiler Design and -- Implementation, 1997. -- -- <math> Brisk, Sarrafzadeh, Interference Graphs for Procedures -- in Static Single Information Form are Interval Graphs, -- 2007. -- -- -- -- Unless stated otherwise all exposed functions might fully evaluate -- their input but are not guaranteed to do so. module GHC.CmmToAsm.CFG.Dominators type Node = Int type Path = [Node] type Edge = (Node, Node) type Graph = IntMap IntSet type Rooted = (Node, Graph) -- | Immediate dominators. O(|E|*alpha(|E|,|V|)), where -- alpha(m,n) is "a functional inverse of Ackermann's function". -- -- This Complexity bound assumes O(1) indexing. Since we're using -- IntMap, it has an additional lg |V| factor somewhere -- in there. I'm not sure where. idom :: Rooted -> [(Node, Node)] -- | Immediate post-dominators. Complexity as for idom. ipdom :: Rooted -> [(Node, Node)] -- | Dominator tree. Complexity as for idom. domTree :: Rooted -> Tree Node -- | Post-dominator tree. Complexity as for idom. pdomTree :: Rooted -> Tree Node -- | Dominators. Complexity as for idom dom :: Rooted -> [(Node, Path)] -- | Post-dominators. Complexity as for idom. pdom :: Rooted -> [(Node, Path)] -- | Post-dominated depth-first search. pddfs :: Rooted -> [Node] -- | Reverse post-dominated depth-first search. rpddfs :: Rooted -> [Node] fromAdj :: [(Node, [Node])] -> Graph fromEdges :: [Edge] -> Graph toAdj :: Graph -> [(Node, [Node])] toEdges :: Graph -> [Edge] asTree :: Rooted -> Tree Node asGraph :: Tree Node -> Rooted parents :: Tree a -> [(a, a)] ancestors :: Tree a -> [(a, [a])] instance GHC.Base.Functor (GHC.CmmToAsm.CFG.Dominators.S z s) instance GHC.Base.Monad (GHC.CmmToAsm.CFG.Dominators.S z s) instance GHC.Base.Applicative (GHC.CmmToAsm.CFG.Dominators.S z s) -- | Generating C symbol names emitted by the compiler. module GHC.CmmToAsm.CPrim atomicReadLabel :: Width -> FastString atomicWriteLabel :: Width -> FastString atomicRMWLabel :: Width -> AtomicMachOp -> FastString cmpxchgLabel :: Width -> FastString xchgLabel :: Width -> FastString popCntLabel :: Width -> FastString pdepLabel :: Width -> FastString pextLabel :: Width -> FastString bSwapLabel :: Width -> FastString bRevLabel :: Width -> FastString clzLabel :: Width -> FastString ctzLabel :: Width -> FastString word2FloatLabel :: Width -> FastString -- | Native code generator configuration module GHC.CmmToAsm.Config -- | Native code generator configuration data NCGConfig NCGConfig :: !Platform -> !SDocContext -> !Module -> !Maybe Int -> !Bool -> !Bool -> !Word -> !Word -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> Maybe SseVersion -> Maybe BmiVersion -> !Bool -> !Bool -> !Bool -> !Weights -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> NCGConfig -- | Target platform [ncgPlatform] :: NCGConfig -> !Platform -- | Context for ASM code generation [ncgAsmContext] :: NCGConfig -> !SDocContext -- | The name of the module we are currently compiling [ncgThisModule] :: NCGConfig -> !Module -- | Mandatory proc alignment [ncgProcAlignment] :: NCGConfig -> !Maybe Int -- | Generate code to link against dynamic libraries [ncgExternalDynamicRefs] :: NCGConfig -> !Bool -- | Enable Position-Independent Code [ncgPIC] :: NCGConfig -> !Bool -- | If inlining memcpy produces less than this threshold (in -- pseudo-instruction unit), do it [ncgInlineThresholdMemcpy] :: NCGConfig -> !Word -- | Ditto for memset [ncgInlineThresholdMemset] :: NCGConfig -> !Word -- | Split sections [ncgSplitSections] :: NCGConfig -> !Bool [ncgRegsIterative] :: NCGConfig -> !Bool [ncgRegsGraph] :: NCGConfig -> !Bool -- | Perform ASM linting pass [ncgAsmLinting] :: NCGConfig -> !Bool -- | Perform CMM constant folding [ncgDoConstantFolding] :: NCGConfig -> !Bool -- | (x86) SSE instructions [ncgSseVersion] :: NCGConfig -> Maybe SseVersion -- | (x86) BMI instructions [ncgBmiVersion] :: NCGConfig -> Maybe BmiVersion [ncgDumpRegAllocStages] :: NCGConfig -> !Bool [ncgDumpAsmStats] :: NCGConfig -> !Bool [ncgDumpAsmConflicts] :: NCGConfig -> !Bool -- | CFG edge weights [ncgCfgWeights] :: NCGConfig -> !Weights -- | Use CFG based block layout algorithm [ncgCfgBlockLayout] :: NCGConfig -> !Bool -- | Layout based on last instruction per block. [ncgCfgWeightlessLayout] :: NCGConfig -> !Bool -- | Enable Dwarf generation [ncgDwarfEnabled] :: NCGConfig -> !Bool -- | Enable unwindings [ncgDwarfUnwindings] :: NCGConfig -> !Bool -- | Strip out block information from generated Dwarf [ncgDwarfStripBlockInfo] :: NCGConfig -> !Bool -- | Expose symbol table entries for internal symbols [ncgExposeInternalSymbols] :: NCGConfig -> !Bool -- | Enable GHC-specific source note DIEs [ncgDwarfSourceNotes] :: NCGConfig -> !Bool -- | Enable static control-flow prediction [ncgCmmStaticPred] :: NCGConfig -> !Bool -- | Enable shortcutting (don't jump to blocks only containing a jump) [ncgEnableShortcutting] :: NCGConfig -> !Bool -- | Compute block unwinding tables [ncgComputeUnwinding] :: NCGConfig -> !Bool -- | Whether to enable the dead-code elimination [ncgEnableDeadCodeElimination] :: NCGConfig -> !Bool -- | Return Word size ncgWordWidth :: NCGConfig -> Width -- | Size in bytes of the pre-allocated spill space on the C stack ncgSpillPreallocSize :: NCGConfig -> Int -- | Return Word size platformWordWidth :: Platform -> Width -- | Formats on this architecture A Format is a combination of width and -- class -- -- TODO: Signed vs unsigned? -- -- TODO: This module is currently shared by all architectures because -- NCGMonad need to know about it to make a VReg. It would be better to -- have architecture specific formats, and do the overloading properly. -- eg SPARC doesn't care about FF80. module GHC.CmmToAsm.Format data Format II8 :: Format II16 :: Format II32 :: Format II64 :: Format FF32 :: Format FF64 :: Format -- | Get the integer format of this width. intFormat :: Width -> Format -- | Get the float format of this width. floatFormat :: Width -> Format -- | Check if a format represent an integer value. isIntFormat :: Format -> Bool -- | Check if a format represents a floating point value. isFloatFormat :: Format -> Bool -- | Convert a Cmm type to a Format. cmmTypeFormat :: CmmType -> Format -- | Get the Width of a Format. formatToWidth :: Format -> Width formatInBytes :: Format -> Int instance GHC.Classes.Eq GHC.CmmToAsm.Format.Format instance GHC.Show.Show GHC.CmmToAsm.Format.Format module GHC.CmmToAsm.AArch64.Regs allMachRegNos :: [RegNo] allocatableRegs :: Platform -> [RealReg] allGpArgRegs :: [Reg] allFpArgRegs :: [Reg] data AddrMode AddrRegReg :: Reg -> Reg -> AddrMode AddrRegImm :: Reg -> Imm -> AddrMode AddrReg :: Reg -> AddrMode data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int mkVirtualReg :: Unique -> Format -> VirtualReg classOfRealReg :: RealReg -> RegClass regDotColor :: RealReg -> SDoc instance GHC.Show.Show GHC.CmmToAsm.AArch64.Regs.Imm instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Regs.Imm instance GHC.Show.Show GHC.CmmToAsm.AArch64.Regs.AddrMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Regs.AddrMode instance GHC.Show.Show GHC.Utils.Outputable.SDoc instance GHC.Classes.Eq GHC.Utils.Outputable.SDoc module GHC.CmmToAsm.Instr -- | Common things that we can do with instructions, on all architectures. -- These are used by the shared parts of the native code generator, -- specifically the register allocators. class Instruction instr -- | Get the registers that are being used by this instruction. regUsage -- doesn't need to do any trickery for jumps and such. Just state -- precisely the regs read and written by that insn. The consequences of -- control flow transfers, as far as register allocation goes, are taken -- care of by the register allocator. regUsageOfInstr :: Instruction instr => Platform -> instr -> RegUsage -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instruction instr => instr -> (Reg -> Reg) -> instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instruction instr => instr -> Bool -- | Give the possible destinations of this jump instruction. Must be -- defined for all jumpish instructions. jumpDestsOfInstr :: Instruction instr => instr -> [BlockId] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instruction instr => instr -> (BlockId -> BlockId) -> instr -- | An instruction to spill a register into a spill slot. mkSpillInstr :: Instruction instr => NCGConfig -> Reg -> Int -> Int -> [instr] -- | An instruction to reload a register from a spill slot. mkLoadInstr :: Instruction instr => NCGConfig -> Reg -> Int -> Int -> [instr] -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instruction instr => instr -> Maybe Int -- | Check whether this instruction is some meta thing inserted into the -- instruction stream for other purposes. -- -- Not something that has to be treated as a real machine instruction and -- have its registers allocated. -- -- eg, comments, delta, ldata, etc. isMetaInstr :: Instruction instr => instr -> Bool -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Instruction instr => Platform -> Reg -> Reg -> instr -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instruction instr => instr -> Maybe (Reg, Reg) -- | Make an unconditional jump instruction. For architectures with branch -- delay slots, its ok to put a NOP after the jump. Don't fill the delay -- slot with an instruction that references regs or you'll confuse the -- linear allocator. mkJumpInstr :: Instruction instr => BlockId -> [instr] mkStackAllocInstr :: Instruction instr => Platform -> Int -> [instr] mkStackDeallocInstr :: Instruction instr => Platform -> Int -> [instr] -- | Pretty-print an instruction pprInstr :: Instruction instr => Platform -> instr -> SDoc mkComment :: Instruction instr => SDoc -> [instr] -- | Holds a list of source and destination registers used by a particular -- instruction. -- -- Machine registers that are pre-allocated to stgRegs are filtered out, -- because they are uninteresting from a register allocation standpoint. -- (We wouldn't want them to end up on the free list!) -- -- As far as we are concerned, the fixed registers simply don't exist -- (for allocation purposes, anyway). data RegUsage RU :: [Reg] -> [Reg] -> RegUsage [reads] :: RegUsage -> [Reg] [writes] :: RegUsage -> [Reg] -- | No regs read or written to. noUsage :: RegUsage instance GHC.Show.Show GHC.CmmToAsm.Instr.RegUsage module GHC.CmmToAsm.PPC.Cond data Cond ALWAYS :: Cond EQQ :: Cond GE :: Cond GEU :: Cond GTT :: Cond GU :: Cond LE :: Cond LEU :: Cond LTT :: Cond LU :: Cond NE :: Cond condNegate :: Cond -> Cond condUnsigned :: Cond -> Bool instance GHC.Classes.Eq GHC.CmmToAsm.PPC.Cond.Cond module GHC.CmmToAsm.PPC.Regs -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int mkVirtualReg :: Unique -> Format -> VirtualReg regDotColor :: RealReg -> SDoc data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm LO :: Imm -> Imm HI :: Imm -> Imm HA :: Imm -> Imm HIGHERA :: Imm -> Imm HIGHESTA :: Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm data AddrMode AddrRegReg :: Reg -> Reg -> AddrMode AddrRegImm :: Reg -> Imm -> AddrMode addrOffset :: AddrMode -> Int -> Maybe AddrMode spRel :: Platform -> Int -> AddrMode argRegs :: RegNo -> [Reg] allArgRegs :: [Reg] callClobberedRegs :: Platform -> [Reg] allMachRegNos :: [RegNo] classOfRealReg :: RealReg -> RegClass showReg :: RegNo -> String toRegNo :: Reg -> RegNo allFPArgRegs :: Platform -> [Reg] fits16Bits :: Integral a => a -> Bool makeImmediate :: Integral a => Width -> Bool -> a -> Maybe Imm fReg :: Int -> RegNo r0 :: Reg sp :: Reg toc :: Reg r3 :: Reg r4 :: Reg r11 :: Reg r12 :: Reg r30 :: Reg tmpReg :: Platform -> Reg f1 :: Reg allocatableRegs :: Platform -> [RealReg] -- | Utils for calculating general worst, bound, squeese and free, -- functions. -- -- as per: "A Generalized Algorithm for Graph-Coloring Register -- Allocation" Michael Smith, Normal Ramsey, Glenn Holloway. PLDI 2004 -- -- These general versions are not used in GHC proper because they are too -- slow. Instead, hand written optimised versions are provided for each -- architecture in MachRegs*.hs -- -- This code is here because we can test the architecture specific code -- against it. module GHC.CmmToAsm.Reg.Graph.Base data RegClass ClassG32 :: RegClass ClassG16 :: RegClass ClassG8 :: RegClass ClassF64 :: RegClass -- | A register of some class data Reg Reg :: RegClass -> Int -> Reg RegSub :: RegSub -> Reg -> Reg -- | A subcomponent of another register data RegSub SubL16 :: RegSub SubL8 :: RegSub SubL8H :: RegSub -- | Worst case displacement -- -- a node N of classN has some number of neighbors, all of which are from -- classC. -- -- (worst neighbors classN classC) is the maximum number of potential -- colors for N that can be lost by coloring its neighbors. -- -- This should be hand coded/cached for each particular architecture, -- because the compute time is very long.. worst :: (RegClass -> UniqSet Reg) -> (Reg -> UniqSet Reg) -> Int -> RegClass -> RegClass -> Int -- | For a node N of classN and neighbors of classesC (bound classN -- classesC) is the maximum number of potential colors for N that can be -- lost by coloring its neighbors. bound :: (RegClass -> UniqSet Reg) -> (Reg -> UniqSet Reg) -> RegClass -> [RegClass] -> Int -- | The total squeese on a particular node with a list of neighbors. -- -- A version of this should be constructed for each particular -- architecture, possibly including uses of bound, so that aliased -- registers don't get counted twice, as per the paper. squeese :: (RegClass -> UniqSet Reg) -> (Reg -> UniqSet Reg) -> RegClass -> [(Int, RegClass)] -> Int instance GHC.Enum.Enum GHC.CmmToAsm.Reg.Graph.Base.RegClass instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Graph.Base.RegClass instance GHC.Show.Show GHC.CmmToAsm.Reg.Graph.Base.RegClass instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Graph.Base.RegSub instance GHC.Classes.Ord GHC.CmmToAsm.Reg.Graph.Base.RegSub instance GHC.Enum.Enum GHC.CmmToAsm.Reg.Graph.Base.RegSub instance GHC.Show.Show GHC.CmmToAsm.Reg.Graph.Base.RegSub instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Graph.Base.Reg instance GHC.Show.Show GHC.CmmToAsm.Reg.Graph.Base.Reg instance GHC.Types.Unique.Uniquable GHC.CmmToAsm.Reg.Graph.Base.Reg -- | A description of the register set of the X86. -- -- This isn't used directly in GHC proper. -- -- See RegArchBase.hs for the reference. See MachRegs.hs for the actual -- trivColorable function used in GHC. module GHC.CmmToAsm.Reg.Graph.X86 -- | Determine the class of a register classOfReg :: Reg -> RegClass -- | Determine all the regs that make up a certain class. regsOfClass :: RegClass -> UniqSet Reg -- | Determine the common name of a reg returns Nothing if this reg is not -- part of the machine. regName :: Reg -> Maybe String -- | Which regs alias what other regs. regAlias :: Reg -> UniqSet Reg -- | Optimised versions of RegColorBase.{worst, squeese} specific to x86 worst :: Int -> RegClass -> RegClass -> Int squeese :: RegClass -> [(Int, RegClass)] -> Int module GHC.CmmToAsm.Reg.Linear.AArch64 -- | Armv6 | Armv7-A | Armv8-A AArch64 | | SIMD extension | NEON | NEON | -- |===========================================================================| -- | - Operates on 32-bit | - Separate reg. bank, | - Separate reg. bank, -- | | GP ARM registers | 32x64-bit NEON regs | 32x128-bit NEON regs | | -- - 8-bit16-bit integer | - 8163264-bit int | - -- 81632/64-bit int | | | - Single percision fp | - Single -- percision fp | | | | - Double precision fp | | | | - Single/Double fp -- are | | | | IEEE compliant | | - 2x16-bit/4x8-bit ops | - Up to -- 16x8-bit ops | - Up to 16x8-bit ops | | per instruction | per -- instruction | per instruction | -- '---------------------------------------------------------------------------' data FreeRegs FreeRegs :: !Word32 -> !Word32 -> FreeRegs noFreeRegs :: FreeRegs showBits :: Word32 -> String allocateReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs getFreeRegs :: RegClass -> FreeRegs -> [RealReg] initFreeRegs :: Platform -> FreeRegs releaseReg :: HasCallStack => RealReg -> FreeRegs -> FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs -- | Free regs map for PowerPC module GHC.CmmToAsm.Reg.Linear.PPC data FreeRegs FreeRegs :: !Word32 -> !Word32 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs -- | The assignment of virtual registers to stack slots module GHC.CmmToAsm.Reg.Linear.StackMap -- | Identifier for a stack slot. type StackSlot = Int data StackMap StackMap :: !Int -> UniqFM Unique StackSlot -> StackMap -- | The slots that are still available to be allocated. [stackMapNextFreeSlot] :: StackMap -> !Int -- | Assignment of vregs to stack slots. [stackMapAssignment] :: StackMap -> UniqFM Unique StackSlot -- | An empty stack map, with all slots available. emptyStackMap :: StackMap -- | If this vreg unique already has a stack assignment then return the -- slot number, otherwise allocate a new slot, and update the map. getStackSlotFor :: StackMap -> Unique -> (StackMap, Int) -- | Return the number of stack slots that were allocated getStackUse :: StackMap -> Int module GHC.CmmToAsm.Reg.Utils toRegMap :: UniqFM VirtualReg elt -> UniqFM Reg elt toVRegMap :: UniqFM Reg elt -> UniqFM VirtualReg elt module GHC.CmmToAsm.Types type NatCmm instr = GenCmmGroup RawCmmStatics (LabelMap RawCmmStatics) (ListGraph instr) type NatCmmDecl statics instr = GenCmmDecl statics (LabelMap RawCmmStatics) (ListGraph instr) type NatBasicBlock instr = GenBasicBlock instr data GenBasicBlock i BasicBlock :: BlockId -> [i] -> GenBasicBlock i -- | The branch block id is that of the first block in the branch, which is -- that branch's entry point blockId :: GenBasicBlock i -> BlockId newtype ListGraph i ListGraph :: [GenBasicBlock i] -> ListGraph i type RawCmmStatics = GenCmmStatics 'True type RawCmmDecl = GenCmmDecl RawCmmStatics LabelMap RawCmmStatics CmmGraph module GHC.CmmToAsm.Utils -- | Returns the info table associated with the CmmDecl's entry point, if -- any. topInfoTable :: GenCmmDecl a (LabelMap i) (ListGraph b) -> Maybe i -- | Return the list of BlockIds in a CmmDecl that are entry points for -- this proc (i.e. they may be jumped to from outside this proc). entryBlocks :: GenCmmDecl a (LabelMap i) (ListGraph b) -> [BlockId] module GHC.CmmToAsm.AArch64.Instr -- | TODO: verify this! stackFrameHeaderSize :: Platform -> Int -- | All registers are 8 byte wide. spillSlotSize :: Int -- | The number of bytes that the stack pointer should be aligned to. stackAlign :: Int -- | The number of spill slots available without allocating more. maxSpillSlots :: NCGConfig -> Int -- | Convert a spill slot number to a *byte* offset, with no sign. spillSlotToOffset :: NCGConfig -> Int -> Int regUsageOfInstr :: Platform -> Instr -> RegUsage -- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -- 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -- 30 | 31 | | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 42 -- | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 -- | 58 | 59 | 60 | 61 | 62 | 63 | |== General Purpose registers -- ==================================================================================================================================| -- | argument passing ------------- | IR | tmp registers -- -------- | IP0| IP1| PL | callee saved ------------ | FP | -- LR | SP | | free registers -- -------------------------------------------------------------------- -- | BR | Sp | Hp | R1 | R2 | R3 | R4 | R5 | R6 | SL | -- | -- | -- | |== -- SIMD/FP Registers -- ==========================================================================================================================================| -- | argument passing ------------- | callee saved (lower 64 -- bits) --- | caller saved ---------------------- | | free -- registers ------------- | F1 | F2 | F3 | F4 | D1 | D2 | D3 | D4 | -- free registers -- ----------------------------------------------------- | -- '---------------------------------------------------------------------------------------------------------------------------------------------------------------' -- IR: Indirect result location register, IP: Intra-procedure register, -- PL: Platform register, FP: Frame pointer, LR: Link register, SP: Stack -- pointer BR: Base, SL: SpLim callerSavedRegisters :: [Reg] -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instr -> Bool -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. jumpDestsOfInstr :: Instr -> [BlockId] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -- | An instruction to spill a register into a spill slot. mkSpillInstr :: HasCallStack => NCGConfig -> Reg -> Int -> Int -> [Instr] mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int isMetaInstr :: Instr -> Bool -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Reg -> Reg -> Instr -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | Make an unconditional jump instruction. mkJumpInstr :: BlockId -> [Instr] mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) data Instr COMMENT :: SDoc -> Instr MULTILINE_COMMENT :: SDoc -> Instr ANN :: SDoc -> Instr -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> RawCmmStatics -> Instr NEWBLOCK :: BlockId -> Instr DELTA :: Int -> Instr SXTB :: Operand -> Operand -> Instr UXTB :: Operand -> Operand -> Instr SXTH :: Operand -> Operand -> Instr UXTH :: Operand -> Operand -> Instr -- | SXTW Operand Operand | SXTX Operand Operand PUSH_STACK_FRAME :: Instr POP_STACK_FRAME :: Instr -- | ADC Operand Operand Operang -- rd = rn + rm + C | ADCS ... ADD :: Operand -> Operand -> Operand -> Instr -- | ADDS Operand Operand Operand -- rd = rn + rm | ADR ... | ADRP ... CMN :: Operand -> Operand -> Instr CMP :: Operand -> Operand -> Instr -- | MADD ... | MNEG ... MSUB :: Operand -> Operand -> Operand -> Operand -> Instr MUL :: Operand -> Operand -> Operand -> Instr NEG :: Operand -> Operand -> Instr -- | NEGS ... | NGC ... | NGCS ... | SBC ... | SBCS ... SDIV :: Operand -> Operand -> Operand -> Instr -- | SMADDL ... | SMNEGL ... | SMSUBL ... | SMULH ... | SMULL ... SUB :: Operand -> Operand -> Operand -> Instr -- | SUBS ... UDIV :: Operand -> Operand -> Operand -> Instr -- | UMADDL ... -- Xd = Xa + Wn × Wm | UMNEGL ... -- Xd = - Wn × Wm | -- UMSUBL ... -- Xd = Xa - Wn × Wm | UMULH ... -- Xd = (Xn × Xm)_127:64 | -- UMULL ... -- Xd = Wn × Wm SBFM :: Operand -> Operand -> Operand -> Operand -> Instr UBFM :: Operand -> Operand -> Operand -> Operand -> Instr SBFX :: Operand -> Operand -> Operand -> Operand -> Instr UBFX :: Operand -> Operand -> Operand -> Operand -> Instr AND :: Operand -> Operand -> Operand -> Instr ANDS :: Operand -> Operand -> Operand -> Instr ASR :: Operand -> Operand -> Operand -> Instr BIC :: Operand -> Operand -> Operand -> Instr BICS :: Operand -> Operand -> Operand -> Instr EON :: Operand -> Operand -> Operand -> Instr EOR :: Operand -> Operand -> Operand -> Instr LSL :: Operand -> Operand -> Operand -> Instr LSR :: Operand -> Operand -> Operand -> Instr MOV :: Operand -> Operand -> Instr MOVK :: Operand -> Operand -> Instr -- | MOVN Operand Operand | MOVZ Operand Operand MVN :: Operand -> Operand -> Instr ORN :: Operand -> Operand -> Operand -> Instr ORR :: Operand -> Operand -> Operand -> Instr ROR :: Operand -> Operand -> Operand -> Instr TST :: Operand -> Operand -> Instr STR :: Format -> Operand -> Operand -> Instr LDR :: Format -> Operand -> Operand -> Instr STP :: Format -> Operand -> Operand -> Operand -> Instr LDP :: Format -> Operand -> Operand -> Operand -> Instr CSET :: Operand -> Cond -> Instr CBZ :: Operand -> Target -> Instr CBNZ :: Operand -> Target -> Instr J :: Target -> Instr B :: Target -> Instr BL :: Target -> [Reg] -> [Reg] -> Instr BCOND :: Cond -> Target -> Instr DMBSY :: Instr FCVT :: Operand -> Operand -> Instr SCVTF :: Operand -> Operand -> Instr FCVTZS :: Operand -> Operand -> Instr FABS :: Operand -> Operand -> Instr data Target TBlock :: BlockId -> Target TLabel :: CLabel -> Target TReg :: Reg -> Target data ExtMode EUXTB :: ExtMode EUXTH :: ExtMode EUXTW :: ExtMode EUXTX :: ExtMode ESXTB :: ExtMode ESXTH :: ExtMode ESXTW :: ExtMode ESXTX :: ExtMode data ShiftMode SLSL :: ShiftMode SLSR :: ShiftMode SASR :: ShiftMode SROR :: ShiftMode type ExtShift = Int type RegShift = Int data Operand OpReg :: Width -> Reg -> Operand OpRegExt :: Width -> Reg -> ExtMode -> ExtShift -> Operand OpRegShift :: Width -> Reg -> ShiftMode -> RegShift -> Operand OpImm :: Imm -> Operand OpImmShift :: Imm -> ShiftMode -> RegShift -> Operand OpAddr :: AddrMode -> Operand opReg :: Width -> Reg -> Operand xzr :: Operand wzr :: Operand sp :: Operand ip0 :: Operand _x :: Int -> Operand x0 :: Operand x1 :: Operand x2 :: Operand x3 :: Operand x4 :: Operand x5 :: Operand x6 :: Operand x7 :: Operand x8 :: Operand x9 :: Operand x10 :: Operand x11 :: Operand x12 :: Operand x13 :: Operand x14 :: Operand x15 :: Operand x16 :: Operand x17 :: Operand x18 :: Operand x19 :: Operand x20 :: Operand x21 :: Operand x22 :: Operand x23 :: Operand x24 :: Operand x25 :: Operand x26 :: Operand x27 :: Operand x28 :: Operand x29 :: Operand x30 :: Operand x31 :: Operand _d :: Int -> Operand d0 :: Operand d1 :: Operand d2 :: Operand d3 :: Operand d4 :: Operand d5 :: Operand d6 :: Operand d7 :: Operand d8 :: Operand d9 :: Operand d10 :: Operand d11 :: Operand d12 :: Operand d13 :: Operand d14 :: Operand d15 :: Operand d16 :: Operand d17 :: Operand d18 :: Operand d19 :: Operand d20 :: Operand d21 :: Operand d22 :: Operand d23 :: Operand d24 :: Operand d25 :: Operand d26 :: Operand d27 :: Operand d28 :: Operand d29 :: Operand d30 :: Operand d31 :: Operand opRegUExt :: Width -> Reg -> Operand opRegSExt :: Width -> Reg -> Operand instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.ExtMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.ExtMode instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.ShiftMode instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.ShiftMode instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.Operand instance GHC.Classes.Eq GHC.CmmToAsm.AArch64.Instr.Operand instance GHC.Show.Show GHC.CmmToAsm.AArch64.Instr.Instr instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Instr.RegUsage module GHC.CmmToAsm.AArch64.RegInfo data JumpDest DestBlockId :: BlockId -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.AArch64.RegInfo.JumpDest module GHC.CmmToAsm.X86.Cond data Cond ALWAYS :: Cond EQQ :: Cond GE :: Cond GEU :: Cond GTT :: Cond GU :: Cond LE :: Cond LEU :: Cond LTT :: Cond LU :: Cond NE :: Cond NEG :: Cond POS :: Cond CARRY :: Cond OFLO :: Cond PARITY :: Cond NOTPARITY :: Cond condToUnsigned :: Cond -> Cond -- | maybeFlipCond c returns Just c' if it is possible to -- flip the arguments to the conditional c, and the new -- condition should be c'. maybeFlipCond :: Cond -> Maybe Cond -- | If we apply maybeInvertCond to the condition of a jump we -- turn jumps taken into jumps not taken and vice versa. -- -- Careful! If the used comparison and the conditional jump don't match -- the above behaviour will NOT hold. When used for FP comparisons this -- does not consider unordered numbers. Also inverting twice might return -- a synonym for the original condition. maybeInvertCond :: Cond -> Maybe Cond instance GHC.Classes.Eq GHC.CmmToAsm.X86.Cond.Cond module GHC.CmmToAsm.X86.Regs -- | regSqueeze_class reg Calculate the maximum number of register colors -- that could be denied to a node of this class due to having this reg as -- a neighbour. virtualRegSqueeze :: RegClass -> VirtualReg -> Int realRegSqueeze :: RegClass -> RealReg -> Int data Imm ImmInt :: Int -> Imm ImmInteger :: Integer -> Imm ImmCLbl :: CLabel -> Imm ImmLit :: SDoc -> Imm ImmIndex :: CLabel -> Int -> Imm ImmFloat :: Rational -> Imm ImmDouble :: Rational -> Imm ImmConstantSum :: Imm -> Imm -> Imm ImmConstantDiff :: Imm -> Imm -> Imm strImmLit :: String -> Imm litToImm :: CmmLit -> Imm data AddrMode AddrBaseIndex :: EABase -> EAIndex -> Displacement -> AddrMode ImmAddr :: Imm -> Int -> AddrMode addrOffset :: AddrMode -> Int -> Maybe AddrMode spRel :: Platform -> Int -> AddrMode argRegs :: RegNo -> [Reg] allArgRegs :: Platform -> [(Reg, Reg)] allIntArgRegs :: Platform -> [Reg] -- | these are the regs which we cannot assume stay alive over a C call. callClobberedRegs :: Platform -> [Reg] instrClobberedRegs :: Platform -> [Reg] -- | The complete set of machine registers. allMachRegNos :: Platform -> [RegNo] -- | Take the class of a register. classOfRealReg :: Platform -> RealReg -> RegClass -- | Get the name of the register with this number. NOTE: fixme, we dont -- track which "way" the XMM registers are used showReg :: Platform -> RegNo -> String data EABase EABaseNone :: EABase EABaseReg :: Reg -> EABase EABaseRip :: EABase data EAIndex EAIndexNone :: EAIndex EAIndex :: Reg -> Int -> EAIndex addrModeRegs :: AddrMode -> [Reg] eax :: Reg ebx :: Reg ecx :: Reg edx :: Reg esi :: Reg edi :: Reg ebp :: Reg esp :: Reg rax :: Reg rbx :: Reg rcx :: Reg rdx :: Reg rsi :: Reg rdi :: Reg rbp :: Reg rsp :: Reg r8 :: Reg r9 :: Reg r10 :: Reg r11 :: Reg r12 :: Reg r13 :: Reg r14 :: Reg r15 :: Reg lastint :: Platform -> RegNo xmm0 :: Reg xmm1 :: Reg xmm2 :: Reg xmm3 :: Reg xmm4 :: Reg xmm5 :: Reg xmm6 :: Reg xmm7 :: Reg xmm8 :: Reg xmm9 :: Reg xmm10 :: Reg xmm11 :: Reg xmm12 :: Reg xmm13 :: Reg xmm14 :: Reg xmm15 :: Reg xmm :: RegNo -> Reg firstxmm :: RegNo lastxmm :: Platform -> RegNo ripRel :: Displacement -> AddrMode -- | on 64bit platforms we pass the first 8 float/double arguments in the -- xmm registers. allFPArgRegs :: Platform -> [Reg] allocatableRegs :: Platform -> [RealReg] module GHC.CmmToAsm.X86.RegInfo mkVirtualReg :: Unique -> Format -> VirtualReg regDotColor :: Platform -> RealReg -> SDoc -- | Hard wired things related to registers. This is module is preventing -- the native code generator being able to emit code for non-host -- architectures. -- -- TODO: Do a better job of the overloading, and eliminate this module. -- We'd probably do better with a Register type class, and hook this to -- Instruction somehow. -- -- TODO: We should also make arch specific versions of -- RegAlloc.Graph.TrivColorable module GHC.CmmToAsm.Reg.Target targetVirtualRegSqueeze :: Platform -> RegClass -> VirtualReg -> Int targetRealRegSqueeze :: Platform -> RegClass -> RealReg -> Int targetClassOfRealReg :: Platform -> RealReg -> RegClass targetMkVirtualReg :: Platform -> Unique -> Format -> VirtualReg targetRegDotColor :: Platform -> RealReg -> SDoc targetClassOfReg :: Platform -> Reg -> RegClass module GHC.CmmToAsm.X86.Instr data Instr COMMENT :: SDoc -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> (Alignment, RawCmmStatics) -> Instr NEWBLOCK :: BlockId -> Instr UNWIND :: CLabel -> UnwindTable -> Instr DELTA :: Int -> Instr MOV :: Format -> Operand -> Operand -> Instr CMOV :: Cond -> Format -> Operand -> Reg -> Instr -- | The format argument is the size of operand 1 (the number of bits we -- keep) We always zero *all* high bits, even though this isn't how the -- actual instruction works. The code generator also seems to rely on -- this behaviour and it's faster to execute on many cpus as well so for -- now I'm just documenting the fact. MOVZxL :: Format -> Operand -> Operand -> Instr MOVSxL :: Format -> Operand -> Operand -> Instr LEA :: Format -> Operand -> Operand -> Instr ADD :: Format -> Operand -> Operand -> Instr ADC :: Format -> Operand -> Operand -> Instr SUB :: Format -> Operand -> Operand -> Instr SBB :: Format -> Operand -> Operand -> Instr MUL :: Format -> Operand -> Operand -> Instr MUL2 :: Format -> Operand -> Instr IMUL :: Format -> Operand -> Operand -> Instr IMUL2 :: Format -> Operand -> Instr DIV :: Format -> Operand -> Instr IDIV :: Format -> Operand -> Instr ADD_CC :: Format -> Operand -> Operand -> Instr SUB_CC :: Format -> Operand -> Operand -> Instr AND :: Format -> Operand -> Operand -> Instr OR :: Format -> Operand -> Operand -> Instr XOR :: Format -> Operand -> Operand -> Instr NOT :: Format -> Operand -> Instr NEGI :: Format -> Operand -> Instr BSWAP :: Format -> Reg -> Instr SHL :: Format -> Operand -> Operand -> Instr SAR :: Format -> Operand -> Operand -> Instr SHR :: Format -> Operand -> Operand -> Instr BT :: Format -> Imm -> Operand -> Instr NOP :: Instr X87Store :: Format -> AddrMode -> Instr CVTSS2SD :: Reg -> Reg -> Instr CVTSD2SS :: Reg -> Reg -> Instr CVTTSS2SIQ :: Format -> Operand -> Reg -> Instr CVTTSD2SIQ :: Format -> Operand -> Reg -> Instr CVTSI2SS :: Format -> Operand -> Reg -> Instr CVTSI2SD :: Format -> Operand -> Reg -> Instr FDIV :: Format -> Operand -> Operand -> Instr SQRT :: Format -> Operand -> Reg -> Instr TEST :: Format -> Operand -> Operand -> Instr CMP :: Format -> Operand -> Operand -> Instr SETCC :: Cond -> Operand -> Instr PUSH :: Format -> Operand -> Instr POP :: Format -> Operand -> Instr JMP :: Operand -> [Reg] -> Instr JXX :: Cond -> BlockId -> Instr JXX_GBL :: Cond -> Imm -> Instr JMP_TBL :: Operand -> [Maybe JumpDest] -> Section -> CLabel -> Instr -- | X86 call instruction CALL :: Either Imm Reg -> [Reg] -> Instr CLTD :: Format -> Instr FETCHGOT :: Reg -> Instr FETCHPC :: Reg -> Instr POPCNT :: Format -> Operand -> Reg -> Instr LZCNT :: Format -> Operand -> Reg -> Instr TZCNT :: Format -> Operand -> Reg -> Instr BSF :: Format -> Operand -> Reg -> Instr BSR :: Format -> Operand -> Reg -> Instr PDEP :: Format -> Operand -> Operand -> Reg -> Instr PEXT :: Format -> Operand -> Operand -> Reg -> Instr PREFETCH :: PrefetchVariant -> Format -> Operand -> Instr LOCK :: Instr -> Instr XADD :: Format -> Operand -> Operand -> Instr CMPXCHG :: Format -> Operand -> Operand -> Instr XCHG :: Format -> Operand -> Reg -> Instr MFENCE :: Instr data Operand OpReg :: Reg -> Operand OpImm :: Imm -> Operand OpAddr :: AddrMode -> Operand data PrefetchVariant NTA :: PrefetchVariant Lvl0 :: PrefetchVariant Lvl1 :: PrefetchVariant Lvl2 :: PrefetchVariant data JumpDest DestBlockId :: BlockId -> JumpDest DestImm :: Imm -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutStatics :: (BlockId -> Maybe JumpDest) -> (Alignment, RawCmmStatics) -> (Alignment, RawCmmStatics) shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) maxSpillSlots :: NCGConfig -> Int archWordFormat :: Bool -> Format -- | Check whether an instruction represents a reg-reg move. The register -- allocator attempts to eliminate reg->reg moves whenever it can, by -- assigning the src and dest temporaries to the same real register. takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | Returns which registers are read and written as a (read, written) -- pair. regUsageOfInstr :: Platform -> Instr -> RegUsage -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int -- | Make a spill reload instruction. mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make an unconditional branch instruction. mkJumpInstr :: BlockId -> [Instr] mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] -- | Make a spill instruction. mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Make a reg-reg move instruction. mkRegRegMoveInstr :: Platform -> Reg -> Reg -> Instr jumpDestsOfInstr :: Instr -> [BlockId] -- | Applies the supplied function to all registers in instructions. -- Typically used to change virtual registers to real registers. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr isMetaInstr :: Instr -> Bool isJumpishInstr :: Instr -> Bool instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.X86.Instr.JumpDest -- | Free regs map for x86_64 module GHC.CmmToAsm.Reg.Linear.X86_64 newtype FreeRegs FreeRegs :: Word64 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: Platform -> RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs -- | Free regs map for i386 module GHC.CmmToAsm.Reg.Linear.X86 newtype FreeRegs FreeRegs :: Word32 -> FreeRegs noFreeRegs :: FreeRegs releaseReg :: RealReg -> FreeRegs -> FreeRegs initFreeRegs :: Platform -> FreeRegs getFreeRegs :: Platform -> RegClass -> FreeRegs -> [RealReg] allocateReg :: RealReg -> FreeRegs -> FreeRegs instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.X86.FreeRegs instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.X86.FreeRegs module GHC.CmmToC cmmToC :: Platform -> RawCmmGroup -> SDoc instance GHC.Base.Functor GHC.CmmToC.TE instance GHC.Base.Applicative GHC.CmmToC.TE instance GHC.Base.Monad GHC.CmmToC.TE -- | Llvm code generator configuration module GHC.CmmToLlvm.Config data LlvmCgConfig LlvmCgConfig :: !Platform -> !SDocContext -> !Bool -> !Bool -> Maybe BmiVersion -> Maybe LlvmVersion -> !Bool -> !String -> !LlvmConfig -> LlvmCgConfig -- | Target platform [llvmCgPlatform] :: LlvmCgConfig -> !Platform -- | Context for LLVM code generation [llvmCgContext] :: LlvmCgConfig -> !SDocContext -- | Fill undefined literals with garbage values [llvmCgFillUndefWithGarbage] :: LlvmCgConfig -> !Bool -- | Split sections [llvmCgSplitSection] :: LlvmCgConfig -> !Bool -- | (x86) BMI instructions [llvmCgBmiVersion] :: LlvmCgConfig -> Maybe BmiVersion -- | version of Llvm we're using [llvmCgLlvmVersion] :: LlvmCgConfig -> Maybe LlvmVersion -- | True ==> warn unsupported Llvm version [llvmCgDoWarn] :: LlvmCgConfig -> !Bool -- | target triple passed to LLVM [llvmCgLlvmTarget] :: LlvmCgConfig -> !String -- | mirror DynFlags LlvmConfig. see Note [LLVM configuration] in -- GHC.SysTools. This can be strict since -- GHC.Driver.Config.CmmToLlvm.initLlvmCgConfig verifies the files are -- present. [llvmCgLlvmConfig] :: LlvmCgConfig -> !LlvmConfig newtype LlvmVersion LlvmVersion :: NonEmpty Int -> LlvmVersion [llvmVersionNE] :: LlvmVersion -> NonEmpty Int instance GHC.Classes.Ord GHC.CmmToLlvm.Config.LlvmVersion instance GHC.Classes.Eq GHC.CmmToLlvm.Config.LlvmVersion -- | GHC LLVM Mangler -- -- This script processes the assembly produced by LLVM, rewriting all -- symbols of type function to object. This keeps them from -- going through the PLT, which would be bad due to tables-next-to-code. -- On x86_64, it also rewrites AVX instructions that require alignment to -- their unaligned counterparts, since the stack is only 16-byte aligned -- but these instructions require 32-byte alignment. module GHC.CmmToLlvm.Mangler -- | Read in assembly file and process llvmFixupAsm :: Platform -> FilePath -> FilePath -> IO () -- | Adds cost-centers after the core piple has run. module GHC.Core.LateCC addLateCostCentres :: ModGuts -> CoreM ModGuts module GHC.Core.Opt.CSE cseProgram :: CoreProgram -> CoreProgram -- | Runs CSE on a single expression. -- -- This entry point is not used in the compiler itself, but is provided -- as a convenient entry point for users of the GHC API. cseOneExpr :: InExpr -> OutExpr module GHC.Core.Opt.Exitify -- | Traverses the AST, simply to find all joinrecs and call -- exitify on them. The really interesting function is -- exitifyRec exitifyProgram :: CoreProgram -> CoreProgram module GHC.Core.Opt.FloatIn floatInwards :: Platform -> CoreProgram -> CoreProgram module GHC.Core.Opt.LiberateCase liberateCase :: DynFlags -> CoreProgram -> CoreProgram module GHC.Core.Opt.SetLevels setLevels :: FloatOutSwitches -> CoreProgram -> UniqSupply -> [LevelledBind] data Level Level :: Int -> Int -> LevelType -> Level data LevelType BndrLvl :: LevelType JoinCeilLvl :: LevelType tOP_LEVEL :: Level isJoinCeilLvl :: Level -> Bool asJoinCeilLvl :: Level -> Level type LevelledBind = TaggedBind FloatSpec type LevelledExpr = TaggedExpr FloatSpec type LevelledBndr = TaggedBndr FloatSpec data FloatSpec FloatMe :: Level -> FloatSpec StayPut :: Level -> FloatSpec floatSpecLevel :: FloatSpec -> Level incMinorLvl :: Level -> Level ltMajLvl :: Level -> Level -> Bool ltLvl :: Level -> Level -> Bool isTopLvl :: Level -> Bool instance GHC.Classes.Eq GHC.Core.Opt.SetLevels.LevelType instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SetLevels.FloatSpec instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SetLevels.Level instance GHC.Classes.Eq GHC.Core.Opt.SetLevels.Level module GHC.Core.Opt.FloatOut floatOutwards :: Logger -> FloatOutSwitches -> UniqSupply -> CoreProgram -> IO CoreProgram instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.FloatOut.FloatBinds module GHC.Core.Opt.Simplify.Monad data SimplM result initSmpl :: Logger -> DynFlags -> IO RuleBase -> RuleEnv -> (FamInstEnv, FamInstEnv) -> Int -> SimplM a -> IO (a, SimplCount) traceSmpl :: String -> SDoc -> SimplM () getSimplRules :: SimplM RuleEnv getFamEnvs :: SimplM (FamInstEnv, FamInstEnv) getOptCoercionOpts :: SimplM OptCoercionOpts -- | A monad for generating unique identifiers class Monad m => MonadUnique (m :: Type -> Type) -- | Get a new UniqueSupply getUniqueSupplyM :: MonadUnique m => m UniqSupply -- | Get a new unique identifier getUniqueM :: MonadUnique m => m Unique -- | Get an infinite list of new unique identifiers getUniquesM :: MonadUnique m => m [Unique] newId :: FastString -> Mult -> Type -> SimplM Id -- | Make a join id with given type and arity but without call-by-value -- annotations. newJoinId :: [Var] -> Type -> SimplM Id data SimplCount tick :: Tick -> SimplM () freeTick :: Tick -> SimplM () checkedTick :: Tick -> SimplM () getSimplCount :: SimplM SimplCount zeroSimplCount :: DynFlags -> SimplCount pprSimplCount :: SimplCount -> SDoc plusSimplCount :: SimplCount -> SimplCount -> SimplCount isZeroSimplCount :: SimplCount -> Bool instance GHC.Base.Functor GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Base.Applicative GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Base.Monad GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Types.Unique.Supply.MonadUnique GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Driver.Session.HasDynFlags GHC.Core.Opt.Simplify.Monad.SimplM instance GHC.Utils.Logger.HasLogger GHC.Core.Opt.Simplify.Monad.SimplM instance Control.Monad.IO.Class.MonadIO GHC.Core.Opt.Simplify.Monad.SimplM module GHC.Core.Opt.Simplify.Env setMode :: SimplMode -> SimplEnv -> SimplEnv getMode :: SimplEnv -> SimplMode updMode :: (SimplMode -> SimplMode) -> SimplEnv -> SimplEnv seDynFlags :: SimplEnv -> DynFlags seUnfoldingOpts :: SimplEnv -> UnfoldingOpts seLogger :: SimplEnv -> Logger data SimplEnv SimplEnv :: !SimplMode -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> !InScopeSet -> !Int -> SimplEnv [seMode] :: SimplEnv -> !SimplMode [seTvSubst] :: SimplEnv -> TvSubstEnv [seCvSubst] :: SimplEnv -> CvSubstEnv [seIdSubst] :: SimplEnv -> SimplIdSubst [seInScope] :: SimplEnv -> !InScopeSet [seCaseDepth] :: SimplEnv -> !Int pprSimplEnv :: SimplEnv -> SDoc mkSimplEnv :: SimplMode -> SimplEnv extendIdSubst :: SimplEnv -> Id -> SimplSR -> SimplEnv extendTvSubst :: SimplEnv -> TyVar -> Type -> SimplEnv extendCvSubst :: SimplEnv -> CoVar -> Coercion -> SimplEnv zapSubstEnv :: SimplEnv -> SimplEnv setSubstEnv :: SimplEnv -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> SimplEnv bumpCaseDepth :: SimplEnv -> SimplEnv getInScope :: SimplEnv -> InScopeSet setInScopeFromE :: SimplEnv -> SimplEnv -> SimplEnv setInScopeFromF :: SimplEnv -> SimplFloats -> SimplEnv setInScopeSet :: SimplEnv -> InScopeSet -> SimplEnv modifyInScope :: SimplEnv -> CoreBndr -> SimplEnv addNewInScopeIds :: SimplEnv -> [CoreBndr] -> SimplEnv getSimplRules :: SimplM RuleEnv -- | A substitution result. data SimplSR DoneEx :: OutExpr -> Maybe JoinArity -> SimplSR DoneId :: OutId -> SimplSR ContEx :: TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> InExpr -> SimplSR mkContEx :: SimplEnv -> InExpr -> SimplSR substId :: SimplEnv -> InId -> SimplSR lookupRecBndr :: SimplEnv -> InId -> OutId refineFromInScope :: InScopeSet -> Var -> Var simplNonRecBndr :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr) simplNonRecJoinBndr :: SimplEnv -> InBndr -> Mult -> OutType -> SimplM (SimplEnv, OutBndr) simplRecBndrs :: SimplEnv -> [InBndr] -> SimplM SimplEnv simplRecJoinBndrs :: SimplEnv -> [InBndr] -> Mult -> OutType -> SimplM SimplEnv simplBinder :: SimplEnv -> InBndr -> SimplM (SimplEnv, OutBndr) simplBinders :: SimplEnv -> [InBndr] -> SimplM (SimplEnv, [OutBndr]) substTy :: SimplEnv -> Type -> Type substTyVar :: SimplEnv -> TyVar -> Type getTCvSubst :: SimplEnv -> TCvSubst substCo :: SimplEnv -> Coercion -> Coercion substCoVar :: SimplEnv -> CoVar -> Coercion data SimplFloats SimplFloats :: LetFloats -> JoinFloats -> InScopeSet -> SimplFloats [sfLetFloats] :: SimplFloats -> LetFloats [sfJoinFloats] :: SimplFloats -> JoinFloats [sfInScope] :: SimplFloats -> InScopeSet emptyFloats :: SimplEnv -> SimplFloats mkRecFloats :: SimplFloats -> SimplFloats mkFloatBind :: SimplEnv -> OutBind -> (SimplFloats, SimplEnv) addLetFloats :: SimplFloats -> LetFloats -> SimplFloats addJoinFloats :: SimplFloats -> JoinFloats -> SimplFloats addFloats :: SimplFloats -> SimplFloats -> SimplFloats extendFloats :: SimplFloats -> OutBind -> SimplFloats wrapFloats :: SimplFloats -> OutExpr -> OutExpr doFloatFromRhs :: TopLevelFlag -> RecFlag -> Bool -> SimplFloats -> OutExpr -> Bool getTopFloatBinds :: SimplFloats -> [CoreBind] data LetFloats letFloatBinds :: LetFloats -> [CoreBind] emptyLetFloats :: LetFloats unitLetFloat :: OutBind -> LetFloats addLetFlts :: LetFloats -> LetFloats -> LetFloats mapLetFloats :: LetFloats -> ((Id, CoreExpr) -> (Id, CoreExpr)) -> LetFloats type JoinFloat = OutBind type JoinFloats = OrdList JoinFloat emptyJoinFloats :: JoinFloats wrapJoinFloats :: JoinFloats -> OutExpr -> OutExpr wrapJoinFloatsX :: SimplFloats -> OutExpr -> (SimplFloats, OutExpr) unitJoinFloat :: OutBind -> JoinFloats addJoinFlts :: JoinFloats -> JoinFloats -> JoinFloats instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Env.SimplFloats instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Env.LetFloats instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Env.FloatFlag instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Env.SimplSR module GHC.Core.Opt.Simplify.Utils mkLam :: SimplEnv -> [OutBndr] -> OutExpr -> SimplCont -> SimplM OutExpr mkCase :: DynFlags -> OutExpr -> OutId -> OutType -> [OutAlt] -> SimplM OutExpr prepareAlts :: OutExpr -> OutId -> [InAlt] -> SimplM ([AltCon], [InAlt]) tryEtaExpandRhs :: SimplEnv -> OutId -> OutExpr -> SimplM (ArityType, OutExpr) preInlineUnconditionally :: SimplEnv -> TopLevelFlag -> InId -> InExpr -> StaticEnv -> Maybe SimplEnv postInlineUnconditionally :: SimplEnv -> TopLevelFlag -> OutId -> OccInfo -> OutExpr -> Bool activeUnfolding :: SimplMode -> Id -> Bool activeRule :: SimplMode -> Activation -> Bool getUnfoldingInRuleMatch :: SimplEnv -> InScopeEnv simplEnvForGHCi :: Logger -> DynFlags -> SimplEnv updModeForStableUnfoldings :: Activation -> SimplMode -> SimplMode updModeForRules :: SimplMode -> SimplMode data SimplCont Stop :: OutType -> CallCtxt -> SimplCont CastIt :: OutCoercion -> SimplCont -> SimplCont ApplyToVal :: DupFlag -> OutType -> InExpr -> StaticEnv -> SimplCont -> SimplCont [sc_dup] :: SimplCont -> DupFlag [sc_hole_ty] :: SimplCont -> OutType [sc_arg] :: SimplCont -> InExpr [sc_env] :: SimplCont -> StaticEnv [sc_cont] :: SimplCont -> SimplCont ApplyToTy :: OutType -> OutType -> SimplCont -> SimplCont [sc_arg_ty] :: SimplCont -> OutType [sc_hole_ty] :: SimplCont -> OutType [sc_cont] :: SimplCont -> SimplCont Select :: DupFlag -> InId -> [InAlt] -> StaticEnv -> SimplCont -> SimplCont [sc_dup] :: SimplCont -> DupFlag [sc_bndr] :: SimplCont -> InId [sc_alts] :: SimplCont -> [InAlt] [sc_env] :: SimplCont -> StaticEnv [sc_cont] :: SimplCont -> SimplCont StrictBind :: DupFlag -> InId -> InExpr -> StaticEnv -> SimplCont -> SimplCont [sc_dup] :: SimplCont -> DupFlag [sc_bndr] :: SimplCont -> InId [sc_body] :: SimplCont -> InExpr [sc_env] :: SimplCont -> StaticEnv [sc_cont] :: SimplCont -> SimplCont StrictArg :: DupFlag -> ArgInfo -> OutType -> SimplCont -> SimplCont [sc_dup] :: SimplCont -> DupFlag [sc_fun] :: SimplCont -> ArgInfo [sc_fun_ty] :: SimplCont -> OutType [sc_cont] :: SimplCont -> SimplCont TickIt :: CoreTickish -> SimplCont -> SimplCont data DupFlag NoDup :: DupFlag Simplified :: DupFlag OkToDup :: DupFlag type StaticEnv = SimplEnv isSimplified :: DupFlag -> Bool contIsStop :: SimplCont -> Bool contIsDupable :: SimplCont -> Bool contResultType :: SimplCont -> OutType contHoleType :: SimplCont -> OutType contHoleScaling :: SimplCont -> Mult contIsTrivial :: SimplCont -> Bool contArgs :: SimplCont -> (Bool, [ArgSummary], SimplCont) countArgs :: SimplCont -> Int mkBoringStop :: OutType -> SimplCont mkRhsStop :: OutType -> SimplCont mkLazyArgStop :: OutType -> CallCtxt -> SimplCont contIsRhsOrArg :: SimplCont -> Bool interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt data ArgInfo ArgInfo :: OutId -> [ArgSpec] -> FunRules -> Bool -> [Demand] -> [Int] -> ArgInfo [ai_fun] :: ArgInfo -> OutId [ai_args] :: ArgInfo -> [ArgSpec] [ai_rules] :: ArgInfo -> FunRules [ai_encl] :: ArgInfo -> Bool [ai_dmds] :: ArgInfo -> [Demand] [ai_discs] :: ArgInfo -> [Int] data ArgSpec ValArg :: Demand -> OutExpr -> OutType -> ArgSpec [as_dmd] :: ArgSpec -> Demand [as_arg] :: ArgSpec -> OutExpr [as_hole_ty] :: ArgSpec -> OutType TyArg :: OutType -> OutType -> ArgSpec [as_arg_ty] :: ArgSpec -> OutType [as_hole_ty] :: ArgSpec -> OutType CastBy :: OutCoercion -> ArgSpec mkArgInfo :: SimplEnv -> Id -> [CoreRule] -> Int -> SimplCont -> ArgInfo addValArgTo :: ArgInfo -> OutExpr -> OutType -> ArgInfo addCastTo :: ArgInfo -> OutCoercion -> ArgInfo addTyArgTo :: ArgInfo -> OutType -> OutType -> ArgInfo argInfoExpr :: OutId -> [ArgSpec] -> OutExpr argInfoAppArgs :: [ArgSpec] -> [OutExpr] pushSimplifiedArgs :: SimplEnv -> [ArgSpec] -> SimplCont -> SimplCont isStrictArgInfo :: ArgInfo -> Bool lazyArgContext :: ArgInfo -> CallCtxt abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats -> OutExpr -> SimplM ([OutBind], OutExpr) isExitJoinId :: Var -> Bool instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Utils.SimplCont instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Utils.ArgInfo instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Utils.ArgSpec instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Simplify.Utils.DupFlag module GHC.Core.Opt.Simplify simplTopBinds :: SimplEnv -> [InBind] -> SimplM (SimplFloats, SimplEnv) simplExpr :: SimplEnv -> CoreExpr -> SimplM CoreExpr simplRules :: SimplEnv -> Maybe OutId -> [CoreRule] -> MaybeJoinCont -> SimplM [CoreRule] module GHC.Core.Opt.Specialise -- | Specialise calls to type-class overloaded functions occurring in a -- program. specProgram :: ModGuts -> CoreM ModGuts specUnfolding :: SimpleOpts -> [Var] -> (CoreExpr -> CoreExpr) -> [CoreArg] -> Unfolding -> Unfolding instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.UsageDetails instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.CallInfoSet instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.CallInfo instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.SpecArg instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.DictBind instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.Specialise.SpecEnv module GHC.Core.Opt.StaticArgs doStaticArgs :: UniqSupply -> CoreProgram -> CoreProgram module GHC.Core.TyCon.Set type TyConSet = UniqSet TyCon emptyTyConSet :: TyConSet unitTyConSet :: TyCon -> TyConSet mkTyConSet :: [TyCon] -> TyConSet unionTyConSet :: TyConSet -> TyConSet -> TyConSet unionTyConSets :: [TyConSet] -> TyConSet minusTyConSet :: TyConSet -> TyConSet -> TyConSet elemTyConSet :: TyCon -> TyConSet -> Bool extendTyConSet :: TyConSet -> TyCon -> TyConSet extendTyConSetList :: TyConSet -> [TyCon] -> TyConSet delFromTyConSet :: TyConSet -> TyCon -> TyConSet delListFromTyConSet :: TyConSet -> [TyCon] -> TyConSet isEmptyTyConSet :: TyConSet -> Bool filterTyConSet :: (TyCon -> Bool) -> TyConSet -> TyConSet -- | True if there is a non-empty intersection. s1 -- intersectsTyConSet s2 doesn't compute s2 if -- s1 is empty intersectsTyConSet :: TyConSet -> TyConSet -> Bool disjointTyConSet :: TyConSet -> TyConSet -> Bool intersectTyConSet :: TyConSet -> TyConSet -> TyConSet nameSetAny :: (TyCon -> Bool) -> TyConSet -> Bool nameSetAll :: (TyCon -> Bool) -> TyConSet -> Bool module GHC.Core.Opt.WorkWrap.Utils data WwOpts MkWwOpts :: !FamInstEnvs -> !SimpleOpts -> !Bool -> !Module -> !Bool -> WwOpts [wo_fam_envs] :: WwOpts -> !FamInstEnvs [wo_simple_opts] :: WwOpts -> !SimpleOpts [wo_cpr_anal] :: WwOpts -> !Bool [wo_module] :: WwOpts -> !Module [wo_unlift_strict] :: WwOpts -> !Bool initWwOpts :: Module -> DynFlags -> FamInstEnvs -> WwOpts -- | Given a function definition -- --
--   data T = MkT Int Bool Char
--   f :: (a, b) -> Int -> T
--   f = \x y -> E
--   
-- -- mkWwBodies _ f ['x::(a,b)','y::Int'] '(a,b)' ['1P(L,L)', -- '1P(L)'] '1' returns -- -- -- --
--   W[_] :: Id -> CoreExpr
--   W[work_fn] = \x y ->          -- args of the wrapper    (cloned_arg_vars)
--     case x of (a, b) ->         -- unbox wrapper args     (wrap_fn_str)
--     case y of I# n ->           --
--     case <work_fn> a b n of     -- call to the worker fun (call_work)
--     (# i, b, c #) -> MkT i b c  -- rebox result           (wrap_fn_cpr)
--   
-- -- -- --
--   w[_] :: CoreExpr -> CoreExpr
--   w[fn_rhs] = \a b n ->              -- args of the worker       (work_lam_args)
--     let { y = I# n; x = (a, b) } in  -- reboxing wrapper args    (work_fn_str)
--     case <fn_rhs> x y of             -- call to the original RHS (call_rhs)
--     MkT i b c -> (# i, b, c #)       -- return CPR transit vars  (work_fn_cpr)
--   
-- -- NB: The wrap_rhs hole is to be filled with the original wrapper RHS -- x y -> E. This is so that we can also use w to -- transform stable unfoldings, the lambda args of which may be different -- than x and y. -- -- -- -- All without looking at E (except for beta reduction, see Note [Join -- points and beta-redexes]), which allows us to apply the same split to -- function body and its unfolding(s) alike. mkWwBodies :: WwOpts -> Id -> [Var] -> Type -> [Demand] -> Cpr -> UniqSM (Maybe WwResult) mkWWstr :: WwOpts -> [Var] -> [CbvMark] -> UniqSM (Bool, [(Var, CbvMark)], CoreExpr -> CoreExpr, [CoreExpr]) mkWWstr_one :: WwOpts -> Var -> CbvMark -> UniqSM (Bool, [(Var, CbvMark)], CoreExpr -> CoreExpr, CoreExpr) -- | Whether the worker needs an additional `Void#` arg as per Note -- [Protecting the last value argument] or Note [Preserving float -- barriers]. needsVoidWorkerArg :: Id -> [Var] -> [Var] -> Bool -- | Inserts a `Void#` arg before the first value argument (but after -- leading type args). addVoidWorkerArg :: [Var] -> [CbvMark] -> ([Var], [Var], [CbvMark]) -- | The information needed to build a pattern for a DataCon to be unboxed. -- The pattern can be generated from dcpc_dc and -- dcpc_tc_args via dataConRepInstPat. The coercion -- dcpc_co is for newtype wrappers. -- -- If we get DataConPatContext dc tys co for some type -- ty and dataConRepInstPat ... dc tys = (exs, flds), -- then -- -- data DataConPatContext DataConPatContext :: !DataCon -> ![Type] -> !Coercion -> DataConPatContext [dcpc_dc] :: DataConPatContext -> !DataCon [dcpc_tc_args] :: DataConPatContext -> ![Type] [dcpc_co] :: DataConPatContext -> !Coercion -- | Describes the outer shape of an argument to be unboxed or left as-is -- Depending on how s is instantiated (e.g., Demand or -- Cpr). data UnboxingDecision s -- | We ran out of strictness info. Leave untouched. StopUnboxing :: UnboxingDecision s -- | The argument/field was absent. Drop it. DropAbsent :: UnboxingDecision s -- | The argument is used strictly or the returned product was constructed, -- so unbox it. The DataConPatContext carries the bits necessary -- for instantiation with dataConRepInstPat. The [s] -- carries the bits of information with which we can continue unboxing, -- e.g. s will be Demand or Cpr. Unbox :: !DataConPatContext -> [s] -> UnboxingDecision s -- | The argument can't be unboxed, but we want it to be passed evaluated -- to the worker. Unlift :: UnboxingDecision s -- | Unwraps the Boxity decision encoded in the given -- SubDemand and returns a DataConPatContext as well the -- nested demands on fields of the DataCon to unbox. wantToUnboxArg :: Bool -> FamInstEnvs -> Type -> Demand -> UnboxingDecision Demand findTypeShape :: FamInstEnvs -> Type -> TypeShape -- | Returned by isRecDataCon. See also Note [Detecting recursive -- data constructors]. data IsRecDataConResult -- | The algorithm detected a loop DefinitelyRecursive :: IsRecDataConResult -- | The algorithm detected no loop, went out of fuel or hit an .hs-boot -- file NonRecursiveOrUnsure :: IsRecDataConResult -- | isRecDataCon _ fuel dc, where tc = dataConTyCon dc -- returns -- -- -- -- If fuel = Infinity and there are no boot files -- involved, then the result is never Nothing and the analysis -- is a depth-first search. If fuel = Int f, then the -- analysis behaves like a depth-limited DFS and returns Nothing -- if the search was inconclusive. -- -- See Note [Detecting recursive data constructors] for which recursive -- DataCons we want to flag. isRecDataCon :: FamInstEnvs -> IntWithInf -> DataCon -> IsRecDataConResult -- | Tries to find a suitable absent filler to bind the given absent -- identifier to. See Note [Absent fillers]. -- -- If mkAbsentFiller _ id == Just e, then e is an -- absent filler with the same type as id. Otherwise, no -- suitable filler could be found. mkAbsentFiller :: WwOpts -> Id -> Maybe CoreExpr isWorkerSmallEnough :: Int -> Int -> [Var] -> Bool -- | Exactly dataConInstArgTys, but lacks the (ASSERT'ed) -- precondition that the DataCon may not have existentials. The -- lack of cloning the existentials compared to -- dataConInstExAndArgVars makes this function "dubious"; only -- use it where type variables aren't substituted for! dubiousDataConInstArgTys :: DataCon -> [Type] -> [Type] isGoodWorker :: Bool -> Bool badWorker :: Bool goodWorker :: Bool instance GHC.Show.Show GHC.Core.Opt.WorkWrap.Utils.IsRecDataConResult instance GHC.Classes.Eq GHC.Core.Opt.WorkWrap.Utils.IsRecDataConResult instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.WorkWrap.Utils.IsRecDataConResult module GHC.Core.Opt.WorkWrap wwTopBinds :: Module -> DynFlags -> FamInstEnvs -> UniqSupply -> CoreProgram -> CoreProgram module GHC.Core.Opt.SpecConstr specConstrProgram :: ModGuts -> CoreM ModGuts data SpecConstrAnnotation NoSpecConstr :: SpecConstrAnnotation ForceSpecConstr :: SpecConstrAnnotation instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.CallPat instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.ScUsage instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.ArgOcc instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.Call instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.HowBound instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.SpecConstr.Value module GHC.Data.Bitmap -- | A bitmap represented by a sequence of StgWords on the -- target architecture. These are used for bitmaps in info tables -- and other generated code which need to be emitted as sequences of -- StgWords. type Bitmap = [StgWord] -- | Make a bitmap from a sequence of bits mkBitmap :: Platform -> [Bool] -> Bitmap -- | Make a bitmap where the slots specified are the zeros in the -- bitmap. eg. [0,1,3], size 4 ==> 0x4 (we leave any bits -- outside the size as zero, just to make the bitmap easier to read). -- -- The list of Ints must be already sorted and -- duplicate-free. intsToReverseBitmap :: Platform -> Int -> [Int] -> Bitmap -- | Magic number, must agree with BITMAP_BITS_SHIFT in -- InfoTables.h. Some kinds of bitmap pack a size/bitmap into a single -- word if possible, or fall back to an external pointer when the bitmap -- is too large. This value represents the largest size of bitmap that -- can be packed into a single word. mAX_SMALL_BITMAP_SIZE :: Platform -> Int module GHC.Cmm.Info mkEmptyContInfoTable :: CLabel -> CmmInfoTable cmmToRawCmm :: Logger -> Profile -> Stream IO CmmGroupSRTs a -> IO (Stream IO RawCmmGroup a) -- | Value of the srt field of an info table when using an StgLargeSRT srtEscape :: Platform -> StgHalfWord -- | Takes a closure pointer and returns the info table pointer closureInfoPtr :: Platform -> DoAlignSanitisation -> CmmExpr -> CmmExpr -- | Takes an info pointer (the first word of a closure) and returns its -- entry code entryCode :: Platform -> CmmExpr -> CmmExpr -- | Takes a closure pointer, and return the *zero-indexed* constructor tag -- obtained from the info table This lives in the SRT field of the info -- table (constructors don't need SRTs). getConstrTag :: Profile -> DoAlignSanitisation -> CmmExpr -> CmmExpr -- | Takes a closure pointer, and return the closure type obtained from the -- info table cmmGetClosureType :: Profile -> DoAlignSanitisation -> CmmExpr -> CmmExpr -- | Takes an info pointer (the first word of a closure) and returns a -- pointer to the first word of the standard-form info table, excluding -- the entry-code word (if present) infoTable :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the constr -- tag field of the info table (same as the srt_bitmap field) infoTableConstrTag :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the -- srt_bitmap field of the info table infoTableSrtBitmap :: Profile -> CmmExpr -> CmmExpr -- | Takes an info table pointer (from infoTable) and returns the closure -- type field of the info table. infoTableClosureType :: Profile -> CmmExpr -> CmmExpr infoTablePtrs :: Profile -> CmmExpr -> CmmExpr infoTableNonPtrs :: Profile -> CmmExpr -> CmmExpr -- | Takes the info pointer of a function, and returns a pointer to the -- first word of the StgFunInfoExtra struct in the info table. funInfoTable :: Profile -> CmmExpr -> CmmExpr -- | Takes the info pointer of a function, returns the function's arity funInfoArity :: Profile -> CmmExpr -> CmmExpr stdInfoTableSizeW :: Profile -> WordOff fixedInfoTableSizeW :: WordOff profInfoTableSizeW :: WordOff maxStdInfoTableSizeW :: WordOff maxRetInfoTableSizeW :: WordOff stdInfoTableSizeB :: Profile -> ByteOff conInfoTableSizeB :: Profile -> Int -- | Byte offset of the SRT bitmap half-word which is in the -- *higher-addressed* part of the type_lit stdSrtBitmapOffset :: Profile -> ByteOff -- | Byte offset of the closure type half-word stdClosureTypeOffset :: Profile -> ByteOff stdPtrsOffset :: Profile -> ByteOff stdNonPtrsOffset :: Profile -> ByteOff module GHC.CmmToAsm.PPC.Instr data Instr COMMENT :: SDoc -> Instr LOCATION :: Int -> Int -> Int -> String -> Instr LDATA :: Section -> RawCmmStatics -> Instr NEWBLOCK :: BlockId -> Instr DELTA :: Int -> Instr LD :: Format -> Reg -> AddrMode -> Instr LDFAR :: Format -> Reg -> AddrMode -> Instr LDR :: Format -> Reg -> AddrMode -> Instr LA :: Format -> Reg -> AddrMode -> Instr ST :: Format -> Reg -> AddrMode -> Instr STFAR :: Format -> Reg -> AddrMode -> Instr STU :: Format -> Reg -> AddrMode -> Instr STC :: Format -> Reg -> AddrMode -> Instr LIS :: Reg -> Imm -> Instr LI :: Reg -> Imm -> Instr MR :: Reg -> Reg -> Instr CMP :: Format -> Reg -> RI -> Instr CMPL :: Format -> Reg -> RI -> Instr BCC :: Cond -> BlockId -> Maybe Bool -> Instr BCCFAR :: Cond -> BlockId -> Maybe Bool -> Instr JMP :: CLabel -> [Reg] -> Instr MTCTR :: Reg -> Instr BCTR :: [Maybe BlockId] -> Maybe CLabel -> [Reg] -> Instr BL :: CLabel -> [Reg] -> Instr BCTRL :: [Reg] -> Instr ADD :: Reg -> Reg -> RI -> Instr ADDO :: Reg -> Reg -> Reg -> Instr ADDC :: Reg -> Reg -> Reg -> Instr ADDE :: Reg -> Reg -> Reg -> Instr ADDZE :: Reg -> Reg -> Instr ADDIS :: Reg -> Reg -> Imm -> Instr SUBF :: Reg -> Reg -> Reg -> Instr SUBFO :: Reg -> Reg -> Reg -> Instr SUBFC :: Reg -> Reg -> RI -> Instr SUBFE :: Reg -> Reg -> Reg -> Instr MULL :: Format -> Reg -> Reg -> RI -> Instr MULLO :: Format -> Reg -> Reg -> Reg -> Instr MFOV :: Format -> Reg -> Instr MULHU :: Format -> Reg -> Reg -> Reg -> Instr DIV :: Format -> Bool -> Reg -> Reg -> Reg -> Instr AND :: Reg -> Reg -> RI -> Instr ANDC :: Reg -> Reg -> Reg -> Instr NAND :: Reg -> Reg -> Reg -> Instr OR :: Reg -> Reg -> RI -> Instr ORIS :: Reg -> Reg -> Imm -> Instr XOR :: Reg -> Reg -> RI -> Instr XORIS :: Reg -> Reg -> Imm -> Instr EXTS :: Format -> Reg -> Reg -> Instr CNTLZ :: Format -> Reg -> Reg -> Instr NEG :: Reg -> Reg -> Instr NOT :: Reg -> Reg -> Instr SL :: Format -> Reg -> Reg -> RI -> Instr SR :: Format -> Reg -> Reg -> RI -> Instr SRA :: Format -> Reg -> Reg -> RI -> Instr RLWINM :: Reg -> Reg -> Int -> Int -> Int -> Instr CLRLI :: Format -> Reg -> Reg -> Int -> Instr CLRRI :: Format -> Reg -> Reg -> Int -> Instr FADD :: Format -> Reg -> Reg -> Reg -> Instr FSUB :: Format -> Reg -> Reg -> Reg -> Instr FMUL :: Format -> Reg -> Reg -> Reg -> Instr FDIV :: Format -> Reg -> Reg -> Reg -> Instr FABS :: Reg -> Reg -> Instr FNEG :: Reg -> Reg -> Instr FCMP :: Reg -> Reg -> Instr FCTIWZ :: Reg -> Reg -> Instr FCTIDZ :: Reg -> Reg -> Instr FCFID :: Reg -> Reg -> Instr FRSP :: Reg -> Reg -> Instr CRNOR :: Int -> Int -> Int -> Instr MFCR :: Reg -> Instr MFLR :: Reg -> Instr FETCHPC :: Reg -> Instr HWSYNC :: Instr ISYNC :: Instr LWSYNC :: Instr NOP :: Instr data RI RIReg :: Reg -> RI RIImm :: Imm -> RI archWordFormat :: Bool -> Format -- | The size of a minimal stackframe header including minimal parameter -- save area. stackFrameHeaderSize :: Platform -> Int -- | The number of spill slots available without allocating more. maxSpillSlots :: NCGConfig -> Int allocMoreStack :: Platform -> Int -> NatCmmDecl statics Instr -> UniqSM (NatCmmDecl statics Instr, [(BlockId, BlockId)]) makeFarBranches :: LabelMap RawCmmStatics -> [NatBasicBlock Instr] -> [NatBasicBlock Instr] -- | Make an unconditional jump instruction. mkJumpInstr :: BlockId -> [Instr] mkLoadInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | An instruction to spill a register into a spill slot. mkSpillInstr :: NCGConfig -> Reg -> Int -> Int -> [Instr] -- | Change the destination of this jump instruction. Used in the linear -- allocator when adding fixup blocks for join points. patchJumpInstr :: Instr -> (BlockId -> BlockId) -> Instr -- | Apply a given mapping to all the register references in this -- instruction. patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. jumpDestsOfInstr :: Instr -> [BlockId] -- | Take the source and destination from this reg -> reg move -- instruction or Nothing if it's not one takeRegRegMoveInstr :: Instr -> Maybe (Reg, Reg) -- | See if this instruction is telling us the current C stack delta takeDeltaInstr :: Instr -> Maybe Int -- | Copy the value in a register to another one. Must work for all -- register classes. mkRegRegMoveInstr :: Reg -> Reg -> Instr mkStackAllocInstr :: Platform -> Int -> [Instr] mkStackDeallocInstr :: Platform -> Int -> [Instr] -- | Get the registers that are being used by this instruction. regUsage -- doesn't need to do any trickery for jumps and such. Just state -- precisely the regs read and written by that insn. The consequences of -- control flow transfers, as far as register allocation goes, are taken -- care of by the register allocator. regUsageOfInstr :: Platform -> Instr -> RegUsage -- | Checks whether this instruction is a jump/branch instruction. One that -- can change the flow of control in a way that the register allocator -- needs to worry about. isJumpishInstr :: Instr -> Bool isMetaInstr :: Instr -> Bool module GHC.CmmToAsm.Reg.Linear.FreeRegs class Show freeRegs => FR freeRegs frAllocateReg :: FR freeRegs => Platform -> RealReg -> freeRegs -> freeRegs frGetFreeRegs :: FR freeRegs => Platform -> RegClass -> freeRegs -> [RealReg] frInitFreeRegs :: FR freeRegs => Platform -> freeRegs frReleaseReg :: FR freeRegs => Platform -> RealReg -> freeRegs -> freeRegs maxSpillSlots :: NCGConfig -> Int instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.X86.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.X86_64.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.PPC.FreeRegs instance GHC.CmmToAsm.Reg.Linear.FreeRegs.FR GHC.CmmToAsm.Reg.Linear.AArch64.FreeRegs module GHC.CmmToAsm.PPC.RegInfo data JumpDest DestBlockId :: BlockId -> JumpDest getJumpDestBlockId :: JumpDest -> Maybe BlockId canShortcut :: Instr -> Maybe JumpDest shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr shortcutStatics :: (BlockId -> Maybe JumpDest) -> RawCmmStatics -> RawCmmStatics instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.PPC.RegInfo.JumpDest module GHC.Cmm.ProcPoint type ProcPointSet = LabelSet data Status ReachedBy :: ProcPointSet -> Status ProcPoint :: Status callProcPoints :: CmmGraph -> ProcPointSet minimalProcPointSet :: Platform -> ProcPointSet -> CmmGraph -> UniqSM ProcPointSet splitAtProcPoints :: Platform -> CLabel -> ProcPointSet -> ProcPointSet -> LabelMap Status -> CmmDecl -> UniqSM [CmmDecl] procPointAnalysis :: ProcPointSet -> CmmGraph -> LabelMap Status attachContInfoTables :: ProcPointSet -> CmmDecl -> CmmDecl instance GHC.Utils.Outputable.Outputable GHC.Cmm.ProcPoint.Status -- | Types for the general graph colorer. module GHC.Data.Graph.Base -- | A fn to check if a node is trivially colorable For graphs who's color -- classes are disjoint then a node is 'trivially colorable' when it has -- less neighbors and exclusions than available colors for that node. -- -- For graph's who's color classes overlap, ie some colors alias other -- colors, then this can be a bit more tricky. There is a general way to -- calculate this, but it's likely be too slow for use in the code. The -- coloring algorithm takes a canned function which can be optimised by -- the user to be specific to the specific graph being colored. -- -- for details, see "A Generalised Algorithm for Graph-Coloring Register -- Allocation" Smith, Ramsey, Holloway - PLDI 2004. type Triv k cls color = cls -> UniqSet k -> UniqSet color -> Bool -- | The Interference graph. There used to be more fields, but they were -- turfed out in a previous revision. maybe we'll want more later.. newtype Graph k cls color Graph :: UniqFM k (Node k cls color) -> Graph k cls color -- | All active nodes in the graph. [graphMap] :: Graph k cls color -> UniqFM k (Node k cls color) -- | An empty graph. initGraph :: Graph k cls color -- | Modify the finite map holding the nodes in the graph. graphMapModify :: (UniqFM k (Node k cls color) -> UniqFM k (Node k cls color)) -> Graph k cls color -> Graph k cls color -- | Graph nodes. Represents a thing that can conflict with another thing. -- For the register allocater the nodes represent registers. data Node k cls color Node :: k -> cls -> Maybe color -> UniqSet k -> UniqSet color -> [color] -> UniqSet k -> Node k cls color -- | A unique identifier for this node. [nodeId] :: Node k cls color -> k -- | The class of this node, determines the set of colors that can be used. [nodeClass] :: Node k cls color -> cls -- | The color of this node, if any. [nodeColor] :: Node k cls color -> Maybe color -- | Neighbors which must be colored differently to this node. [nodeConflicts] :: Node k cls color -> UniqSet k -- | Colors that cannot be used by this node. [nodeExclusions] :: Node k cls color -> UniqSet color -- | Colors that this node would prefer to be, in descending order. [nodePreference] :: Node k cls color -> [color] -- | Neighbors that this node would like to be colored the same as. [nodeCoalesce] :: Node k cls color -> UniqSet k -- | An empty node. newNode :: k -> cls -> Node k cls color module GHC.CmmToAsm.Reg.Graph.TrivColorable trivColorable :: Platform -> (RegClass -> VirtualReg -> Int) -> (RegClass -> RealReg -> Int) -> Triv VirtualReg RegClass RealReg -- | Basic operations on graphs. module GHC.Data.Graph.Ops -- | Add a node to the graph, linking up its edges addNode :: Uniquable k => k -> Node k cls color -> Graph k cls color -> Graph k cls color -- | Delete a node and all its edges from the graph. delNode :: Uniquable k => k -> Graph k cls color -> Maybe (Graph k cls color) -- | Get a node from the graph, throwing an error if it's not there getNode :: Uniquable k => Graph k cls color -> k -> Node k cls color -- | Lookup a node from the graph. lookupNode :: Uniquable k => Graph k cls color -> k -> Maybe (Node k cls color) -- | Modify a node in the graph. returns Nothing if the node isn't present. modNode :: Uniquable k => (Node k cls color -> Node k cls color) -> k -> Graph k cls color -> Maybe (Graph k cls color) -- | Get the size of the graph, O(n) size :: Graph k cls color -> Int -- | Union two graphs together. union :: Graph k cls color -> Graph k cls color -> Graph k cls color -- | Add a conflict between nodes to the graph, creating the nodes -- required. Conflicts are virtual regs which need to be colored -- differently. addConflict :: Uniquable k => (k, cls) -> (k, cls) -> Graph k cls color -> Graph k cls color -- | Delete a conflict edge. k1 -> k2 returns Nothing if the node isn't -- in the graph delConflict :: Uniquable k => k -> k -> Graph k cls color -> Maybe (Graph k cls color) -- | Add some conflicts to the graph, creating nodes if required. All the -- nodes in the set are taken to conflict with each other. addConflicts :: Uniquable k => UniqSet k -> (k -> cls) -> Graph k cls color -> Graph k cls color -- | Add a coalescence edge to the graph, creating nodes if required. It is -- considered adventageous to assign the same color to nodes in a -- coalesence. addCoalesce :: Uniquable k => (k, cls) -> (k, cls) -> Graph k cls color -> Graph k cls color -- | Delete a coalescence edge (k1 -> k2) from the graph. delCoalesce :: Uniquable k => k -> k -> Graph k cls color -> Maybe (Graph k cls color) -- | Add an exclusion to the graph, creating nodes if required. These are -- extra colors that the node cannot use. addExclusion :: (Uniquable k, Uniquable color) => k -> (k -> cls) -> color -> Graph k cls color -> Graph k cls color addExclusions :: (Uniquable k, Uniquable color) => k -> (k -> cls) -> [color] -> Graph k cls color -> Graph k cls color -- | Add a color preference to the graph, creating nodes if required. The -- most recently added preference is the most preferred. The algorithm -- tries to assign a node it's preferred color if possible. addPreference :: Uniquable k => (k, cls) -> color -> Graph k cls color -> Graph k cls color -- | Coalesce this pair of nodes unconditionally / aggressively. The -- resulting node is the one with the least key. -- -- returns: Just the pair of keys if the nodes were coalesced the second -- element of the pair being the least one -- -- Nothing if either of the nodes weren't in the graph coalesceNodes :: (Uniquable k, Ord k, Eq cls) => Bool -> Triv k cls color -> Graph k cls color -> (k, k) -> (Graph k cls color, Maybe (k, k)) -- | Do aggressive coalescing on this graph. returns the new graph and the -- list of pairs of nodes that got coalesced together. for each pair, the -- resulting node will have the least key and be second in the pair. coalesceGraph :: (Uniquable k, Ord k, Eq cls, Outputable k) => Bool -> Triv k cls color -> Graph k cls color -> (Graph k cls color, [(k, k)]) -- | Freeze a node This is for the iterative coalescer. By freezing a node -- we give up on ever coalescing it. Move all its coalesce edges into the -- frozen set - and update back edges from other nodes. freezeNode :: Uniquable k => k -> Graph k cls color -> Graph k cls color -- | Freeze one node in the graph This if for the iterative coalescer. Look -- for a move related node of low degree and freeze it. -- -- We probably don't need to scan the whole graph looking for the node of -- absolute lowest degree. Just sample the first few and choose the one -- with the lowest degree out of those. Also, we don't make any -- distinction between conflicts of different classes.. this is just a -- heuristic, after all. -- -- IDEA: freezing a node might free it up for Simplify.. would be good to -- check for triv right here, and add it to a worklist if known -- triv/non-move nodes. freezeOneInGraph :: Uniquable k => Graph k cls color -> (Graph k cls color, Bool) -- | Freeze all the nodes in the graph for debugging the iterative -- allocator. freezeAllInGraph :: Uniquable k => Graph k cls color -> Graph k cls color -- | Find all the nodes in the graph that meet some criteria scanGraph :: (Node k cls color -> Bool) -> Graph k cls color -> [Node k cls color] -- | Set the color of a certain node setColor :: Uniquable k => k -> color -> Graph k cls color -> Graph k cls color -- | validate the internal structure of a graph all its edges should point -- to valid nodes If they don't then throw an error validateGraph :: (Uniquable k, Outputable k, Eq color) => SDoc -> Bool -> Graph k cls color -> Graph k cls color -- | Slurp out a map of how many nodes had a certain number of conflict -- neighbours slurpNodeConflictCount :: Graph k cls color -> UniqFM Int (Int, Int) -- | Pretty printing of graphs. module GHC.Data.Graph.Ppr -- | Pretty print a graph in a somewhat human readable format. dumpGraph :: (Outputable k, Outputable color) => Graph k cls color -> SDoc -- | Pretty print a graph in graphviz .dot format. Conflicts get solid -- edges. Coalescences get dashed edges. dotGraph :: (Uniquable k, Outputable k, Outputable cls, Outputable color) => (color -> SDoc) -> Triv k cls color -> Graph k cls color -> SDoc -- | Graph Coloring. This is a generic graph coloring library, abstracted -- over the type of the node keys, nodes and colors. module GHC.Data.Graph.Color -- | Try to color a graph with this set of colors. Uses Chaitin's algorithm -- to color the graph. The graph is scanned for nodes which are deamed -- 'trivially colorable'. These nodes are pushed onto a stack and removed -- from the graph. Once this process is complete the graph can be colored -- by removing nodes from the stack (ie in reverse order) and assigning -- them colors different to their neighbors. colorGraph :: forall k cls color. (Uniquable k, Uniquable cls, Uniquable color, Eq cls, Ord k, Outputable k, Outputable cls, Outputable color) => Bool -> Int -> UniqFM cls (UniqSet color) -> Triv k cls color -> (Graph k cls color -> k) -> Graph k cls color -> (Graph k cls color, UniqSet k, UniqFM k k) module GHC.Data.Graph.UnVar data UnVarSet emptyUnVarSet :: UnVarSet mkUnVarSet :: [Var] -> UnVarSet varEnvDom :: VarEnv a -> UnVarSet unionUnVarSet :: UnVarSet -> UnVarSet -> UnVarSet unionUnVarSets :: [UnVarSet] -> UnVarSet extendUnVarSet :: Var -> UnVarSet -> UnVarSet delUnVarSet :: UnVarSet -> Var -> UnVarSet elemUnVarSet :: Var -> UnVarSet -> Bool isEmptyUnVarSet :: UnVarSet -> Bool data UnVarGraph emptyUnVarGraph :: UnVarGraph unionUnVarGraph :: UnVarGraph -> UnVarGraph -> UnVarGraph unionUnVarGraphs :: [UnVarGraph] -> UnVarGraph completeGraph :: UnVarSet -> UnVarGraph completeBipartiteGraph :: UnVarSet -> UnVarSet -> UnVarGraph neighbors :: UnVarGraph -> Var -> UnVarSet hasLoopAt :: UnVarGraph -> Var -> Bool delNode :: UnVarGraph -> Var -> UnVarGraph instance GHC.Classes.Eq GHC.Data.Graph.UnVar.UnVarSet instance GHC.Utils.Outputable.Outputable GHC.Data.Graph.UnVar.UnVarGraph instance GHC.Utils.Outputable.Outputable GHC.Data.Graph.UnVar.UnVarSet module GHC.Core.Opt.CallArity callArityAnalProgram :: CoreProgram -> CoreProgram callArityRHS :: CoreExpr -> CoreExpr module GHC.Data.UnionFind -- | A variable which can be unified; alternately, this can be thought of -- as an equivalence class with a distinguished representative. newtype Point s a Point :: STRef s (Link s a) -> Point s a -- | Mutable write to a Point writePoint :: Point s a -> Link s a -> ST s () -- | Read the current value of Point. readPoint :: Point s a -> ST s (Link s a) -- | The internal data structure for a Point, which either records -- the representative element of an equivalence class, or a link to the -- Point that actually stores the representative type. data Link s a Info :: {-# UNPACK #-} !STRef s Int -> {-# UNPACK #-} !STRef s a -> Link s a Link :: {-# UNPACK #-} !Point s a -> Link s a -- | Create a fresh equivalence class with one element. fresh :: a -> ST s (Point s a) -- | Flatten any chains of links, returning a Point which points -- directly to the canonical representation. repr :: Point s a -> ST s (Point s a) -- | Return the canonical element of an equivalence class Point. find :: Point s a -> ST s a -- | Unify two equivalence classes, so that they share a canonical element. -- Keeps the descriptor of point2. union :: Point s a -> Point s a -> ST s () -- | Test if two points are in the same equivalence class. equivalent :: Point s a -> Point s a -> ST s Bool instance GHC.Classes.Eq (GHC.Data.UnionFind.Point s a) module GHC.CmmToAsm.CFG -- | A control flow graph where edges have been annotated with a weight. -- Implemented as IntMap (IntMap <edgeData>) We must uphold the -- invariant that for each edge A -> B we must have: A entry B in the -- outer map. A entry B in the map we get when looking up A. Maintaining -- this invariant is useful as any failed lookup now indicates an actual -- error in code which might go unnoticed for a while otherwise. type CFG = EdgeInfoMap EdgeInfo data CfgEdge CfgEdge :: !BlockId -> !BlockId -> !EdgeInfo -> CfgEdge [edgeFrom] :: CfgEdge -> !BlockId [edgeTo] :: CfgEdge -> !BlockId [edgeInfo] :: CfgEdge -> !EdgeInfo -- | Information about edges data EdgeInfo EdgeInfo :: !TransitionSource -> !EdgeWeight -> EdgeInfo [transitionSource] :: EdgeInfo -> !TransitionSource [edgeWeight] :: EdgeInfo -> !EdgeWeight newtype EdgeWeight EdgeWeight :: Double -> EdgeWeight [weightToDouble] :: EdgeWeight -> Double -- | Can we trace back a edge to a specific Cmm Node or has it been -- introduced during assembly codegen. We use this to maintain some -- information which would otherwise be lost during the Cmm <-> asm -- transition. See also Note [Inverting conditions] data TransitionSource CmmSource :: CmmNode O C -> BranchInfo -> TransitionSource [trans_cmmNode] :: TransitionSource -> CmmNode O C [trans_info] :: TransitionSource -> BranchInfo AsmCodeGen :: TransitionSource -- | Adds a edge with the given weight to the cfg If there already existed -- an edge it is overwritten. `addWeightEdge from to weight cfg` addWeightEdge :: BlockId -> BlockId -> EdgeWeight -> CFG -> CFG -- | Adds a new edge, overwrites existing edges if present addEdge :: BlockId -> BlockId -> EdgeInfo -> CFG -> CFG delEdge :: BlockId -> BlockId -> CFG -> CFG -- | Insert a block in the control flow between two other blocks. We pass a -- list of tuples (A,B,C) where * A -> C: Old edge * A -> B -> C -- : New Arc, where B is the new block. It's possible that a block has -- two jumps to the same block in the assembly code. However we still -- only store a single edge for these cases. We assign the old edge info -- to the edge A -> B and assign B -> C the weight of an -- unconditional jump. addNodesBetween :: Weights -> CFG -> [(BlockId, BlockId, BlockId)] -> CFG shortcutWeightMap :: LabelMap (Maybe BlockId) -> CFG -> CFG reverseEdges :: CFG -> CFG -- | Filter the CFG with a custom function f. Parameters are `f from to -- edgeInfo` filterEdges :: (BlockId -> BlockId -> EdgeInfo -> Bool) -> CFG -> CFG -- | Sometimes we insert a block which should unconditionally be executed -- after a given block. This function updates the CFG for these cases. So -- we get A -> B => A -> A' -> B -> C => -> C addImmediateSuccessor :: Weights -> BlockId -> BlockId -> CFG -> CFG -- | Convenience function, generate edge info based on weight not -- originating from cmm. mkWeightInfo :: EdgeWeight -> EdgeInfo -- | Adjust the weight between the blocks using the given function. If -- there is no such edge returns the original map. adjustEdgeWeight :: CFG -> (EdgeWeight -> EdgeWeight) -> BlockId -> BlockId -> CFG -- | Set the weight between the blocks to the given weight. If there is no -- such edge returns the original map. setEdgeWeight :: CFG -> EdgeWeight -> BlockId -> BlockId -> CFG -- | Returns a unordered list of all edges with info infoEdgeList :: CFG -> [CfgEdge] -- | Returns a unordered list of all edges without weights edgeList :: CFG -> [Edge] -- | Get successors of a given node with edge weights. getSuccessorEdges :: HasDebugCallStack => CFG -> BlockId -> [(BlockId, EdgeInfo)] -- | Get successors of a given node without edge weights. getSuccessors :: HasDebugCallStack => CFG -> BlockId -> [BlockId] -- | Destinations from bid ordered by weight (descending) getSuccEdgesSorted :: CFG -> BlockId -> [(BlockId, EdgeInfo)] getEdgeInfo :: BlockId -> BlockId -> CFG -> Maybe EdgeInfo getCfgNodes :: CFG -> [BlockId] -- | Is this block part of this graph? hasNode :: CFG -> BlockId -> Bool -- | Determine loop membership of blocks based on SCC analysis This is -- faster but only gives yes/no answers. loopMembers :: HasDebugCallStack => CFG -> LabelMap Bool loopLevels :: CFG -> BlockId -> LabelMap Int -- | Determine loop membership of blocks based on Dominator analysis. This -- is slower but gives loop levels instead of just loop membership. -- However it only detects natural loops. Irreducible control flow is not -- recognized even if it loops. But that is rare enough that we don't -- have to care about that special case. loopInfo :: HasDebugCallStack => CFG -> BlockId -> LoopInfo getCfg :: Platform -> Weights -> CmmGraph -> CFG -- | Generate weights for a Cmm proc based on some simple heuristics. getCfgProc :: Platform -> Weights -> RawCmmDecl -> CFG pprEdgeWeights :: CFG -> SDoc -- | Check if the nodes in the cfg and the set of blocks are the same. In a -- case of a missmatch we panic and show the difference. sanityCheckCfg :: CFG -> LabelSet -> SDoc -> Bool optimizeCFG :: Bool -> Weights -> RawCmmDecl -> CFG -> CFG -- | We take in a CFG which has on its edges weights which are relative -- only to other edges originating from the same node. -- -- We return a CFG for which each edge represents a GLOBAL weight. This -- means edge weights are comparable across the whole graph. -- -- For irreducible control flow results might be imprecise, otherwise -- they are reliable. -- -- The algorithm is based on the Paper "Static Branch Prediction and -- Program Profile Analysis" by Y Wu, JR Larus The only big change is -- that we go over the nodes in the body of loops in reverse post order. -- Which is required for diamond control flow to work probably. -- -- We also apply a few prediction heuristics (based on the same paper) -- -- The returned result represents frequences. For blocks it's the -- expected number of executions and for edges is the number of -- traversals. mkGlobalWeights :: HasDebugCallStack => BlockId -> CFG -> (LabelMap Double, LabelMap (LabelMap Double)) instance GHC.Real.Fractional GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Real.Real GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Num.Num GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Enum.Enum GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Ord GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Eq GHC.CmmToAsm.CFG.EdgeWeight instance GHC.Classes.Eq GHC.CmmToAsm.CFG.BranchInfo instance GHC.Classes.Eq GHC.CmmToAsm.CFG.TransitionSource instance GHC.Classes.Eq GHC.CmmToAsm.CFG.EdgeInfo instance GHC.Cmm.Dataflow.Graph.NonLocal GHC.CmmToAsm.CFG.BlockNode instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.LoopInfo instance GHC.Classes.Eq GHC.CmmToAsm.CFG.CfgEdge instance GHC.Classes.Ord GHC.CmmToAsm.CFG.CfgEdge instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.CfgEdge instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.EdgeInfo instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.BranchInfo instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.CFG.EdgeWeight module GHC.CmmToAsm.Reg.Liveness type RegSet = UniqSet Reg -- | Map from some kind of register to a. -- -- While we give the type for keys as Reg which is the common case -- sometimes we end up using VirtualReq or naked Uniques. See Note -- [UniqFM and the register allocator] type RegMap a = UniqFM Reg a emptyRegMap :: RegMap a type BlockMap a = LabelMap a mapEmpty :: IsMap map => map a -- | A top level thing which carries liveness information. type LiveCmmDecl statics instr = GenCmmDecl statics LiveInfo [SCC (LiveBasicBlock instr)] -- | The register allocator also wants to use SPILL/RELOAD meta -- instructions, so we'll keep those here. data InstrSR instr -- | A real machine instruction Instr :: instr -> InstrSR instr -- | spill this reg to a stack slot SPILL :: Reg -> Int -> InstrSR instr -- | reload this reg from a stack slot RELOAD :: Int -> Reg -> InstrSR instr -- | An instruction with liveness information. data LiveInstr instr LiveInstr :: InstrSR instr -> Maybe Liveness -> LiveInstr instr -- | Liveness information. The regs which die are ones which are no longer -- live in the *next* instruction in this sequence. (NB. if the -- instruction is a jump, these registers might still be live at the jump -- target(s) - you have to check the liveness at the destination block to -- find out). data Liveness -- | registers that died because they were clobbered by something. Liveness :: RegSet -> RegSet -> RegSet -> Liveness -- | registers born in this instruction (written to for first time). [liveBorn] :: Liveness -> RegSet -- | registers that died because they were read for the last time. [liveDieRead] :: Liveness -> RegSet [liveDieWrite] :: Liveness -> RegSet -- | Stash regs live on entry to each basic block in the info part of the -- cmm code. data LiveInfo LiveInfo :: LabelMap RawCmmStatics -> [BlockId] -> BlockMap RegSet -> BlockMap IntSet -> LiveInfo -- | A basic block with liveness information. type LiveBasicBlock instr = GenBasicBlock (LiveInstr instr) -- | map a function across all the basic blocks in this code mapBlockTop :: (LiveBasicBlock instr -> LiveBasicBlock instr) -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | map a function across all the basic blocks in this code (monadic -- version) mapBlockTopM :: Monad m => (LiveBasicBlock instr -> m (LiveBasicBlock instr)) -> LiveCmmDecl statics instr -> m (LiveCmmDecl statics instr) mapSCCM :: Monad m => (a -> m b) -> SCC a -> m (SCC b) mapGenBlockTop :: (GenBasicBlock i -> GenBasicBlock i) -> GenCmmDecl d h (ListGraph i) -> GenCmmDecl d h (ListGraph i) -- | map a function across all the basic blocks in this code (monadic -- version) mapGenBlockTopM :: Monad m => (GenBasicBlock i -> m (GenBasicBlock i)) -> GenCmmDecl d h (ListGraph i) -> m (GenCmmDecl d h (ListGraph i)) -- | Map over instruction type in LiveCmmDecl mapLiveCmmDecl :: (instr -> b) -> LiveCmmDecl statics instr -> LiveCmmDecl statics b -- | Pretty-print a LiveCmmDecl pprLiveCmmDecl :: (OutputableP Platform statics, Instruction instr) => Platform -> LiveCmmDecl statics instr -> SDoc -- | Strip away liveness information, yielding NatCmmDecl stripLive :: (OutputableP Platform statics, Instruction instr) => NCGConfig -> LiveCmmDecl statics instr -> NatCmmDecl statics instr -- | Strip away liveness information from a basic block, and make real -- spill instructions out of SPILL, RELOAD pseudos along the way. stripLiveBlock :: Instruction instr => NCGConfig -> LiveBasicBlock instr -> NatBasicBlock instr -- | Slurp out the list of register conflicts and reg-reg moves from this -- top level thing. Slurping of conflicts and moves is wrapped up -- together so we don't have to make two passes over the same code when -- we want to build the graph. slurpConflicts :: Instruction instr => LiveCmmDecl statics instr -> (Bag (UniqSet Reg), Bag (Reg, Reg)) -- | For spill/reloads -- -- SPILL v1, slot1 ... RELOAD slot1, v2 -- -- If we can arrange that v1 and v2 are allocated to the same hreg it's -- more likely the spill/reload instrs can be cleaned and replaced by a -- nop reg-reg move. slurpReloadCoalesce :: forall statics instr. Instruction instr => LiveCmmDecl statics instr -> Bag (Reg, Reg) -- | Erase Delta instructions. eraseDeltasLive :: Instruction instr => LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | Patch the registers in this code according to this register mapping. -- also erase reg -> reg moves when the reg is the same. also erase -- reg -> reg moves when the destination dies in this instr. patchEraseLive :: Instruction instr => (Reg -> Reg) -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr -- | Patch registers in this LiveInstr, including the liveness information. patchRegsLiveInstr :: Instruction instr => (Reg -> Reg) -> LiveInstr instr -> LiveInstr instr -- | If we've compute liveness info for this code already we have to -- reverse the SCCs in each top to get them back to the right order so we -- can do it again. reverseBlocksInTops :: LiveCmmDecl statics instr -> LiveCmmDecl statics instr regLiveness :: Instruction instr => Platform -> LiveCmmDecl statics instr -> UniqSM (LiveCmmDecl statics instr) -- | Convert a NatCmmDecl to a LiveCmmDecl, with liveness information cmmTopLiveness :: Instruction instr => Maybe CFG -> Platform -> NatCmmDecl statics instr -> UniqSM (LiveCmmDecl statics instr) instance GHC.Base.Functor GHC.CmmToAsm.Reg.Liveness.InstrSR instance GHC.Base.Functor GHC.CmmToAsm.Reg.Liveness.LiveInstr instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.CmmToAsm.Reg.Liveness.LiveInfo instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Liveness.LiveInstr instr) instance GHC.Utils.Outputable.OutputableP env instr => GHC.Utils.Outputable.OutputableP env (GHC.CmmToAsm.Reg.Liveness.LiveInstr instr) instance GHC.CmmToAsm.Instr.Instruction instr => GHC.CmmToAsm.Instr.Instruction (GHC.CmmToAsm.Reg.Liveness.InstrSR instr) instance GHC.Utils.Outputable.Outputable instr => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Liveness.InstrSR instr) -- | Put common type definitions here to break recursive module -- dependencies. module GHC.CmmToAsm.Reg.Linear.Base -- | Used to store the register assignment on entry to a basic block. We -- use this to handle join points, where multiple branch instructions -- target a particular label. We have to insert fixup code to make the -- register assignments from the different sources match up. data BlockAssignment freeRegs -- | Find the register mapping for a specific BlockId. lookupBlockAssignment :: BlockId -> BlockAssignment freeRegs -> Maybe (freeRegs, RegMap Loc) -- | Lookup which register a virtual register was first assigned to. lookupFirstUsed :: VirtualReg -> BlockAssignment freeRegs -> Maybe RealReg -- | An initial empty BlockAssignment emptyBlockAssignment :: BlockAssignment freeRegs -- | Add new register mappings for a specific block. updateBlockAssignment :: BlockId -> (freeRegs, RegMap Loc) -> BlockAssignment freeRegs -> BlockAssignment freeRegs -- | Where a vreg is currently stored A temporary can be marked as living -- in both a register and memory (InBoth), for example if it was recently -- loaded from a spill location. This makes it cheap to spill (no save -- instruction required), but we have to be careful to turn this into -- InReg if the value in the register is changed. data Loc -- | vreg is in a register InReg :: !RealReg -> Loc -- | vreg is held in a stack slot InMem :: {-# UNPACK #-} !StackSlot -> Loc -- | vreg is held in both a register and a stack slot InBoth :: !RealReg -> {-# UNPACK #-} !StackSlot -> Loc -- | Get the reg numbers stored in this Loc. regsOfLoc :: Loc -> [RealReg] -- | Reasons why instructions might be inserted by the spiller. Used when -- generating stats for -ddrop-asm-stats. data SpillReason -- | vreg was spilled to a slot so we could use its current hreg for -- another vreg SpillAlloc :: !Unique -> SpillReason -- | vreg was moved because its hreg was clobbered SpillClobber :: !Unique -> SpillReason -- | vreg was loaded from a spill slot SpillLoad :: !Unique -> SpillReason -- | reg-reg move inserted during join to targets SpillJoinRR :: !Unique -> SpillReason -- | reg-mem move inserted during join to targets SpillJoinRM :: !Unique -> SpillReason -- | Used to carry interesting stats out of the register allocator. data RegAllocStats RegAllocStats :: UniqFM Unique [Int] -> [(BlockId, BlockId, BlockId)] -> RegAllocStats [ra_spillInstrs] :: RegAllocStats -> UniqFM Unique [Int] -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixupList] :: RegAllocStats -> [(BlockId, BlockId, BlockId)] -- | The register allocator state data RA_State freeRegs RA_State :: BlockAssignment freeRegs -> !freeRegs -> RegMap Loc -> Int -> StackMap -> UniqSupply -> [SpillReason] -> !NCGConfig -> [(BlockId, BlockId, BlockId)] -> RA_State freeRegs -- | the current mapping from basic blocks to the register assignments at -- the beginning of that block. [ra_blockassig] :: RA_State freeRegs -> BlockAssignment freeRegs -- | free machine registers [ra_freeregs] :: RA_State freeRegs -> !freeRegs -- | assignment of temps to locations [ra_assig] :: RA_State freeRegs -> RegMap Loc -- | current stack delta [ra_delta] :: RA_State freeRegs -> Int -- | free stack slots for spilling [ra_stack] :: RA_State freeRegs -> StackMap -- | unique supply for generating names for join point fixup blocks. [ra_us] :: RA_State freeRegs -> UniqSupply -- | Record why things were spilled, for -ddrop-asm-stats. Just keep a list -- here instead of a map of regs -> reasons. We don't want to slow -- down the allocator if we're not going to emit the stats. [ra_spills] :: RA_State freeRegs -> [SpillReason] -- | Native code generator configuration [ra_config] :: RA_State freeRegs -> !NCGConfig -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixups] :: RA_State freeRegs -> [(BlockId, BlockId, BlockId)] instance GHC.Classes.Ord GHC.CmmToAsm.Reg.Linear.Base.ReadingOrWriting instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Linear.Base.ReadingOrWriting instance GHC.Classes.Ord GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Show.Show GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Classes.Eq GHC.CmmToAsm.Reg.Linear.Base.Loc instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Linear.Base.Loc module GHC.CmmToAsm.Reg.Linear.Stats -- | Build a map of how many times each reg was alloced, clobbered, loaded -- etc. binSpillReasons :: [SpillReason] -> UniqFM Unique [Int] -- | Count reg-reg moves remaining in this code. countRegRegMovesNat :: Instruction instr => NatCmmDecl statics instr -> Int -- | Pretty print some RegAllocStats pprStats :: Instruction instr => [NatCmmDecl statics instr] -> [RegAllocStats] -> SDoc -- | State monad for the linear register allocator. module GHC.CmmToAsm.Reg.Linear.State -- | The register allocator state data RA_State freeRegs RA_State :: BlockAssignment freeRegs -> !freeRegs -> RegMap Loc -> Int -> StackMap -> UniqSupply -> [SpillReason] -> !NCGConfig -> [(BlockId, BlockId, BlockId)] -> RA_State freeRegs -- | the current mapping from basic blocks to the register assignments at -- the beginning of that block. [ra_blockassig] :: RA_State freeRegs -> BlockAssignment freeRegs -- | free machine registers [ra_freeregs] :: RA_State freeRegs -> !freeRegs -- | assignment of temps to locations [ra_assig] :: RA_State freeRegs -> RegMap Loc -- | current stack delta [ra_delta] :: RA_State freeRegs -> Int -- | free stack slots for spilling [ra_stack] :: RA_State freeRegs -> StackMap -- | unique supply for generating names for join point fixup blocks. [ra_us] :: RA_State freeRegs -> UniqSupply -- | Record why things were spilled, for -ddrop-asm-stats. Just keep a list -- here instead of a map of regs -> reasons. We don't want to slow -- down the allocator if we're not going to emit the stats. [ra_spills] :: RA_State freeRegs -> [SpillReason] -- | Native code generator configuration [ra_config] :: RA_State freeRegs -> !NCGConfig -- | (from,fixup,to) : We inserted fixup code between from and to [ra_fixups] :: RA_State freeRegs -> [(BlockId, BlockId, BlockId)] -- | The register allocator monad type. data RegM freeRegs a -- | Run a computation in the RegM register allocator monad. runR :: NCGConfig -> BlockAssignment freeRegs -> freeRegs -> RegMap Loc -> StackMap -> UniqSupply -> RegM freeRegs a -> (BlockAssignment freeRegs, StackMap, RegAllocStats, a) spillR :: Instruction instr => Reg -> Unique -> RegM freeRegs ([instr], Int) loadR :: Instruction instr => Reg -> Int -> RegM freeRegs [instr] getFreeRegsR :: RegM freeRegs freeRegs setFreeRegsR :: freeRegs -> RegM freeRegs () getAssigR :: RegM freeRegs (RegMap Loc) setAssigR :: RegMap Loc -> RegM freeRegs () getBlockAssigR :: RegM freeRegs (BlockAssignment freeRegs) setBlockAssigR :: BlockAssignment freeRegs -> RegM freeRegs () setDeltaR :: Int -> RegM freeRegs () getDeltaR :: RegM freeRegs Int getUniqueR :: RegM freeRegs Unique -- | Get native code generator configuration getConfig :: RegM a NCGConfig -- | Get target platform from native code generator configuration getPlatform :: RegM a Platform -- | Record that a spill instruction was inserted, for profiling. recordSpill :: SpillReason -> RegM freeRegs () -- | Record a created fixup block recordFixupBlock :: BlockId -> BlockId -> BlockId -> RegM freeRegs () instance GHC.Base.Functor (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) instance GHC.Base.Applicative (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) instance GHC.Base.Monad (GHC.CmmToAsm.Reg.Linear.State.RegM freeRegs) -- | Handles joining of a jump instruction to its targets. module GHC.CmmToAsm.Reg.Linear.JoinToTargets -- | For a jump instruction at the end of a block, generate fixup code so -- its vregs are in the correct regs for its destination. joinToTargets :: (FR freeRegs, Instruction instr) => BlockMap RegSet -> BlockId -> instr -> RegM freeRegs ([NatBasicBlock instr], instr) module GHC.CmmToAsm.Reg.Linear regAlloc :: Instruction instr => NCGConfig -> LiveCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, Maybe Int, Maybe RegAllocStats) -- | Clean out unneeded spill/reload instructions. -- -- Handling of join points ~~~~~~~~~~~~~~~~~~~~~~~ -- --
--   B1:                          B2:
--    ...                          ...
--       RELOAD SLOT(0), %r1          RELOAD SLOT(0), %r1
--       ... A ...                    ... B ...
--       jump B3                      jump B3
--   
--                B3: ... C ...
--                    RELOAD SLOT(0), %r1
--                    ...
--   
--   
-- -- The Plan ~~~~~~~~ -- -- As long as %r1 hasn't been written to in A, B or C then we don't need -- the reload in B3. -- -- What we really care about here is that on the entry to B3, %r1 will -- always have the same value that is in SLOT(0) (ie, %r1 is _valid_) -- -- This also works if the reloads in B1/B2 were spills instead, because -- spilling %r1 to a slot makes that slot have the same value as %r1. module GHC.CmmToAsm.Reg.Graph.SpillClean -- | Clean out unneeded spill/reloads from this top level thing. cleanSpills :: Instruction instr => Platform -> LiveCmmDecl statics instr -> LiveCmmDecl statics instr instance GHC.Types.Unique.Uniquable GHC.CmmToAsm.Reg.Graph.SpillClean.Store instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Graph.SpillClean.Store -- | When there aren't enough registers to hold all the vregs we have to -- spill some of those vregs to slots on the stack. This module is used -- modify the code to use those slots. module GHC.CmmToAsm.Reg.Graph.Spill -- | Spill all these virtual regs to stack slots. -- -- Bumps the number of required stack slots if required. -- -- TODO: See if we can split some of the live ranges instead of just -- globally spilling the virtual reg. This might make the spill cleaner's -- job easier. -- -- TODO: On CISCy x86 and x86_64 we don't necessarily have to add a mov -- instruction when making spills. If an instr is using a spilled virtual -- we may be able to address the spill slot directly. regSpill :: Instruction instr => Platform -> [LiveCmmDecl statics instr] -> UniqSet Int -> Int -> UniqSet VirtualReg -> UniqSM ([LiveCmmDecl statics instr], UniqSet Int, Int, SpillStats) -- | Spiller statistics. Tells us what registers were spilled. data SpillStats SpillStats :: UniqFM Reg (Reg, Int, Int) -> SpillStats [spillStoreLoad] :: SpillStats -> UniqFM Reg (Reg, Int, Int) -- | Add a spill/reload count to a stats record for a register. accSpillSL :: (Reg, Int, Int) -> (Reg, Int, Int) -> (Reg, Int, Int) instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.Reg.Graph.Spill.SpillStats -- | Register coalescing. module GHC.CmmToAsm.Reg.Graph.Coalesce -- | Do register coalescing on this top level thing -- -- For Reg -> Reg moves, if the first reg dies at the same time the -- second reg is born then the mov only serves to join live ranges. The -- two regs can be renamed to be the same and the move instruction safely -- erased. regCoalesce :: Instruction instr => [LiveCmmDecl statics instr] -> UniqSM [LiveCmmDecl statics instr] -- | Slurp out mov instructions that only serve to join live ranges. -- -- During a mov, if the source reg dies and the destination reg is born -- then we can rename the two regs to the same thing and eliminate the -- move. slurpJoinMovs :: Instruction instr => LiveCmmDecl statics instr -> Bag (Reg, Reg) module GHC.CmmToAsm.Reg.Graph.SpillCost -- | Records the expected cost to spill some register. type SpillCostRecord = (VirtualReg, Int, Int, Int) -- | Add two spill cost records. plusSpillCostRecord :: SpillCostRecord -> SpillCostRecord -> SpillCostRecord -- | Show a spill cost record, including the degree from the graph and -- final calculated spill cost. pprSpillCostRecord :: (VirtualReg -> RegClass) -> (Reg -> SDoc) -> Graph VirtualReg RegClass RealReg -> SpillCostRecord -> SDoc -- | Map of SpillCostRecord type SpillCostInfo = UniqFM VirtualReg SpillCostRecord -- | An empty map of spill costs. zeroSpillCostInfo :: SpillCostInfo -- | Add two spill cost infos. plusSpillCostInfo :: SpillCostInfo -> SpillCostInfo -> SpillCostInfo -- | Slurp out information used for determining spill costs. -- -- For each vreg, the number of times it was written to, read from, and -- the number of instructions it was live on entry to (lifetime) slurpSpillCostInfo :: forall instr statics. Instruction instr => Platform -> Maybe CFG -> LiveCmmDecl statics instr -> SpillCostInfo -- | Choose a node to spill from this graph chooseSpill :: SpillCostInfo -> Graph VirtualReg RegClass RealReg -> VirtualReg -- | Extract a map of register lifetimes from a SpillCostInfo. lifeMapFromSpillCostInfo :: SpillCostInfo -> UniqFM VirtualReg (VirtualReg, Int) -- | Carries interesting info for debugging / profiling of the graph -- coloring register allocator. module GHC.CmmToAsm.Reg.Graph.Stats -- | Holds interesting statistics from the register allocator. data RegAllocStats statics instr RegAllocStatsStart :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> SpillCostInfo -> !Platform -> RegAllocStats statics instr -- | Initial code, with liveness. [raLiveCmm] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | Information to help choose which regs to spill. [raSpillCosts] :: RegAllocStats statics instr -> SpillCostInfo -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform RegAllocStatsSpill :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> UniqFM VirtualReg VirtualReg -> SpillStats -> SpillCostInfo -> [LiveCmmDecl statics instr] -> !Platform -> RegAllocStats statics instr -- | Code we tried to allocate registers for. [raCode] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | The regs that were coalesced. [raCoalesced] :: RegAllocStats statics instr -> UniqFM VirtualReg VirtualReg -- | Spiller stats. [raSpillStats] :: RegAllocStats statics instr -> SpillStats -- | Information to help choose which regs to spill. [raSpillCosts] :: RegAllocStats statics instr -> SpillCostInfo -- | Code with spill instructions added. [raSpilled] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform RegAllocStatsColored :: [LiveCmmDecl statics instr] -> Graph VirtualReg RegClass RealReg -> Graph VirtualReg RegClass RealReg -> UniqFM VirtualReg VirtualReg -> [LiveCmmDecl statics instr] -> [LiveCmmDecl statics instr] -> [LiveCmmDecl statics instr] -> [NatCmmDecl statics instr] -> (Int, Int, Int) -> !Platform -> RegAllocStats statics instr -- | Code we tried to allocate registers for. [raCode] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | The initial, uncolored graph. [raGraph] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | Coalesced and colored graph. [raGraphColored] :: RegAllocStats statics instr -> Graph VirtualReg RegClass RealReg -- | The regs that were coalesced. [raCoalesced] :: RegAllocStats statics instr -> UniqFM VirtualReg VirtualReg -- | Code with coalescings applied. [raCodeCoalesced] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Code with vregs replaced by hregs. [raPatched] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Code with unneeded spill/reloads cleaned out. [raSpillClean] :: RegAllocStats statics instr -> [LiveCmmDecl statics instr] -- | Final code. [raFinal] :: RegAllocStats statics instr -> [NatCmmDecl statics instr] -- | Spill/reload/reg-reg moves present in this code. [raSRMs] :: RegAllocStats statics instr -> (Int, Int, Int) -- | Target platform [raPlatform] :: RegAllocStats statics instr -> !Platform -- | Do all the different analysis on this list of RegAllocStats pprStats :: [RegAllocStats statics instr] -> Graph VirtualReg RegClass RealReg -> SDoc -- | Dump a table of how many spill loads / stores were inserted for each -- vreg. pprStatsSpills :: [RegAllocStats statics instr] -> SDoc -- | Dump a table of how long vregs tend to live for in the initial code. pprStatsLifetimes :: [RegAllocStats statics instr] -> SDoc -- | Dump a table of how many conflicts vregs tend to have in the initial -- code. pprStatsConflict :: [RegAllocStats statics instr] -> SDoc -- | For every vreg, dump how many conflicts it has, and its lifetime. Good -- for making a scatter plot. pprStatsLifeConflict :: [RegAllocStats statics instr] -> Graph VirtualReg RegClass RealReg -> SDoc -- | Count spillreloadreg-reg moves. Lets us see how well the -- register allocator has done. countSRMs :: Instruction instr => LiveCmmDecl statics instr -> (Int, Int, Int) addSRM :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int) instance GHC.Base.Functor (GHC.CmmToAsm.Reg.Graph.Stats.RegAllocStats statics) instance (GHC.Utils.Outputable.OutputableP GHC.Platform.Platform statics, GHC.Utils.Outputable.OutputableP GHC.Platform.Platform instr) => GHC.Utils.Outputable.Outputable (GHC.CmmToAsm.Reg.Graph.Stats.RegAllocStats statics instr) -- | Graph coloring register allocator. module GHC.CmmToAsm.Reg.Graph -- | The top level of the graph coloring register allocator. regAlloc :: (OutputableP Platform statics, Instruction instr) => NCGConfig -> UniqFM RegClass (UniqSet RealReg) -> UniqSet Int -> Int -> [LiveCmmDecl statics instr] -> Maybe CFG -> UniqSM ([NatCmmDecl statics instr], Maybe Int, [RegAllocStats statics instr]) module GHC.CmmToAsm.Monad data NcgImpl statics instr jumpDest NcgImpl :: !NCGConfig -> (RawCmmDecl -> NatM [NatCmmDecl statics instr]) -> (instr -> Maybe (NatCmmDecl statics instr)) -> (jumpDest -> Maybe BlockId) -> (instr -> Maybe jumpDest) -> ((BlockId -> Maybe jumpDest) -> statics -> statics) -> ((BlockId -> Maybe jumpDest) -> instr -> instr) -> (NatCmmDecl statics instr -> SDoc) -> Int -> [RealReg] -> (Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)])) -> (LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> ([instr] -> [UnwindPoint]) -> (Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> NcgImpl statics instr jumpDest [ncgConfig] :: NcgImpl statics instr jumpDest -> !NCGConfig [cmmTopCodeGen] :: NcgImpl statics instr jumpDest -> RawCmmDecl -> NatM [NatCmmDecl statics instr] [generateJumpTableForInstr] :: NcgImpl statics instr jumpDest -> instr -> Maybe (NatCmmDecl statics instr) [getJumpDestBlockId] :: NcgImpl statics instr jumpDest -> jumpDest -> Maybe BlockId [canShortcut] :: NcgImpl statics instr jumpDest -> instr -> Maybe jumpDest [shortcutStatics] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> statics -> statics [shortcutJump] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> instr -> instr -- | Module is only for printing internal labels. See Note [Internal -- proc labels] in CLabel. [pprNatCmmDecl] :: NcgImpl statics instr jumpDest -> NatCmmDecl statics instr -> SDoc [maxSpillSlots] :: NcgImpl statics instr jumpDest -> Int [allocatableRegs] :: NcgImpl statics instr jumpDest -> [RealReg] -- | The list of block ids records the redirected jumps to allow us to -- update the CFG. [ncgAllocMoreStack] :: NcgImpl statics instr jumpDest -> Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)]) [ncgMakeFarBranches] :: NcgImpl statics instr jumpDest -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] -- | given the instruction sequence of a block, produce a list of the -- block's UnwindPoints See Note [What is this unwinding -- business?] in GHC.Cmm.DebugBlock and Note [Unwinding -- information in the NCG] in this module. [extractUnwindPoints] :: NcgImpl statics instr jumpDest -> [instr] -> [UnwindPoint] -- | Turn the sequence of jcc l1; jmp l2 into jncc l2; -- <block_l1> when possible. [invertCondBranches] :: NcgImpl statics instr jumpDest -> Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] data NatM_State NatM_State :: UniqSupply -> Int -> [CLabel] -> Maybe Reg -> NCGConfig -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State [natm_us] :: NatM_State -> UniqSupply [natm_delta] :: NatM_State -> Int [natm_imports] :: NatM_State -> [CLabel] [natm_pic] :: NatM_State -> Maybe Reg [natm_config] :: NatM_State -> NCGConfig [natm_modloc] :: NatM_State -> ModLocation [natm_fileid] :: NatM_State -> DwarfFiles [natm_debug_map] :: NatM_State -> LabelMap DebugBlock -- | Having a CFG with additional information is essential for some -- operations. However we can't reconstruct all information once we -- generated instructions. So instead we update the CFG as we go. [natm_cfg] :: NatM_State -> CFG mkNatM_State :: UniqSupply -> Int -> NCGConfig -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State data NatM result initNat :: NatM_State -> NatM a -> (a, NatM_State) addImportNat :: CLabel -> NatM () -- | Record that we added a block between from and old. addNodeBetweenNat :: BlockId -> BlockId -> BlockId -> NatM () -- | Place succ after block and change any edges block -- -> X to succ -> X addImmediateSuccessorNat :: BlockId -> BlockId -> NatM () updateCfgNat :: (CFG -> CFG) -> NatM () getUniqueNat :: NatM Unique mapAccumLNat :: (acc -> x -> NatM (acc, y)) -> acc -> [x] -> NatM (acc, [y]) setDeltaNat :: Int -> NatM () -- | Get native code generator configuration getConfig :: NatM NCGConfig -- | Get target platform from native code generator configuration getPlatform :: NatM Platform getDeltaNat :: NatM Int getThisModuleNat :: NatM Module getBlockIdNat :: NatM BlockId getNewLabelNat :: NatM CLabel getNewRegNat :: Format -> NatM Reg getPicBaseMaybeNat :: NatM (Maybe Reg) getPicBaseNat :: Format -> NatM Reg -- | Get CFG edge weights getCfgWeights :: NatM Weights getModLoc :: NatM ModLocation getFileId :: FastString -> NatM Int getDebugBlock :: Label -> NatM (Maybe DebugBlock) type DwarfFiles = UniqFM FastString (FastString, Int) -- | Two 32-bit regs used as a single virtual 64-bit register data Reg64 Reg64 :: !Reg -> !Reg -> Reg64 -- | Two 32-bit regs used as a single virtual 64-bit register and the code -- to set them appropriately data RegCode64 code RegCode64 :: code -> !Reg -> !Reg -> RegCode64 code -- | Return a virtual 64-bit register getNewReg64 :: NatM Reg64 -- | Convert a 64-bit LocalReg into two virtual 32-bit regs. -- -- Used to handle 64-bit "registers" on 32-bit architectures localReg64 :: HasDebugCallStack => LocalReg -> Reg64 instance GHC.Base.Functor GHC.CmmToAsm.Monad.NatM instance GHC.Base.Applicative GHC.CmmToAsm.Monad.NatM instance GHC.Base.Monad GHC.CmmToAsm.Monad.NatM instance GHC.Types.Unique.Supply.MonadUnique GHC.CmmToAsm.Monad.NatM instance GHC.Unit.Module.HasModule GHC.CmmToAsm.Monad.NatM module GHC.CmmToAsm.PIC cmmMakeDynamicReference :: CmmMakeDynamicReferenceM m => NCGConfig -> ReferenceKind -> CLabel -> m CmmExpr class Monad m => CmmMakeDynamicReferenceM m addImport :: CmmMakeDynamicReferenceM m => CLabel -> m () data ReferenceKind DataReference :: ReferenceKind CallReference :: ReferenceKind JumpReference :: ReferenceKind needImportedSymbols :: NCGConfig -> Bool pprImportedSymbol :: NCGConfig -> CLabel -> SDoc pprGotDeclaration :: NCGConfig -> SDoc initializePicBase_ppc :: Arch -> OS -> Reg -> [NatCmmDecl RawCmmStatics Instr] -> NatM [NatCmmDecl RawCmmStatics Instr] initializePicBase_x86 :: Arch -> OS -> Reg -> [NatCmmDecl (Alignment, RawCmmStatics) Instr] -> NatM [NatCmmDecl (Alignment, RawCmmStatics) Instr] instance GHC.Classes.Eq GHC.CmmToAsm.PIC.ReferenceKind instance GHC.CmmToAsm.PIC.CmmMakeDynamicReferenceM GHC.CmmToAsm.Monad.NatM module GHC.CmmToAsm.PPC.CodeGen -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal (pre-order?) yields the -- insns in the correct order. cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl RawCmmStatics Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl RawCmmStatics Instr) -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr module GHC.CmmToAsm.AArch64.CodeGen cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl RawCmmStatics Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl RawCmmStatics Instr) module GHC.CmmToAsm.BlockLayout sequenceTop :: Instruction instr => NcgImpl statics instr jumpDest -> Maybe CFG -> NatCmmDecl statics instr -> NatCmmDecl statics instr backendMaintainsCfg :: Platform -> Bool instance GHC.Classes.Eq GHC.CmmToAsm.BlockLayout.BlockChain instance GHC.Classes.Ord GHC.CmmToAsm.BlockLayout.BlockChain instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.BlockLayout.BlockChain module GHC.Driver.Config.Cmm initCmmConfig :: DynFlags -> CmmConfig module GHC.Driver.Config.CmmToAsm -- | Initialize the native code generator configuration from the DynFlags initNCGConfig :: DynFlags -> Module -> NCGConfig module GHC.Driver.Config.Finder -- | Locations and information the finder cares about. -- -- Should be taken from DynFlags via initFinderOpts. data FinderOpts FinderOpts :: [FilePath] -> Bool -> Bool -> Ways -> Bool -> Maybe FilePath -> Maybe FastString -> Set ModuleName -> Set ModuleName -> Maybe FilePath -> String -> Maybe FilePath -> String -> String -> Maybe FilePath -> String -> String -> Maybe FilePath -> FinderOpts -- | Where are we allowed to look for Modules and Source files [finder_importPaths] :: FinderOpts -> [FilePath] -- | When looking up a home module: -- -- [finder_lookupHomeInterfaces] :: FinderOpts -> Bool -- | Don't check that an imported interface file actually exists if it can -- only be at one location. The interface will be reported as -- InstalledFound even if the file doesn't exist, so this is only -- useful in specific cases (e.g. to generate dependencies with `ghc -M`) [finder_bypassHiFileCheck] :: FinderOpts -> Bool [finder_ways] :: FinderOpts -> Ways -- | If we encounter unknown modules, should we suggest modules that have a -- similar name. [finder_enableSuggestions] :: FinderOpts -> Bool [finder_workingDirectory] :: FinderOpts -> Maybe FilePath [finder_thisPackageName] :: FinderOpts -> Maybe FastString [finder_hiddenModules] :: FinderOpts -> Set ModuleName [finder_reexportedModules] :: FinderOpts -> Set ModuleName [finder_hieDir] :: FinderOpts -> Maybe FilePath [finder_hieSuf] :: FinderOpts -> String [finder_hiDir] :: FinderOpts -> Maybe FilePath [finder_hiSuf] :: FinderOpts -> String [finder_dynHiSuf] :: FinderOpts -> String [finder_objectDir] :: FinderOpts -> Maybe FilePath [finder_objectSuf] :: FinderOpts -> String [finder_dynObjectSuf] :: FinderOpts -> String [finder_stubDir] :: FinderOpts -> Maybe FilePath -- | Create a new FinderOpts from DynFlags. initFinderOpts :: DynFlags -> FinderOpts module GHC.Driver.Config.HsToCore initBangOpts :: DynFlags -> BangOpts module GHC.Driver.Config.Stg.Ppr -- | Initialize STG pretty-printing options from DynFlags initStgPprOpts :: DynFlags -> StgPprOpts module GHC.Driver.Config.StgToCmm initStgToCmmConfig :: DynFlags -> Module -> StgToCmmConfig module GHC.Driver.Pipeline.LogQueue -- | Each module is given a unique LogQueue to redirect compilation -- messages to. A Nothing value contains the result of -- compilation, and denotes the end of the message queue. data LogQueue LogQueue :: !Int -> !IORef [Maybe (MessageClass, SrcSpan, SDoc, LogFlags)] -> !MVar () -> LogQueue [logQueueId] :: LogQueue -> !Int [logQueueMessages] :: LogQueue -> !IORef [Maybe (MessageClass, SrcSpan, SDoc, LogFlags)] [logQueueSemaphore] :: LogQueue -> !MVar () newLogQueue :: Int -> IO LogQueue finishLogQueue :: LogQueue -> IO () writeLogQueue :: LogQueue -> (MessageClass, SrcSpan, SDoc, LogFlags) -> IO () parLogAction :: LogQueue -> LogAction data LogQueueQueue LogQueueQueue :: Int -> IntMap LogQueue -> LogQueueQueue initLogQueue :: TVar LogQueueQueue -> LogQueue -> STM () -- | Return all items in the queue in ascending order allLogQueues :: LogQueueQueue -> [LogQueue] newLogQueueQueue :: LogQueueQueue logThread :: Int -> Int -> Logger -> TVar Bool -> TVar LogQueueQueue -> IO (IO ()) -- | See GHC 15021. module GHC.HandleEncoding -- | Handle GHC-specific character encoding flags, allowing us to control -- how GHC produces output regardless of OS. configureHandleEncoding :: IO () -- | Statistics for per-module compilations -- -- (c) The GRASP/AQUA Project, Glasgow University, 1993-1998 module GHC.Hs.Stats -- | Source Statistics ppSourceStats :: Bool -> Located HsModule -> SDoc -- | Compute the Type of an HsExpr GhcTc in a -- pure fashion. -- -- Note that this does not currently support the use case of -- annotating every subexpression in an HsExpr with its -- Type. For more information on this task, see 15320, 17331. module GHC.Hs.Syn.Type -- | Compute the Type of an LHsExpr GhcTc in -- a pure fashion. lhsExprType :: LHsExpr GhcTc -> Type -- | Compute the Type of an HsExpr GhcTc in a -- pure fashion. hsExprType :: HsExpr GhcTc -> Type hsWrapperType :: HsWrapper -> Type -> Type hsLitType :: HsLit (GhcPass p) -> Type hsPatType :: Pat GhcTc -> Type hsLPatType :: LPat GhcTc -> Type module GHC.HsToCore.Coverage data CoverageConfig CoverageConfig :: Logger -> DynFlags -> Maybe Interp -> CoverageConfig [coverageConfig_logger] :: CoverageConfig -> Logger [coverageConfig_dynFlags] :: CoverageConfig -> DynFlags [coverageConfig_mInterp] :: CoverageConfig -> Maybe Interp addTicksToBinds :: CoverageConfig -> Module -> ModLocation -> NameSet -> [TyCon] -> LHsBinds GhcTc -> IO (LHsBinds GhcTc, HpcInfo, Maybe ModBreaks) hpcInitCode :: Platform -> Module -> HpcInfo -> CStub instance GHC.Classes.Eq GHC.HsToCore.Coverage.TickDensity instance GHC.Classes.Eq GHC.HsToCore.Coverage.TickishType instance GHC.Base.Functor GHC.HsToCore.Coverage.TM instance GHC.Base.Applicative GHC.HsToCore.Coverage.TM instance GHC.Base.Monad GHC.HsToCore.Coverage.TM -- | Extract docs from the renamer output so they can be serialized. module GHC.HsToCore.Docs -- | Extract docs from renamer output. This is monadic since we need to be -- able to read documentation added from Template Haskell's -- putDoc, which is stored in tcg_th_docs. extractDocs :: MonadIO m => DynFlags -> TcGblEnv -> m (Maybe Docs) -- | If we have an explicit export list, we extract the documentation -- structure from that. Otherwise we use the renamed exports and -- declarations. mkDocStructure :: Module -> ImportAvails -> Maybe [(LIE GhcRn, Avails)] -> HsGroup GhcRn -> [AvailInfo] -> OccEnv Name -> DocStructure mkDocStructureFromExportList :: Module -> ImportAvails -> [(LIE GhcRn, Avails)] -> DocStructure -- | Figure out the documentation structure by correlating the module -- exports with the located declarations. mkDocStructureFromDecls :: OccEnv Name -> [AvailInfo] -> HsGroup GhcRn -> DocStructure -- | Extract named documentation chunks from the renamed declarations. -- -- If there is no explicit export list, we simply return an empty map -- since there would be no way to link to a named chunk. getNamedChunks :: Bool -> HsGroup (GhcPass pass) -> Map String (HsDoc (GhcPass pass)) -- | Create decl and arg doc-maps by looping through the declarations. For -- each declaration, find its names, its subordinates, and its doc -- strings. mkMaps :: OccEnv Name -> [Name] -> [(LHsDecl GhcRn, [HsDoc GhcRn])] -> (UniqMap Name [HsDoc GhcRn], UniqMap Name (IntMap (HsDoc GhcRn))) getMainDeclBinder :: OccEnv Name -> HsDecl GhcRn -> [Name] -- | The "OccEnv Name" is the default method environment for this module -- Ultimately, the a special "defaultMethodOcc" name is used for the -- signatures on bindings for default methods. Unfortunately, this name -- isn't generated until typechecking, so it is not in the renamed AST. -- We have to look it up from the OccEnv parameter constructed -- from the typechecked AST. See also Note [default method Name] in -- GHC.Iface.Recomp sigNameNoLoc :: forall a. (UnXRec a, HasOccName (IdP a)) => OccEnv (IdP a) -> Sig a -> [IdP a] getInstLoc :: Anno (IdGhcP p) ~ SrcSpanAnnN => InstDecl (GhcPass p) -> SrcSpan -- | Get all subordinate declarations inside a declaration, and their docs. -- A subordinate declaration is something like the associate type or data -- family of a type class. subordinates :: OccEnv Name -> Map RealSrcSpan Name -> HsDecl GhcRn -> [(Name, [HsDoc GhcRn], IntMap (HsDoc GhcRn))] -- | Extract constructor argument docs from inside constructor decls. conArgDocs :: ConDecl GhcRn -> IntMap (HsDoc GhcRn) h98ConArgDocs :: HsConDeclH98Details GhcRn -> IntMap (HsDoc GhcRn) gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> IntMap (HsDoc GhcRn) con_arg_docs :: Int -> [HsType GhcRn] -> IntMap (HsDoc GhcRn) isValD :: HsDecl a -> Bool -- | All the sub declarations of a class (that we handle), ordered by -- source location, with documentation attached if it exists. classDecls :: TyClDecl GhcRn -> [(LHsDecl GhcRn, [HsDoc GhcRn])] -- | Extract function argument docs from inside top-level decls. declTypeDocs :: HsDecl GhcRn -> IntMap (HsDoc GhcRn) nubByName :: (a -> Name) -> [a] -> [a] -- | Extract function argument docs from inside types. typeDocs :: HsType GhcRn -> IntMap (HsDoc GhcRn) -- | Extract function argument docs from inside types. sigTypeDocs :: HsSigType GhcRn -> IntMap (HsDoc GhcRn) -- | The top-level declarations of a module that we care about, ordered by -- source location, with documentation attached if it exists. topDecls :: HsGroup GhcRn -> [(LHsDecl GhcRn, [HsDoc GhcRn])] -- | Take all declarations except pragmas, infix decls, rules from an -- HsGroup. ungroup :: HsGroup GhcRn -> [LHsDecl GhcRn] -- | Collect docs and attach them to the right declarations. -- -- A declaration may have multiple doc strings attached to it. -- -- This is an example. collectDocs :: forall p. UnXRec p => [LHsDecl p] -> [(LHsDecl p, [HsDoc p])] -- | Filter out declarations that we don't handle in Haddock filterDecls :: forall p doc. UnXRec p => [(LHsDecl p, doc)] -> [(LHsDecl p, doc)] -- | Go through all class declarations and filter their sub-declarations filterClasses :: forall p doc. IsPass p => [(LHsDecl (GhcPass p), doc)] -> [(LHsDecl (GhcPass p), doc)] -- | Was this signature given by the user? isUserSig :: Sig name -> Bool -- | Take a field of declarations from a data structure and create HsDecls -- using the given constructor mkDecls :: (struct -> [GenLocated l decl]) -> (decl -> hsDecl) -> struct -> [GenLocated l hsDecl] -- | Extracts out individual maps of documentation added via Template -- Haskell's putDoc. extractTHDocs :: THDocs -> ExtractedTHDocs -- | Unions together two ArgDocMaps (or ArgMaps in haddock-api), -- such that two maps with values for the same key merge the inner map as -- well. Left biased so unionArgMaps a b prefers a over -- b. unionArgMaps :: forall b. UniqMap Name (IntMap b) -> UniqMap Name (IntMap b) -> UniqMap Name (IntMap b) -- | Various types used during desugaring. module GHC.HsToCore.Types -- | Desugaring monad. See also TcM. type DsM = TcRnIf DsGblEnv DsLclEnv -- | Local state of the desugarer, extended as we lexically descend data DsLclEnv DsLclEnv :: DsMetaEnv -> RealSrcSpan -> Nablas -> DsLclEnv -- | Template Haskell bindings [dsl_meta] :: DsLclEnv -> DsMetaEnv -- | To put in pattern-matching error msgs [dsl_loc] :: DsLclEnv -> RealSrcSpan -- | See Note [Long-distance information] in GHC.HsToCore.Pmc. The -- set of reaching values Nablas is augmented as we walk inwards, refined -- through each pattern match in turn [dsl_nablas] :: DsLclEnv -> Nablas -- | Global read-only context and state of the desugarer. The statefulness -- is implemented through IORefs. data DsGblEnv DsGblEnv :: Module -> FamInstEnv -> GlobalRdrEnv -> PrintUnqualified -> IORef (Messages DsMessage) -> (IfGblEnv, IfLclEnv) -> CompleteMatches -> IORef CostCentreState -> IORef (ModuleEnv Int) -> DsGblEnv [ds_mod] :: DsGblEnv -> Module [ds_fam_inst_env] :: DsGblEnv -> FamInstEnv [ds_gbl_rdr_env] :: DsGblEnv -> GlobalRdrEnv [ds_unqual] :: DsGblEnv -> PrintUnqualified [ds_msgs] :: DsGblEnv -> IORef (Messages DsMessage) [ds_if_env] :: DsGblEnv -> (IfGblEnv, IfLclEnv) [ds_complete_matches] :: DsGblEnv -> CompleteMatches [ds_cc_st] :: DsGblEnv -> IORef CostCentreState -- | See Note [Generating fresh names for FFI wrappers] [ds_next_wrapper_num] :: DsGblEnv -> IORef (ModuleEnv Int) type DsMetaEnv = NameEnv DsMetaVal data DsMetaVal DsBound :: Id -> DsMetaVal DsSplice :: HsExpr GhcTc -> DsMetaVal type CompleteMatches = [CompleteMatch] instance GHC.Unit.Module.ContainsModule GHC.HsToCore.Types.DsGblEnv module GHC.Iface.Errors badIfaceFile :: String -> SDoc -> SDoc hiModuleNameMismatchWarn :: Module -> Module -> SDoc homeModError :: InstalledModule -> ModLocation -> SDoc cannotFindInterface :: UnitState -> Maybe HomeUnit -> Profile -> ([FilePath] -> SDoc) -> ModuleName -> InstalledFindResult -> SDoc cantFindInstalledErr :: SDoc -> SDoc -> UnitState -> Maybe HomeUnit -> Profile -> ([FilePath] -> SDoc) -> ModuleName -> InstalledFindResult -> SDoc cannotFindModule :: HscEnv -> ModuleName -> FindResult -> SDoc cantFindErr :: BuildingCabalPackage -> SDoc -> SDoc -> UnitEnv -> Profile -> ([FilePath] -> SDoc) -> ModuleName -> FindResult -> SDoc mayShowLocations :: DynFlags -> [FilePath] -> SDoc module GHC.Iface.Ext.Types type Span = RealSrcSpan -- | Current version of .hie files hieVersion :: Integer -- | GHC builds up a wealth of information about Haskell source as it -- compiles it. .hie files are a way of persisting some of this -- information to disk so that external tools that need to work with -- haskell source don't need to parse, typecheck, and rename all over -- again. These files contain: -- -- -- -- Besides saving compilation cycles, .hie files also offer a -- more stable interface than the GHC API. data HieFile HieFile :: FilePath -> Module -> Array TypeIndex HieTypeFlat -> HieASTs TypeIndex -> [AvailInfo] -> ByteString -> HieFile -- | Initial Haskell source file path [hie_hs_file] :: HieFile -> FilePath -- | The module this HIE file is for [hie_module] :: HieFile -> Module -- | Types referenced in the hie_asts. -- -- See Note [Efficient serialization of redundant type info] [hie_types] :: HieFile -> Array TypeIndex HieTypeFlat -- | Type-annotated abstract syntax trees [hie_asts] :: HieFile -> HieASTs TypeIndex -- | The names that this module exports [hie_exports] :: HieFile -> [AvailInfo] -- | Raw bytes of the initial Haskell source [hie_hs_src] :: HieFile -> ByteString type TypeIndex = Int -- | A flattened version of Type. -- -- See Note [Efficient serialization of redundant type info] data HieType a HTyVarTy :: Name -> HieType a HAppTy :: a -> HieArgs a -> HieType a HTyConApp :: IfaceTyCon -> HieArgs a -> HieType a HForAllTy :: ((Name, a), ArgFlag) -> a -> HieType a HFunTy :: a -> a -> a -> HieType a -- | type with constraint: t1 => t2 (see IfaceDFunTy) HQualTy :: a -> a -> HieType a HLitTy :: IfaceTyLit -> HieType a HCastTy :: a -> HieType a HCoercionTy :: HieType a type HieTypeFlat = HieType TypeIndex -- | Roughly isomorphic to the original core Type. newtype HieTypeFix Roll :: HieType HieTypeFix -> HieTypeFix -- | A list of type arguments along with their respective visibilities (ie. -- is this an argument that would return True for -- isVisibleArgFlag?). newtype HieArgs a HieArgs :: [(Bool, a)] -> HieArgs a type HiePath = LexicalFastString pattern HiePath :: FastString -> HiePath -- | Mapping from filepaths to the corresponding AST newtype HieASTs a HieASTs :: Map HiePath (HieAST a) -> HieASTs a [getAsts] :: HieASTs a -> Map HiePath (HieAST a) data HieAST a Node :: SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a [sourcedNodeInfo] :: HieAST a -> SourcedNodeInfo a [nodeSpan] :: HieAST a -> Span [nodeChildren] :: HieAST a -> [HieAST a] -- | NodeInfos grouped by source newtype SourcedNodeInfo a SourcedNodeInfo :: Map NodeOrigin (NodeInfo a) -> SourcedNodeInfo a [getSourcedNodeInfo] :: SourcedNodeInfo a -> Map NodeOrigin (NodeInfo a) -- | Source of node info data NodeOrigin SourceInfo :: NodeOrigin GeneratedInfo :: NodeOrigin -- | A node annotation data NodeAnnotation NodeAnnotation :: !FastString -> !FastString -> NodeAnnotation -- | name of the AST node constructor [nodeAnnotConstr] :: NodeAnnotation -> !FastString -- | name of the AST node Type [nodeAnnotType] :: NodeAnnotation -> !FastString -- | The information stored in one AST node. -- -- The type parameter exists to provide flexibility in representation of -- types (see Note [Efficient serialization of redundant type info]). data NodeInfo a NodeInfo :: Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a -- | Annotations [nodeAnnotations] :: NodeInfo a -> Set NodeAnnotation -- | The Haskell types of this node, if any. [nodeType] :: NodeInfo a -> [a] -- | All the identifiers and their details [nodeIdentifiers] :: NodeInfo a -> NodeIdentifiers a pprNodeIdents :: Outputable a => NodeIdentifiers a -> SDoc pprIdentifier :: Identifier -> SDoc type Identifier = Either ModuleName Name type NodeIdentifiers a = Map Identifier (IdentifierDetails a) -- | Information associated with every identifier -- -- We need to include types with identifiers because sometimes multiple -- identifiers occur in the same span(Overloaded Record Fields and so on) data IdentifierDetails a IdentifierDetails :: Maybe a -> Set ContextInfo -> IdentifierDetails a [identType] :: IdentifierDetails a -> Maybe a [identInfo] :: IdentifierDetails a -> Set ContextInfo -- | Different contexts under which identifiers exist data ContextInfo -- | regular variable Use :: ContextInfo MatchBind :: ContextInfo -- | import/export IEThing :: IEType -> ContextInfo TyDecl :: ContextInfo -- | Value binding ValBind :: BindType -> Scope -> Maybe Span -> ContextInfo -- | Pattern binding -- -- This case is tricky because the bound identifier can be used in two -- distinct scopes. Consider the following example (with -- -XViewPatterns) -- --
--   do (b, a, (a -> True)) <- bar
--      foo a
--   
-- -- The identifier a has two scopes: in the view pattern (a -- -> True) and in the rest of the do-block in foo -- a. PatternBind :: Scope -> Scope -> Maybe Span -> ContextInfo ClassTyDecl :: Maybe Span -> ContextInfo -- | Declaration Decl :: DeclType -> Maybe Span -> ContextInfo -- | Type variable TyVarBind :: Scope -> TyVarScope -> ContextInfo -- | Record field RecField :: RecFieldContext -> Maybe Span -> ContextInfo -- | Constraint/Dictionary evidence variable binding EvidenceVarBind :: EvVarSource -> Scope -> Maybe Span -> ContextInfo -- | Usage of evidence variable EvidenceVarUse :: ContextInfo pprBindSpan :: Maybe Span -> SDoc data EvVarSource -- | bound by a pattern match EvPatternBind :: EvVarSource -- | bound by a type signature EvSigBind :: EvVarSource -- | bound by a hswrapper EvWrapperBind :: EvVarSource -- | bound by an implicit variable EvImplicitBind :: EvVarSource -- | Bound by some instance of given class EvInstBind :: Bool -> Name -> EvVarSource [isSuperInst] :: EvVarSource -> Bool [cls] :: EvVarSource -> Name -- | A direct let binding EvLetBind :: EvBindDeps -> EvVarSource -- | Eq/Ord instances compare on the converted HieName, as non-exported -- names may have different uniques after a roundtrip newtype EvBindDeps EvBindDeps :: [Name] -> EvBindDeps [getEvBindDeps] :: EvBindDeps -> [Name] -- | Types of imports and exports data IEType Import :: IEType ImportAs :: IEType ImportHiding :: IEType Export :: IEType data RecFieldContext RecFieldDecl :: RecFieldContext RecFieldAssign :: RecFieldContext RecFieldMatch :: RecFieldContext RecFieldOcc :: RecFieldContext data BindType RegularBind :: BindType InstanceBind :: BindType data DeclType -- | type or data family FamDec :: DeclType -- | type synonym SynDec :: DeclType -- | data declaration DataDec :: DeclType -- | constructor declaration ConDec :: DeclType -- | pattern synonym PatSynDec :: DeclType -- | class declaration ClassDec :: DeclType -- | instance declaration InstDec :: DeclType data Scope NoScope :: Scope LocalScope :: Span -> Scope ModuleScope :: Scope -- | Scope of a type variable. -- -- This warrants a data type apart from Scope because of -- complexities introduced by features like -- -XScopedTypeVariables and -XInstanceSigs. For -- example, consider: -- --
--   foo, bar, baz :: forall a. a -> a
--   
-- -- Here a is in scope in all the definitions of foo, -- bar, and baz, so we need a list of scopes to keep -- track of this. Furthermore, this list cannot be computed until we -- resolve the binding sites of foo, bar, and -- baz. -- -- Consequently, a starts with an UnresolvedScope -- [foo, bar, baz] Nothing which later gets resolved into a -- ResolvedScopes. data TyVarScope ResolvedScopes :: [Scope] -> TyVarScope -- | Unresolved scopes should never show up in the final .hie file UnresolvedScope :: [Name] -> Maybe Span -> TyVarScope -- | Name's get converted into HieName's before being written -- into .hie files. See toHieName and -- fromHieName for logic on how to convert between these two -- types. data HieName ExternalName :: !Module -> !OccName -> !SrcSpan -> HieName LocalName :: !OccName -> !SrcSpan -> HieName KnownKeyName :: !Unique -> HieName hieNameOcc :: HieName -> OccName toHieName :: Name -> HieName instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.HieArgs a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieArgs instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieArgs instance GHC.Base.Functor GHC.Iface.Ext.Types.HieArgs instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.HieType a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieType instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieType instance GHC.Base.Functor GHC.Iface.Ext.Types.HieType instance GHC.Classes.Eq GHC.Iface.Ext.Types.HieTypeFix instance GHC.Classes.Ord GHC.Iface.Ext.Types.NodeOrigin instance GHC.Enum.Enum GHC.Iface.Ext.Types.NodeOrigin instance GHC.Classes.Eq GHC.Iface.Ext.Types.NodeOrigin instance GHC.Classes.Eq GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Eq GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Ord GHC.Iface.Ext.Types.IEType instance GHC.Enum.Enum GHC.Iface.Ext.Types.IEType instance GHC.Classes.Eq GHC.Iface.Ext.Types.IEType instance GHC.Classes.Ord GHC.Iface.Ext.Types.RecFieldContext instance GHC.Enum.Enum GHC.Iface.Ext.Types.RecFieldContext instance GHC.Classes.Eq GHC.Iface.Ext.Types.RecFieldContext instance GHC.Enum.Enum GHC.Iface.Ext.Types.BindType instance GHC.Classes.Ord GHC.Iface.Ext.Types.BindType instance GHC.Classes.Eq GHC.Iface.Ext.Types.BindType instance GHC.Enum.Enum GHC.Iface.Ext.Types.DeclType instance GHC.Classes.Ord GHC.Iface.Ext.Types.DeclType instance GHC.Classes.Eq GHC.Iface.Ext.Types.DeclType instance Data.Data.Data GHC.Iface.Ext.Types.Scope instance GHC.Classes.Ord GHC.Iface.Ext.Types.Scope instance GHC.Classes.Eq GHC.Iface.Ext.Types.Scope instance GHC.Classes.Ord GHC.Iface.Ext.Types.TyVarScope instance GHC.Classes.Eq GHC.Iface.Ext.Types.TyVarScope instance GHC.Classes.Ord GHC.Iface.Ext.Types.ContextInfo instance GHC.Classes.Eq GHC.Iface.Ext.Types.ContextInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.IdentifierDetails instance Data.Foldable.Foldable GHC.Iface.Ext.Types.IdentifierDetails instance GHC.Base.Functor GHC.Iface.Ext.Types.IdentifierDetails instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Types.IdentifierDetails a) instance Data.Traversable.Traversable GHC.Iface.Ext.Types.NodeInfo instance Data.Foldable.Foldable GHC.Iface.Ext.Types.NodeInfo instance GHC.Base.Functor GHC.Iface.Ext.Types.NodeInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.SourcedNodeInfo instance Data.Foldable.Foldable GHC.Iface.Ext.Types.SourcedNodeInfo instance GHC.Base.Functor GHC.Iface.Ext.Types.SourcedNodeInfo instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieAST instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieAST instance GHC.Base.Functor GHC.Iface.Ext.Types.HieAST instance Data.Traversable.Traversable GHC.Iface.Ext.Types.HieASTs instance Data.Foldable.Foldable GHC.Iface.Ext.Types.HieASTs instance GHC.Base.Functor GHC.Iface.Ext.Types.HieASTs instance GHC.Classes.Eq GHC.Iface.Ext.Types.HieName instance GHC.Classes.Ord GHC.Iface.Ext.Types.HieName instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.HieName instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.HieFile instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieASTs GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.HieASTs a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieAST GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.HieAST a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.SourcedNodeInfo GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.SourcedNodeInfo a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.NodeInfo GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.NodeInfo a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Base.Semigroup (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Base.Monoid (GHC.Iface.Ext.Types.IdentifierDetails a) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.IdentifierDetails GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.ContextInfo instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.ContextInfo instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.TyVarScope instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.TyVarScope instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.Scope instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.Scope instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.DeclType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.DeclType instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.BindType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.BindType instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.RecFieldContext instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.RecFieldContext instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.IEType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.IEType instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.EvVarSource instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.EvVarSource instance GHC.Classes.Eq GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.EvBindDeps instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.EvBindDeps instance GHC.Classes.Ord GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.NodeAnnotation instance GHC.Utils.Outputable.Outputable GHC.Iface.Ext.Types.NodeOrigin instance GHC.Utils.Binary.Binary GHC.Iface.Ext.Types.NodeOrigin instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieType GHC.Iface.Ext.Types.TypeIndex) instance GHC.Utils.Binary.Binary (GHC.Iface.Ext.Types.HieArgs GHC.Iface.Ext.Types.TypeIndex) module GHC.Iface.Ext.Utils type RefMap a = Map Identifier [(Span, IdentifierDetails a)] generateReferencesMap :: Foldable f => f (HieAST a) -> RefMap a renderHieType :: DynFlags -> HieTypeFix -> String resolveVisibility :: Type -> [Type] -> [(Bool, Type)] foldType :: (HieType a -> a) -> HieTypeFix -> a selectPoint :: HieFile -> (Int, Int) -> Maybe (HieAST Int) findEvidenceUse :: NodeIdentifiers a -> [Name] data EvidenceInfo a EvidenceInfo :: Name -> RealSrcSpan -> a -> Maybe (EvVarSource, Scope, Maybe Span) -> EvidenceInfo a [evidenceVar] :: EvidenceInfo a -> Name [evidenceSpan] :: EvidenceInfo a -> RealSrcSpan [evidenceType] :: EvidenceInfo a -> a [evidenceDetails] :: EvidenceInfo a -> Maybe (EvVarSource, Scope, Maybe Span) getEvidenceTreesAtPoint :: HieFile -> RefMap a -> (Int, Int) -> Forest (EvidenceInfo a) getEvidenceTree :: RefMap a -> Name -> Maybe (Tree (EvidenceInfo a)) hieTypeToIface :: HieTypeFix -> IfaceType data HieTypeState HTS :: !TypeMap TypeIndex -> !IntMap HieTypeFlat -> !TypeIndex -> HieTypeState [tyMap] :: HieTypeState -> !TypeMap TypeIndex [htyTable] :: HieTypeState -> !IntMap HieTypeFlat [freshIndex] :: HieTypeState -> !TypeIndex initialHTS :: HieTypeState freshTypeIndex :: State HieTypeState TypeIndex compressTypes :: HieASTs Type -> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat) recoverFullType :: TypeIndex -> Array TypeIndex HieTypeFlat -> HieTypeFix getTypeIndex :: Type -> State HieTypeState TypeIndex resolveTyVarScopes :: Map HiePath (HieAST a) -> Map HiePath (HieAST a) resolveTyVarScopeLocal :: HieAST a -> Map HiePath (HieAST a) -> HieAST a getNameBinding :: Name -> Map HiePath (HieAST a) -> Maybe Span getNameScope :: Name -> Map HiePath (HieAST a) -> Maybe [Scope] getNameBindingInClass :: Name -> Span -> Map HiePath (HieAST a) -> Maybe Span getNameScopeAndBinding :: Name -> Map HiePath (HieAST a) -> Maybe ([Scope], Maybe Span) getScopeFromContext :: ContextInfo -> Maybe [Scope] getBindSiteFromContext :: ContextInfo -> Maybe Span flattenAst :: HieAST a -> [HieAST a] smallestContainingSatisfying :: Span -> (HieAST a -> Bool) -> HieAST a -> Maybe (HieAST a) selectLargestContainedBy :: Span -> HieAST a -> Maybe (HieAST a) selectSmallestContaining :: Span -> HieAST a -> Maybe (HieAST a) definedInAsts :: Map HiePath (HieAST a) -> Name -> Bool getEvidenceBindDeps :: ContextInfo -> [Name] isEvidenceBind :: ContextInfo -> Bool isEvidenceContext :: ContextInfo -> Bool isEvidenceUse :: ContextInfo -> Bool isOccurrence :: ContextInfo -> Bool scopeContainsSpan :: Scope -> Span -> Bool -- | One must contain the other. Leaf nodes cannot contain anything combineAst :: HieAST Type -> HieAST Type -> HieAST Type -- | Insert an AST in a sorted list of disjoint Asts insertAst :: HieAST Type -> [HieAST Type] -> [HieAST Type] nodeInfo :: HieAST Type -> NodeInfo Type emptyNodeInfo :: NodeInfo a sourcedNodeIdents :: SourcedNodeInfo a -> NodeIdentifiers a combineSourcedNodeInfo :: SourcedNodeInfo Type -> SourcedNodeInfo Type -> SourcedNodeInfo Type -- | Merge two nodes together. -- -- Precondition and postcondition: elements in nodeType are -- ordered. combineNodeInfo :: NodeInfo Type -> NodeInfo Type -> NodeInfo Type -- | Merge two sorted, disjoint lists of ASTs, combining when necessary. -- -- In the absence of position-altering pragmas (ex: # line "file.hs" -- 3), different nodes in an AST tree should either have disjoint -- spans (in which case you can say for sure which one comes first) or -- one span should be completely contained in the other (in which case -- the contained span corresponds to some child node). -- -- However, since Haskell does have position-altering pragmas it -- is possible for spans to be overlapping. Here is an example of -- a source file in which foozball and quuuuuux have -- overlapping spans: -- --
--   module Baz where
--   
--   # line 3 "Baz.hs"
--   foozball :: Int
--   foozball = 0
--   
--   # line 3 "Baz.hs"
--   bar, quuuuuux :: Int
--   bar = 1
--   quuuuuux = 2
--   
-- -- In these cases, we just do our best to produce sensible -- HieAST's. The blame should be laid at the feet of whoever wrote -- the line pragmas in the first place (usually the C preprocessor...). mergeAsts :: [HieAST Type] -> [HieAST Type] -> [HieAST Type] rightOf :: Span -> Span -> Bool leftOf :: Span -> Span -> Bool startsRightOf :: Span -> Span -> Bool -- | combines and sorts ASTs using a merge sort mergeSortAsts :: [HieAST Type] -> [HieAST Type] simpleNodeInfo :: FastString -> FastString -> NodeInfo a locOnly :: Monad m => SrcSpan -> ReaderT NodeOrigin m [HieAST a] mkScopeA :: SrcSpanAnn' ann -> Scope mkScope :: SrcSpan -> Scope mkLScope :: Located a -> Scope mkLScopeA :: GenLocated (SrcSpanAnn' a) e -> Scope mkLScopeN :: LocatedN a -> Scope combineScopes :: Scope -> Scope -> Scope mkSourcedNodeInfo :: NodeOrigin -> NodeInfo a -> SourcedNodeInfo a makeNodeA :: (Monad m, Data a) => a -> SrcSpanAnn' ann -> ReaderT NodeOrigin m [HieAST b] makeNode :: (Monad m, Data a) => a -> SrcSpan -> ReaderT NodeOrigin m [HieAST b] makeTypeNodeA :: (Monad m, Data a) => a -> SrcSpanAnnA -> Type -> ReaderT NodeOrigin m [HieAST Type] makeTypeNode :: (Monad m, Data a) => a -> SrcSpan -> Type -> ReaderT NodeOrigin m [HieAST Type] instance GHC.Base.Functor GHC.Iface.Ext.Utils.EvidenceInfo instance GHC.Classes.Ord a => GHC.Classes.Ord (GHC.Iface.Ext.Utils.EvidenceInfo a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.Iface.Ext.Utils.EvidenceInfo a) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Iface.Ext.Utils.EvidenceInfo a) module GHC.Iface.Ext.Debug type Diff a = a -> a -> [SDoc] diffFile :: Diff HieFile diffAsts :: (Outputable a, Eq a, Ord a) => Diff a -> Diff (Map HiePath (HieAST a)) diffAst :: (Outputable a, Eq a, Ord a) => Diff a -> Diff (HieAST a) type DiffIdent = Either ModuleName HieName normalizeIdents :: Ord a => NodeIdentifiers a -> [(DiffIdent, IdentifierDetails a)] diffList :: Diff a -> Diff [a] eqDiff :: (Outputable a, Eq a) => Diff a validAst :: HieAST a -> Either SDoc () -- | Look for any identifiers which occur outside of their supposed scopes. -- Returns a list of error messages. validateScopes :: Module -> Map HiePath (HieAST a) -> [SDoc] -- | This module manages storing the various GHC option flags in a modules -- interface file as part of the recompilation checking infrastructure. module GHC.Iface.Recomp.Flags -- | Produce a fingerprint of a DynFlags value. We only base the -- finger print on important fields in DynFlags so that the -- recompilation checker can use this fingerprint. -- -- NB: The Module parameter is the Module recorded by the -- *interface* file, not the actual Module according to our -- DynFlags. fingerprintDynFlags :: HscEnv -> Module -> (BinHandle -> Name -> IO ()) -> IO Fingerprint fingerprintOptFlags :: DynFlags -> (BinHandle -> Name -> IO ()) -> IO Fingerprint fingerprintHpcFlags :: DynFlags -> (BinHandle -> Name -> IO ()) -> IO Fingerprint -- | Code generation for the Static Pointer Table -- -- (c) 2014 I/O Tweag -- -- Each module that uses static keyword declares an -- initialization function of the form hs_spt_init_<module>() which -- is emitted into the _stub.c file and annotated with -- attribute((constructor)) so that it gets executed at startup -- time. -- -- The function's purpose is to call hs_spt_insert to insert the static -- pointers of this module in the hashtable of the RTS, and it looks -- something like this: -- --
--   static void hs_hpc_init_Main(void) __attribute__((constructor));
--   static void hs_hpc_init_Main(void) {
--   
--     static StgWord64 k0[2] = {16252233372134256ULL,7370534374096082ULL};
--     extern StgPtr Main_r2wb_closure;
--     hs_spt_insert(k0, &Main_r2wb_closure);
--   
--     static StgWord64 k1[2] = {12545634534567898ULL,5409674567544151ULL};
--     extern StgPtr Main_r2wc_closure;
--     hs_spt_insert(k1, &Main_r2wc_closure);
--   
--   }
--   
-- -- where the constants are fingerprints produced from the static forms. -- -- The linker must find the definitions matching the extern StgPtr -- name declarations. For this to work, the identifiers of -- static pointers need to be exported. This is done in newLvlVar. -- -- There is also a finalization function for the time when the module is -- unloaded. -- --
--   static void hs_hpc_fini_Main(void) __attribute__((destructor));
--   static void hs_hpc_fini_Main(void) {
--   
--     static StgWord64 k0[2] = {16252233372134256ULL,7370534374096082ULL};
--     hs_spt_remove(k0);
--   
--     static StgWord64 k1[2] = {12545634534567898ULL,5409674567544151ULL};
--     hs_spt_remove(k1);
--   
--   }
--   
module GHC.Iface.Tidy.StaticPtrTable -- | Replaces all bindings of the form -- --
--   b = /\ ... -> makeStatic location value
--   
-- -- with -- --
--   b = /\ ... ->
--     StaticPtr key (StaticPtrInfo "pkg key" "module" location) value
--   
-- -- where a distinct key is generated for each binding. -- -- It also yields the C stub that inserts these bindings into the static -- pointer table. sptCreateStaticBinds :: StaticPtrOpts -> Module -> CoreProgram -> IO ([SptEntry], Maybe CStub, CoreProgram) -- | sptModuleInitCode module fps is a C stub to insert the static -- entries of module into the static pointer table. -- -- fps is a list associating each binding corresponding to a -- static entry with its fingerprint. sptModuleInitCode :: Platform -> Module -> [SptEntry] -> CStub data StaticPtrOpts StaticPtrOpts :: !Platform -> !Bool -> !MkStringIds -> !DataCon -> !DataCon -> StaticPtrOpts -- | Target platform [opt_platform] :: StaticPtrOpts -> !Platform -- | Generate CStub or not [opt_gen_cstub] :: StaticPtrOpts -> !Bool -- | Ids for `unpackCString[Utf8]#` [opt_mk_string] :: StaticPtrOpts -> !MkStringIds -- | StaticPtrInfo datacon [opt_static_ptr_info_datacon] :: StaticPtrOpts -> !DataCon -- | StaticPtr datacon [opt_static_ptr_datacon] :: StaticPtrOpts -> !DataCon module GHC.Linker -- | Linking Haskell units module GHC.Linker.Unit collectLinkOpts :: DynFlags -> [UnitInfo] -> ([String], [String], [String]) collectArchives :: DynFlags -> UnitInfo -> IO [FilePath] -- | Find all the link options in these and the preload packages, returning -- (package hs lib options, extra library options, other flags) getUnitLinkOpts :: DynFlags -> UnitEnv -> [UnitId] -> IO ([String], [String], [String]) getLibs :: DynFlags -> UnitEnv -> [UnitId] -> IO [(String, String)] module GHC.Parser.Utils -- | Returns True if passed string is a statement. isStmt :: ParserOpts -> String -> Bool -- | Returns True if passed string has an import declaration. hasImport :: ParserOpts -> String -> Bool -- | Returns True if passed string is an import declaration. isImport :: ParserOpts -> String -> Bool -- | Returns True if passed string is a declaration but not -- a splice. isDecl :: ParserOpts -> String -> Bool module GHC.Platform.Host hostPlatformArch :: Arch hostPlatformOS :: OS hostPlatformArchOS :: ArchOS module GHC.Settings.Utils maybeRead :: Read a => String -> Maybe a maybeReadFuzzy :: Read a => String -> Maybe a type RawSettings = Map String String -- | Read target Arch/OS from the settings getTargetArchOS :: FilePath -> RawSettings -> Either String ArchOS getRawSetting :: FilePath -> RawSettings -> String -> Either String String getRawFilePathSetting :: FilePath -> FilePath -> RawSettings -> String -> Either String String getRawBooleanSetting :: FilePath -> RawSettings -> String -> Either String Bool readRawSetting :: (Show a, Read a) => FilePath -> RawSettings -> String -> Either String a module GHC.Settings.IO data SettingsError SettingsError_MissingData :: String -> SettingsError SettingsError_BadData :: String -> SettingsError initSettings :: forall m. MonadIO m => String -> ExceptT SettingsError m Settings -- | Prepare the STG for bytecode generation: -- -- module GHC.Stg.BcPrep bcPrep :: UniqSupply -> [InStgTopBinding] -> [OutStgTopBinding] -- | Note [CSE for Stg] ~~~~~~~~~~~~~~~~~~ -- -- This module implements a simple common subexpression elimination pass -- for STG. This is useful because there are expressions that we want to -- common up (because they are operationally equivalent), but that we -- cannot common up in Core, because their types differ. This was -- originally reported as #9291. -- -- There are two types of common code occurrences that we aim for, see -- Note [Case 1: CSEing allocated closures] and Note [Case 2: CSEing case -- binders] below. -- -- Note [Case 1: CSEing allocated closures] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The first kind of CSE opportunity we aim for is generated by this -- Haskell code: -- -- bar :: a -> (Either Int a, Either Bool a) bar x = (Right x, Right -- x) -- -- which produces this Core: -- -- bar :: forall a. a -> (Either Int a, Either Bool a) bar a x = -- (Right Int a x, Right Bool @a x) -- -- where the two components of the tuple are different terms, and cannot -- be commoned up (easily). On the STG level we have -- -- bar [x] = let c1 = Right [x] c2 = Right [x] in (c1,c2) -- -- and now it is obvious that we can write -- -- bar [x] = let c1 = Right [x] in (c1,c1) -- -- instead. -- -- Note [Case 2: CSEing case binders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- The second kind of CSE opportunity we aim for is more interesting, and -- came up in 5344: The Haskell code -- -- foo :: Either Int a -> Either Bool a foo (Right x) = Right x foo _ -- = Left False -- -- produces this Core -- -- foo :: forall a. Either Int a -> Either Bool a foo a e = case e -- of b { Left n -> … , Right x -> Right Bool @a x } -- -- where we cannot CSE `Right Bool a x` with the case binder -- b as they have different types. But in STG we have -- -- foo [e] = case e of b { Left [n] -> … , Right [x] -> Right [x] } -- -- and nothing stops us from transforming that to -- -- foo [e] = case e of b { Left [n] -> … , Right [x] -> b} -- -- Note [StgCse after unarisation] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- -- Consider two unboxed sum terms: -- -- () :: ( #) () :: () -- -- These two terms are not equal as they unarise to different unboxed -- tuples. However if we run StgCse before Unarise, it'll think the two -- terms () are equal, and replace one of these with a binder to the -- other. That's bad -- #15300. -- -- Solution: do unarise first. module GHC.Stg.CSE stgCse :: [InStgTopBinding] -> [OutStgTopBinding] instance GHC.Data.TrieMap.TrieMap GHC.Stg.CSE.ConAppMap instance GHC.Data.TrieMap.TrieMap GHC.Stg.CSE.StgArgMap module GHC.Stg.Debug data StgDebugOpts StgDebugOpts :: !Bool -> !Bool -> StgDebugOpts [stgDebug_infoTableMap] :: StgDebugOpts -> !Bool [stgDebug_distinctConstructorTables] :: StgDebugOpts -> !Bool collectDebugInformation :: StgDebugOpts -> ModLocation -> [StgTopBinding] -> ([StgTopBinding], InfoTableProvMap) module GHC.Driver.Config.Stg.Debug -- | Initialize STG pretty-printing options from DynFlags initStgDebugOpts :: DynFlags -> StgDebugOpts module GHC.Stg.InferTags.Types data TagEnv p TE :: TagSigEnv -> (BinderP p -> Id) -> TagEnv p [te_env] :: TagEnv p -> TagSigEnv [te_get] :: TagEnv p -> BinderP p -> Id type TagSigEnv = IdEnv TagSig type InferStgAlt = GenStgAlt 'InferTaggedBinders type InferStgRhs = GenStgRhs 'InferTaggedBinders type InferStgExpr = GenStgExpr 'InferTaggedBinders type InferStgBinding = GenStgBinding 'InferTaggedBinders type InferStgTopBinding = GenStgTopBinding 'InferTaggedBinders combineAltInfo :: TagInfo -> TagInfo -> TagInfo getBinderId :: TagEnv p -> BinderP p -> Id initEnv :: TagEnv 'CodeGen -- | Simple convert env to a env of the 'InferTaggedBinders pass with no -- other changes. makeTagged :: TagEnv p -> TagEnv 'InferTaggedBinders noSig :: TagEnv p -> BinderP p -> (Id, TagSig) lookupSig :: TagEnv p -> Id -> Maybe TagSig lookupInfo :: TagEnv p -> StgArg -> TagInfo isDunnoSig :: TagSig -> Bool isTaggedInfo :: TagInfo -> Bool extendSigEnv :: TagEnv p -> [(Id, TagSig)] -> TagEnv p instance GHC.Utils.Outputable.Outputable (GHC.Stg.InferTags.Types.TagEnv p) -- | Configuration options for Lift the lambda lifter. module GHC.Stg.Lift.Config data StgLiftConfig StgLiftConfig :: !Profile -> !Maybe Int -> !Maybe Int -> !Bool -> StgLiftConfig [c_targetProfile] :: StgLiftConfig -> !Profile -- | Maximum number of arguments after lambda lifting a recursive function. [c_liftLamsRecArgs] :: StgLiftConfig -> !Maybe Int -- | Maximum number of arguments after lambda lifting non-recursive -- function. [c_liftLamsNonRecArgs] :: StgLiftConfig -> !Maybe Int -- | Lambda lift even when this turns a known call into an unknown call. [c_liftLamsKnown] :: StgLiftConfig -> !Bool instance GHC.Classes.Ord GHC.Stg.Lift.Config.StgLiftConfig instance GHC.Classes.Eq GHC.Stg.Lift.Config.StgLiftConfig instance GHC.Read.Read GHC.Stg.Lift.Config.StgLiftConfig instance GHC.Show.Show GHC.Stg.Lift.Config.StgLiftConfig module GHC.Driver.Config.Stg.Lift initStgLiftConfig :: DynFlags -> StgLiftConfig module GHC.Stg.Stats showStgStats :: [StgTopBinding] -> String instance GHC.Classes.Ord GHC.Stg.Stats.CounterType instance GHC.Classes.Eq GHC.Stg.Stats.CounterType module GHC.Stg.Subst -- | A renaming substitution from Ids to Ids. Like -- RnEnv2, but not maintaining pairs of substitutions. Like -- Subst, but with the domain being Ids instead of entire -- CoreExpr. data Subst Subst :: InScopeSet -> IdSubstEnv -> Subst type IdSubstEnv = IdEnv Id -- |
--   emptySubst = mkEmptySubst emptyInScopeSet
--   
emptySubst :: Subst -- | Constructs a new Subst assuming the variables in the given -- InScopeSet are in scope. mkEmptySubst :: InScopeSet -> Subst -- | Substitutes an Id for another one according to the Subst -- given in a way that avoids shadowing the InScopeSet, returning -- the result and an updated Subst that should be used by -- subsequent substitutions. substBndr :: Id -> Subst -> (Id, Subst) -- |
--   substBndrs = runState . traverse (state . substBndr)
--   
substBndrs :: Traversable f => f Id -> Subst -> (f Id, Subst) -- | Substitutes an occurrence of an identifier for its counterpart -- recorded in the Subst. lookupIdSubst :: HasCallStack => Id -> Subst -> Id -- | Substitutes an occurrence of an identifier for its counterpart -- recorded in the Subst. Does not generate a debug warning if the -- identifier to to substitute wasn't in scope. noWarnLookupIdSubst :: HasCallStack => Id -> Subst -> Id -- | Add the Id to the in-scope set and remove any existing -- substitutions for it. extendInScope :: Id -> Subst -> Subst -- | Add a substitution for an Id to the Subst: you must -- ensure that the in-scope set is such that TyCoSubst Note [The -- substitution invariant] holds after extending the substitution like -- this. extendSubst :: Id -> Id -> Subst -> Subst -- | Hides away distracting bookkeeping while lambda lifting into a -- LiftM monad. module GHC.Stg.Lift.Monad -- |
--   uncurry mkStgBinding . decomposeStgBinding = id
--   
decomposeStgBinding :: GenStgBinding pass -> (RecFlag, [(BinderP pass, GenStgRhs pass)]) mkStgBinding :: RecFlag -> [(BinderP pass, GenStgRhs pass)] -> GenStgBinding pass -- | Environment threaded around in a scoped, Reader-like fashion. data Env Env :: StgLiftConfig -> !Subst -> !IdEnv DIdSet -> Env -- | Read-only. [e_config] :: Env -> StgLiftConfig -- | We need to track the renamings of local InIds to their lifted -- OutId, because shadowing might make a closure's free variables -- unavailable at its call sites. Consider: let f y = x + y in let x -- = 4 in f x Here, f can't be lifted to top-level, -- because its free variable x isn't available at its call site. [e_subst] :: Env -> !Subst -- | Lifted Ids don't occur as free variables in any closure -- anymore, because they are bound at the top-level. Every occurrence -- must supply the formerly free variables of the lifted Id, so -- they in turn become free variables of the call sites. This environment -- tracks this expansion from lifted Ids to their free variables. -- -- InIds to OutIds. -- -- Invariant: Ids not present in this map won't be substituted. [e_expansions] :: Env -> !IdEnv DIdSet -- | We need to detect when we are lifting something out of the RHS of a -- recursive binding (c.f. GHC.Stg.Lift.Monad#floats), in which -- case that binding needs to be added to the same top-level recursive -- group. This requires we detect a certain nesting structure, which is -- encoded by StartBindingGroup and EndBindingGroup. -- -- Although collectFloats will only ever care if the current -- binding to be lifted (through LiftedBinding) will occur inside -- such a binding group or not, e.g. doesn't care about the nesting level -- as long as its greater than 0. data FloatLang StartBindingGroup :: FloatLang EndBindingGroup :: FloatLang PlainTopBinding :: OutStgTopBinding -> FloatLang LiftedBinding :: OutStgBinding -> FloatLang -- | Flattens an expression in [FloatLang] into an STG -- program, see GHC.Stg.Lift.Monad#floats. Important -- pre-conditions: The nesting of opening StartBindinGroups and -- closing EndBindinGroups is balanced. Also, it is crucial that -- every binding group has at least one recursive binding inside. -- Otherwise there's no point in announcing the binding group in the -- first place and an ASSERT will trigger. collectFloats :: [FloatLang] -> [OutStgTopBinding] -- | The analysis monad consists of the following RWST components: -- -- data LiftM a runLiftM :: StgLiftConfig -> UniqSupply -> LiftM () -> [OutStgTopBinding] getConfig :: LiftM StgLiftConfig -- | Starts a recursive binding group. See GHC.Stg.Lift.Monad#floats -- and collectFloats. startBindingGroup :: LiftM () -- | Ends a recursive binding group. See GHC.Stg.Lift.Monad#floats -- and collectFloats. endBindingGroup :: LiftM () -- | Writes a plain StgTopStringLit to the output. addTopStringLit :: OutId -> ByteString -> LiftM () -- | Lifts a binding to top-level. Depending on whether it's declared -- inside a recursive RHS (see GHC.Stg.Lift.Monad#floats and -- collectFloats), this might be added to an existing recursive -- top-level binding group. addLiftedBinding :: OutStgBinding -> LiftM () -- | Takes a binder and a continuation which is called with the substituted -- binder. The continuation will be evaluated in a LiftM context -- in which that binder is deemed in scope. Think of it as a local -- computation: After the continuation finishes, the new binding won't be -- in scope anymore. withSubstBndr :: Id -> (Id -> LiftM a) -> LiftM a -- | See withSubstBndr. withSubstBndrs :: Traversable f => f Id -> (f Id -> LiftM a) -> LiftM a -- | Similarly to withSubstBndr, this function takes a set of -- variables to abstract over, the binder to lift (and generate a fresh, -- substituted name for) and a continuation in which that fresh, lifted -- binder is in scope. -- -- It takes care of all the details involved with copying and adjusting -- the binder and fresh name generation. withLiftedBndr :: DIdSet -> Id -> (Id -> LiftM a) -> LiftM a -- | See withLiftedBndr. withLiftedBndrs :: Traversable f => DIdSet -> f Id -> (f Id -> LiftM a) -> LiftM a -- | Substitutes a binder occurrence, which was brought in scope -- earlier by withSubstBndr / withLiftedBndr. substOcc :: Id -> LiftM Id -- | Whether the given binding was decided to be lambda lifted. isLifted :: InId -> LiftM Bool -- | Returns an empty list for a binding that was not lifted and the list -- of all local variables the binding abstracts over (so, exactly the -- additional arguments at adjusted call sites) otherwise. formerFreeVars :: InId -> LiftM [OutId] -- | Creates an expander function for the current set of lifted -- binders. This expander function will replace any InId by their -- corresponding OutId and, in addition, will expand any lifted -- binders by the former free variables it abstracts over. liftedIdsExpander :: LiftM (DIdSet -> DIdSet) instance GHC.Base.Monad GHC.Stg.Lift.Monad.LiftM instance GHC.Base.Applicative GHC.Stg.Lift.Monad.LiftM instance GHC.Base.Functor GHC.Stg.Lift.Monad.LiftM instance GHC.Types.Unique.Supply.MonadUnique GHC.Stg.Lift.Monad.LiftM instance GHC.Utils.Outputable.Outputable GHC.Stg.Lift.Monad.FloatLang module GHC.Stg.Utils mkStgAltTypeFromStgAlts :: forall p. Id -> [GenStgAlt p] -> AltType bindersOf :: BinderP a ~ Id => GenStgBinding a -> [Id] bindersOfX :: GenStgBinding a -> [BinderP a] bindersOfTop :: BinderP a ~ Id => GenStgTopBinding a -> [Id] bindersOfTopBinds :: BinderP a ~ Id => [GenStgTopBinding a] -> [Id] -- | Strip ticks of a given type from an STG expression. stripStgTicksTop :: (StgTickish -> Bool) -> GenStgExpr p -> ([StgTickish], GenStgExpr p) -- | Strip ticks of a given type from an STG expression returning only the -- expression. stripStgTicksTopE :: (StgTickish -> Bool) -> GenStgExpr p -> GenStgExpr p idArgs :: [StgArg] -> [Id] mkUnarisedId :: MonadUnique m => FastString -> UnaryType -> m Id mkUnarisedIds :: MonadUnique m => FastString -> [UnaryType] -> m [Id] module GHC.Stg.Unarise unarise :: UniqSupply -> [StgTopBinding] -> [StgTopBinding] instance GHC.Utils.Outputable.Outputable GHC.Stg.Unarise.UnariseVal -- | (c) The GRASP/AQUA Project, Glasgow University, 1993-1998 -- -- A lint pass to check basic STG invariants: -- -- -- -- Because we don't have types and coercions in STG we can't really check -- types here. -- -- Some history: -- -- StgLint used to check types, but it never worked and so it was -- disabled in 2000 with this note: -- -- WARNING: ~~~~~~~~ -- -- This module has suffered bit-rot; it is likely to yield lint errors -- for Stg code that is currently perfectly acceptable for code -- generation. Solution: don't use it! (KSW 2000-05). -- -- Since then there were some attempts at enabling it again, as -- summarised in #14787. It's finally decided that we remove all type -- checking and only look for basic properties listed above. module GHC.Stg.Lint lintStgTopBindings :: forall a. (OutputablePass a, BinderP a ~ Id) => Logger -> DiagOpts -> StgPprOpts -> InteractiveContext -> Module -> Bool -> String -> [GenStgTopBinding a] -> IO () instance GHC.Base.Functor GHC.Stg.Lint.LintM instance GHC.Base.Applicative GHC.Stg.Lint.LintM instance GHC.Base.Monad GHC.Stg.Lint.LintM module GHC.Stg.InferTags.Rewrite rewriteTopBinds :: Module -> UniqSupply -> [GenStgTopBinding 'InferTaggedBinders] -> [TgStgTopBinding] instance GHC.Base.Applicative GHC.Stg.InferTags.Rewrite.RM instance GHC.Base.Monad GHC.Stg.InferTags.Rewrite.RM instance GHC.Base.Functor GHC.Stg.InferTags.Rewrite.RM instance GHC.Types.Unique.Supply.MonadUnique GHC.Stg.InferTags.Rewrite.RM module GHC.Stg.InferTags inferTags :: DynFlags -> Logger -> Module -> [CgStgTopBinding] -> IO ([TgStgTopBinding], NameEnv TagSig) -- | Non-global free variable analysis on STG terms. This pass annotates -- non-top-level closure bindings with captured variables. Global -- variables are not captured. For example, in a top-level binding like -- (pseudo-STG) -- -- f = [x,y] . let g = [p] . reverse (x ++ p) in g y -- -- In g, reverse and (++) are global variables so they're -- not considered free. p is an argument, so x is the -- only actual free variable here. The annotated version is thus: -- -- f = [x,y] . let g = [x] [p] . reverse (x ++ p) in g y -- -- Note that non-top-level recursive bindings are also considered free -- within the group: -- -- map = {} r [f xs0] let { Rec { go = {f, go} r [xs1] case xs1 of { [] -- -> [] []; : x xs2 -> let { xs' = {go, xs2} u [] go xs2; } in let -- { x' = {f, x} u [] f x; } in : [x' xs']; }; end Rec } } in go xs0; -- -- Here go is free in its RHS. -- -- Top-level closure bindings never capture variables as all of their -- free variables are global. module GHC.Stg.FVs -- | Dependency sort a STG program, and annotate it with free variables The -- returned bindings: * Are in dependency order * Each StgRhsClosure is -- correctly annotated (in its extension field) with the free variables -- needed in the closure * Each StgCase is correctly annotated (in its -- extension field) with the variables that must be saved across the case depSortWithAnnotStgPgm :: Module -> [StgTopBinding] -> [CgStgTopBinding] -- | Dependency analysis on STG terms. -- -- Dependencies of a binding are just free variables in the binding. This -- includes imported ids and ids in the current module. For recursive -- groups we just return one set of free variables which is just the -- union of dependencies of all bindings in the group. -- -- Implementation: pass bound variables (NestedIds) to recursive calls, -- get free variables (TopFVs) back. We ignore imported TopFVs as they do -- not change the ordering but it improves performance (see -- nameIsExternalFrom call in vars_fvs). annBindingFreeVars :: Module -> StgBinding -> CgStgBinding module GHC.CoreToStg coreToStg :: DynFlags -> Module -> ModLocation -> CoreProgram -> ([StgTopBinding], InfoTableProvMap, CollectedCCs) instance GHC.Classes.Eq GHC.CoreToStg.LetInfo instance GHC.Classes.Eq GHC.CoreToStg.HowBound instance GHC.Base.Functor GHC.CoreToStg.CtsM instance GHC.Base.Applicative GHC.CoreToStg.CtsM instance GHC.Base.Monad GHC.CoreToStg.CtsM instance GHC.Driver.Session.HasDynFlags GHC.CoreToStg.CtsM module GHC.StgToCmm.CgUtils -- | Fixup global registers so that they assign to locations within the -- RegTable if they aren't pinned for the current target. fixStgRegisters :: Platform -> RawCmmDecl -> RawCmmDecl baseRegOffset :: Platform -> GlobalReg -> Int get_Regtable_addr_from_offset :: Platform -> Int -> CmmExpr regTableOffset :: Platform -> Int -> CmmExpr -- | We map STG registers onto appropriate CmmExprs. Either they map to -- real machine registers or stored as offsets from BaseReg. Given a -- GlobalReg, get_GlobalReg_addr always produces the register table -- address for it. get_GlobalReg_addr :: Platform -> GlobalReg -> CmmExpr module GHC.StgToCmm.Sequel -- | A Sequel tells what to do with the result of this expression data Sequel -- | Return result(s) to continuation found on the stack. Return :: Sequel AssignTo :: [LocalReg] -> Bool -> Sequel type SelfLoopInfo = (Id, BlockId, [LocalReg]) instance GHC.Utils.Outputable.Outputable GHC.StgToCmm.Sequel.Sequel module GHC.StgToCmm.Closure type DynTag = Int tagForCon :: Platform -> DataCon -> DynTag isSmallFamily :: Platform -> Int -> Bool -- | Assumes that there is precisely one PrimRep of the type. This -- assumption holds after unarise. See Note [Post-unarisation invariants] idPrimRep :: Id -> PrimRep isVoidRep :: PrimRep -> Bool isGcPtrRep :: PrimRep -> Bool -- | Assumes that Ids have one PrimRep, which holds after unarisation. See -- Note [Post-unarisation invariants] addIdReps :: [NonVoid Id] -> [NonVoid (PrimRep, Id)] -- | Assumes that arguments have one PrimRep, which holds after -- unarisation. See Note [Post-unarisation invariants] addArgReps :: [NonVoid StgArg] -> [NonVoid (PrimRep, StgArg)] -- | Assumes that the argument has one PrimRep, which holds after -- unarisation. See Note [Post-unarisation invariants] argPrimRep :: StgArg -> PrimRep newtype NonVoid a NonVoid :: a -> NonVoid a fromNonVoid :: NonVoid a -> a nonVoidIds :: [Id] -> [NonVoid Id] nonVoidStgArgs :: [StgArg] -> [NonVoid StgArg] -- | Used in places where some invariant ensures that all these Ids are -- non-void; e.g. constructor field binders in case expressions. See Note -- [Post-unarisation invariants] in GHC.Stg.Unarise. assertNonVoidIds :: [Id] -> [NonVoid Id] -- | Used in places where some invariant ensures that all these arguments -- are non-void; e.g. constructor arguments. See Note [Post-unarisation -- invariants] in GHC.Stg.Unarise. assertNonVoidStgArgs :: [StgArg] -> [NonVoid StgArg] -- | Information about an identifier, from the code generator's point of -- view. Every identifier is bound to a LambdaFormInfo in the -- environment, which gives the code generator enough info to be able to -- tail call or return that identifier. data LambdaFormInfo -- | StandardFormInfo tells whether this thunk has one of a small number of -- standard forms data StandardFormInfo mkLFThunk :: Type -> TopLevelFlag -> [Id] -> UpdateFlag -> LambdaFormInfo mkLFReEntrant :: TopLevelFlag -> [Id] -> [Id] -> ArgDescr -> LambdaFormInfo mkConLFInfo :: DataCon -> LambdaFormInfo mkSelectorLFInfo :: Id -> Int -> Bool -> LambdaFormInfo mkApLFInfo :: Id -> UpdateFlag -> Arity -> LambdaFormInfo mkLFImported :: Id -> LambdaFormInfo mkLFArgument :: Id -> LambdaFormInfo mkLFLetNoEscape :: LambdaFormInfo mkLFStringLit :: LambdaFormInfo -- | Return the tag in the low order bits of a variable bound to this -- LambdaForm lfDynTag :: Platform -> LambdaFormInfo -> DynTag isLFThunk :: LambdaFormInfo -> Bool isLFReEntrant :: LambdaFormInfo -> Bool lfUpdatable :: LambdaFormInfo -> Bool data CgLoc CmmLoc :: CmmExpr -> CgLoc LneLoc :: BlockId -> [LocalReg] -> CgLoc data CallMethod -- | No args, not a function EnterIt :: CallMethod JumpToIt :: BlockId -> [LocalReg] -> CallMethod ReturnIt :: CallMethod InferedReturnIt :: CallMethod SlowCall :: CallMethod DirectEntry :: CLabel -> RepArity -> CallMethod nodeMustPointToIt :: Profile -> LambdaFormInfo -> Bool isKnownFun :: LambdaFormInfo -> Bool funTag :: Platform -> ClosureInfo -> DynTag tagForArity :: Platform -> RepArity -> DynTag getCallMethod :: StgToCmmConfig -> Name -> Id -> LambdaFormInfo -> RepArity -> RepArity -> CgLoc -> Maybe SelfLoopInfo -> CallMethod data ClosureInfo mkClosureInfo :: Profile -> Bool -> Id -> LambdaFormInfo -> Int -> Int -> String -> ClosureInfo -- | Convert from ClosureInfo to CmmInfoTable. mkCmmInfo :: ClosureInfo -> Id -> CostCentreStack -> CmmInfoTable closureLFInfo :: ClosureInfo -> LambdaFormInfo closureName :: ClosureInfo -> Id closureInfoLabel :: ClosureInfo -> CLabel staticClosureLabel :: Platform -> ClosureInfo -> CLabel closureSlowEntryLabel :: Platform -> ClosureInfo -> CLabel closureLocalEntryLabel :: Platform -> ClosureInfo -> CLabel closureUpdReqd :: ClosureInfo -> Bool closureReEntrant :: ClosureInfo -> Bool closureFunInfo :: ClosureInfo -> Maybe (RepArity, ArgDescr) isToplevClosure :: ClosureInfo -> Bool blackHoleOnEntry :: ClosureInfo -> Bool isStaticClosure :: ClosureInfo -> Bool mkDataConInfoTable :: Profile -> DataCon -> ConInfoTableLocation -> Bool -> Int -> Int -> CmmInfoTable cafBlackHoleInfoTable :: CmmInfoTable indStaticInfoTable :: CmmInfoTable staticClosureNeedsLink :: Bool -> CmmInfoTable -> Bool -- | Get the info table label for a *thunk*. mkClosureInfoTableLabel :: Platform -> Id -> LambdaFormInfo -> CLabel instance GHC.Show.Show a => GHC.Show.Show (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Classes.Eq a => GHC.Classes.Eq (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Utils.Outputable.Outputable GHC.StgToCmm.Closure.CallMethod instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.StgToCmm.Closure.NonVoid a) instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.StgToCmm.Closure.CgLoc module GHC.StgToCmm.Monad data FCode a initC :: IO CgState initFCodeState :: Platform -> FCodeState runC :: StgToCmmConfig -> FCodeState -> CgState -> FCode a -> (a, CgState) fixC :: (a -> FCode a) -> FCode a newUnique :: FCode Unique emitLabel :: BlockId -> FCode () emit :: CmmAGraph -> FCode () emitDecl :: CmmDecl -> FCode () emitProcWithConvention :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> CmmAGraphScoped -> FCode () emitProcWithStackFrame :: Convention -> Maybe CmmInfoTable -> CLabel -> [CmmFormal] -> [CmmFormal] -> CmmAGraphScoped -> Bool -> FCode () emitOutOfLine :: BlockId -> CmmAGraphScoped -> FCode () emitAssign :: CmmReg -> CmmExpr -> FCode () -- | Assumes natural alignment. emitStore :: CmmExpr -> CmmExpr -> FCode () emitStore' :: AlignmentSpec -> CmmExpr -> CmmExpr -> FCode () emitComment :: FastString -> FCode () emitTick :: CmmTickish -> FCode () emitUnwind :: [(GlobalReg, Maybe CmmExpr)] -> FCode () newTemp :: MonadUnique m => CmmType -> m LocalReg getCmm :: FCode a -> FCode (a, CmmGroup) aGraphToGraph :: CmmAGraphScoped -> FCode CmmGraph getPlatform :: FCode Platform getProfile :: FCode Profile getCodeR :: FCode a -> FCode (a, CmmAGraph) getCode :: FCode a -> FCode CmmAGraph -- | Generate code into a fresh tick (sub-)scope and gather generated code getCodeScoped :: FCode a -> FCode (a, CmmAGraphScoped) getHeapUsage :: (VirtualHpOffset -> FCode a) -> FCode a getContext :: FCode SDocContext mkCmmIfThenElse :: CmmExpr -> CmmAGraph -> CmmAGraph -> FCode CmmAGraph mkCmmIfThen :: CmmExpr -> CmmAGraph -> FCode CmmAGraph mkCmmIfGoto :: CmmExpr -> BlockId -> FCode CmmAGraph mkCmmIfThenElse' :: CmmExpr -> CmmAGraph -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph mkCmmIfThen' :: CmmExpr -> CmmAGraph -> Maybe Bool -> FCode CmmAGraph mkCmmIfGoto' :: CmmExpr -> BlockId -> Maybe Bool -> FCode CmmAGraph mkCall :: CmmExpr -> (Convention, Convention) -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> FCode CmmAGraph mkCmmCall :: CmmExpr -> [CmmFormal] -> [CmmExpr] -> UpdFrameOffset -> FCode CmmAGraph forkClosureBody :: FCode () -> FCode () forkLneBody :: FCode a -> FCode a forkAlts :: [FCode a] -> FCode [a] forkAltPair :: FCode a -> FCode a -> FCode (a, a) codeOnly :: FCode () -> FCode () -- | A *zero-indexed* constructor tag type ConTagZ = Int -- | A Sequel tells what to do with the result of this expression data Sequel -- | Return result(s) to continuation found on the stack. Return :: Sequel AssignTo :: [LocalReg] -> Bool -> Sequel data ReturnKind AssignedDirectly :: ReturnKind ReturnedTo :: BlockId -> ByteOff -> ReturnKind withSequel :: Sequel -> FCode a -> FCode a getSequel :: FCode Sequel setTickyCtrLabel :: CLabel -> FCode a -> FCode a getTickyCtrLabel :: FCode CLabel -- | Places blocks generated by the given code into a fresh (sub-)scope. -- This will make sure that Cmm annotations in our scope will apply to -- the Cmm blocks generated therein - but not the other way around. tickScope :: FCode a -> FCode a -- | The current tick scope. We will assign this to generated blocks. getTickScope :: FCode CmmTickScope withUpdFrameOff :: UpdFrameOffset -> FCode a -> FCode a getUpdFrameOff :: FCode UpdFrameOffset data HeapUsage HeapUsage :: VirtualHpOffset -> VirtualHpOffset -> HeapUsage [virtHp] :: HeapUsage -> VirtualHpOffset [realHp] :: HeapUsage -> VirtualHpOffset type VirtualHpOffset = WordOff initHpUsage :: HeapUsage getHpUsage :: FCode HeapUsage setHpUsage :: HeapUsage -> FCode () heapHWM :: HeapUsage -> VirtualHpOffset setVirtHp :: VirtualHpOffset -> FCode () getVirtHp :: FCode VirtualHpOffset setRealHp :: VirtualHpOffset -> FCode () getModuleName :: FCode Module getState :: FCode CgState setState :: CgState -> FCode () getSelfLoop :: FCode (Maybe SelfLoopInfo) withSelfLoop :: SelfLoopInfo -> FCode a -> FCode a getStgToCmmConfig :: FCode StgToCmmConfig data CgIdInfo CgIdInfo :: Id -> LambdaFormInfo -> CgLoc -> CgIdInfo [cg_id] :: CgIdInfo -> Id [cg_lf] :: CgIdInfo -> LambdaFormInfo [cg_loc] :: CgIdInfo -> CgLoc getBinds :: FCode CgBindings setBinds :: CgBindings -> FCode () data StgToCmmConfig StgToCmmConfig :: !Profile -> Module -> !TempDir -> !SDocContext -> !Int -> !Maybe Word -> !Int -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> Maybe String -> !Bool -> !Bool -> !Bool -> StgToCmmConfig -- | Current profile [stgToCmmProfile] :: StgToCmmConfig -> !Profile -- | The module being compiled. This field kept lazy for Cmm/Parser.y which -- preloads it with a panic [stgToCmmThisModule] :: StgToCmmConfig -> Module -- | Temp Dir for files used in compilation [stgToCmmTmpDir] :: StgToCmmConfig -> !TempDir -- | Context for StgToCmm phase [stgToCmmContext] :: StgToCmmConfig -> !SDocContext -- | The verbosity of debug messages [stgToCmmDebugLevel] :: StgToCmmConfig -> !Int -- | Threshold at which Binary literals (e.g. strings) are either dumped to -- a file and a CmmFileEmbed literal is emitted (over threshold), or -- become a CmmString Literal (under or at threshold). CmmFileEmbed is -- only supported with the NCG, thus a Just means two things: We have a -- threshold, and will be using the NCG. Conversely, a Nothing implies we -- are not using NCG and disables CmmFileEmbed. See Note [Embedding large -- binary blobs] in GHC.CmmToAsm.Ppr, and cgTopBinding in -- GHC.StgToCmm. [stgToCmmBinBlobThresh] :: StgToCmmConfig -> !Maybe Word -- | Max size, in bytes, of inline array allocations. [stgToCmmMaxInlAllocSize] :: StgToCmmConfig -> !Int -- | Ticky profiling enabled (cf -ticky) [stgToCmmDoTicky] :: StgToCmmConfig -> !Bool -- | True indicates ticky prof traces allocs of each named thing in -- addition to allocs _by_ that thing [stgToCmmTickyAllocd] :: StgToCmmConfig -> !Bool -- | True indicates ticky uses name-specific counters for join-points -- (let-no-escape) [stgToCmmTickyLNE] :: StgToCmmConfig -> !Bool -- | True indicates ticky uses name-specific counters for dynamic thunks [stgToCmmTickyDynThunk] :: StgToCmmConfig -> !Bool -- | True indicates ticky will count number of avoided tag checks by tag -- inference. [stgToCmmTickyTag] :: StgToCmmConfig -> !Bool -- | Loopification enabled (cf -floopification) [stgToCmmLoopification] :: StgToCmmConfig -> !Bool -- | Insert alignment check (cf -falignment-sanitisation) [stgToCmmAlignCheck] :: StgToCmmConfig -> !Bool -- | perform code generation for code coverage [stgToCmmOptHpc] :: StgToCmmConfig -> !Bool [stgToCmmFastPAPCalls] :: StgToCmmConfig -> !Bool -- | Check if cost-centre profiling is enabled [stgToCmmSCCProfiling] :: StgToCmmConfig -> !Bool [stgToCmmEagerBlackHole] :: StgToCmmConfig -> !Bool -- | true means generate C Stub for IPE map, See note [Mapping Info Tables -- to Source Positions] [stgToCmmInfoTableMap] :: StgToCmmConfig -> !Bool -- | true means omit heap checks when no allocation is performed [stgToCmmOmitYields] :: StgToCmmConfig -> !Bool -- | true means don't generate interface programs (implied by -O0) [stgToCmmOmitIfPragmas] :: StgToCmmConfig -> !Bool -- | true if -fPIC [stgToCmmPIC] :: StgToCmmConfig -> !Bool -- | true if -fPIE [stgToCmmPIE] :: StgToCmmConfig -> !Bool -- | true if -fexternal-dynamic-refs, meaning generate code for -- linking against dynamic libraries [stgToCmmExtDynRefs] :: StgToCmmConfig -> !Bool -- | decides whether to check array bounds in StgToCmm.Prim or not [stgToCmmDoBoundsCheck] :: StgToCmmConfig -> !Bool -- | Verify tag inference predictions. [stgToCmmDoTagCheck] :: StgToCmmConfig -> !Bool -- | Allowed to emit larger than native size arithmetic (only LLVM and C -- backends) [stgToCmmAllowBigArith] :: StgToCmmConfig -> !Bool -- | Allowed to generate QuotRem instructions [stgToCmmAllowQuotRemInstr] :: StgToCmmConfig -> !Bool -- | Allowed to generate QuotRem [stgToCmmAllowQuotRem2] :: StgToCmmConfig -> !Bool -- | Allowed to generate AddWordC, SubWordC, Add2, etc. [stgToCmmAllowExtendedAddSubInstrs] :: StgToCmmConfig -> !Bool -- | Allowed to generate IntMul2 instruction [stgToCmmAllowIntMul2Instr] :: StgToCmmConfig -> !Bool -- | Allowed to generate Fabs instructions [stgToCmmAllowFabsInstrs] :: StgToCmmConfig -> !Bool -- | Disable use of precomputed standard thunks. [stgToCmmTickyAP] :: StgToCmmConfig -> !Bool -- | Error (if any) to raise when vector instructions are used, see -- StgToCmm.Prim.checkVecCompatibility [stgToCmmVecInstrsErr] :: StgToCmmConfig -> Maybe String -- | check for Advanced Vector Extensions [stgToCmmAvx] :: StgToCmmConfig -> !Bool -- | check for Advanced Vector Extensions 2 [stgToCmmAvx2] :: StgToCmmConfig -> !Bool -- | check for Advanced Vector 512-bit Extensions [stgToCmmAvx512f] :: StgToCmmConfig -> !Bool data CgState MkCgState :: CmmAGraph -> OrdList CmmDecl -> CgBindings -> HeapUsage -> UniqSupply -> CgState [cgs_stmts] :: CgState -> CmmAGraph [cgs_tops] :: CgState -> OrdList CmmDecl [cgs_binds] :: CgState -> CgBindings [cgs_hp_usg] :: CgState -> HeapUsage [cgs_uniqs] :: CgState -> UniqSupply instance GHC.Base.Functor GHC.StgToCmm.Monad.FCode instance GHC.Base.Applicative GHC.StgToCmm.Monad.FCode instance GHC.Base.Monad GHC.StgToCmm.Monad.FCode instance GHC.Types.Unique.Supply.MonadUnique GHC.StgToCmm.Monad.FCode instance GHC.Utils.Outputable.OutputableP GHC.Platform.Platform GHC.StgToCmm.Monad.CgIdInfo -- | Our extended FCode monad. module GHC.StgToCmm.ExtCode -- | Does a computation in the FCode monad, with a current environment and -- a list of local declarations. Returns the resulting list of -- declarations. data CmmParse a unEC :: CmmParse a -> String -> Env -> Decls -> FCode (Decls, a) -- | The environment contains variable definitions or blockids. data Named -- | Holds CmmLit(CmmLabel ..) which gives the label type, eg, RtsLabel, -- ForeignLabel, CmmLabel etc. VarN :: CmmExpr -> Named -- | A function name from this unit FunN :: UnitId -> Named -- | A blockid of some code or data. LabelN :: BlockId -> Named -- | An environment of named things. type Env = UniqFM FastString Named -- | Takes the variable declarations and imports from the monad and makes -- an environment, which is looped back into the computation. In this -- way, we can have embedded declarations that scope over the whole -- procedure, and imports that scope over the entire module. Discards the -- local declaration contained within decl' loopDecls :: CmmParse a -> CmmParse a -- | Get the current environment from the monad. getEnv :: CmmParse Env -- | Set context name for a sub-parse withName :: String -> CmmParse a -> CmmParse a -- | Get the current context name from the monad getName :: CmmParse String -- | Create a fresh local variable of a given type. newLocal :: CmmType -> FastString -> CmmParse LocalReg -- | Allocate a fresh label. newLabel :: FastString -> CmmParse BlockId newBlockId :: MonadUnique m => m BlockId -- | Add a local function to the environment. newFunctionName :: FastString -> UnitId -> ExtCode -- | Add an imported foreign label to the list of local declarations. If -- this is done at the start of the module the declaration will scope -- over the whole module. newImport :: (FastString, CLabel) -> CmmParse () -- | Lookup the BlockId bound to the label with this name. If one hasn't -- been bound yet, create a fresh one based on the Unique of the name. lookupLabel :: FastString -> CmmParse BlockId -- | Lookup the location of a named variable. Unknown names are treated as -- if they had been 'import'ed from the runtime system. This saves us a -- lot of bother in the RTS sources, at the expense of deferring some -- errors to link time. lookupName :: FastString -> CmmParse CmmExpr -- | Lift an FCode computation into the CmmParse monad code :: FCode a -> CmmParse a emit :: CmmAGraph -> CmmParse () emitLabel :: BlockId -> CmmParse () emitAssign :: CmmReg -> CmmExpr -> CmmParse () emitStore :: CmmExpr -> CmmExpr -> CmmParse () getCode :: CmmParse a -> CmmParse CmmAGraph getCodeR :: CmmParse a -> CmmParse (a, CmmAGraph) getCodeScoped :: CmmParse a -> CmmParse (a, CmmAGraphScoped) emitOutOfLine :: BlockId -> CmmAGraphScoped -> CmmParse () withUpdFrameOff :: UpdFrameOffset -> CmmParse () -> CmmParse () getUpdFrameOff :: CmmParse UpdFrameOffset getProfile :: CmmParse Profile getPlatform :: CmmParse Platform getContext :: CmmParse SDocContext instance GHC.Base.Functor GHC.StgToCmm.ExtCode.CmmParse instance GHC.Base.Applicative GHC.StgToCmm.ExtCode.CmmParse instance GHC.Base.Monad GHC.StgToCmm.ExtCode.CmmParse instance GHC.Types.Unique.Supply.MonadUnique GHC.StgToCmm.ExtCode.CmmParse module GHC.StgToCmm.Env data CgIdInfo litIdInfo :: Platform -> Id -> LambdaFormInfo -> CmmLit -> CgIdInfo lneIdInfo :: Platform -> Id -> [NonVoid Id] -> CgIdInfo rhsIdInfo :: Id -> LambdaFormInfo -> FCode (CgIdInfo, LocalReg) mkRhsInit :: Platform -> LocalReg -> LambdaFormInfo -> CmmExpr -> CmmAGraph idInfoToAmode :: CgIdInfo -> CmmExpr addBindC :: CgIdInfo -> FCode () addBindsC :: [CgIdInfo] -> FCode () bindArgsToRegs :: [NonVoid Id] -> FCode [LocalReg] bindToReg :: NonVoid Id -> LambdaFormInfo -> FCode LocalReg rebindToReg :: NonVoid Id -> FCode LocalReg bindArgToReg :: NonVoid Id -> FCode LocalReg idToReg :: Platform -> NonVoid Id -> LocalReg getCgIdInfo :: Id -> FCode CgIdInfo -- | Retrieve cg info for a name if it already exists. getCgInfo_maybe :: Name -> FCode (Maybe CgIdInfo) maybeLetNoEscape :: CgIdInfo -> Maybe (BlockId, [LocalReg]) module GHC.StgToCmm.Lit cgLit :: Literal -> FCode CmmExpr mkSimpleLit :: Platform -> Literal -> CmmLit -- | Make a global definition for the string, and return its label newStringCLit :: String -> FCode CmmLit newByteStringCLit :: ByteString -> FCode CmmLit module GHC.StgToCmm.ArgRep data ArgRep P :: ArgRep N :: ArgRep L :: ArgRep V :: ArgRep F :: ArgRep D :: ArgRep V16 :: ArgRep V32 :: ArgRep V64 :: ArgRep toArgRep :: Platform -> PrimRep -> ArgRep argRepSizeW :: Platform -> ArgRep -> WordOff argRepString :: ArgRep -> String isNonV :: ArgRep -> Bool idArgRep :: Platform -> Id -> ArgRep slowCallPattern :: [ArgRep] -> (FastString, RepArity) instance GHC.Classes.Eq GHC.StgToCmm.ArgRep.ArgRep instance GHC.Utils.Outputable.Outputable GHC.StgToCmm.ArgRep.ArgRep module GHC.StgToCmm.Utils -- | Emit a data-segment data block emitDataLits :: CLabel -> [CmmLit] -> FCode () -- | Emit a read-only data block emitRODataLits :: CLabel -> [CmmLit] -> FCode () emitDataCon :: CLabel -> CmmInfoTable -> CostCentreStack -> [CmmLit] -> FCode () emitRtsCall :: UnitId -> FastString -> [(CmmExpr, ForeignHint)] -> Bool -> FCode () emitRtsCallWithResult :: LocalReg -> ForeignHint -> UnitId -> FastString -> [(CmmExpr, ForeignHint)] -> Bool -> FCode () emitRtsCallGen :: [(LocalReg, ForeignHint)] -> CLabel -> [(CmmExpr, ForeignHint)] -> Bool -> FCode () emitBarf :: String -> FCode () assignTemp :: CmmExpr -> FCode LocalReg newTemp :: MonadUnique m => CmmType -> m LocalReg newUnboxedTupleRegs :: Type -> FCode ([LocalReg], [ForeignHint]) emitMultiAssign :: [LocalReg] -> [CmmExpr] -> FCode () emitCmmLitSwitch :: CmmExpr -> [(Literal, CmmAGraphScoped)] -> CmmAGraphScoped -> FCode () emitSwitch :: CmmExpr -> [(ConTagZ, CmmAGraphScoped)] -> Maybe CmmAGraphScoped -> ConTagZ -> ConTagZ -> FCode () tagToClosure :: Platform -> TyCon -> CmmExpr -> CmmExpr mkTaggedObjectLoad :: Platform -> LocalReg -> LocalReg -> ByteOff -> DynTag -> CmmAGraph -- | Returns True if this global register is stored in a -- caller-saves machine register. callerSaves :: Platform -> GlobalReg -> Bool callerSaveVolatileRegs :: Platform -> (CmmAGraph, CmmAGraph) -- | We map STG registers onto appropriate CmmExprs. Either they map to -- real machine registers or stored as offsets from BaseReg. Given a -- GlobalReg, get_GlobalReg_addr always produces the register table -- address for it. get_GlobalReg_addr :: Platform -> GlobalReg -> CmmExpr callerSaveGlobalReg :: Platform -> GlobalReg -> CmmAGraph callerRestoreGlobalReg :: Platform -> GlobalReg -> CmmAGraph cmmAndWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmOrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmNegate :: Platform -> CmmExpr -> CmmExpr cmmEqWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmNeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUGtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmSubWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmMulWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmAddWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmUShrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmOffsetExprW :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmOffsetExprB :: Platform -> CmmExpr -> CmmExpr -> CmmExpr cmmRegOffW :: Platform -> CmmReg -> WordOff -> CmmExpr cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr cmmLabelOffW :: Platform -> CLabel -> WordOff -> CmmLit cmmLabelOffB :: CLabel -> ByteOff -> CmmLit cmmOffsetW :: Platform -> CmmExpr -> WordOff -> CmmExpr cmmOffsetB :: Platform -> CmmExpr -> ByteOff -> CmmExpr cmmOffsetLitW :: Platform -> CmmLit -> WordOff -> CmmLit cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit cmmLoadIndexW :: Platform -> CmmExpr -> Int -> CmmType -> CmmExpr cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr cmmUntag :: Platform -> CmmExpr -> CmmExpr cmmIsTagged :: Platform -> CmmExpr -> CmmExpr -- | addToMem rep ptr n adds n to the integer pointed-to -- by ptr. addToMem :: CmmType -> CmmExpr -> Int -> CmmAGraph -- | addToMemE rep ptr n adds n to the integer pointed-to -- by ptr. addToMemE :: CmmType -> CmmExpr -> CmmExpr -> CmmAGraph addToMemLblE :: CmmType -> CLabel -> CmmExpr -> CmmAGraph addToMemLbl :: CmmType -> CLabel -> Int -> CmmAGraph whenUpdRemSetEnabled :: FCode a -> FCode () -- | Emit code to add an entry to a now-overwritten pointer to the update -- remembered set. emitUpdRemSetPush :: CmmExpr -> FCode () emitUpdRemSetPushThunk :: CmmExpr -> FCode () -- | Convert source information collected about identifiers in Debug -- to entries suitable for placing into the info table provenenance -- table. convertInfoProvMap :: [CmmInfoTable] -> Module -> InfoTableProvMap -> [InfoProvEnt] -- | A bare bones InfoProvEnt for things which don't have a good source -- location cmmInfoTableToInfoProvEnt :: Module -> CmmInfoTable -> InfoProvEnt module GHC.StgToCmm.Ticky withNewTickyCounterFun :: Bool -> Id -> [NonVoid Id] -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterLNE :: Id -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterThunk :: Bool -> Bool -> Id -> [NonVoid Id] -> FCode a -> FCode a withNewTickyCounterStdThunk :: Bool -> Id -> [StgArg] -> FCode a -> FCode a withNewTickyCounterCon :: Id -> DataCon -> ConstructorNumber -> FCode a -> FCode a emitTickyCounterTag :: Unique -> NonVoid Id -> FCode CLabel tickyDynAlloc :: Maybe Id -> SMRep -> LambdaFormInfo -> FCode () tickyAllocHeap :: Bool -> VirtualHpOffset -> FCode () tickyAllocPrim :: CmmExpr -> CmmExpr -> CmmExpr -> FCode () tickyAllocThunk :: CmmExpr -> CmmExpr -> FCode () tickyAllocPAP :: CmmExpr -> CmmExpr -> FCode () tickyHeapCheck :: FCode () tickyStackCheck :: FCode () tickyDirectCall :: RepArity -> [StgArg] -> FCode () tickyPushUpdateFrame :: FCode () tickyUpdateFrameOmitted :: FCode () tickyEnterDynCon :: FCode () tickyEnterFun :: ClosureInfo -> FCode () tickyEnterThunk :: ClosureInfo -> FCode () tickyEnterLNE :: FCode () tickyUpdateBhCaf :: ClosureInfo -> FCode () tickyUnboxedTupleReturn :: RepArity -> FCode () tickyReturnOldCon :: RepArity -> FCode () tickyReturnNewCon :: RepArity -> FCode () tickyKnownCallTooFewArgs :: FCode () tickyKnownCallExact :: FCode () tickyKnownCallExtraArgs :: FCode () tickySlowCall :: LambdaFormInfo -> [StgArg] -> FCode () tickySlowCallPat :: [PrimRep] -> FCode () -- | Predicted a pointer would be tagged correctly (GHC will crash if not -- so no miss case) tickyTagged :: FCode () -- | Pass a boolean expr indicating if tag was present. tickyUntagged :: CmmExpr -> FCode () -- | Called when for `case v of ...` we can avoid entering v based on tag -- inference information. tickyTagSkip :: Unique -> Id -> FCode () instance GHC.Utils.Json.ToJson GHC.StgToCmm.Ticky.TickyClosureType module GHC.StgToCmm.TagCheck -- | Call barf if we failed to predict a tag correctly. This is immensly -- useful when debugging issues in tag inference as it will result in a -- program abort when we encounter an invalid call/heap object, rather -- than leaving it be and segfaulting arbitrary or producing invalid -- results. We check if either: * A tag is present * Or the object is a -- 25 (for which zero is the proper tag) emitTagAssertion :: String -> CmmExpr -> FCode () emitArgTagCheck :: SDoc -> [CbvMark] -> [Id] -> FCode () checkArg :: SDoc -> CbvMark -> StgArg -> FCode () whenCheckTags :: FCode () -> FCode () checkArgStatic :: SDoc -> StrictnessMark -> StgArg -> FCode () -- | Check all arguments marked as already tagged for a function are tagged -- by inserting runtime checks. checkFunctionArgTags :: SDoc -> Id -> [Id] -> FCode () -- | Check all required-tagged arguments of a constructor are tagged *at -- compile time*. checkConArgsStatic :: SDoc -> DataCon -> [StgArg] -> FCode () checkConArgsDyn :: SDoc -> DataCon -> [StgArg] -> FCode () module GHC.StgToCmm.Layout mkArgDescr :: Platform -> [Id] -> ArgDescr -- | emitCall conv fun args makes a call to the entry-code of -- fun, using the call/return convention conv, passing -- args, and returning the results to the current sequel. emitCall :: (Convention, Convention) -> CmmExpr -> [CmmExpr] -> FCode ReturnKind -- | Return multiple values to the sequel -- -- If the sequel is Return -- --
--   return (x,y)
--   
-- -- If the sequel is AssignTo [p,q] -- --
--   p=x; q=y;
--   
emitReturn :: [CmmExpr] -> FCode ReturnKind adjustHpBackwards :: FCode () emitClosureProcAndInfoTable :: Bool -> Id -> LambdaFormInfo -> CmmInfoTable -> [NonVoid Id] -> ((Int, LocalReg, [LocalReg]) -> FCode ()) -> FCode () emitClosureAndInfoTable :: Platform -> CmmInfoTable -> Convention -> [LocalReg] -> FCode () -> FCode () slowCall :: CmmExpr -> [StgArg] -> FCode ReturnKind directCall :: Convention -> CLabel -> RepArity -> [StgArg] -> FCode ReturnKind data FieldOffOrPadding a FieldOff :: NonVoid a -> ByteOff -> FieldOffOrPadding a Padding :: ByteOff -> ByteOff -> FieldOffOrPadding a -- | Used to tell the various mkVirtHeapOffsets functions what -- kind of header the object has. This will be accounted for in the -- offsets of the fields returned. data ClosureHeader NoHeader :: ClosureHeader StdHeader :: ClosureHeader ThunkHeader :: ClosureHeader mkVirtHeapOffsets :: Profile -> ClosureHeader -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, ByteOff)]) mkVirtHeapOffsetsWithPadding :: Profile -> ClosureHeader -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [FieldOffOrPadding a]) -- | Just like mkVirtHeapOffsets, but for constructors mkVirtConstrOffsets :: Profile -> [NonVoid (PrimRep, a)] -> (WordOff, WordOff, [(NonVoid a, ByteOff)]) -- | Just like mkVirtConstrOffsets, but used when we don't have the actual -- arguments. Useful when e.g. generating info tables; we just need to -- know sizes of pointer and non-pointer fields. mkVirtConstrSizes :: Profile -> [NonVoid PrimRep] -> (WordOff, WordOff) getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr data ArgRep P :: ArgRep N :: ArgRep L :: ArgRep V :: ArgRep F :: ArgRep D :: ArgRep V16 :: ArgRep V32 :: ArgRep V64 :: ArgRep toArgRep :: Platform -> PrimRep -> ArgRep argRepSizeW :: Platform -> ArgRep -> WordOff getArgAmode :: NonVoid StgArg -> FCode CmmExpr getNonVoidArgAmodes :: [StgArg] -> FCode [CmmExpr] -- | Provides the heuristics for when it's beneficial to lambda lift -- bindings. Most significantly, this employs a cost model to estimate -- impact on heap allocations, by looking at an STG expression's -- Skeleton. module GHC.Stg.Lift.Analysis -- | Captures details of the syntax tree relevant to the cost model, such -- as closures, multi-shot lambdas and case expressions. data Skeleton ClosureSk :: !Id -> !DIdSet -> !Skeleton -> Skeleton RhsSk :: !Card -> !Skeleton -> Skeleton AltSk :: !Skeleton -> !Skeleton -> Skeleton BothSk :: !Skeleton -> !Skeleton -> Skeleton NilSk :: Skeleton -- | The type used in binder positions in GenStgExprs. data BinderInfo -- | Let(-no-escape)-bound thing with a flag indicating whether it occurs -- as an argument or in a nullary application (see -- GHC.Stg.Lift.Analysis#arg_occs). BindsClosure :: !Id -> !Bool -> BinderInfo -- | Every other kind of binder BoringBinder :: !Id -> BinderInfo -- | Gets the bound Id out a BinderInfo. binderInfoBndr :: BinderInfo -> Id type LlStgBinding = GenStgBinding 'LiftLams type LlStgExpr = GenStgExpr 'LiftLams type LlStgRhs = GenStgRhs 'LiftLams type LlStgAlt = GenStgAlt 'LiftLams -- | Tags every binder with its BinderInfo and let bindings with -- their Skeletons. tagSkeletonTopBind :: CgStgBinding -> LlStgBinding -- | Combines several heuristics to decide whether to lambda-lift a given -- let-binding to top-level. See -- GHC.Stg.Lift.Analysis#when for details. goodToLift :: StgLiftConfig -> TopLevelFlag -> RecFlag -> (DIdSet -> DIdSet) -> [(BinderInfo, LlStgRhs)] -> Skeleton -> Maybe DIdSet -- | closureGrowth expander sizer f fvs computes the closure -- growth in words as a result of lifting f to top-level. If -- there was any growing closure under a multi-shot lambda, the result -- will be infinity. Also see GHC.Stg.Lift.Analysis#clogro. closureGrowth :: (DIdSet -> DIdSet) -> (Id -> Int) -> IdSet -> DIdSet -> Skeleton -> IntWithInf instance GHC.Utils.Outputable.Outputable GHC.Stg.Lift.Analysis.BinderInfo instance GHC.Utils.Outputable.OutputableBndr GHC.Stg.Lift.Analysis.BinderInfo instance GHC.Utils.Outputable.Outputable GHC.Stg.Lift.Analysis.Skeleton -- | Implements a selective lambda lifter, running late in the optimisation -- pipeline. -- -- If you are interested in the cost model that is employed to decide -- whether to lift a binding or not, look at -- GHC.Stg.Lift.Analysis. GHC.Stg.Lift.Monad contains the -- transformation monad that hides away some plumbing of the -- transformation. module GHC.Stg.Lift data StgLiftConfig StgLiftConfig :: !Profile -> !Maybe Int -> !Maybe Int -> !Bool -> StgLiftConfig [c_targetProfile] :: StgLiftConfig -> !Profile -- | Maximum number of arguments after lambda lifting a recursive function. [c_liftLamsRecArgs] :: StgLiftConfig -> !Maybe Int -- | Maximum number of arguments after lambda lifting non-recursive -- function. [c_liftLamsNonRecArgs] :: StgLiftConfig -> !Maybe Int -- | Lambda lift even when this turns a known call into an unknown call. [c_liftLamsKnown] :: StgLiftConfig -> !Bool -- | Lambda lifts bindings to top-level deemed worth lifting (see -- goodToLift). -- -- (Mostly) textbook instance of the lambda lifting transformation, -- selecting which bindings to lambda lift by consulting -- goodToLift. stgLiftLams :: Module -> StgLiftConfig -> UniqSupply -> [InStgTopBinding] -> [OutStgTopBinding] module GHC.Stg.Pipeline data StgPipelineOpts StgPipelineOpts :: ![StgToDo] -> !Maybe DiagOpts -> !StgPprOpts -> StgPipelineOpts -- | Spec of what stg-to-stg passes to do [stgPipeline_phases] :: StgPipelineOpts -> ![StgToDo] -- | Should we lint the STG at various stages of the pipeline? [stgPipeline_lint] :: StgPipelineOpts -> !Maybe DiagOpts [stgPipeline_pprOpts] :: StgPipelineOpts -> !StgPprOpts -- | Optional Stg-to-Stg passes. data StgToDo -- | Common subexpression elimination StgCSE :: StgToDo -- | Lambda lifting closure variables, trading stack/register allocation -- for heap allocation StgLiftLams :: StgLiftConfig -> StgToDo StgStats :: StgToDo -- | Mandatory unarise pass, desugaring unboxed tuple and sum binders StgUnarise :: StgToDo -- | Mandatory when compiling to bytecode StgBcPrep :: StgToDo -- | Useful for building up getStgToDo StgDoNothing :: StgToDo stg2stg :: Logger -> InteractiveContext -> StgPipelineOpts -> Module -> [StgTopBinding] -> IO [CgStgTopBinding] instance Control.Monad.IO.Class.MonadIO GHC.Stg.Pipeline.StgM instance GHC.Base.Monad GHC.Stg.Pipeline.StgM instance GHC.Base.Applicative GHC.Stg.Pipeline.StgM instance GHC.Base.Functor GHC.Stg.Pipeline.StgM instance GHC.Classes.Ord GHC.Stg.Pipeline.StgToDo instance GHC.Classes.Eq GHC.Stg.Pipeline.StgToDo instance GHC.Read.Read GHC.Stg.Pipeline.StgToDo instance GHC.Show.Show GHC.Stg.Pipeline.StgToDo instance GHC.Types.Unique.Supply.MonadUnique GHC.Stg.Pipeline.StgM module GHC.Driver.Config.Stg.Pipeline -- | Initialize STG pretty-printing options from DynFlags initStgPipelineOpts :: DynFlags -> Bool -> StgPipelineOpts -- | Bytecode instruction definitions module GHC.ByteCode.Instr data BCInstr STKCHECK :: Word -> BCInstr PUSH_L :: !Word16 -> BCInstr PUSH_LL :: !Word16 -> !Word16 -> BCInstr PUSH_LLL :: !Word16 -> !Word16 -> !Word16 -> BCInstr PUSH8 :: !Word16 -> BCInstr PUSH16 :: !Word16 -> BCInstr PUSH32 :: !Word16 -> BCInstr PUSH8_W :: !Word16 -> BCInstr PUSH16_W :: !Word16 -> BCInstr PUSH32_W :: !Word16 -> BCInstr PUSH_G :: Name -> BCInstr PUSH_PRIMOP :: PrimOp -> BCInstr PUSH_BCO :: ProtoBCO Name -> BCInstr PUSH_ALTS :: ProtoBCO Name -> BCInstr PUSH_ALTS_UNLIFTED :: ProtoBCO Name -> ArgRep -> BCInstr PUSH_ALTS_TUPLE :: ProtoBCO Name -> !TupleInfo -> ProtoBCO Name -> BCInstr PUSH_PAD8 :: BCInstr PUSH_PAD16 :: BCInstr PUSH_PAD32 :: BCInstr PUSH_UBX8 :: Literal -> BCInstr PUSH_UBX16 :: Literal -> BCInstr PUSH_UBX32 :: Literal -> BCInstr PUSH_UBX :: Literal -> Word16 -> BCInstr PUSH_APPLY_N :: BCInstr PUSH_APPLY_V :: BCInstr PUSH_APPLY_F :: BCInstr PUSH_APPLY_D :: BCInstr PUSH_APPLY_L :: BCInstr PUSH_APPLY_P :: BCInstr PUSH_APPLY_PP :: BCInstr PUSH_APPLY_PPP :: BCInstr PUSH_APPLY_PPPP :: BCInstr PUSH_APPLY_PPPPP :: BCInstr PUSH_APPLY_PPPPPP :: BCInstr SLIDE :: Word16 -> Word16 -> BCInstr ALLOC_AP :: !Word16 -> BCInstr ALLOC_AP_NOUPD :: !Word16 -> BCInstr ALLOC_PAP :: !Word16 -> !Word16 -> BCInstr MKAP :: !Word16 -> !Word16 -> BCInstr MKPAP :: !Word16 -> !Word16 -> BCInstr UNPACK :: !Word16 -> BCInstr PACK :: DataCon -> !Word16 -> BCInstr LABEL :: LocalLabel -> BCInstr TESTLT_I :: Int -> LocalLabel -> BCInstr TESTEQ_I :: Int -> LocalLabel -> BCInstr TESTLT_W :: Word -> LocalLabel -> BCInstr TESTEQ_W :: Word -> LocalLabel -> BCInstr TESTLT_F :: Float -> LocalLabel -> BCInstr TESTEQ_F :: Float -> LocalLabel -> BCInstr TESTLT_D :: Double -> LocalLabel -> BCInstr TESTEQ_D :: Double -> LocalLabel -> BCInstr TESTLT_P :: Word16 -> LocalLabel -> BCInstr TESTEQ_P :: Word16 -> LocalLabel -> BCInstr CASEFAIL :: BCInstr JMP :: LocalLabel -> BCInstr CCALL :: Word16 -> RemotePtr C_ffi_cif -> Word16 -> BCInstr SWIZZLE :: Word16 -> Word16 -> BCInstr ENTER :: BCInstr RETURN :: BCInstr RETURN_UNLIFTED :: ArgRep -> BCInstr RETURN_TUPLE :: BCInstr BRK_FUN :: Word16 -> Unique -> RemotePtr CostCentre -> BCInstr data ProtoBCO a ProtoBCO :: a -> [BCInstr] -> [StgWord] -> Word16 -> Int -> Either [CgStgAlt] CgStgRhs -> [FFIInfo] -> ProtoBCO a [protoBCOName] :: ProtoBCO a -> a [protoBCOInstrs] :: ProtoBCO a -> [BCInstr] [protoBCOBitmap] :: ProtoBCO a -> [StgWord] [protoBCOBitmapSize] :: ProtoBCO a -> Word16 [protoBCOArity] :: ProtoBCO a -> Int [protoBCOExpr] :: ProtoBCO a -> Either [CgStgAlt] CgStgRhs [protoBCOFFIs] :: ProtoBCO a -> [FFIInfo] bciStackUse :: BCInstr -> Word -- | A local block label (e.g. identifying a case alternative). newtype LocalLabel LocalLabel :: Word32 -> LocalLabel [getLocalLabel] :: LocalLabel -> Word32 instance GHC.Classes.Ord GHC.ByteCode.Instr.LocalLabel instance GHC.Classes.Eq GHC.ByteCode.Instr.LocalLabel instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.ByteCode.Instr.ProtoBCO a) instance GHC.Utils.Outputable.Outputable GHC.ByteCode.Instr.BCInstr instance GHC.Utils.Outputable.Outputable GHC.ByteCode.Instr.LocalLabel -- | Generate infotables for interpreter-made bytecodes module GHC.ByteCode.InfoTable mkITbls :: Interp -> Profile -> [TyCon] -> IO ItblEnv -- | Bytecode assembler and linker module GHC.ByteCode.Asm assembleBCOs :: Interp -> Profile -> [ProtoBCO Name] -> [TyCon] -> [RemotePtr ()] -> Maybe ModBreaks -> IO CompiledByteCode assembleOneBCO :: Interp -> Profile -> ProtoBCO Name -> IO UnlinkedBCO -- | Finds external references. Remember to remove the names defined by -- this group of BCOs themselves bcoFreeNames :: UnlinkedBCO -> UniqDSet Name data SizedSeq a sizeSS :: SizedSeq a -> Word ssElts :: SizedSeq a -> [a] iNTERP_STACK_CHECK_THRESH :: Int mkTupleInfoLit :: Platform -> TupleInfo -> Literal instance GHC.Base.Functor GHC.ByteCode.Asm.Assembler instance GHC.Base.Applicative GHC.ByteCode.Asm.Assembler instance GHC.Base.Monad GHC.ByteCode.Asm.Assembler -- | GHC.StgToByteCode: Generate bytecode from STG module GHC.StgToByteCode data UnlinkedBCO byteCodeGen :: HscEnv -> Module -> [CgStgTopBinding] -> [TyCon] -> Maybe ModBreaks -> IO CompiledByteCode instance GHC.Classes.Ord GHC.StgToByteCode.Discr instance GHC.Classes.Eq GHC.StgToByteCode.Discr instance GHC.Base.Functor GHC.StgToByteCode.BcM instance GHC.Base.Applicative GHC.StgToByteCode.BcM instance GHC.Base.Monad GHC.StgToByteCode.BcM instance GHC.Driver.Session.HasDynFlags GHC.StgToByteCode.BcM instance GHC.Utils.Outputable.Outputable GHC.StgToByteCode.Discr module GHC.StgToCmm.Hpc -- | Emit top-level tables for HPC and return code to initialise initHpc :: Module -> HpcInfo -> FCode () mkTickBox :: Platform -> Module -> Int -> CmmAGraph module GHC.SysTools.Ar data ArchiveEntry ArchiveEntry :: String -> Int -> Int -> Int -> Int -> Int -> ByteString -> ArchiveEntry -- | File name. [filename] :: ArchiveEntry -> String -- | File modification time. [filetime] :: ArchiveEntry -> Int -- | File owner. [fileown] :: ArchiveEntry -> Int -- | File group. [filegrp] :: ArchiveEntry -> Int -- | File mode. [filemode] :: ArchiveEntry -> Int -- | File size. [filesize] :: ArchiveEntry -> Int -- | File bytes. [filedata] :: ArchiveEntry -> ByteString newtype Archive Archive :: [ArchiveEntry] -> Archive afilter :: (ArchiveEntry -> Bool) -> Archive -> Archive parseAr :: ByteString -> Archive loadAr :: FilePath -> IO Archive loadObj :: FilePath -> IO ArchiveEntry writeBSDAr :: FilePath -> Archive -> IO () writeGNUAr :: FilePath -> Archive -> IO () isBSDSymdef :: ArchiveEntry -> Bool isGNUSymdef :: ArchiveEntry -> Bool instance GHC.Show.Show GHC.SysTools.Ar.ArchiveEntry instance GHC.Classes.Eq GHC.SysTools.Ar.ArchiveEntry instance GHC.Base.Monoid GHC.SysTools.Ar.Archive instance GHC.Base.Semigroup GHC.SysTools.Ar.Archive instance GHC.Show.Show GHC.SysTools.Ar.Archive instance GHC.Classes.Eq GHC.SysTools.Ar.Archive module GHC.SysTools.Process -- | Enable process jobs support on Windows if it can be expected to work -- (e.g. process >= 1.6.9.0). enableProcessJobs :: CreateProcess -> CreateProcess hGetContents' :: Handle -> IO String readCreateProcessWithExitCode' :: CreateProcess -> IO (ExitCode, String) replaceVar :: (String, String) -> [(String, String)] -> [(String, String)] -- | Version of System.Process.readProcessWithExitCode that takes -- a key-value tuple to insert into the environment. readProcessEnvWithExitCode :: String -> [String] -> (String, String) -> IO (ExitCode, String, String) c_locale_env :: (String, String) getGccEnv :: [Option] -> IO (Maybe [(String, String)]) runSomething :: Logger -> String -> String -> [Option] -> IO () -- | Run a command, placing the arguments in an external response file. -- -- This command is used in order to avoid overlong command line arguments -- on Windows. The command line arguments are first written to an -- external, temporary response file, and then passed to the linker via -- @filepath. response files for passing them in. See: -- -- https://gcc.gnu.org/wiki/Response_Files -- https://gitlab.haskell.org/ghc/ghc/issues/10777 runSomethingResponseFile :: Logger -> TmpFs -> DynFlags -> (String -> String) -> String -> String -> [Option] -> Maybe [(String, String)] -> IO () runSomethingFiltered :: Logger -> (String -> String) -> String -> String -> [Option] -> Maybe FilePath -> Maybe [(String, String)] -> IO () runSomethingWith :: Logger -> String -> String -> [Option] -> ([String] -> IO (ExitCode, a)) -> IO a handleProc :: String -> String -> IO (ExitCode, r) -> IO r builderMainLoop :: Logger -> (String -> String) -> FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO ExitCode readerProc :: Chan BuildMessage -> Handle -> (String -> String) -> IO () parseError :: String -> Maybe (String, Int, Int, String) -- | Break a line of an error message into a filename and the rest of the -- line, taking care to ignore colons in Windows drive letters (as noted -- in #17786). For instance, -- -- breakColon :: String -> Maybe (String, String) breakIntColon :: String -> Maybe (Int, String) data BuildMessage BuildMsg :: !SDoc -> BuildMessage BuildError :: !SrcLoc -> !SDoc -> BuildMessage EOF :: BuildMessage linesPlatform :: String -> [String] module GHC.SysTools.Info neededLinkArgs :: LinkerInfo -> [Option] getLinkerInfo :: Logger -> DynFlags -> IO LinkerInfo getLinkerInfo' :: Logger -> DynFlags -> IO LinkerInfo -- | Grab compiler info and cache it in DynFlags. getCompilerInfo :: Logger -> DynFlags -> IO CompilerInfo -- | Grab assembler info and cache it in DynFlags. getAssemblerInfo :: Logger -> DynFlags -> IO CompilerInfo getCompilerInfo' :: Logger -> String -> IO CompilerInfo -- | Functional dependencies -- -- It's better to read it as: "if we know these, then we're going to know -- these" module GHC.Tc.Instance.FunDeps data FunDepEqn loc FDEqn :: [TyVar] -> [TypeEqn] -> PredType -> PredType -> loc -> FunDepEqn loc [fd_qtvs] :: FunDepEqn loc -> [TyVar] [fd_eqs] :: FunDepEqn loc -> [TypeEqn] [fd_pred1] :: FunDepEqn loc -> PredType [fd_pred2] :: FunDepEqn loc -> PredType [fd_loc] :: FunDepEqn loc -> loc pprEquation :: FunDepEqn a -> SDoc improveFromInstEnv :: InstEnvs -> (PredType -> SrcSpan -> loc) -> Class -> [Type] -> [FunDepEqn loc] improveFromAnother :: loc -> PredType -> PredType -> [FunDepEqn loc] checkInstCoverage :: Bool -> Class -> [PredType] -> [Type] -> Validity checkFunDeps :: InstEnvs -> ClsInst -> [ClsInst] pprFundeps :: Outputable a => [FunDep a] -> SDoc instFD :: FunDep TyVar -> [TyVar] -> [Type] -> FunDep Type closeWrtFunDeps :: [PredType] -> TyCoVarSet -> TyCoVarSet instance GHC.Base.Functor GHC.Tc.Instance.FunDeps.FunDepEqn instance GHC.Utils.Outputable.Outputable (GHC.Tc.Instance.FunDeps.FunDepEqn a) module GHC.Tc.Types.EvTerm evDelayedError :: Type -> String -> EvTerm evCallStack :: (MonadThings m, HasModule m, HasDynFlags m) => EvCallStack -> m EvExpr -- | Functions for working with the typechecker environment (setters, -- getters...). module GHC.Tc.Utils.Monad -- | Setup the initial typechecking environment initTc :: HscEnv -> HscSource -> Bool -> Module -> RealSrcSpan -> TcM r -> IO (Messages TcRnMessage, Maybe r) -- | Run a TcM action in the context of an existing GblEnv. initTcWithGbl :: HscEnv -> TcGblEnv -> RealSrcSpan -> TcM r -> IO (Messages TcRnMessage, Maybe r) initTcInteractive :: HscEnv -> TcM a -> IO (Messages TcRnMessage, Maybe a) initTcRnIf :: Char -> HscEnv -> gbl -> lcl -> TcRnIf gbl lcl a -> IO a discardResult :: TcM a -> TcM () getTopEnv :: TcRnIf gbl lcl HscEnv updTopEnv :: (HscEnv -> HscEnv) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a getGblEnv :: TcRnIf gbl lcl gbl updGblEnv :: (gbl -> gbl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a setGblEnv :: gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a getLclEnv :: TcRnIf gbl lcl lcl updLclEnv :: (lcl -> lcl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a setLclEnv :: lcl' -> TcRnIf gbl lcl' a -> TcRnIf gbl lcl a restoreLclEnv :: TcLclEnv -> TcRnIf gbl TcLclEnv a -> TcRnIf gbl TcLclEnv a updTopFlags :: (DynFlags -> DynFlags) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a getEnvs :: TcRnIf gbl lcl (gbl, lcl) setEnvs :: (gbl', lcl') -> TcRnIf gbl' lcl' a -> TcRnIf gbl lcl a updEnvs :: ((gbl, lcl) -> (gbl, lcl)) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a restoreEnvs :: (TcGblEnv, TcLclEnv) -> TcRn a -> TcRn a xoptM :: Extension -> TcRnIf gbl lcl Bool doptM :: DumpFlag -> TcRnIf gbl lcl Bool goptM :: GeneralFlag -> TcRnIf gbl lcl Bool woptM :: WarningFlag -> TcRnIf gbl lcl Bool setXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a unsetXOptM :: Extension -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a -- | Do it flag is true whenDOptM :: DumpFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () whenWOptM :: WarningFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () whenXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () unlessXOptM :: Extension -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () getGhcMode :: TcRnIf gbl lcl GhcMode withoutDynamicNow :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a getEpsVar :: TcRnIf gbl lcl (TcRef ExternalPackageState) getEps :: TcRnIf gbl lcl ExternalPackageState -- | Update the external package state. Returns the second result of the -- modifier function. -- -- This is an atomic operation and forces evaluation of the modified EPS -- in order to avoid space leaks. updateEps :: (ExternalPackageState -> (ExternalPackageState, a)) -> TcRnIf gbl lcl a -- | Update the external package state. -- -- This is an atomic operation and forces evaluation of the modified EPS -- in order to avoid space leaks. updateEps_ :: (ExternalPackageState -> ExternalPackageState) -> TcRnIf gbl lcl () getHpt :: TcRnIf gbl lcl HomePackageTable getEpsAndHug :: TcRnIf gbl lcl (ExternalPackageState, HomeUnitGraph) newArrowScope :: TcM a -> TcM a escapeArrowScope :: TcM a -> TcM a newUnique :: TcRnIf gbl lcl Unique newUniqueSupply :: TcRnIf gbl lcl UniqSupply newName :: OccName -> TcM Name newNameAt :: OccName -> SrcSpan -> TcM Name cloneLocalName :: Name -> TcM Name newSysName :: OccName -> TcRnIf gbl lcl Name newSysLocalId :: FastString -> Mult -> TcType -> TcRnIf gbl lcl TcId newSysLocalIds :: FastString -> [Scaled TcType] -> TcRnIf gbl lcl [TcId] newTcRef :: a -> TcRnIf gbl lcl (TcRef a) readTcRef :: TcRef a -> TcRnIf gbl lcl a writeTcRef :: TcRef a -> a -> TcRnIf gbl lcl () updTcRef :: TcRef a -> (a -> a) -> TcRnIf gbl lcl () traceTc :: String -> SDoc -> TcRn () traceRn :: String -> SDoc -> TcRn () traceOptTcRn :: DumpFlag -> SDoc -> TcRn () -- | Dump if the given DumpFlag is set. dumpOptTcRn :: DumpFlag -> String -> DumpFormat -> SDoc -> TcRn () -- | Unconditionally dump some trace output -- -- Certain tests (T3017, Roles3, T12763 etc.) expect part of the output -- generated by `-ddump-types` to be in PprUser style. However, -- generally we want all other debugging output to use PprDump -- style. We PprUser style if useUserStyle is True. dumpTcRn :: Bool -> DumpFlag -> String -> DumpFormat -> SDoc -> TcRn () getPrintUnqualified :: TcRn PrintUnqualified -- | Like logInfoTcRn, but for user consumption printForUserTcRn :: SDoc -> TcRn () traceIf :: SDoc -> TcRnIf m n () traceOptIf :: DumpFlag -> SDoc -> TcRnIf m n () debugTc :: TcM () -> TcM () getIsGHCi :: TcRn Bool getGHCiMonad :: TcRn Name getInteractivePrintName :: TcRn Name tcIsHsBootOrSig :: TcRn Bool tcIsHsig :: TcRn Bool tcSelfBootInfo :: TcRn SelfBootInfo getGlobalRdrEnv :: TcRn GlobalRdrEnv getRdrEnvs :: TcRn (GlobalRdrEnv, LocalRdrEnv) getImports :: TcRn ImportAvails getFixityEnv :: TcRn FixityEnv extendFixityEnv :: [(Name, FixItem)] -> RnM a -> RnM a getRecFieldEnv :: TcRn RecFieldEnv getDeclaredDefaultTys :: TcRn (Maybe [Type]) addDependentFiles :: [FilePath] -> TcRn () getSrcSpanM :: TcRn SrcSpan setSrcSpan :: SrcSpan -> TcRn a -> TcRn a setSrcSpanA :: SrcSpanAnn' ann -> TcRn a -> TcRn a addLocM :: (a -> TcM b) -> Located a -> TcM b addLocMA :: (a -> TcM b) -> GenLocated (SrcSpanAnn' ann) a -> TcM b inGeneratedCode :: TcRn Bool wrapLocM :: (a -> TcM b) -> Located a -> TcM (Located b) wrapLocAM :: (a -> TcM b) -> LocatedAn an a -> TcM (Located b) wrapLocFstM :: (a -> TcM (b, c)) -> Located a -> TcM (Located b, c) wrapLocFstMA :: (a -> TcM (b, c)) -> GenLocated (SrcSpanAnn' ann) a -> TcM (GenLocated (SrcSpanAnn' ann) b, c) wrapLocSndM :: (a -> TcM (b, c)) -> Located a -> TcM (b, Located c) wrapLocSndMA :: (a -> TcM (b, c)) -> GenLocated (SrcSpanAnn' ann) a -> TcM (b, GenLocated (SrcSpanAnn' ann) c) wrapLocM_ :: (a -> TcM ()) -> Located a -> TcM () wrapLocMA_ :: (a -> TcM ()) -> LocatedA a -> TcM () wrapLocMA :: (a -> TcM b) -> GenLocated (SrcSpanAnn' ann) a -> TcRn (GenLocated (SrcSpanAnn' ann) b) getErrsVar :: TcRn (TcRef (Messages TcRnMessage)) setErrsVar :: TcRef (Messages TcRnMessage) -> TcRn a -> TcRn a addErr :: TcRnMessage -> TcRn () failWith :: TcRnMessage -> TcRn a failAt :: SrcSpan -> TcRnMessage -> TcRn a addErrAt :: SrcSpan -> TcRnMessage -> TcRn () addErrs :: [(SrcSpan, TcRnMessage)] -> TcRn () checkErr :: Bool -> TcRnMessage -> TcRn () addMessages :: Messages TcRnMessage -> TcRn () discardWarnings :: TcRn a -> TcRn a -- | tcCollectingUsage thing_inside runs thing_inside and -- returns the usage information which was collected as part of the -- execution of thing_inside. Careful: tcCollectingUsage -- thing_inside itself does not report any usage information, it's -- up to the caller to incorporate the returned usage information into -- the larger context appropriately. tcCollectingUsage :: TcM a -> TcM (UsageEnv, a) -- | tcScalingUsage mult thing_inside runs thing_inside -- and scales all the usage information by mult. tcScalingUsage :: Mult -> TcM a -> TcM a tcEmitBindingUsage :: UsageEnv -> TcM () recoverM :: TcRn r -> TcRn r -> TcRn r -- | Drop elements of the input that fail, so the result list can be -- shorter than the argument list mapAndRecoverM :: (a -> TcRn b) -> [a] -> TcRn [b] -- | Apply the function to all elements on the input list If all succeed, -- return the list of results Otherwise fail, propagating all errors mapAndReportM :: (a -> TcRn b) -> [a] -> TcRn [b] -- | The accumulator is not updated if the action fails foldAndRecoverM :: (b -> a -> TcRn b) -> b -> [a] -> TcRn b attemptM :: TcRn r -> TcRn (Maybe r) tryTc :: TcRn a -> TcRn (Maybe a, Messages TcRnMessage) askNoErrs :: TcRn a -> TcRn (a, Bool) discardErrs :: TcRn a -> TcRn a tryTcDiscardingErrs :: TcM r -> TcM r -> TcM r checkNoErrs :: TcM r -> TcM r whenNoErrs :: TcM () -> TcM () ifErrsM :: TcRn r -> TcRn r -> TcRn r failIfErrsM :: TcRn () getErrCtxt :: TcM [ErrCtxt] setErrCtxt :: [ErrCtxt] -> TcM a -> TcM a -- | Add a fixed message to the error context. This message should not do -- any tidying. addErrCtxt :: SDoc -> TcM a -> TcM a -- | Add a message to the error context. This message may do tidying. addErrCtxtM :: (TidyEnv -> TcM (TidyEnv, SDoc)) -> TcM a -> TcM a -- | Add a fixed landmark message to the error context. A landmark message -- is always sure to be reported, even if there is a lot of context. It -- also doesn't count toward the maximum number of contexts reported. addLandmarkErrCtxt :: SDoc -> TcM a -> TcM a -- | Variant of addLandmarkErrCtxt that allows for monadic -- operations and tidying. addLandmarkErrCtxtM :: (TidyEnv -> TcM (TidyEnv, SDoc)) -> TcM a -> TcM a popErrCtxt :: TcM a -> TcM a getCtLocM :: CtOrigin -> Maybe TypeOrKind -> TcM CtLoc setCtLocM :: CtLoc -> TcM a -> TcM a addErrTc :: TcRnMessage -> TcM () addErrTcM :: (TidyEnv, TcRnMessage) -> TcM () failWithTc :: TcRnMessage -> TcM a failWithTcM :: (TidyEnv, TcRnMessage) -> TcM a checkTc :: Bool -> TcRnMessage -> TcM () checkTcM :: Bool -> (TidyEnv, TcRnMessage) -> TcM () failIfTc :: Bool -> TcRnMessage -> TcM () failIfTcM :: Bool -> (TidyEnv, TcRnMessage) -> TcM () mkErrInfo :: TidyEnv -> [ErrCtxt] -> TcM SDoc addTcRnDiagnostic :: TcRnMessage -> TcM () -- | A variation of addDiagnostic that takes a function to produce a -- TcRnDsMessage given some additional context about the -- diagnostic. addDetailedDiagnostic :: (ErrInfo -> TcRnMessage) -> TcM () mkTcRnMessage :: SrcSpan -> TcRnMessage -> TcRn (MsgEnvelope TcRnMessage) reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn () reportDiagnostics :: [MsgEnvelope TcRnMessage] -> TcM () -- | Display a warning if a condition is met. warnIf :: Bool -> TcRnMessage -> TcRn () -- | Display a warning if a condition is met. diagnosticTc :: Bool -> TcRnMessage -> TcM () -- | Display a diagnostic if a condition is met. diagnosticTcM :: Bool -> (TidyEnv, TcRnMessage) -> TcM () -- | Display a diagnostic in the current context. addDiagnosticTc :: TcRnMessage -> TcM () -- | Display a diagnostic in a given context. addDiagnosticTcM :: (TidyEnv, TcRnMessage) -> TcM () -- | Display a diagnostic for the current source location, taken from the -- TcRn monad. addDiagnostic :: TcRnMessage -> TcRn () -- | Display a diagnostic for a given source location. addDiagnosticAt :: SrcSpan -> TcRnMessage -> TcRn () newTcEvBinds :: TcM EvBindsVar -- | Creates an EvBindsVar incapable of holding any bindings. It still -- tracks covar usages (see comments on ebv_tcvs in -- GHC.Tc.Types.Evidence), thus must be made monadically newNoTcEvBinds :: TcM EvBindsVar cloneEvBindsVar :: EvBindsVar -> TcM EvBindsVar addTcEvBind :: EvBindsVar -> EvBind -> TcM () addTopEvBinds :: Bag EvBind -> TcM a -> TcM a getTcEvTyCoVars :: EvBindsVar -> TcM TyCoVarSet getTcEvBindsMap :: EvBindsVar -> TcM EvBindMap setTcEvBindsMap :: EvBindsVar -> EvBindMap -> TcM () chooseUniqueOccTc :: (OccSet -> OccName) -> TcM OccName getConstraintVar :: TcM (TcRef WantedConstraints) setConstraintVar :: TcRef WantedConstraints -> TcM a -> TcM a emitConstraints :: WantedConstraints -> TcM () emitStaticConstraints :: WantedConstraints -> TcM () emitSimple :: Ct -> TcM () emitSimples :: Cts -> TcM () emitImplication :: Implication -> TcM () emitImplications :: Bag Implication -> TcM () emitInsoluble :: Ct -> TcM () emitHole :: Hole -> TcM () emitHoles :: Bag Hole -> TcM () -- | Throw out any constraints emitted by the thing_inside discardConstraints :: TcM a -> TcM a captureConstraints :: TcM a -> TcM (a, WantedConstraints) tryCaptureConstraints :: TcM a -> TcM (Maybe a, WantedConstraints) -- | The name says it all. The returned TcLevel is the *inner* TcLevel. pushLevelAndCaptureConstraints :: TcM a -> TcM (TcLevel, WantedConstraints, a) pushTcLevelM_ :: TcM a -> TcM a pushTcLevelM :: TcM a -> TcM (TcLevel, a) getTcLevel :: TcM TcLevel setTcLevel :: TcLevel -> TcM a -> TcM a isTouchableTcM :: TcTyVar -> TcM Bool getLclTypeEnv :: TcM TcTypeEnv setLclTypeEnv :: TcLclEnv -> TcM a -> TcM a traceTcConstraints :: String -> TcM () emitNamedTypeHole :: (Name, TcTyVar) -> TcM () data IsExtraConstraint YesExtraConstraint :: IsExtraConstraint NoExtraConstraint :: IsExtraConstraint emitAnonTypeHole :: IsExtraConstraint -> TcTyVar -> TcM () recordThUse :: TcM () recordThSpliceUse :: TcM () recordThNeededRuntimeDeps :: [Linkable] -> PkgsLoaded -> TcM () keepAlive :: Name -> TcRn () getStage :: TcM ThStage getStageAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, ThLevel, ThStage)) setStage :: ThStage -> TcM a -> TcRn a -- | Adds the given modFinalizers to the global environment and set them to -- use the current local environment. addModFinalizersWithLclEnv :: ThModFinalizers -> TcM () -- | Mark that safe inference has failed See Note [Safe Haskell Overlapping -- Instances Implementation] although this is used for more than just -- that failure case. recordUnsafeInfer :: Messages TcRnMessage -> TcM () -- | Figure out the final correct safe haskell mode finalSafeMode :: DynFlags -> TcGblEnv -> IO SafeHaskellMode -- | Switch instances to safe instances if we're in Safe mode. fixSafeInstances :: SafeHaskellMode -> [ClsInst] -> [ClsInst] getLocalRdrEnv :: RnM LocalRdrEnv setLocalRdrEnv :: LocalRdrEnv -> RnM a -> RnM a mkIfLclEnv :: Module -> SDoc -> IsBootInterface -> IfLclEnv -- | Run an IfG (top-level interface monad) computation inside an -- existing TcRn (typecheck-renaming monad) computation by -- initializing an IfGblEnv based on TcGblEnv. initIfaceTcRn :: IfG a -> TcRn a initIfaceCheck :: SDoc -> HscEnv -> IfG a -> IO a initIfaceLcl :: Module -> SDoc -> IsBootInterface -> IfL a -> IfM lcl a -- | Initialize interface typechecking, but with a NameShape to -- apply when typechecking top-level OccNames (see -- lookupIfaceTop) initIfaceLclWithSubst :: Module -> SDoc -> IsBootInterface -> NameShape -> IfL a -> IfM lcl a -- | initIfaceLoad can be used when there's no chance that the -- action will call typecheckIface when inside a module loop and -- hence tcIfaceGlobal. initIfaceLoad :: HscEnv -> IfG a -> IO a -- | This is used when we are doing to call typecheckModule on an -- ModIface, if it's part of a loop with some other modules then -- we need to use their IORef TypeEnv vars when typechecking but -- crucially not our own. initIfaceLoadModule :: HscEnv -> Module -> IfG a -> IO a getIfModule :: IfL Module failIfM :: SDoc -> IfL a -- | Run thing_inside in an interleaved thread. It shares everything with -- the parent thread, so this is DANGEROUS. -- -- It throws an error if the computation fails -- -- It's used for lazily type-checking interface signatures, which is -- pretty benign. -- -- See Note [Masking exceptions in forkM] forkM :: SDoc -> IfL a -> IfL a setImplicitEnvM :: TypeEnv -> IfL a -> IfL a -- | A convenient wrapper for taking a MaybeErr SDoc a and -- throwing an exception if it is an error. withException :: MonadIO m => SDocContext -> m (MaybeErr SDoc a) -> m a -- | Get the next cost centre index associated with a given name. getCCIndexM :: (gbl -> TcRef CostCentreState) -> FastString -> TcRnIf gbl lcl CostCentreIndex -- | See getCCIndexM. getCCIndexTcM :: FastString -> TcM CostCentreIndex instance GHC.Utils.Outputable.Outputable GHC.Tc.Utils.Monad.IsExtraConstraint instance GHC.Types.Unique.Supply.MonadUnique (GHC.Data.IOEnv.IOEnv (GHC.Tc.Types.Env gbl lcl)) -- | Typechecking annotations module GHC.Tc.Gen.Annotation tcAnnotations :: [LAnnDecl GhcRn] -> TcM [Annotation] annCtxt :: OutputableBndrId p => AnnDecl (GhcPass p) -> SDoc module GHC.Rename.Unbound mkUnboundName :: OccName -> Name mkUnboundNameRdr :: RdrName -> Name isUnboundName :: Name -> Bool reportUnboundName :: RdrName -> RnM Name reportUnboundName' :: WhatLooking -> RdrName -> RnM Name -- | Called from the typechecker (GHC.Tc.Errors) when we find an -- unbound variable unknownNameSuggestions :: WhatLooking -> DynFlags -> HomePackageTable -> Module -> GlobalRdrEnv -> LocalRdrEnv -> ImportAvails -> RdrName -> ([ImportError], [GhcHint]) data WhatLooking WL_Anything :: WhatLooking WL_Constructor :: WhatLooking WL_RecField :: WhatLooking WL_None :: WhatLooking data WhereLooking WL_Anywhere :: WhereLooking WL_Global :: WhereLooking WL_LocalTop :: WhereLooking WL_LocalOnly :: WhereLooking data LookingFor LF :: WhatLooking -> WhereLooking -> LookingFor [lf_which] :: LookingFor -> WhatLooking [lf_where] :: LookingFor -> WhereLooking unboundName :: LookingFor -> RdrName -> RnM Name unboundNameX :: LookingFor -> RdrName -> [GhcHint] -> RnM Name notInScopeErr :: WhereLooking -> RdrName -> NotInScopeError nameSpacesRelated :: DynFlags -> WhatLooking -> NameSpace -> NameSpace -> Bool instance GHC.Classes.Eq GHC.Rename.Unbound.WhatLooking module GHC.Iface.Env newGlobalBinder :: Module -> OccName -> SrcSpan -> TcRnIf a b Name newInteractiveBinder :: HscEnv -> OccName -> SrcSpan -> IO Name externaliseName :: Module -> Name -> TcRnIf m n Name -- | Look up a top-level name from the current Iface module lookupIfaceTop :: OccName -> IfL Name -- | Look up the Name for a given Module and OccName. -- Consider alternatively using lookupIfaceTop if you're in the -- IfL monad and Module is simply that of the -- ModIface you are typechecking. lookupOrig :: Module -> OccName -> TcRnIf a b Name lookupOrigIO :: HscEnv -> Module -> OccName -> IO Name lookupOrigNameCache :: OrigNameCache -> Module -> OccName -> Maybe Name newIfaceName :: OccName -> IfL Name newIfaceNames :: [OccName] -> IfL [Name] extendIfaceIdEnv :: [Id] -> IfL a -> IfL a extendIfaceTyVarEnv :: [TyVar] -> IfL a -> IfL a tcIfaceLclId :: FastString -> IfL Id tcIfaceTyVar :: FastString -> IfL TyVar lookupIfaceVar :: IfaceBndr -> IfL (Maybe TyCoVar) lookupIfaceTyVar :: IfaceTvBndr -> IfL (Maybe TyVar) extendIfaceEnvs :: [TyCoVar] -> IfL a -> IfL a -- | Set the Module of a Name. setNameModule :: Maybe Module -> Name -> TcRnIf m n Name ifaceExportNames :: [IfaceExport] -> TcRnIf gbl lcl [AvailInfo] trace_if :: Logger -> SDoc -> IO () trace_hi_diffs :: Logger -> SDoc -> IO () allocateGlobalBinder :: NameCache -> Module -> OccName -> SrcSpan -> IO Name module GHC.Tc.TyCl.Build buildDataCon :: FamInstEnvs -> DataConBangOpts -> Name -> Bool -> TyConRepName -> [HsSrcBang] -> [FieldLabel] -> [TyVar] -> [TyCoVar] -> [InvisTVBinder] -> [EqSpec] -> KnotTied ThetaType -> [KnotTied (Scaled Type)] -> KnotTied Type -> KnotTied TyCon -> NameEnv ConTag -> TcRnIf m n DataCon buildPatSyn :: Name -> Bool -> PatSynMatcher -> PatSynBuilder -> ([InvisTVBinder], ThetaType) -> ([InvisTVBinder], ThetaType) -> [Type] -> Type -> [FieldLabel] -> PatSyn type TcMethInfo = MethInfo type MethInfo = (Name, Type, Maybe (DefMethSpec (SrcSpan, Type))) buildClass :: Name -> [TyConBinder] -> [Role] -> [FunDep TyVar] -> Maybe (KnotTied ThetaType, [ClassATItem], [KnotTied MethInfo], ClassMinimalDef) -> TcRnIf m n Class -- | Monadic because it makes a Name for the coercion TyCon We pass the -- Name of the parent TyCon, as well as the TyCon itself, because the -- latter is part of a knot, whereas the former is not. mkNewTyConRhs :: Name -> TyCon -> DataCon -> TcRnIf m n AlgTyConRhs newImplicitBinder :: Name -> (OccName -> OccName) -> TcRnIf m n Name -- | Make the TyConRepName for this TyCon newTyConRepName :: Name -> TcRnIf gbl lcl TyConRepName -- | Binary interface file support. module GHC.Iface.Binary -- | Write an interface file writeBinIface :: Profile -> TraceBinIFace -> FilePath -> ModIface -> IO () -- | Read an interface file. readBinIface :: Profile -> NameCache -> CheckHiWay -> TraceBinIFace -> FilePath -> IO ModIface -- | Read an interface file header, checking the magic number, version, and -- way. Returns the hash of the source file and a BinHandle which points -- at the start of the rest of the interface file data. readBinIfaceHeader :: Profile -> NameCache -> CheckHiWay -> TraceBinIFace -> FilePath -> IO (Fingerprint, BinHandle) getSymtabName :: NameCache -> Dictionary -> SymbolTable -> BinHandle -> IO Name getDictFastString :: Dictionary -> BinHandle -> IO FastString data CheckHiWay CheckHiWay :: CheckHiWay IgnoreHiWay :: CheckHiWay data TraceBinIFace TraceBinIFace :: (SDoc -> IO ()) -> TraceBinIFace QuietBinIFace :: TraceBinIFace -- | This performs a get action after reading the dictionary and symbol -- table. It is necessary to run this before trying to deserialise any -- Names or FastStrings. getWithUserData :: Binary a => NameCache -> BinHandle -> IO a -- | Put a piece of data with an initialised UserData field. This is -- necessary if you want to serialise Names or FastStrings. It also -- writes a symbol table and the dictionary. This segment should be read -- using getWithUserData. putWithUserData :: Binary a => TraceBinIFace -> BinHandle -> a -> IO () getSymbolTable :: BinHandle -> NameCache -> IO SymbolTable putName :: BinDictionary -> BinSymbolTable -> BinHandle -> Name -> IO () putDictionary :: BinHandle -> Int -> UniqFM FastString (Int, FastString) -> IO () putFastString :: BinDictionary -> BinHandle -> FastString -> IO () putSymbolTable :: BinHandle -> Int -> UniqFM Name (Int, Name) -> IO () data BinSymbolTable BinSymbolTable :: !FastMutInt -> !IORef (UniqFM Name (Int, Name)) -> BinSymbolTable [bin_symtab_next] :: BinSymbolTable -> !FastMutInt [bin_symtab_map] :: BinSymbolTable -> !IORef (UniqFM Name (Int, Name)) data BinDictionary BinDictionary :: !FastMutInt -> !IORef (UniqFM FastString (Int, FastString)) -> BinDictionary [bin_dict_next] :: BinDictionary -> !FastMutInt [bin_dict_map] :: BinDictionary -> !IORef (UniqFM FastString (Int, FastString)) instance GHC.Classes.Eq GHC.Iface.Binary.CheckHiWay module GHC.Iface.Ext.Binary -- | Read a HieFile from a FilePath. Can use an existing -- NameCache. readHieFile :: NameCache -> FilePath -> IO HieFileResult -- | Read a HieFile from a FilePath. Can use an existing -- NameCache. Allows you to specify which versions of hieFile to -- attempt to read. Left case returns the failing header versions. readHieFileWithVersion :: (HieHeader -> Bool) -> NameCache -> FilePath -> IO (Either HieHeader HieFileResult) type HieHeader = (Integer, ByteString) -- | Write a HieFile to the given FilePath, with a proper -- header and symbol tables for Names and FastStrings writeHieFile :: FilePath -> HieFile -> IO () -- | Name's get converted into HieName's before being written -- into .hie files. See toHieName and -- fromHieName for logic on how to convert between these two -- types. data HieName ExternalName :: !Module -> !OccName -> !SrcSpan -> HieName LocalName :: !OccName -> !SrcSpan -> HieName KnownKeyName :: !Unique -> HieName toHieName :: Name -> HieName data HieFileResult HieFileResult :: Integer -> ByteString -> HieFile -> HieFileResult [hie_file_result_version] :: HieFileResult -> Integer [hie_file_result_ghc_version] :: HieFileResult -> ByteString [hie_file_result] :: HieFileResult -> HieFile -- | The header for HIE files - Capital ASCII letters "HIE". hieMagic :: [Word8] hieNameOcc :: HieName -> OccName -- | Monadic type operations -- -- This module contains monadic operations over types that contain -- mutable type variables. module GHC.Tc.Utils.TcMType -- | Type variable that might be a metavariable type TcTyVar = Var type TcKind = Kind type TcType = Type type TcTauType = TcType type TcThetaType = ThetaType type TcTyVarSet = TyVarSet newFlexiTyVar :: Kind -> TcM TcTyVar -- | Create a new flexi ty var with a specific name newNamedFlexiTyVar :: FastString -> Kind -> TcM TcTyVar newFlexiTyVarTy :: Kind -> TcM TcType newFlexiTyVarTys :: Int -> Kind -> TcM [TcType] newOpenFlexiTyVar :: TcM TcTyVar -- | Create a tyvar that can be a lifted or unlifted type. Returns alpha :: -- TYPE kappa, where both alpha and kappa are fresh newOpenFlexiTyVarTy :: TcM TcType newOpenTypeKind :: TcM TcKind newOpenBoxedTypeKind :: TcM TcKind newMetaKindVar :: TcM TcKind newMetaKindVars :: Int -> TcM [TcKind] newMetaTyVarTyAtLevel :: TcLevel -> TcKind -> TcM TcType newAnonMetaTyVar :: MetaInfo -> Kind -> TcM TcTyVar cloneMetaTyVar :: TcTyVar -> TcM TcTyVar newCycleBreakerTyVar :: TcKind -> TcM TcTyVar newMultiplicityVar :: TcM TcType readMetaTyVar :: TyVar -> TcM MetaDetails writeMetaTyVar :: TcTyVar -> TcType -> TcM () writeMetaTyVarRef :: TcTyVar -> TcRef MetaDetails -> TcType -> TcM () newTauTvDetailsAtLevel :: TcLevel -> TcM TcTyVarDetails newMetaDetails :: MetaInfo -> TcM TcTyVarDetails newMetaTyVarName :: FastString -> TcM Name isFilledMetaTyVar_maybe :: TcTyVar -> TcM (Maybe Type) isFilledMetaTyVar :: TyVar -> TcM Bool isUnfilledMetaTyVar :: TyVar -> TcM Bool newEvVar :: TcPredType -> TcRnIf gbl lcl EvVar newEvVars :: TcThetaType -> TcM [EvVar] newDict :: Class -> [TcType] -> TcM DictId -- | Create a new Wanted constraint with the given CtLoc. newWantedWithLoc :: CtLoc -> PredType -> TcM CtEvidence -- | Create a new Wanted constraint with the given CtOrigin, and -- location information taken from the TcM environment. newWanted :: CtOrigin -> Maybe TypeOrKind -> PredType -> TcM CtEvidence -- | Create new Wanted constraints with the given CtOrigin, and -- location information taken from the TcM environment. newWanteds :: CtOrigin -> ThetaType -> TcM [CtEvidence] cloneWanted :: Ct -> TcM Ct cloneWC :: WantedConstraints -> TcM WantedConstraints cloneWantedCtEv :: CtEvidence -> TcM CtEvidence -- | Emits a new Wanted. Deals with both equalities and non-equalities. emitWanted :: CtOrigin -> TcPredType -> TcM EvTerm -- | Emits a new equality constraint emitWantedEq :: CtOrigin -> TypeOrKind -> Role -> TcType -> TcType -> TcM Coercion -- | Creates a new EvVar and immediately emits it as a Wanted. No equality -- predicates here. emitWantedEvVar :: CtOrigin -> TcPredType -> TcM EvVar emitWantedEvVars :: CtOrigin -> [TcPredType] -> TcM [EvVar] emitWantedEqs :: CtOrigin -> [(TcType, TcType)] -> TcM () newTcEvBinds :: TcM EvBindsVar -- | Creates an EvBindsVar incapable of holding any bindings. It still -- tracks covar usages (see comments on ebv_tcvs in -- GHC.Tc.Types.Evidence), thus must be made monadically newNoTcEvBinds :: TcM EvBindsVar addTcEvBind :: EvBindsVar -> EvBind -> TcM () -- | Emit a new wanted expression hole emitNewExprHole :: OccName -> Type -> TcM HoleExprRef newCoercionHole :: TcPredType -> TcM CoercionHole -- | Put a value in a coercion hole fillCoercionHole :: CoercionHole -> Coercion -> TcM () -- | Is a coercion hole filled in? isFilledCoercionHole :: CoercionHole -> TcM Bool -- | Retrieve the contents of a coercion hole. Panics if the hole is -- unfilled unpackCoercionHole :: CoercionHole -> TcM Coercion -- | Retrieve the contents of a coercion hole, if it is filled unpackCoercionHole_maybe :: CoercionHole -> TcM (Maybe Coercion) -- | Check that a coercion is appropriate for filling a hole. (The hole -- itself is needed only for printing.) Always returns the checked -- coercion, but this return value is necessary so that the input -- coercion is forced only when the output is forced. checkCoercionHole :: CoVar -> Coercion -> TcM Coercion -- | A coercion hole used to store evidence for `Concrete#` constraints. -- -- See Note [The Concrete mechanism]. type ConcreteHole = CoercionHole -- | Create a new (initially unfilled) coercion hole, to hold evidence for -- a 'Concrete#' (ty :: ki) constraint. newConcreteHole :: Kind -> Type -> TcM (ConcreteHole, TcType) -- | Create a new Implication with as many sensible defaults for its -- fields as possible. Note that the ic_tclvl, ic_binds, -- and ic_info fields do not have sensible defaults, so -- they are initialized with lazy thunks that will panic if -- forced, so one should take care to initialize these fields after -- creation. -- -- This is monadic to look up the TcLclEnv, which is used to -- initialize ic_env, and to set the -Winaccessible-code flag. See -- Note [Avoid -Winaccessible-code when deriving] in -- GHC.Tc.TyCl.Instance. newImplication :: TcM Implication newMetaTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) newMetaTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) newMetaTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) newMetaTyVarTyVarX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) newTyVarTyVar :: Name -> Kind -> TcM TcTyVar cloneTyVarTyVar :: Name -> Kind -> TcM TcTyVar newPatSigTyVar :: Name -> Kind -> TcM TcTyVar newSkolemTyVar :: SkolemInfo -> Name -> Kind -> TcM TcTyVar newWildCardX :: TCvSubst -> TyVar -> TcM (TCvSubst, TcTyVar) -- | An expected type to check against during type-checking. See Note -- [ExpType] in GHC.Tc.Utils.TcMType, where you'll also find -- manipulators. data ExpType Check :: TcType -> ExpType Infer :: !InferResult -> ExpType type ExpSigmaType = ExpType type ExpRhoType = ExpType -- | Make an ExpType suitable for checking. mkCheckExpType :: TcType -> ExpType newInferExpType :: TcM ExpType -- | Infer a type using a fresh ExpType See also Note [ExpType] in -- GHC.Tc.Utils.TcMType tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) -- | Extract a type out of an ExpType. Otherwise, panics. readExpType :: ExpType -> TcM TcType -- | Extract a type out of an ExpType, if one exists. But one should always -- exist. Unless you're quite sure you know what you're doing. readExpType_maybe :: ExpType -> TcM (Maybe TcType) -- | Same as readExpType, but for Scaled ExpTypes readScaledExpType :: Scaled ExpType -> TcM (Scaled Type) -- | Extracts the expected type if there is one, or generates a new TauTv -- if there isn't. expTypeToType :: ExpType -> TcM TcType scaledExpTypeToType :: Scaled ExpType -> TcM (Scaled TcType) -- | Returns the expected type when in checking mode. checkingExpType_maybe :: ExpType -> Maybe TcType -- | Returns the expected type when in checking mode. Panics if in -- inference mode. checkingExpType :: String -> ExpType -> TcType inferResultToType :: InferResult -> TcM Type fillInferResult :: TcType -> InferResult -> TcM TcCoercionN promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType) zonkTidyTcType :: TidyEnv -> TcType -> TcM (TidyEnv, TcType) zonkTidyTcTypes :: TidyEnv -> [TcType] -> TcM (TidyEnv, [TcType]) zonkTidyOrigin :: TidyEnv -> CtOrigin -> TcM (TidyEnv, CtOrigin) zonkTidyOrigins :: TidyEnv -> [CtOrigin] -> TcM (TidyEnv, [CtOrigin]) tidyEvVar :: TidyEnv -> EvVar -> EvVar tidyCt :: TidyEnv -> Ct -> Ct tidyHole :: TidyEnv -> Hole -> Hole zonkTcTyVar :: TcTyVar -> TcM TcType zonkTcTyVars :: [TcTyVar] -> TcM [TcType] zonkTcTyVarToTcTyVar :: HasDebugCallStack => TcTyVar -> TcM TcTyVar zonkTcTyVarsToTcTyVars :: HasDebugCallStack => [TcTyVar] -> TcM [TcTyVar] zonkInvisTVBinder :: VarBndr TcTyVar spec -> TcM (VarBndr TcTyVar spec) zonkTyCoVarsAndFV :: TyCoVarSet -> TcM TyCoVarSet zonkTcTypeAndFV :: TcType -> TcM DTyCoVarSet zonkDTyCoVarSetAndFV :: DTyCoVarSet -> TcM DTyCoVarSet zonkTyCoVarsAndFVList :: [TyCoVar] -> TcM [TyCoVar] zonkTcType :: TcType -> TcM TcType zonkTcTypes :: [TcType] -> TcM [TcType] zonkCo :: Coercion -> TcM Coercion zonkTyCoVarKind :: TyCoVar -> TcM TyCoVar zonkEvVar :: EvVar -> TcM EvVar zonkWC :: WantedConstraints -> TcM WantedConstraints zonkImplication :: Implication -> TcM Implication zonkSimples :: Cts -> TcM Cts zonkId :: TcId -> TcM TcId zonkCoVar :: CoVar -> TcM CoVar zonkCt :: Ct -> TcM Ct zonkSkolemInfo :: SkolemInfo -> TcM SkolemInfo zonkSkolemInfoAnon :: SkolemInfoAnon -> TcM SkolemInfoAnon -- | Default a type variable using the given defaulting strategy. -- -- See Note [Type variable defaulting options] in GHC.Types.Basic. defaultTyVar :: DefaultingStrategy -> TcTyVar -> TcM Bool promoteMetaTyVarTo :: TcLevel -> TcTyVar -> TcM Bool promoteTyVarSet :: TcTyVarSet -> TcM Bool quantifyTyVars :: SkolemInfo -> NonStandardDefaultingStrategy -> CandidatesQTvs -> TcM [TcTyVar] isQuantifiableTv :: TcLevel -> TcTyVar -> Bool zonkAndSkolemise :: SkolemInfo -> TcTyCoVar -> TcM TcTyCoVar skolemiseQuantifiedTyVar :: SkolemInfo -> TcTyVar -> TcM TcTyVar doNotQuantifyTyVars :: CandidatesQTvs -> (TidyEnv -> TcM (TidyEnv, SDoc)) -> TcM () -- | Gathers free variables to use as quantification candidates (in -- quantifyTyVars). This might output the same var in both sets, -- if it's used in both a type and a kind. The variables to quantify must -- have a TcLevel strictly greater than the ambient level. (See Wrinkle -- in Note [Naughty quantification candidates]) See Note [CandidatesQTvs -- determinism and order] See Note [Dependent type variables] candidateQTyVarsOfType :: TcType -> TcM CandidatesQTvs -- | Like candidateQTyVarsOfType, but consider every free variable -- to be dependent. This is appropriate when generalizing a *kind*, -- instead of a type. (That way, -XNoPolyKinds will default the variables -- to Type.) candidateQTyVarsOfKind :: TcKind -> TcM CandidatesQTvs -- | Like candidateQTyVarsOfType, but over a list of types The -- variables to quantify must have a TcLevel strictly greater than the -- ambient level. (See Wrinkle in Note [Naughty quantification -- candidates]) candidateQTyVarsOfTypes :: [Type] -> TcM CandidatesQTvs candidateQTyVarsOfKinds :: [TcKind] -> TcM CandidatesQTvs candidateQTyVarsWithBinders :: [TyVar] -> Type -> TcM CandidatesQTvs data CandidatesQTvs DV :: DTyVarSet -> DTyVarSet -> CoVarSet -> CandidatesQTvs [dv_kvs] :: CandidatesQTvs -> DTyVarSet [dv_tvs] :: CandidatesQTvs -> DTyVarSet [dv_cvs] :: CandidatesQTvs -> CoVarSet delCandidates :: CandidatesQTvs -> [Var] -> CandidatesQTvs candidateKindVars :: CandidatesQTvs -> TyVarSet partitionCandidates :: CandidatesQTvs -> (TyVar -> Bool) -> (TyVarSet, CandidatesQTvs) -- | Check that the specified type has a fixed runtime representation. -- -- If it isn't, throw a representation-polymorphism error appropriate for -- the context (as specified by the FixedRuntimeRepProvenance). -- -- Unlike the other representation polymorphism checks, which can emit -- new Wanted constraints to be solved by the constraint solver, this -- function does not emit any constraints: it has enough information to -- immediately make a decision. -- -- See (1) in Note [Representation polymorphism checking] in -- GHC.Tc.Utils.Concrete checkTypeHasFixedRuntimeRep :: FixedRuntimeRepProvenance -> Type -> TcM () -- | Check whether any coercion hole in a RewriterSet is still unsolved. -- Does this by recursively looking through filled coercion holes until -- one is found that is not yet filled in, at which point this aborts. anyUnfilledCoercionHoles :: RewriterSet -> TcM Bool instance GHC.Base.Semigroup GHC.Tc.Utils.TcMType.UnfilledCoercionHoleMonoid instance GHC.Base.Monoid GHC.Tc.Utils.TcMType.UnfilledCoercionHoleMonoid instance GHC.Base.Semigroup GHC.Tc.Utils.TcMType.CandidatesQTvs instance GHC.Base.Monoid GHC.Tc.Utils.TcMType.CandidatesQTvs instance GHC.Utils.Outputable.Outputable GHC.Tc.Utils.TcMType.CandidatesQTvs -- | Checking for representation-polymorphism using the Concrete mechanism. -- -- This module contains the logic for enforcing the -- representation-polymorphism invariants by way of emitting constraints. module GHC.Tc.Utils.Concrete -- | Given a type ty :: ki, this function ensures that ty -- has a fixed RuntimeRep, by emitting a new equality -- constraint ki ~ concrete_tv for a concrete metavariable -- concrete_tv. -- -- Returns a coercion co :: ki ~# concrete_tv as evidence. If -- ty obviously has a fixed RuntimeRep, e.g ki = -- IntRep, then this function immediately returns Nothing -- instead of emitting a new constraint. hasFixedRuntimeRep :: FRROrigin -> TcType -> TcM (Maybe (TcType, TcCoercion, TcTyVar)) -- | Like hasFixedRuntimeRep, but we insist that the obtained -- coercion must be Refl. -- -- This is useful if we are not actually going to use the coercion -- returned from hasFixedRuntimeRep; it would generally be unsound -- to allow a non-reflexive coercion but not actually make use of it in a -- cast. See Note [IsRefl#]. -- -- The goal is to eliminate all uses of this function and replace them -- with hasFixedRuntimeRep, making use of the returned coercion. hasFixedRuntimeRep_MustBeRefl :: FRROrigin -> TcType -> TcM () module GHC.ThToHs convertToHsExpr :: Origin -> SrcSpan -> Exp -> Either SDoc (LHsExpr GhcPs) convertToPat :: Origin -> SrcSpan -> Pat -> Either SDoc (LPat GhcPs) convertToHsDecls :: Origin -> SrcSpan -> [Dec] -> Either SDoc [LHsDecl GhcPs] convertToHsType :: Origin -> SrcSpan -> Type -> Either SDoc (LHsType GhcPs) thRdrNameGuesses :: Name -> [RdrName] instance GHC.Base.Functor GHC.ThToHs.CvtM instance GHC.ThToHs.CvtFlag () () instance GHC.ThToHs.CvtFlag Language.Haskell.TH.Syntax.Specificity GHC.Types.Var.Specificity instance GHC.Base.Applicative GHC.ThToHs.CvtM instance GHC.Base.Monad GHC.ThToHs.CvtM module GHC.Types.Name.Shape -- | A NameShape is a substitution on Names that can be used -- to refine the identities of a hole while we are renaming interfaces -- (see GHC.Iface.Rename). Specifically, a NameShape for -- ns_module_name A, defines a mapping from -- {A.T} (for some OccName T) to some arbitrary -- other Name. -- -- The most intruiging thing about a NameShape, however, is how -- it's constructed. A NameShape is *implied* by the exported -- AvailInfos of the implementor of an interface: if an -- implementor of signature <H> exports M.T, you -- implicitly define a substitution from {H.T} to M.T. -- So a NameShape is computed from the list of AvailInfos -- that are exported by the implementation of a module, or successively -- merged together by the export lists of signatures which are joining -- together. -- -- It's not the most obvious way to go about doing this, but it does seem -- to work! -- -- NB: Can't boot this and put it in NameShape because then we start -- pulling in too many DynFlags things. data NameShape NameShape :: ModuleName -> [AvailInfo] -> OccEnv Name -> NameShape [ns_mod_name] :: NameShape -> ModuleName [ns_exports] :: NameShape -> [AvailInfo] [ns_map] :: NameShape -> OccEnv Name -- | Create an empty NameShape (i.e., the renaming that would occur -- with an implementing module with no exports) for a specific hole -- mod_name. emptyNameShape :: ModuleName -> NameShape -- | Create a NameShape corresponding to an implementing module for -- the hole mod_name that exports a list of AvailInfos. mkNameShape :: ModuleName -> [AvailInfo] -> NameShape -- | Given an existing NameShape, merge it with a list of -- AvailInfos with Backpack style mix-in linking. This is used -- solely when merging signatures together: we successively merge the -- exports of each signature until we have the final, full exports of the -- merged signature. -- -- What makes this operation nontrivial is what we are supposed to do -- when we want to merge in an export for M.T when we already have an -- existing export {H.T}. What should happen in this case is that {H.T} -- should be unified with M.T: we've determined a more *precise* -- identity for the export at OccName T. -- -- Note that we don't do unrestricted unification: only name holes from -- ns_mod_name ns are flexible. This is because we have a much -- more restricted notion of shaping than in Backpack'14: we do shaping -- *as* we do type-checking. Thus, once we shape a signature, its exports -- are *final* and we're not allowed to refine them further, extendNameShape :: HscEnv -> NameShape -> [AvailInfo] -> IO (Either SDoc NameShape) -- | The export list associated with this NameShape (i.e., what the -- exports of an implementing module which induces this NameShape -- would be.) nameShapeExports :: NameShape -> [AvailInfo] -- | Given a Name, substitute it according to the NameShape -- implied substitution, i.e. map {A.T} to M.T, if the -- implementing module exports M.T. substNameShape :: NameShape -> Name -> Name -- | Like substNameShape, but returns Nothing if no -- substitution works. maybeSubstNameShape :: NameShape -> Name -> Maybe Name -- | This module implements interface renaming, which is used to rewrite -- interface files on the fly when we are doing indefinite typechecking -- and need instantiations of modules which do not necessarily exist yet. module GHC.Iface.Rename -- | What we have is a generalized ModIface, which corresponds to a module -- that looks like p[A=<A>]:B. We need a *specific* ModIface, e.g. -- p[A=q():A]:B (or maybe even p[A=<B>]:B) which we load up (either -- to merge it, or to just use during typechecking). -- -- Suppose we have: -- -- p[A=<A>]:M ==> p[A=q():A]:M -- -- Substitute all occurrences of <A> with q():A (renameHoleModule). -- Then, for any Name of form {A.T}, replace the Name with the Name -- according to the exports of the implementing module. This works even -- for p[A=<B>]:M, since we just read in the exports of B.hi, which -- is assumed to be ready now. -- -- This function takes an optional NameShape, which can be used to -- further refine the identities in this interface: suppose we read a -- declaration for {H.T} but we actually know that this should be Foo.T; -- then we'll also rename this (this is used when loading an interface to -- merge it into a requirement.) rnModIface :: HscEnv -> [(ModuleName, Module)] -> Maybe NameShape -> ModIface -> IO (Either (Messages TcRnMessage) ModIface) -- | Rename just the exports of a ModIface. Useful when we're doing -- shaping prior to signature merging. rnModExports :: HscEnv -> [(ModuleName, Module)] -> ModIface -> IO (Either (Messages TcRnMessage) [AvailInfo]) tcRnModIface :: [(ModuleName, Module)] -> Maybe NameShape -> ModIface -> TcM ModIface tcRnModExports :: [(ModuleName, Module)] -> ModIface -> TcM [AvailInfo] module GHC.Types.Unique.MemoFun memoiseUniqueFun :: Uniquable k => (k -> a) -> k -> a module GHC.Core.Opt.DmdAnal -- | Options for the demand analysis data DmdAnalOpts DmdAnalOpts :: !Bool -> !Int -> !Int -> DmdAnalOpts -- | Use strict dictionaries [dmd_strict_dicts] :: DmdAnalOpts -> !Bool -- | Use strict dictionaries [dmd_unbox_width] :: DmdAnalOpts -> !Int [dmd_max_worker_args] :: DmdAnalOpts -> !Int -- | Outputs a new copy of the Core program in which binders have been -- annotated with demand and strictness information. -- -- Note: use seqBinds on the result to avoid leaks due to -- lazyness (cf Note [Stamp out space leaks in demand analysis]) dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> [CoreRule] -> CoreProgram -> CoreProgram instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.DmdAnal.AnalEnv -- | Constructed Product Result analysis. Identifies functions that surely -- return heap-allocated records on every code path, so that we can -- eliminate said heap allocation by performing a worker/wrapper split. -- -- See -- https://www.microsoft.com/en-us/research/publication/constructed-product-result-analysis-haskell/. -- CPR analysis should happen after strictness analysis. See Note [Phase -- ordering]. module GHC.Core.Opt.CprAnal cprAnalProgram :: Logger -> FamInstEnvs -> CoreProgram -> IO CoreProgram instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.CprAnal.AnalEnv instance GHC.Utils.Outputable.Outputable GHC.Core.Opt.CprAnal.SigEnv module GHC.Core.Opt.Pipeline core2core :: HscEnv -> ModGuts -> IO ModGuts simplifyExpr :: HscEnv -> CoreExpr -> IO CoreExpr -- | Module finder module GHC.Unit.Finder -- | The result of searching for an imported module. -- -- NB: FindResult manages both user source-import lookups (which can -- result in Module) as well as direct imports for interfaces -- (which always result in InstalledModule). data FindResult -- | The module was found Found :: ModLocation -> Module -> FindResult -- | The requested unit was not found NoPackage :: Unit -> FindResult -- | _Error_: both in multiple packages FoundMultiple :: [(Module, ModuleOrigin)] -> FindResult -- | Not found NotFound :: [FilePath] -> Maybe Unit -> [Unit] -> [Unit] -> [(Unit, UnusableUnitReason)] -> [ModuleSuggestion] -> FindResult -- | Places where I looked [fr_paths] :: FindResult -> [FilePath] -- | Just p => module is in this unit's manifest, but couldn't find the -- .hi file [fr_pkg] :: FindResult -> Maybe Unit -- | Module is in these units, but the *module* is hidden [fr_mods_hidden] :: FindResult -> [Unit] -- | Module is in these units, but the *unit* is hidden [fr_pkgs_hidden] :: FindResult -> [Unit] -- | Module is in these units, but it is unusable [fr_unusables] :: FindResult -> [(Unit, UnusableUnitReason)] -- | Possible mis-spelled modules [fr_suggestions] :: FindResult -> [ModuleSuggestion] data InstalledFindResult InstalledFound :: ModLocation -> InstalledModule -> InstalledFindResult InstalledNoPackage :: UnitId -> InstalledFindResult InstalledNotFound :: [FilePath] -> Maybe UnitId -> InstalledFindResult -- | Locations and information the finder cares about. -- -- Should be taken from DynFlags via initFinderOpts. data FinderOpts FinderOpts :: [FilePath] -> Bool -> Bool -> Ways -> Bool -> Maybe FilePath -> Maybe FastString -> Set ModuleName -> Set ModuleName -> Maybe FilePath -> String -> Maybe FilePath -> String -> String -> Maybe FilePath -> String -> String -> Maybe FilePath -> FinderOpts -- | Where are we allowed to look for Modules and Source files [finder_importPaths] :: FinderOpts -> [FilePath] -- | When looking up a home module: -- -- [finder_lookupHomeInterfaces] :: FinderOpts -> Bool -- | Don't check that an imported interface file actually exists if it can -- only be at one location. The interface will be reported as -- InstalledFound even if the file doesn't exist, so this is only -- useful in specific cases (e.g. to generate dependencies with `ghc -M`) [finder_bypassHiFileCheck] :: FinderOpts -> Bool [finder_ways] :: FinderOpts -> Ways -- | If we encounter unknown modules, should we suggest modules that have a -- similar name. [finder_enableSuggestions] :: FinderOpts -> Bool [finder_workingDirectory] :: FinderOpts -> Maybe FilePath [finder_thisPackageName] :: FinderOpts -> Maybe FastString [finder_hiddenModules] :: FinderOpts -> Set ModuleName [finder_reexportedModules] :: FinderOpts -> Set ModuleName [finder_hieDir] :: FinderOpts -> Maybe FilePath [finder_hieSuf] :: FinderOpts -> String [finder_hiDir] :: FinderOpts -> Maybe FilePath [finder_hiSuf] :: FinderOpts -> String [finder_dynHiSuf] :: FinderOpts -> String [finder_objectDir] :: FinderOpts -> Maybe FilePath [finder_objectSuf] :: FinderOpts -> String [finder_dynObjectSuf] :: FinderOpts -> String [finder_stubDir] :: FinderOpts -> Maybe FilePath data FinderCache initFinderCache :: IO FinderCache flushFinderCaches :: FinderCache -> UnitEnv -> IO () -- | Locate a module that was imported by the user. We have the module's -- name, and possibly a package name. Without a package name, this -- function will use the search path and the known exposed packages to -- find the module, if a package is specified then only that package is -- searched for the module. findImportedModule :: HscEnv -> ModuleName -> PkgQual -> IO FindResult -- | Locate a plugin module requested by the user, for a compiler plugin. -- This consults the same set of exposed packages as -- findImportedModule, unless -hide-all-plugin-packages -- or -plugin-package are specified. findPluginModule :: FinderCache -> FinderOpts -> UnitState -> Maybe HomeUnit -> ModuleName -> IO FindResult -- | Locate a specific Module. The purpose of this function is to -- create a ModLocation for a given Module, that is to find -- out where the files associated with this module live. It is used when -- reading the interface for a module mentioned by another interface, for -- example (a "system import"). findExactModule :: FinderCache -> FinderOpts -> UnitEnvGraph FinderOpts -> UnitState -> Maybe HomeUnit -> InstalledModule -> IO InstalledFindResult findHomeModule :: FinderCache -> FinderOpts -> HomeUnit -> ModuleName -> IO FindResult findExposedPackageModule :: FinderCache -> FinderOpts -> UnitState -> ModuleName -> PkgQual -> IO FindResult mkHomeModLocation :: FinderOpts -> ModuleName -> FilePath -> ModLocation mkHomeModLocation2 :: FinderOpts -> ModuleName -> FilePath -> String -> ModLocation mkHiOnlyModLocation :: FinderOpts -> Suffix -> Suffix -> FilePath -> String -> ModLocation -- | Constructs the filename of a .hi file for a given source file. Does -- not check whether the .hi file exists mkHiPath :: FinderOpts -> FilePath -> String -> FilePath -- | Constructs the filename of a .o file for a given source file. Does -- not check whether the .o file exists mkObjPath :: FinderOpts -> FilePath -> String -> FilePath addModuleToFinder :: FinderCache -> Module -> ModLocation -> IO () addHomeModuleToFinder :: FinderCache -> HomeUnit -> ModuleName -> ModLocation -> IO Module uncacheModule :: FinderCache -> HomeUnit -> ModuleName -> IO () mkStubPaths :: FinderOpts -> ModuleName -> ModLocation -> FilePath findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable) findObjectLinkable :: Module -> FilePath -> UTCTime -> IO Linkable lookupFileCache :: FinderCache -> FilePath -> IO Fingerprint -- | Loading interface files module GHC.Iface.Load tcLookupImported_maybe :: Name -> TcM (MaybeErr SDoc TyThing) importDecl :: Name -> IfM lcl (MaybeErr SDoc TyThing) checkWiredInTyCon :: TyCon -> TcM () ifCheckWiredInThing :: TyThing -> IfL () -- | Load interface directly for a fully qualified Module. (This is -- a fairly rare operation, but in particular it is used to load orphan -- modules in order to pull their instances into the global package table -- and to handle some operations in GHCi). loadModuleInterface :: SDoc -> Module -> TcM ModIface -- | Load interfaces for a collection of modules. loadModuleInterfaces :: SDoc -> [Module] -> TcM () -- | Load the interface corresponding to an import directive in -- source code. On a failure, fail in the monad with an error message. loadSrcInterface :: SDoc -> ModuleName -> IsBootInterface -> PkgQual -> RnM ModIface -- | Like loadSrcInterface, but returns a MaybeErr. loadSrcInterface_maybe :: SDoc -> ModuleName -> IsBootInterface -> PkgQual -> RnM (MaybeErr SDoc ModIface) -- | Loads the interface for a given Name. Should only be called for an -- imported name; otherwise loadSysInterface may not find the interface loadInterfaceForName :: SDoc -> Name -> TcRn ModIface -- | Loads the interface for a given Module. loadInterfaceForModule :: SDoc -> Module -> TcRn ModIface loadInterface :: SDoc -> Module -> WhereFrom -> IfM lcl (MaybeErr SDoc ModIface) -- | Loads a system interface and throws an exception if it fails loadSysInterface :: SDoc -> Module -> IfM lcl ModIface -- | Loads a user interface and throws an exception if it fails. The first -- parameter indicates whether we should import the boot variant of the -- module loadUserInterface :: IsBootInterface -> SDoc -> Module -> IfM lcl ModIface loadPluginInterface :: SDoc -> Module -> IfM lcl ModIface findAndReadIface :: HscEnv -> SDoc -> InstalledModule -> Module -> IsBootInterface -> IO (MaybeErr SDoc (ModIface, FilePath)) -- | readIface tries just the one file. -- -- Failed err = file not found, or unreadable, or illegible -- Succeeded iface = successfully found and parsed readIface :: DynFlags -> NameCache -> Module -> FilePath -> IO (MaybeErr SDoc ModIface) -- | Write interface file writeIface :: Logger -> Profile -> FilePath -> ModIface -> IO () -- | Compute the signatures which must be compiled in order to load the -- interface for a Module. The output of this function is always a -- subset of moduleFreeHoles; it is more precise because in -- signature p[A=<A>,B=<B>]:B, although the free -- holes are A and B, B might not depend on A at all! -- -- If this is invoked on a signature, this does NOT include the signature -- itself; e.g. precise free module holes of -- p[A=<A>,B=<B>]:B never includes B. moduleFreeHolesPrecise :: SDoc -> Module -> TcRnIf gbl lcl (MaybeErr SDoc (UniqDSet ModuleName)) needWiredInHomeIface :: TyThing -> Bool -- | An IfM function to load the home interface for a wired-in -- thing, so that we're sure that we see its instance declarations and -- rules See Note [Loading instances for wired-in things] loadWiredInHomeIface :: Name -> IfM lcl () -- | Show a ModIface but don't display details; suitable for ModIfaces -- stored in the EPT. pprModIfaceSimple :: UnitState -> ModIface -> SDoc ifaceStats :: ExternalPackageState -> SDoc -- | Show a ModIface -- -- The UnitState is used to pretty-print units pprModIface :: UnitState -> ModIface -> SDoc -- | Read binary interface, and print it out showIface :: Logger -> DynFlags -> UnitState -> NameCache -> FilePath -> IO () instance GHC.Utils.Outputable.Outputable (GHC.Unit.Module.Warnings.Warnings pass) module GHC.Tc.Utils.Env -- | A global typecheckable-thing, essentially anything that has a name. -- Not to be confused with a TcTyThing, which is also a -- typecheckable thing but in the *local* context. See -- GHC.Tc.Utils.Env for how to retrieve a TyThing given a -- Name. data TyThing AnId :: Id -> TyThing AConLike :: ConLike -> TyThing ATyCon :: TyCon -> TyThing ACoAxiom :: CoAxiom Branched -> TyThing -- | A typecheckable thing available in a local context. Could be -- AGlobal TyThing, but also lexically scoped variables, -- etc. See GHC.Tc.Utils.Env for how to retrieve a TyThing -- given a Name. data TcTyThing AGlobal :: TyThing -> TcTyThing ATcId :: TcId -> IdBindingInfo -> TcTyThing [tct_id] :: TcTyThing -> TcId [tct_info] :: TcTyThing -> IdBindingInfo ATyVar :: Name -> TcTyVar -> TcTyThing ATcTyCon :: TyCon -> TcTyThing APromotionErr :: PromotionErr -> TcTyThing type TcId = Id data InstInfo a InstInfo :: ClsInst -> InstBindings a -> InstInfo a [iSpec] :: InstInfo a -> ClsInst [iBinds] :: InstInfo a -> InstBindings a iDFunId :: InstInfo a -> DFunId pprInstInfoDetails :: OutputableBndrId a => InstInfo (GhcPass a) -> SDoc simpleInstInfoClsTy :: InstInfo a -> (Class, Type) simpleInstInfoTy :: InstInfo a -> Type simpleInstInfoTyCon :: InstInfo a -> TyCon data InstBindings a InstBindings :: [Name] -> LHsBinds a -> [LSig a] -> [Extension] -> Bool -> InstBindings a [ib_tyvars] :: InstBindings a -> [Name] [ib_binds] :: InstBindings a -> LHsBinds a [ib_pragmas] :: InstBindings a -> [LSig a] [ib_extensions] :: InstBindings a -> [Extension] [ib_derived] :: InstBindings a -> Bool tcExtendGlobalEnv :: [TyThing] -> TcM r -> TcM r tcExtendTyConEnv :: [TyCon] -> TcM r -> TcM r tcExtendGlobalEnvImplicit :: [TyThing] -> TcM r -> TcM r setGlobalTypeEnv :: TcGblEnv -> TypeEnv -> TcM TcGblEnv tcExtendGlobalValEnv :: [Id] -> TcM a -> TcM a tcTyThBinders :: [TyThing] -> TcM ThBindEnv tcLookupLocatedGlobal :: LocatedA Name -> TcM TyThing tcLookupGlobal :: Name -> TcM TyThing tcLookupGlobalOnly :: Name -> TcM TyThing tcLookupTyCon :: Name -> TcM TyCon tcLookupClass :: Name -> TcM Class tcLookupDataCon :: Name -> TcM DataCon tcLookupPatSyn :: Name -> TcM PatSyn tcLookupConLike :: Name -> TcM ConLike tcLookupLocatedGlobalId :: LocatedA Name -> TcM Id tcLookupLocatedTyCon :: LocatedN Name -> TcM TyCon tcLookupLocatedClass :: LocatedA Name -> TcM Class tcLookupAxiom :: Name -> TcM (CoAxiom Branched) lookupGlobal :: HscEnv -> Name -> IO TyThing lookupGlobal_maybe :: HscEnv -> Name -> IO (MaybeErr SDoc TyThing) ioLookupDataCon :: HscEnv -> Name -> IO DataCon addTypecheckedBinds :: TcGblEnv -> [LHsBinds GhcTc] -> TcGblEnv tcExtendKindEnv :: NameEnv TcTyThing -> TcM r -> TcM r tcExtendKindEnvList :: [(Name, TcTyThing)] -> TcM r -> TcM r tcExtendTyVarEnv :: [TyVar] -> TcM r -> TcM r tcExtendNameTyVarEnv :: [(Name, TcTyVar)] -> TcM r -> TcM r tcExtendLetEnv :: TopLevelFlag -> TcSigFun -> IsGroupClosed -> [TcId] -> TcM a -> TcM a tcExtendSigIds :: TopLevelFlag -> [TcId] -> TcM a -> TcM a tcExtendRecIds :: [(Name, TcId)] -> TcM a -> TcM a tcExtendIdEnv :: [TcId] -> TcM a -> TcM a tcExtendIdEnv1 :: Name -> TcId -> TcM a -> TcM a tcExtendIdEnv2 :: [(Name, TcId)] -> TcM a -> TcM a tcExtendBinderStack :: [TcBinder] -> TcM a -> TcM a tcExtendLocalTypeEnv :: TcLclEnv -> [(Name, TcTyThing)] -> TcLclEnv isTypeClosedLetBndr :: Id -> Bool -- | tcCheckUsage name mult thing_inside runs -- thing_inside, checks that the usage of name is a -- submultiplicity of mult, and removes name from the -- usage environment. See also Note [Wrapper returned from tcSubMult] in -- GHC.Tc.Utils.Unify, which applies to the wrapper returned from this -- function. tcCheckUsage :: Name -> Mult -> TcM a -> TcM (a, HsWrapper) tcLookup :: Name -> TcM TcTyThing tcLookupLocated :: LocatedA Name -> TcM TcTyThing tcLookupLocalIds :: [Name] -> TcM [TcId] tcLookupId :: Name -> TcM Id tcLookupIdMaybe :: Name -> TcM (Maybe Id) tcLookupTyVar :: Name -> TcM TcTyVar tcLookupTcTyCon :: HasDebugCallStack => Name -> TcM TcTyCon tcLookupLcl_maybe :: Name -> TcM (Maybe TcTyThing) getInLocalScope :: TcM (Name -> Bool) wrongThingErr :: String -> TcTyThing -> Name -> TcM a pprBinders :: [Name] -> SDoc tcAddDataFamConPlaceholders :: [LInstDecl GhcRn] -> TcM a -> TcM a tcAddPatSynPlaceholders :: [PatSynBind GhcRn GhcRn] -> TcM a -> TcM a getTypeSigNames :: [LSig GhcRn] -> NameSet tcExtendRecEnv :: [(Name, TyThing)] -> TcM r -> TcM r tcInitTidyEnv :: TcM TidyEnv -- | Get a TidyEnv that includes mappings for all vars free in the -- given type. Useful when tidying open types. tcInitOpenTidyEnv :: [TyCoVar] -> TcM TidyEnv tcLookupInstance :: Class -> [Type] -> TcM ClsInst tcGetInstEnvs :: TcM InstEnvs tcExtendRules :: [LRuleDecl GhcTc] -> TcM a -> TcM a tcGetDefaultTys :: TcM ([Type], (Bool, Bool)) checkWellStaged :: SDoc -> ThLevel -> ThLevel -> TcM () tcMetaTy :: Name -> TcM Type thLevel :: ThStage -> ThLevel topIdLvl :: Id -> ThLevel isBrackStage :: ThStage -> Bool -- | Make a name for the dict fun for an instance decl. It's an *external* -- name, like other top-level names, and hence must be made with -- newGlobalBinder. newDFunName :: Class -> [Type] -> SrcSpan -> TcM Name newFamInstTyConName :: LocatedN Name -> [Type] -> TcM Name newFamInstAxiomName :: LocatedN Name -> [[Type]] -> TcM Name mkStableIdFromString :: String -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId mkStableIdFromName :: Name -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId -- |
--   mkWrapperName ref what nameBase
--   
-- -- See Note [Generating fresh names for ccall wrapper] for ref's -- purpose. mkWrapperName :: (MonadIO m, HasModule m) => IORef (ModuleEnv Int) -> String -> String -> m FastString instance GHC.Hs.Extension.OutputableBndrId a => GHC.Utils.Outputable.Outputable (GHC.Tc.Utils.Env.InstInfo (GHC.Hs.Extension.GhcPass a)) instance GHC.Types.TyThing.MonadThings (GHC.Data.IOEnv.IOEnv (GHC.Tc.Types.Env GHC.Tc.Types.TcGblEnv GHC.Tc.Types.TcLclEnv)) -- | Specialisations of the HsSyn syntax for the typechecker -- -- This module is an extension of HsSyn syntax, for use in the -- type checker. module GHC.Tc.Utils.Zonk mkHsDictLet :: TcEvBinds -> LHsExpr GhcTc -> LHsExpr GhcTc mkHsApp :: forall (id :: Pass). LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id) mkHsAppTy :: forall (p :: Pass). LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -- | A simple case alternative with a single pattern, no binds, no guards; -- pre-typechecking mkHsCaseAlt :: forall (p :: Pass) body. (Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcAnn NoEpAnns, Anno (Match (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA) => LPat (GhcPass p) -> LocatedA (body (GhcPass p)) -> LMatch (GhcPass p) (LocatedA (body (GhcPass p))) tcShortCutLit :: HsOverLit GhcRn -> ExpRhoType -> TcM (Maybe (HsOverLit GhcTc)) shortCutLit :: Platform -> OverLitVal -> TcType -> Maybe (HsExpr GhcTc) hsOverLitName :: OverLitVal -> Name -- | Returns the type of the whole pattern conLikeResTy :: ConLike -> [Type] -> Type type TcId = Id type TcIdSet = IdSet zonkTopDecls :: Bag EvBind -> LHsBinds GhcTc -> [LRuleDecl GhcTc] -> [LTcSpecPrag] -> [LForeignDecl GhcTc] -> TcM (TypeEnv, Bag EvBind, LHsBinds GhcTc, [LForeignDecl GhcTc], [LTcSpecPrag], [LRuleDecl GhcTc]) zonkTopExpr :: HsExpr GhcTc -> TcM (HsExpr GhcTc) zonkTopLExpr :: LHsExpr GhcTc -> TcM (LHsExpr GhcTc) zonkTopBndrs :: [TcId] -> TcM [Id] -- | See Note [The ZonkEnv] Confused by zonking? See Note [What is -- zonking?] in GHC.Tc.Utils.TcMType. data ZonkEnv data ZonkFlexi DefaultFlexi :: ZonkFlexi SkolemiseFlexi :: ZonkFlexi RuntimeUnkFlexi :: ZonkFlexi NoFlexi :: ZonkFlexi emptyZonkEnv :: TcM ZonkEnv mkEmptyZonkEnv :: ZonkFlexi -> TcM ZonkEnv initZonkEnv :: (ZonkEnv -> TcM b) -> TcM b zonkTyVarBindersX :: ZonkEnv -> [VarBndr TcTyVar vis] -> TcM (ZonkEnv, [VarBndr TyVar vis]) zonkTyVarBinderX :: ZonkEnv -> VarBndr TcTyVar vis -> TcM (ZonkEnv, VarBndr TyVar vis) zonkTyBndrs :: [TcTyVar] -> TcM (ZonkEnv, [TyVar]) zonkTyBndrsX :: ZonkEnv -> [TcTyVar] -> TcM (ZonkEnv, [TyVar]) zonkTcTypeToType :: TcType -> TcM Type zonkTcTypeToTypeX :: ZonkEnv -> TcType -> TcM Type zonkTcTypesToTypesX :: ZonkEnv -> [TcType] -> TcM [Type] zonkScaledTcTypesToTypesX :: ZonkEnv -> [Scaled TcType] -> TcM [Scaled Type] zonkTyVarOcc :: ZonkEnv -> TcTyVar -> TcM Type zonkCoToCo :: ZonkEnv -> Coercion -> TcM Coercion zonkEvBinds :: ZonkEnv -> Bag EvBind -> TcM (ZonkEnv, Bag EvBind) zonkTcEvBinds :: ZonkEnv -> TcEvBinds -> TcM (ZonkEnv, TcEvBinds) zonkTcMethInfoToMethInfoX :: ZonkEnv -> TcMethInfo -> TcM MethInfo lookupTyVarX :: ZonkEnv -> TcTyVar -> TyVar instance GHC.Utils.Outputable.Outputable GHC.Tc.Utils.Zonk.ZonkEnv module GHC.Tc.Utils.Instantiate topSkolemise :: SkolemInfo -> TcSigmaType -> TcM (HsWrapper, [(Name, TyVar)], [EvVar], TcRhoType) topInstantiate :: CtOrigin -> TcSigmaType -> TcM (HsWrapper, TcRhoType) instantiateSigma :: CtOrigin -> [TyVar] -> TcThetaType -> TcSigmaType -> TcM ([TcTyVar], HsWrapper, TcSigmaType) instCall :: CtOrigin -> [TcType] -> TcThetaType -> TcM HsWrapper instDFunType :: DFunId -> [DFunInstType] -> TcM ([TcType], TcThetaType) instStupidTheta :: CtOrigin -> TcThetaType -> TcM () instTyVarsWith :: CtOrigin -> [TyVar] -> [TcType] -> TcM TCvSubst -- | Create a new Wanted constraint with the given CtOrigin, and -- location information taken from the TcM environment. newWanted :: CtOrigin -> Maybe TypeOrKind -> PredType -> TcM CtEvidence -- | Create new Wanted constraints with the given CtOrigin, and -- location information taken from the TcM environment. newWanteds :: CtOrigin -> ThetaType -> TcM [CtEvidence] tcInstType :: ([TyVar] -> TcM (TCvSubst, [TcTyVar])) -> Id -> TcM ([(Name, TcTyVar)], TcThetaType, TcType) tcInstTypeBndrs :: Id -> TcM ([(Name, InvisTVBinder)], TcThetaType, TcType) tcSkolemiseInvisibleBndrs :: SkolemInfoAnon -> Type -> TcM ([TcTyVar], TcType) -- | Given a list of [TyVar], skolemize the type variables, -- returning a substitution mapping the original tyvars to the skolems, -- and the list of newly bound skolems. tcInstSkolTyVars :: SkolemInfo -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) tcInstSkolTyVarsX :: SkolemInfo -> TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) tcSkolDFunType :: SkolemInfo -> DFunId -> TcM ([TcTyVar], TcThetaType, TcType) tcSuperSkolTyVars :: TcLevel -> SkolemInfo -> [TyVar] -> (TCvSubst, [TcTyVar]) tcInstSuperSkolTyVarsX :: SkolemInfo -> TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) -- | Give fresh uniques to a bunch of TyVars, but they stay as TyVars, -- rather than becoming TcTyVars Used in newFamInst, and -- newClsInst freshenTyVarBndrs :: [TyVar] -> TcM (TCvSubst, [TyVar]) -- | Give fresh uniques to a bunch of CoVars Used in -- "GHC.Tc.Instance.Family.newFamInst" freshenCoVarBndrsX :: TCvSubst -> [CoVar] -> TcM (TCvSubst, [CoVar]) tcInstInvisibleTyBindersN :: Int -> TcKind -> TcM ([TcType], TcKind) -- | Given ty::forall k1 k2. k, instantiate all the invisible -- forall-binders returning ty kk1 kk2 :: k[kk1k1, kk2k1] tcInstInvisibleTyBinders :: TcType -> TcKind -> TcM (TcType, TcKind) -- | Used only in *types* tcInstInvisibleTyBinder :: TCvSubst -> TyBinder -> TcM (TCvSubst, TcType) newOverloadedLit :: HsOverLit GhcRn -> ExpRhoType -> TcM (HsOverLit GhcTc) mkOverLit :: OverLitVal -> TcM (HsLit GhcTc) newClsInst :: Maybe OverlapMode -> Name -> [TyVar] -> ThetaType -> Class -> [Type] -> TcM ClsInst tcGetInsts :: TcM [ClsInst] tcGetInstEnvs :: TcM InstEnvs getOverlapFlag :: Maybe OverlapMode -> TcM OverlapFlag tcExtendLocalInstEnv :: [ClsInst] -> TcM a -> TcM a instCallConstraints :: CtOrigin -> TcThetaType -> TcM HsWrapper -- | Used when Name is the wired-in name for a wired-in class -- method, so the caller knows its type for sure, which should be of form -- --
--   forall a. C a => <blah>
--   
-- -- newMethodFromName is supposed to instantiate just the outer -- type variable and constraint newMethodFromName :: CtOrigin -> Name -> [TcRhoType] -> TcM (HsExpr GhcTc) tcSyntaxName :: CtOrigin -> TcType -> (Name, HsExpr GhcRn) -> TcM (Name, HsExpr GhcTc) -- | Returns free variables of WantedConstraints as a non-deterministic -- set. See Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfWC :: WantedConstraints -> TyCoVarSet -- | Returns free variables of constraints as a non-deterministic set tyCoVarsOfCt :: Ct -> TcTyCoVarSet -- | Returns free variables of a bag of constraints as a non-deterministic -- set. See Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfCts :: Cts -> TcTyCoVarSet -- | Type subsumption and unification module GHC.Tc.Utils.Unify tcWrapResult :: HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc) tcWrapResultO :: CtOrigin -> HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc) tcWrapResultMono :: HsExpr GhcRn -> HsExpr GhcTc -> TcRhoType -> ExpRhoType -> TcM (HsExpr GhcTc) tcSkolemise :: UserTypeCtxt -> TcSigmaType -> (TcType -> TcM result) -> TcM (HsWrapper, result) tcSkolemiseScoped :: UserTypeCtxt -> TcSigmaType -> (TcType -> TcM result) -> TcM (HsWrapper, result) -- | Variant of tcSkolemise that takes an ExpType tcSkolemiseET :: UserTypeCtxt -> ExpSigmaType -> (ExpRhoType -> TcM result) -> TcM (HsWrapper, result) tcSubType :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper tcSubTypeSigma :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper tcSubTypePat :: CtOrigin -> UserTypeCtxt -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper tcSubMult :: CtOrigin -> Mult -> Mult -> TcM HsWrapper checkConstraints :: SkolemInfoAnon -> [TcTyVar] -> [EvVar] -> TcM result -> TcM (TcEvBinds, result) checkTvConstraints :: SkolemInfo -> [TcTyVar] -> TcM result -> TcM result buildImplicationFor :: TcLevel -> SkolemInfoAnon -> [TcTyVar] -> [EvVar] -> WantedConstraints -> TcM (Bag Implication, TcEvBinds) buildTvImplication :: SkolemInfoAnon -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM Implication emitResidualTvConstraint :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM () unifyType :: Maybe TypedThing -> TcTauType -> TcTauType -> TcM TcCoercionN unifyKind :: Maybe TypedThing -> TcKind -> TcKind -> TcM CoercionN unifyExpectedType :: HsExpr GhcRn -> TcRhoType -> ExpRhoType -> TcM TcCoercionN uType :: TypeOrKind -> CtOrigin -> TcType -> TcType -> TcM CoercionN promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType) swapOverTyVars :: Bool -> TcTyVar -> TcTyVar -> Bool -- | Checks (TYVAR-TV), (COERCION-HOLE) and (CONCRETE) of Note [Unification -- preconditions]; returns True if these conditions are satisfied. But -- see the Note for other preconditions, too. canSolveByUnification :: MetaInfo -> TcType -> Bool -- | Infer a type using a fresh ExpType See also Note [ExpType] in -- GHC.Tc.Utils.TcMType tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) matchExpectedListTy :: TcRhoType -> TcM (TcCoercionN, TcRhoType) matchExpectedTyConApp :: TyCon -> TcRhoType -> TcM (TcCoercionN, [TcSigmaType]) matchExpectedAppTy :: TcRhoType -> TcM (TcCoercion, (TcSigmaType, TcSigmaType)) -- | Use this function to split off arguments types when you have an -- "expected" type. -- -- This function skolemises at each polytype. -- -- Invariant: this function only applies the provided function to a list -- of argument types which all have a fixed RuntimeRep in the sense of -- Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete. See Note [Return -- arguments with a fixed RuntimeRep]. matchExpectedFunTys :: forall a. ExpectedFunTyOrigin -> UserTypeCtxt -> Arity -> ExpRhoType -> ([Scaled ExpSigmaTypeFRR] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) -- | Breaks apart a function kind into its pieces. matchExpectedFunKind :: TypedThing -> Arity -> TcKind -> TcM Coercion -- | matchActualFunTySigma looks for just one function arrow, -- returning an uninstantiated sigma-type. -- -- Invariant: the returned argument type has a fixed RuntimeRep as per -- Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete. See Note [Return -- arguments with a fixed RuntimeRep]. matchActualFunTySigma :: ExpectedFunTyOrigin -> Maybe TypedThing -> (Arity, [Scaled TcSigmaType]) -> TcRhoType -> TcM (HsWrapper, Scaled TcSigmaTypeFRR, TcSigmaType) -- | Like matchExpectedFunTys, but used when you have an "actual" -- type, for example in function application. -- -- INVARIANT: the returned arguemnt types all have a fixed RuntimeRep in -- the sense of Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete. See -- Note [Return arguments with a fixed RuntimeRep]. matchActualFunTysRho :: ExpectedFunTyOrigin -> CtOrigin -> Maybe TypedThing -> Arity -> TcSigmaType -> TcM (HsWrapper, [Scaled TcSigmaTypeFRR], TcRhoType) checkTyVarEq :: TcTyVar -> TcType -> CheckTyEqResult checkTyFamEq :: TyCon -> [TcType] -> TcType -> CheckTyEqResult checkTypeEq :: CanEqLHS -> TcType -> CheckTyEqResult module GHC.Tc.Instance.Typeable -- | Generate the Typeable bindings for a module. This is the only -- entry-point of this module and is invoked by the typechecker driver in -- tcRnSrcDecls. -- -- See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable. mkTypeableBinds :: TcM TcGblEnv -- | Is a particular TyCon representable by Typeable?. -- These exclude type families and polytypes. tyConIsTypeable :: TyCon -> Bool instance GHC.Base.Monad GHC.Tc.Instance.Typeable.KindRepM instance GHC.Base.Applicative GHC.Tc.Instance.Typeable.KindRepM instance GHC.Base.Functor GHC.Tc.Instance.Typeable.KindRepM module GHC.Runtime.Heap.Inspect -- | Term reconstruction -- -- Given a pointer to a heap object (HValue) and its type, build a -- Term representation of the object. Subterms (objects in the -- payload) are also built up to the given max_depth. After -- max_depth any subterms will appear as Suspensions. Any -- thunks found while traversing the object will be forced based on -- force parameter. -- -- Types of terms will be refined based on constructors we find during -- term reconstruction. See cvReconstructType for an overview of -- how type reconstruction works. cvObtainTerm :: HscEnv -> Int -> Bool -> RttiType -> ForeignHValue -> IO Term -- | Fast, breadth-first Type reconstruction -- -- Given a heap object (HValue) and its (possibly polymorphic) -- type (usually obtained in GHCi), try to reconstruct a more monomorphic -- type of the object. This is used for improving type information in -- debugger. For example, if we have a polymorphic function: -- -- sumNumList :: Num a => [a] -> a sumNumList [] = 0 sumNumList (x -- : xs) = x + sumList xs -- -- and add a breakpoint to it: -- -- ghci> break sumNumList ghci> sumNumList ([0 .. 9] :: [Int]) -- -- ghci shows us more precise types than just as: -- -- Stopped in Main.sumNumList, debugger.hs:3:23-39 _result :: Int = _ x -- :: Int = 0 xs :: [Int] = _ cvReconstructType :: HscEnv -> Int -> GhciType -> ForeignHValue -> IO (Maybe Type) improveRTTIType :: HscEnv -> RttiType -> RttiType -> Maybe TCvSubst data Term Term :: RttiType -> Either String DataCon -> ForeignHValue -> [Term] -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [val] :: Term -> ForeignHValue [subTerms] :: Term -> [Term] Prim :: RttiType -> [Word] -> Term [ty] :: Term -> RttiType [valRaw] :: Term -> [Word] Suspension :: ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> Term [ctype] :: Term -> ClosureType [ty] :: Term -> RttiType [val] :: Term -> ForeignHValue [bound_to] :: Term -> Maybe Name NewtypeWrap :: RttiType -> Either String DataCon -> Term -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [wrapped_term] :: Term -> Term RefWrap :: RttiType -> Term -> Term [ty] :: Term -> RttiType [wrapped_term] :: Term -> Term isFullyEvaluatedTerm :: Term -> Bool termType :: Term -> RttiType mapTermType :: (RttiType -> Type) -> Term -> Term termTyCoVars :: Term -> TyCoVarSet foldTerm :: TermFold a -> Term -> a data TermFold a TermFold :: TermProcessor a a -> (RttiType -> [Word] -> a) -> (ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> a) -> (RttiType -> Either String DataCon -> a -> a) -> (RttiType -> a -> a) -> TermFold a [fTerm] :: TermFold a -> TermProcessor a a [fPrim] :: TermFold a -> RttiType -> [Word] -> a [fSuspension] :: TermFold a -> ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> a [fNewtypeWrap] :: TermFold a -> RttiType -> Either String DataCon -> a -> a [fRefWrap] :: TermFold a -> RttiType -> a -> a -- | Takes a list of custom printers with a explicit recursion knot and a -- term, and returns the output of the first successful printer, or the -- default printer cPprTerm :: Monad m => CustomTermPrinter m -> Term -> m SDoc cPprTermBase :: forall m. Monad m => CustomTermPrinter m constrClosToName :: HscEnv -> GenClosure a -> IO (Either String Name) instance GHC.Utils.Outputable.Outputable GHC.Runtime.Heap.Inspect.Term module GHC.Rename.Utils checkDupRdrNames :: [LocatedN RdrName] -> RnM () checkDupRdrNamesN :: [LocatedN RdrName] -> RnM () checkShadowedRdrNames :: [LocatedN RdrName] -> RnM () checkDupNames :: [Name] -> RnM () checkDupAndShadowedNames :: (GlobalRdrEnv, LocalRdrEnv) -> [Name] -> RnM () dupNamesErr :: Outputable n => (n -> SrcSpan) -> NonEmpty n -> RnM () -- | Ensure that a boxed or unboxed tuple has arity no larger than -- mAX_TUPLE_SIZE. checkTupSize :: Int -> TcM () -- | Ensure that a constraint tuple has arity no larger than -- mAX_CTUPLE_SIZE. checkCTupSize :: Int -> TcM () addFvRn :: FreeVars -> RnM (thing, FreeVars) -> RnM (thing, FreeVars) mapFvRn :: (a -> RnM (b, FreeVars)) -> [a] -> RnM ([b], FreeVars) mapMaybeFvRn :: (a -> RnM (b, FreeVars)) -> Maybe a -> RnM (Maybe b, FreeVars) warnUnusedMatches :: [Name] -> FreeVars -> RnM () warnUnusedTypePatterns :: [Name] -> FreeVars -> RnM () warnUnusedTopBinds :: [GlobalRdrElt] -> RnM () warnUnusedLocalBinds :: [Name] -> FreeVars -> RnM () warnForallIdentifier :: LocatedN RdrName -> RnM () -- | Checks to see if we need to warn for -Wunused-record-wildcards or -- -Wredundant-record-wildcards checkUnusedRecordWildcard :: SrcSpan -> FreeVars -> Maybe [Name] -> RnM () -- | Make a map from selector names to field labels and parent tycon names, -- to be used when reporting unused record fields. mkFieldEnv :: GlobalRdrEnv -> NameEnv (FieldLabelString, Parent) badQualBndrErr :: RdrName -> TcRnMessage typeAppErr :: String -> LHsType GhcPs -> TcRnMessage badFieldConErr :: Name -> FieldLabelString -> TcRnMessage wrapGenSpan :: a -> LocatedAn an a genHsVar :: Name -> HsExpr GhcRn genLHsVar :: Name -> LHsExpr GhcRn genHsApp :: HsExpr GhcRn -> LHsExpr GhcRn -> HsExpr GhcRn genHsApps :: Name -> [LHsExpr GhcRn] -> HsExpr GhcRn genAppType :: HsExpr GhcRn -> HsType (NoGhcTc GhcRn) -> HsExpr GhcRn genHsIntegralLit :: IntegralLit -> LocatedAn an (HsExpr GhcRn) genHsTyLit :: FastString -> HsType GhcRn newLocalBndrRn :: LocatedN RdrName -> RnM Name newLocalBndrsRn :: [LocatedN RdrName] -> RnM [Name] bindLocalNames :: [Name] -> RnM a -> RnM a bindLocalNamesFV :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars) addNameClashErrRn :: RdrName -> NonEmpty GlobalRdrElt -> RnM () -- | Throw an error message if a user attempts to quantify an inferred type -- variable in a place where specificity cannot be observed. For example, -- forall {a}. [a] -> [a] would be rejected to the inferred -- type variable {a}, but forall a. [a] -> [a] would -- be accepted. See Note [Unobservably inferred type variables]. checkInferredVars :: HsDocContext -> Maybe SDoc -> LHsSigType GhcPs -> RnM () -- | Examines a non-outermost type for foralls or contexts, which -- are assumed to be nested. For example, in the following declaration: -- --
--   instance forall a. forall b. C (Either a b)
--   
-- -- The outermost forall a is fine, but the nested forall -- b is not. We invoke noNestedForallsContextsErr on the type -- forall b. C (Either a b) to catch the nested forall -- and create a suitable error message. noNestedForallsContextsErr -- returns Just err_msg if such a forall or -- context is found, and returns Nothing otherwise. -- -- This is currently used in the following places: -- -- noNestedForallsContextsErr :: SDoc -> LHsType GhcRn -> Maybe (SrcSpan, SDoc) -- | A common way to invoke noNestedForallsContextsErr. addNoNestedForallsContextsErr :: HsDocContext -> SDoc -> LHsType GhcRn -> RnM () -- | This module is not used by GHC itself. Rather, it exports all of the -- functions and types you are likely to need when writing a plugin for -- GHC. So authors of plugins can probably get away simply with saying -- "import GHC.Plugins". -- -- Particularly interesting modules for plugin writers include -- GHC.Core and GHC.Core.Opt.Monad. module GHC.Plugins tidyOccName :: TidyOccEnv -> OccName -> (TidyOccEnv, OccName) avoidClashesOccEnv :: TidyOccEnv -> [OccName] -> TidyOccEnv delTidyOccEnvList :: TidyOccEnv -> [FastString] -> TidyOccEnv initTidyOccEnv :: [OccName] -> TidyOccEnv emptyTidyOccEnv :: TidyOccEnv mkMethodOcc :: OccName -> OccName mkDFunOcc :: String -> Bool -> OccSet -> OccName -- | Derive a name for the representation type constructor of a -- data/newtype instance. mkInstTyTcOcc :: String -> OccSet -> OccName mkLocalOcc :: Unique -> OccName -> OccName mkSuperDictSelOcc :: Int -> OccName -> OccName mkSuperDictAuxOcc :: Int -> OccName -> OccName mkDataConWorkerOcc :: OccName -> OccName mkGen1R :: OccName -> OccName mkGenR :: OccName -> OccName mkTyConRepOcc :: OccName -> OccName mkDataCOcc :: OccName -> OccName mkDataTOcc :: OccName -> OccName mkMaxTagOcc :: OccName -> OccName mkTag2ConOcc :: OccName -> OccName mkCon2TagOcc :: OccName -> OccName mkEqPredCoOcc :: OccName -> OccName mkInstTyCoOcc :: OccName -> OccName mkNewTyCoOcc :: OccName -> OccName mkClassDataConOcc :: OccName -> OccName mkRepEqOcc :: OccName -> OccName mkForeignExportOcc :: OccName -> OccName mkSpecOcc :: OccName -> OccName mkIPOcc :: OccName -> OccName mkDictOcc :: OccName -> OccName mkClassOpAuxOcc :: OccName -> OccName mkDefaultMethodOcc :: OccName -> OccName mkBuilderOcc :: OccName -> OccName mkMatcherOcc :: OccName -> OccName mkWorkerOcc :: OccName -> OccName mkDataConWrapperOcc :: OccName -> OccName -- | Is an OccName one of a Typeable TyCon or -- Module binding? This is needed as these bindings are renamed -- differently. See Note [Grand plan for Typeable] in -- GHC.Tc.Instance.Typeable. isTypeableBindOcc :: OccName -> Bool isDefaultMethodOcc :: OccName -> Bool -- | Test for definitions internally generated by GHC. This predicate is -- used to suppress printing of internal definitions in some debug prints isDerivedOccName :: OccName -> Bool -- | Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with _: this implements that -- test startsWithUnderscore :: OccName -> Bool -- | Wrap parens around an operator parenSymOcc :: OccName -> SDoc -> SDoc -- | Test if the OccName is that for any operator (whether it is a -- data constructor or variable or whatever) isSymOcc :: OccName -> Bool -- | Test if the OccName is a data constructor that starts with a -- symbol (e.g. :, or []) isDataSymOcc :: OccName -> Bool isDataOcc :: OccName -> Bool -- | Value OccNamess are those that are either in the -- variable or data constructor namespaces isValOcc :: OccName -> Bool isTcOcc :: OccName -> Bool isTvOcc :: OccName -> Bool isVarOcc :: OccName -> Bool setOccNameSpace :: NameSpace -> OccName -> OccName -- | Converts an OccSet to an OccEnv (operationally the identity) occSetToEnv :: OccSet -> OccEnv OccName filterOccSet :: (OccName -> Bool) -> OccSet -> OccSet intersectOccSet :: OccSet -> OccSet -> OccSet isEmptyOccSet :: OccSet -> Bool elemOccSet :: OccName -> OccSet -> Bool minusOccSet :: OccSet -> OccSet -> OccSet unionManyOccSets :: [OccSet] -> OccSet unionOccSets :: OccSet -> OccSet -> OccSet extendOccSetList :: OccSet -> [OccName] -> OccSet extendOccSet :: OccSet -> OccName -> OccSet mkOccSet :: [OccName] -> OccSet unitOccSet :: OccName -> OccSet emptyOccSet :: OccSet pprOccEnv :: (a -> SDoc) -> OccEnv a -> SDoc -- | Alters (replaces or removes) those elements of the map that are -- mentioned in the second map minusOccEnv_C :: (a -> b -> Maybe a) -> OccEnv a -> OccEnv b -> OccEnv a minusOccEnv :: OccEnv a -> OccEnv b -> OccEnv a alterOccEnv :: (Maybe elt -> Maybe elt) -> OccEnv elt -> OccName -> OccEnv elt filterOccEnv :: (elt -> Bool) -> OccEnv elt -> OccEnv elt delListFromOccEnv :: OccEnv a -> [OccName] -> OccEnv a delFromOccEnv :: OccEnv a -> OccName -> OccEnv a mkOccEnv_C :: (a -> a -> a) -> [(OccName, a)] -> OccEnv a mapOccEnv :: (a -> b) -> OccEnv a -> OccEnv b extendOccEnv_Acc :: (a -> b -> b) -> (a -> b) -> OccEnv b -> OccName -> a -> OccEnv b extendOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccName -> a -> OccEnv a plusOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccEnv a -> OccEnv a plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a nonDetOccEnvElts :: OccEnv a -> [a] foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b elemOccEnv :: OccName -> OccEnv a -> Bool mkOccEnv :: [(OccName, a)] -> OccEnv a lookupOccEnv :: OccEnv a -> OccName -> Maybe a extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a unitOccEnv :: OccName -> a -> OccEnv a emptyOccEnv :: OccEnv a promoteOccName :: OccName -> Maybe OccName demoteOccName :: OccName -> Maybe OccName mkClsOccFS :: FastString -> OccName mkClsOcc :: String -> OccName mkTcOccFS :: FastString -> OccName mkTcOcc :: String -> OccName mkTyVarOccFS :: FastString -> OccName mkTyVarOcc :: String -> OccName mkDataOccFS :: FastString -> OccName mkDataOcc :: String -> OccName mkVarOcc :: String -> OccName mkOccNameFS :: NameSpace -> FastString -> OccName mkOccName :: NameSpace -> String -> OccName pprOccName :: OccName -> SDoc pprNameSpaceBrief :: NameSpace -> SDoc pprNonVarNameSpace :: NameSpace -> SDoc pprNameSpace :: NameSpace -> SDoc isValNameSpace :: NameSpace -> Bool isVarNameSpace :: NameSpace -> Bool isTvNameSpace :: NameSpace -> Bool isTcClsNameSpace :: NameSpace -> Bool isDataConNameSpace :: NameSpace -> Bool tvName :: NameSpace srcDataName :: NameSpace dataName :: NameSpace tcClsName :: NameSpace clsName :: NameSpace tcName :: NameSpace data NameSpace data OccEnv a type OccSet = UniqSet OccName type TidyOccEnv = UniqFM FastString Int mkFsEnv :: [(FastString, a)] -> FastStringEnv a lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a emptyFsEnv :: FastStringEnv a -- | A non-deterministic set of FastStrings. See Note [Deterministic -- UniqFM] in GHC.Types.Unique.DFM for explanation why it's not -- deterministic and why it matters. Use DFastStringEnv if the set -- eventually gets converted into a list or folded over in a way where -- the order changes the generated code. type FastStringEnv a = UniqFM FastString a occNameString :: OccName -> String mkRecFldSelOcc :: String -> OccName mkVarOccFS :: FastString -> OccName -- | Occurrence Name -- -- In this context that means: "classified (i.e. as a type name, value -- name, etc) but not qualified and not yet resolved" data OccName -- | Other names in the compiler add additional information to an OccName. -- This class provides a consistent way to access the underlying OccName. class HasOccName name occName :: HasOccName name => name -> OccName pprPrefixName :: NamedThing a => a -> SDoc pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc getOccFS :: NamedThing a => a -> FastString getOccString :: NamedThing a => a -> String getSrcSpan :: NamedThing a => a -> SrcSpan getSrcLoc :: NamedThing a => a -> SrcLoc -- | Get a string representation of a Name that's unique and stable -- across recompilations. Used for deterministic generation of binds for -- derived instances. eg. -- "$aeson_70dylHtv1FFGeai1IoxcQr$Data.Aeson.Types.Internal$String" nameStableString :: Name -> String pprNameDefnLoc :: Name -> SDoc pprDefinedAt :: Name -> SDoc pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc -- | Print the string of Name unqualifiedly directly. pprNameUnqualified :: Name -> SDoc -- | Print a ticky ticky styled name -- -- Module argument is the module to use for internal and system names. -- When printing the name in a ticky profile, the module name is included -- even for local things. However, ticky uses the format "x (M)" rather -- than "M.x". Hence, this function provides a separation from normal -- styling. pprTickyName :: Module -> Name -> SDoc -- | Print fully qualified name (with unit-id, module and unique) pprFullName :: Module -> Name -> SDoc -- | Compare Names lexicographically This only works for Names that -- originate in the source code or have been tidied. stableNameCmp :: Name -> Name -> Ordering -- | Make the Name into an internal name, regardless of what it was -- to begin with localiseName :: Name -> Name setNameLoc :: Name -> SrcSpan -> Name -- | Make a name for a foreign call mkFCallName :: Unique -> String -> Name mkSysTvName :: Unique -> FastString -> Name mkSystemVarName :: Unique -> FastString -> Name mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name -- | Create a name brought into being by the compiler mkSystemName :: Unique -> OccName -> Name -- | Create a name which is actually defined by the compiler itself mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name -- | Create a name which definitely originates in the given module mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name mkClonedInternalName :: Unique -> Name -> Name -- | Create a name which is (for now at least) local to the current module -- and hence does not need a Module to disambiguate it from other -- Names mkInternalName :: Unique -> OccName -> SrcSpan -> Name isSystemName :: Name -> Bool isVarName :: Name -> Bool isValName :: Name -> Bool isDataConName :: Name -> Bool isTyConName :: Name -> Bool isTyVarName :: Name -> Bool -- | Returns True if the Name comes from some other package: neither this -- package nor the interactive package. nameIsFromExternalPackage :: HomeUnit -> Name -> Bool nameIsHomePackageImport :: Module -> Name -> Bool nameIsHomePackage :: Module -> Name -> Bool -- | Returns True if the name is external or from the interactive -- package See documentation of nameIsLocalOrFrom function nameIsExternalOrFrom :: Module -> Name -> Bool -- | Returns True if the name is (a) Internal (b) External but from the -- specified module (c) External but from the interactive -- package -- -- The key idea is that False means: the entity is defined in some other -- module you can find the details (type, fixity, instances) in some -- interface file those details will be stored in the EPT or HPT -- -- True means: the entity is defined in this module or earlier in the -- GHCi session you can find details (type, fixity, instances) in the -- TcGblEnv or TcLclEnv -- -- The isInteractiveModule part is because successive interactions of a -- GHCi session each give rise to a fresh module (Ghci1, Ghci2, etc), but -- they all come from the magic interactive package; and all the -- details are kept in the TcLclEnv, TcGblEnv, NOT in the HPT or EPT. See -- Note [The interactive package] in GHC.Runtime.Context nameIsLocalOrFrom :: Module -> Name -> Bool nameModule_maybe :: Name -> Maybe Module nameModule :: HasDebugCallStack => Name -> Module -- | Will the Name come from a dynamically linked package? isDynLinkName :: Platform -> Module -> Name -> Bool isHoleName :: Name -> Bool isInternalName :: Name -> Bool isExternalName :: Name -> Bool isBuiltInSyntax :: Name -> Bool wiredInNameTyThing_maybe :: Name -> Maybe TyThing isWiredIn :: NamedThing thing => thing -> Bool isWiredInName :: Name -> Bool nameSrcSpan :: Name -> SrcSpan nameSrcLoc :: Name -> SrcLoc nameNameSpace :: Name -> NameSpace -- | BuiltInSyntax is for things like (:), [] and tuples, -- which have special syntactic forms. They aren't in scope as such. data BuiltInSyntax BuiltInSyntax :: BuiltInSyntax UserSyntax :: BuiltInSyntax tidyOccName :: TidyOccEnv -> OccName -> (TidyOccEnv, OccName) avoidClashesOccEnv :: TidyOccEnv -> [OccName] -> TidyOccEnv delTidyOccEnvList :: TidyOccEnv -> [FastString] -> TidyOccEnv initTidyOccEnv :: [OccName] -> TidyOccEnv emptyTidyOccEnv :: TidyOccEnv mkMethodOcc :: OccName -> OccName mkDFunOcc :: String -> Bool -> OccSet -> OccName -- | Derive a name for the representation type constructor of a -- data/newtype instance. mkInstTyTcOcc :: String -> OccSet -> OccName mkLocalOcc :: Unique -> OccName -> OccName mkSuperDictSelOcc :: Int -> OccName -> OccName mkSuperDictAuxOcc :: Int -> OccName -> OccName mkDataConWorkerOcc :: OccName -> OccName mkGen1R :: OccName -> OccName mkGenR :: OccName -> OccName mkTyConRepOcc :: OccName -> OccName mkDataCOcc :: OccName -> OccName mkDataTOcc :: OccName -> OccName mkMaxTagOcc :: OccName -> OccName mkTag2ConOcc :: OccName -> OccName mkCon2TagOcc :: OccName -> OccName mkEqPredCoOcc :: OccName -> OccName mkInstTyCoOcc :: OccName -> OccName mkNewTyCoOcc :: OccName -> OccName mkClassDataConOcc :: OccName -> OccName mkRepEqOcc :: OccName -> OccName mkForeignExportOcc :: OccName -> OccName mkSpecOcc :: OccName -> OccName mkIPOcc :: OccName -> OccName mkDictOcc :: OccName -> OccName mkClassOpAuxOcc :: OccName -> OccName mkDefaultMethodOcc :: OccName -> OccName mkBuilderOcc :: OccName -> OccName mkMatcherOcc :: OccName -> OccName mkWorkerOcc :: OccName -> OccName mkDataConWrapperOcc :: OccName -> OccName -- | Is an OccName one of a Typeable TyCon or -- Module binding? This is needed as these bindings are renamed -- differently. See Note [Grand plan for Typeable] in -- GHC.Tc.Instance.Typeable. isTypeableBindOcc :: OccName -> Bool isDefaultMethodOcc :: OccName -> Bool -- | Test for definitions internally generated by GHC. This predicate is -- used to suppress printing of internal definitions in some debug prints isDerivedOccName :: OccName -> Bool -- | Haskell 98 encourages compilers to suppress warnings about unused -- names in a pattern if they start with _: this implements that -- test startsWithUnderscore :: OccName -> Bool -- | Wrap parens around an operator parenSymOcc :: OccName -> SDoc -> SDoc -- | Test if the OccName is that for any operator (whether it is a -- data constructor or variable or whatever) isSymOcc :: OccName -> Bool -- | Test if the OccName is a data constructor that starts with a -- symbol (e.g. :, or []) isDataSymOcc :: OccName -> Bool isDataOcc :: OccName -> Bool -- | Value OccNamess are those that are either in the -- variable or data constructor namespaces isValOcc :: OccName -> Bool isTcOcc :: OccName -> Bool isTvOcc :: OccName -> Bool isVarOcc :: OccName -> Bool setOccNameSpace :: NameSpace -> OccName -> OccName -- | Converts an OccSet to an OccEnv (operationally the identity) occSetToEnv :: OccSet -> OccEnv OccName filterOccSet :: (OccName -> Bool) -> OccSet -> OccSet intersectOccSet :: OccSet -> OccSet -> OccSet isEmptyOccSet :: OccSet -> Bool elemOccSet :: OccName -> OccSet -> Bool minusOccSet :: OccSet -> OccSet -> OccSet unionManyOccSets :: [OccSet] -> OccSet unionOccSets :: OccSet -> OccSet -> OccSet extendOccSetList :: OccSet -> [OccName] -> OccSet extendOccSet :: OccSet -> OccName -> OccSet mkOccSet :: [OccName] -> OccSet unitOccSet :: OccName -> OccSet emptyOccSet :: OccSet pprOccEnv :: (a -> SDoc) -> OccEnv a -> SDoc -- | Alters (replaces or removes) those elements of the map that are -- mentioned in the second map minusOccEnv_C :: (a -> b -> Maybe a) -> OccEnv a -> OccEnv b -> OccEnv a minusOccEnv :: OccEnv a -> OccEnv b -> OccEnv a alterOccEnv :: (Maybe elt -> Maybe elt) -> OccEnv elt -> OccName -> OccEnv elt filterOccEnv :: (elt -> Bool) -> OccEnv elt -> OccEnv elt delListFromOccEnv :: OccEnv a -> [OccName] -> OccEnv a delFromOccEnv :: OccEnv a -> OccName -> OccEnv a mkOccEnv_C :: (a -> a -> a) -> [(OccName, a)] -> OccEnv a mapOccEnv :: (a -> b) -> OccEnv a -> OccEnv b extendOccEnv_Acc :: (a -> b -> b) -> (a -> b) -> OccEnv b -> OccName -> a -> OccEnv b extendOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccName -> a -> OccEnv a plusOccEnv_C :: (a -> a -> a) -> OccEnv a -> OccEnv a -> OccEnv a plusOccEnv :: OccEnv a -> OccEnv a -> OccEnv a nonDetOccEnvElts :: OccEnv a -> [a] foldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b elemOccEnv :: OccName -> OccEnv a -> Bool mkOccEnv :: [(OccName, a)] -> OccEnv a lookupOccEnv :: OccEnv a -> OccName -> Maybe a extendOccEnvList :: OccEnv a -> [(OccName, a)] -> OccEnv a extendOccEnv :: OccEnv a -> OccName -> a -> OccEnv a unitOccEnv :: OccName -> a -> OccEnv a emptyOccEnv :: OccEnv a promoteOccName :: OccName -> Maybe OccName demoteOccName :: OccName -> Maybe OccName mkClsOccFS :: FastString -> OccName mkClsOcc :: String -> OccName mkTcOccFS :: FastString -> OccName mkTcOcc :: String -> OccName mkTyVarOccFS :: FastString -> OccName mkTyVarOcc :: String -> OccName mkDataOccFS :: FastString -> OccName mkDataOcc :: String -> OccName mkVarOcc :: String -> OccName mkOccNameFS :: NameSpace -> FastString -> OccName mkOccName :: NameSpace -> String -> OccName pprOccName :: OccName -> SDoc pprNameSpaceBrief :: NameSpace -> SDoc pprNonVarNameSpace :: NameSpace -> SDoc pprNameSpace :: NameSpace -> SDoc isValNameSpace :: NameSpace -> Bool isVarNameSpace :: NameSpace -> Bool isTvNameSpace :: NameSpace -> Bool isTcClsNameSpace :: NameSpace -> Bool isDataConNameSpace :: NameSpace -> Bool tvName :: NameSpace srcDataName :: NameSpace dataName :: NameSpace tcClsName :: NameSpace clsName :: NameSpace tcName :: NameSpace data NameSpace data OccEnv a type OccSet = UniqSet OccName type TidyOccEnv = UniqFM FastString Int mkFsEnv :: [(FastString, a)] -> FastStringEnv a lookupFsEnv :: FastStringEnv a -> FastString -> Maybe a extendFsEnv :: FastStringEnv a -> FastString -> a -> FastStringEnv a emptyFsEnv :: FastStringEnv a -- | A non-deterministic set of FastStrings. See Note [Deterministic -- UniqFM] in GHC.Types.Unique.DFM for explanation why it's not -- deterministic and why it matters. Use DFastStringEnv if the set -- eventually gets converted into a list or folded over in a way where -- the order changes the generated code. type FastStringEnv a = UniqFM FastString a nameUnique :: Name -> Unique setNameUnique :: Name -> Unique -> Name nameOccName :: Name -> OccName tidyNameOcc :: Name -> OccName -> Name -- | A unique, unambiguous name for something, containing information about -- where that thing originated. data Name -- | A class allowing convenient access to the Name of various -- datatypes class NamedThing a getOccName :: NamedThing a => a -> OccName getName :: NamedThing a => a -> Name occNameString :: OccName -> String mkRecFldSelOcc :: String -> OccName mkVarOccFS :: FastString -> OccName -- | Occurrence Name -- -- In this context that means: "classified (i.e. as a type name, value -- name, etc) but not qualified and not yet resolved" data OccName -- | Other names in the compiler add additional information to an OccName. -- This class provides a consistent way to access the underlying OccName. class HasOccName name occName :: HasOccName name => name -> OccName isNeverRepPolyId :: Id -> Bool transferPolyIdInfo :: Id -> [Var] -> Id -> Id zapStableUnfolding :: Id -> Id zapIdTailCallInfo :: Id -> Id zapIdUsedOnceInfo :: Id -> Id zapIdUsageEnvInfo :: Id -> Id zapIdUsageInfo :: Id -> Id zapIdDemandInfo :: Id -> Id zapFragileIdInfo :: Id -> Id zapLamIdInfo :: Id -> Id updOneShotInfo :: Id -> OneShotInfo -> Id setIdOneShotInfo :: Id -> OneShotInfo -> Id infixl 1 `setIdOneShotInfo` clearOneShotLambda :: Id -> Id setOneShotLambda :: Id -> Id isProbablyOneShotLambda :: Id -> Bool isStateHackType :: Type -> Bool typeOneShot :: Type -> OneShotInfo -- | Should we apply the state hack to values of this Type? stateHackOneShot :: OneShotInfo -- | Returns whether the lambda associated with the Id is certainly -- applied at most once This one is the "business end", called -- externally. It works on type variables as well as Ids, returning True -- Its main purpose is to encapsulate the Horrible State Hack See Note -- [The state-transformer hack] in GHC.Core.Opt.Arity isOneShotBndr :: Var -> Bool -- | Like idOneShotInfo, but taking the Horrible State Hack in to -- account See Note [The state-transformer hack] in -- GHC.Core.Opt.Arity idStateHackOneShotInfo :: Id -> OneShotInfo idOneShotInfo :: Id -> OneShotInfo isConLikeId :: Id -> Bool idRuleMatchInfo :: Id -> RuleMatchInfo setInlineActivation :: Id -> Activation -> Id infixl 1 `setInlineActivation` idInlineActivation :: Id -> Activation modifyInlinePragma :: Id -> (InlinePragma -> InlinePragma) -> Id setInlinePragma :: Id -> InlinePragma -> Id infixl 1 `setInlinePragma` idInlinePragma :: Id -> InlinePragma zapIdOccInfo :: Id -> Id setIdOccInfo :: Id -> OccInfo -> Id infixl 1 `setIdOccInfo` idOccInfo :: Id -> OccInfo setIdLFInfo :: Id -> LambdaFormInfo -> Id idLFInfo_maybe :: Id -> Maybe LambdaFormInfo setIdCafInfo :: Id -> CafInfo -> Id idCafInfo :: Id -> CafInfo infixl 1 `idCafInfo` setIdSpecialisation :: Id -> RuleInfo -> Id infixl 1 `setIdSpecialisation` idHasRules :: Id -> Bool idCoreRules :: Id -> [CoreRule] idSpecialisation :: Id -> RuleInfo setCaseBndrEvald :: StrictnessMark -> Id -> Id idCbvMarkArity :: Id -> Arity idCbvMarks_maybe :: Id -> Maybe [CbvMark] -- | If all marks are NotMarkedStrict we just set nothing. setIdCbvMarks :: Id -> [CbvMark] -> Id infixl 1 `setIdCbvMarks` setIdTagSig :: Id -> TagSig -> Id setIdDemandInfo :: Id -> Demand -> Id infixl 1 `setIdDemandInfo` idDemandInfo :: Id -> Demand setIdUnfolding :: Id -> Unfolding -> Id infixl 1 `setIdUnfolding` -- | Expose the unfolding if there is one, including for loop breakers realIdUnfolding :: Id -> Unfolding -- | Returns the Ids unfolding, but does not expose the unfolding of -- a strong loop breaker. See unfoldingInfo. -- -- If you really want the unfolding of a strong loopbreaker, call -- realIdUnfolding. idUnfolding :: Id -> Unfolding idTagSig_maybe :: Id -> Maybe TagSig -- | This predicate says whether the Id has a strict demand placed -- on it or has a type such that it can always be evaluated strictly (i.e -- an unlifted type, as of GHC 7.6). We need to check separately whether -- the Id has a so-called "strict type" because if the demand for -- the given id hasn't been computed yet but id has a -- strict type, we still want isStrictId id to be True. isStrictId :: Id -> Bool zapIdDmdSig :: Id -> Id setIdCprSig :: Id -> CprSig -> Id infixl 1 `setIdCprSig` idCprSig :: Id -> CprSig setIdDmdSig :: Id -> DmdSig -> Id infixl 1 `setIdDmdSig` -- | Accesses the Id's dmdSigInfo. idDmdSig :: Id -> DmdSig -- | Returns true if an application to n args diverges or throws an -- exception See Note [Dead ends] in GHC.Types.Demand. isDeadEndId :: Var -> Bool idFunRepArity :: Id -> RepArity setIdCallArity :: Id -> Arity -> Id infixl 1 `setIdCallArity` idCallArity :: Id -> Arity setIdArity :: Id -> Arity -> Id infixl 1 `setIdArity` idArity :: Id -> Arity asJoinId_maybe :: Id -> Maybe JoinArity -> Id infixl 1 `asJoinId_maybe` zapJoinId :: Id -> Id asJoinId :: Id -> JoinArity -> JoinId infixl 1 `asJoinId` idJoinArity :: JoinId -> JoinArity isDeadBinder :: Id -> Bool idIsFrom :: Module -> Id -> Bool -- | isImplicitId tells whether an Ids info is implied by -- other declarations, so we don't need to put its signature in an -- interface file, even if it's mentioned in some other interface -- unfolding. isImplicitId :: Id -> Bool -- | Returns True of an Id which may not have a binding, -- even though it is defined in this module. hasNoBinding :: Id -> Bool -- | Get from either the worker or the wrapper Id to the -- DataCon. Currently used only in the desugarer. -- -- INVARIANT: idDataCon (dataConWrapId d) = d: remember, -- dataConWrapId can return either the wrapper or the worker idDataCon :: Id -> DataCon -- | Doesn't return strictness marks isJoinId_maybe :: Var -> Maybe JoinArity isJoinId :: Var -> Bool isDataConId_maybe :: Id -> Maybe DataCon isDataConWrapId_maybe :: Id -> Maybe DataCon isDataConWrapId :: Id -> Bool isDataConWorkId_maybe :: Id -> Maybe DataCon isDataConWorkId :: Id -> Bool isFCallId_maybe :: Id -> Maybe ForeignCall isFCallId :: Id -> Bool isPrimOpId_maybe :: Id -> Maybe PrimOp isDFunId :: Id -> Bool isPrimOpId :: Id -> Bool isClassOpId_maybe :: Id -> Maybe Class isClassOpId :: Id -> Bool isNaughtyRecordSelector :: Id -> Bool isPatSynRecordSelector :: Id -> Bool isDataConRecordSelector :: Id -> Bool isRecordSelector :: Id -> Bool recordSelectorTyCon_maybe :: Id -> Maybe RecSelParent -- | If the Id is that for a record selector, extract the -- sel_tycon. Panic otherwise. recordSelectorTyCon :: Id -> RecSelParent -- | Create a template local for a series of type, but start from a -- specified template local mkTemplateLocalsNum :: Int -> [Type] -> [Id] -- | Create a template local for a series of types mkTemplateLocals :: [Type] -> [Id] mkScaledTemplateLocal :: Int -> Scaled Type -> Id -- | Create a template local: a family of system local Ids in -- bijection with Ints, typically used in unfoldings mkTemplateLocal :: Int -> Type -> Id -- | Workers get local names. CoreTidy will externalise these if -- necessary mkWorkerId :: Unique -> Id -> Type -> Id -- | Like mkUserLocal, but checks if we have a coercion type mkUserLocalOrCoVar :: OccName -> Unique -> Mult -> Type -> SrcSpan -> Id -- | Create a user local Id. These are local Ids (see -- GHC.Types.Var#globalvslocal) with a name and location that the -- user might recognize mkUserLocal :: OccName -> Unique -> Mult -> Type -> SrcSpan -> Id mkSysLocalOrCoVarM :: MonadUnique m => FastString -> Mult -> Type -> m Id mkSysLocalM :: MonadUnique m => FastString -> Mult -> Type -> m Id -- | Like mkSysLocal, but checks to see if we have a covar type mkSysLocalOrCoVar :: FastString -> Unique -> Mult -> Type -> Id -- | Create a system local Id. These are local Ids (see -- Var#globalvslocal) that are created by the compiler out of thin -- air mkSysLocal :: FastString -> Unique -> Mult -> Type -> Id mkExportedVanillaId :: Name -> Type -> Id -- | Create a local Id that is marked as exported. This prevents -- things attached to it from being removed as dead code. See Note -- [Exported LocalIds] mkExportedLocalId :: IdDetails -> Name -> Type -> Id mkLocalIdWithInfo :: HasDebugCallStack => Name -> Mult -> Type -> IdInfo -> Id -- | Like mkLocalId, but checks the type to see if it should make a -- covar mkLocalIdOrCoVar :: Name -> Mult -> Type -> Id -- | Make a local CoVar mkLocalCoVar :: Name -> Type -> CoVar -- | For an explanation of global vs. local Ids, see -- GHC.Types.Var#globalvslocal mkLocalId :: HasDebugCallStack => Name -> Mult -> Type -> Id -- | Make a global Id with no global information but some generic -- IdInfo mkVanillaGlobalWithInfo :: Name -> Type -> IdInfo -> Id -- | Make a global Id without any extra information at all mkVanillaGlobal :: Name -> Type -> Id -- | For an explanation of global vs. local Ids, see -- GHC.Types.Var.Var#globalvslocal mkGlobalId :: IdDetails -> Name -> Type -> IdInfo -> Id maybeModifyIdInfo :: Maybe IdInfo -> Id -> Id modifyIdInfo :: HasDebugCallStack => (IdInfo -> IdInfo) -> Id -> Id setIdInfo :: Id -> IdInfo -> Id localiseId :: Id -> Id -- | Not only does this set the Id Type, it also evaluates -- the type to try and reduce space usage setIdType :: Id -> Type -> Id setIdUnique :: Id -> Unique -> Id setIdName :: Id -> Name -> Id -- | Like scaleIdBy, but skips non-Ids. Useful for scaling a mixed -- list of ids and tyvars. scaleVarBy :: Mult -> Var -> Var scaleIdBy :: Mult -> Id -> Id idScaledType :: Id -> Scaled Type idMult :: Id -> Mult idType :: Id -> Kind idUnique :: Id -> Unique -- | isExportedIdVar means "don't throw this away" isExportedId :: Var -> Bool isGlobalId :: Var -> Bool isLocalId :: Var -> Bool -- | Is this a value-level (i.e., computationally relevant) -- Identifier? Satisfies isId = not . isTyVar. isId :: Var -> Bool setIdMult :: Id -> Mult -> Id updateIdTypeAndMultM :: Monad m => (Type -> m Type) -> Id -> m Id updateIdTypeAndMult :: (Type -> Type) -> Id -> Id updateIdTypeButNotMult :: (Type -> Type) -> Id -> Id -- | If it's a local, make it global globaliseId :: Id -> Id idDetails :: Id -> IdDetails idInfo :: HasDebugCallStack => Id -> IdInfo type JoinId = Id type InVar = Var type InId = Id type OutVar = Var type OutId = Id idName :: Id -> Name -- | Variable -- -- Essentially a typed Name, that may also contain some additional -- information about the Var and its use sites. data Var -- | Identifier type Id = Var substTickish :: Subst -> CoreTickish -> CoreTickish substDVarSet :: HasDebugCallStack => Subst -> DVarSet -> DVarSet substRulesForImportedIds :: Subst -> [CoreRule] -> [CoreRule] -- | Substitutes for the Ids within the RuleInfo given the -- new function Id substRuleInfo :: Subst -> Id -> RuleInfo -> RuleInfo substIdOcc :: Subst -> Id -> Id -- | Substitutes for the Ids within an unfolding NB: substUnfolding -- discards any unfolding without without a Stable source. This is -- usually what we want, but it may be a bit unexpected substUnfolding :: Subst -> Unfolding -> Unfolding -- | Substitutes for the Ids within an unfolding NB: substUnfolding -- discards any unfolding without without a Stable source. This is -- usually what we want, but it may be a bit unexpected substUnfoldingSC :: Subst -> Unfolding -> Unfolding -- | Substitute into some IdInfo with regard to the supplied new -- Id. substIdInfo :: Subst -> Id -> IdInfo -> Maybe IdInfo substIdType :: Subst -> Id -> Id -- | See substCo substCo :: HasCallStack => Subst -> Coercion -> Coercion getTCvSubst :: Subst -> TCvSubst -- | See substTy. substTy :: Subst -> Type -> Type -- | Clone a mutually recursive group of Ids cloneRecIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id]) cloneBndr :: Subst -> Unique -> Var -> (Subst, Var) cloneBndrs :: Subst -> UniqSupply -> [Var] -> (Subst, [Var]) -- | Applies cloneIdBndr to a number of Ids, accumulating a -- final substitution from left to right cloneIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id]) -- | Very similar to substBndr, but it always allocates a new -- Unique for each variable in its output. It substitutes the -- IdInfo though. cloneIdBndr :: Subst -> UniqSupply -> Id -> (Subst, Id) -- | Substitute in a mutually recursive group of Ids substRecBndrs :: Subst -> [Id] -> (Subst, [Id]) -- | Applies substBndr to a number of Vars, accumulating a -- new Subst left-to-right substBndrs :: Subst -> [Var] -> (Subst, [Var]) -- | Substitutes a Var for another one according to the Subst -- given, returning the result and an updated Subst that should be -- used by subsequent substitutions. IdInfo is preserved by this -- process, although it is substituted into appropriately. substBndr :: Subst -> Var -> (Subst, Var) -- | De-shadowing the program is sometimes a useful pre-pass. It can be -- done simply by running over the bindings with an empty substitution, -- because substitution returns a result that has no-shadowing -- guaranteed. -- -- (Actually, within a single type there might still be shadowing, -- because substTy is a no-op for the empty substitution, but -- that's probably OK.) -- -- deShadowBinds :: CoreProgram -> CoreProgram -- | Apply a substitution to an entire CoreBind, additionally -- returning an updated Subst that should be used by subsequent -- substitutions. substBind :: HasDebugCallStack => Subst -> CoreBind -> (Subst, CoreBind) -- | Apply a substitution to an entire CoreBind, additionally -- returning an updated Subst that should be used by subsequent -- substitutions. substBindSC :: HasDebugCallStack => Subst -> CoreBind -> (Subst, CoreBind) -- | substExpr applies a substitution to an entire CoreExpr. -- Remember, you may only apply the substitution once: See Note -- [Substitutions apply only once] in GHC.Core.TyCo.Subst -- -- Do *not* attempt to short-cut in the case of an empty substitution! -- See Note [Extending the Subst] substExpr :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr substExprSC :: HasDebugCallStack => Subst -> CoreExpr -> CoreExpr setInScope :: Subst -> InScopeSet -> Subst -- | Optimized version of extendInScopeList that can be used if you -- are certain all the things being added are Ids and hence none -- are TyVars or CoVars extendInScopeIds :: Subst -> [Id] -> Subst -- | Add the Vars to the in-scope set: see also extendInScope extendInScopeList :: Subst -> [Var] -> Subst -- | Add the Var to the in-scope set: as a side effect, and remove -- any existing substitutions for it extendInScope :: Subst -> Var -> Subst isInScope :: Var -> Subst -> Bool -- | Simultaneously substitute for a bunch of variables No left-right -- shadowing ie the substitution for (x y. e) a1 a2 so neither x nor y -- scope over a1 a2 mkOpenSubst :: InScopeSet -> [(Var, CoreArg)] -> Subst delBndrs :: Subst -> [Var] -> Subst delBndr :: Subst -> Var -> Subst -- | Find the substitution for an Id in the Subst lookupIdSubst :: HasDebugCallStack => Subst -> Id -> CoreExpr -- | Add a substitution as appropriate to each of the terms being -- substituted (whether expressions, types, or coercions). See also -- extendSubst. extendSubstList :: Subst -> [(Var, CoreArg)] -> Subst extendSubstWithVar :: Subst -> Var -> Var -> Subst -- | Add a substitution appropriate to the thing being substituted (whether -- an expression, type, or coercion). See also extendIdSubst, -- extendTvSubst, extendCvSubst extendSubst :: Subst -> Var -> CoreArg -> Subst -- | Adds multiple TyVar substitutions to the Subst: see also -- extendTvSubst extendTvSubstList :: Subst -> [(TyVar, Type)] -> Subst -- | Add a substitution for a TyVar to the Subst The -- TyVar *must* be a real TyVar, and not a CoVar You must ensure -- that the in-scope set is such that GHC.Core.TyCo.Subst Note -- [The substitution invariant] holds after extending the substitution -- like this. extendTvSubst :: Subst -> TyVar -> Type -> Subst -- | Adds multiple Id substitutions to the Subst: see also -- extendIdSubst extendIdSubstList :: Subst -> [(Id, CoreExpr)] -> Subst -- | Add a substitution for an Id to the Subst: you must -- ensure that the in-scope set is such that TyCoSubst Note [The -- substitution invariant] holds after extending the substitution like -- this extendIdSubst :: Subst -> Id -> CoreExpr -> Subst -- | Remove all substitutions for Ids and Vars that might -- have been built up while preserving the in-scope set zapSubstEnv :: Subst -> Subst -- | Find the in-scope set: see GHC.Core.TyCo.Subst Note [The -- substitution invariant] substInScope :: Subst -> InScopeSet mkSubst :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> IdSubstEnv -> Subst mkEmptySubst :: InScopeSet -> Subst emptySubst :: Subst isEmptySubst :: Subst -> Bool -- | A substitution environment, containing Id, TyVar, and -- CoVar substitutions. -- -- Some invariants apply to how you use the substitution: -- --
    --
  1. Note [The substitution invariant] in -- GHC.Core.TyCo.Subst
  2. --
  3. Note [Substitutions apply only once] in -- GHC.Core.TyCo.Subst
  4. --
data Subst Subst :: InScopeSet -> IdSubstEnv -> TvSubstEnv -> CvSubstEnv -> Subst -- | An environment for substituting for Ids type IdSubstEnv = IdEnv CoreExpr extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst -- | A substitution of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type -- | A set of variables that are in scope at some point. -- -- Note that this is a superset of the variables that are -- currently in scope. See Note [The InScopeSet invariant]. -- -- "Secrets of the Glasgow Haskell Compiler inliner" Section 3.2 provides -- the motivation for this abstraction. data InScopeSet -- | isLinear t returns True of a if t is a type -- of (curried) function where at least one argument is linear (or -- otherwise non-unrestricted). We use this function to check whether it -- is safe to eta reduce an Id in CorePrep. It is always safe to return -- True, because True deactivates the optimisation. isLinearType :: Type -> Bool isOneDataConTy :: Mult -> Bool isManyDataConTy :: Mult -> Bool scaledSet :: Scaled a -> b -> Scaled b mkScaled :: Mult -> a -> Scaled a irrelevantMult :: Scaled a -> a -- | Scale a payload by Many; used for type arguments in core tymult :: a -> Scaled a -- | Scale a payload by One linear :: a -> Scaled a -- | Scale a payload by Many unrestricted :: a -> Scaled a -- | Does a TyCon (that is applied to some number of arguments) need -- to be ascribed with an explicit kind signature to resolve ambiguity if -- rendered as a source-syntax type? (See Note [When does a tycon -- application need an explicit kind signature?] for a full -- explanation of what this function checks for.) tyConAppNeedsKindSig :: Bool -> TyCon -> Int -> Bool -- | Does this classify a type allowed to have values? Responds True to -- things like *, TYPE Lifted, TYPE IntRep, TYPE v, Constraint. -- -- True of any sub-kind of OpenTypeKind classifiesTypeWithValues :: Kind -> Bool -- | Tests whether the given type is concrete, i.e. it whether it consists -- only of concrete type constructors, concrete type variables, and -- applications. -- -- See Note [Concrete types] in GHC.Tc.Utils.Concrete. isConcrete :: Type -> Bool -- | Checks that a kind of the form Type, Constraint or -- 'TYPE r is concrete. See isConcrete. -- -- Precondition: The type has kind (TYPE blah). isFixedRuntimeRepKind :: HasDebugCallStack => Kind -> Bool splitVisVarsOfTypes :: [Type] -> Pair TyCoVarSet -- | Retrieve the free variables in this type, splitting them based on -- whether they are used visibly or invisibly. Invisible ones come first. splitVisVarsOfType :: Type -> Pair TyCoVarSet -- | All type constructors occurring in the type; looking through type -- synonyms, but not newtypes. When it finds a Class, it returns the -- class TyCon. tyConsOfType :: Type -> UniqSet TyCon occCheckExpand :: [Var] -> Type -> Maybe Type -- | Looking past all pi-types, does the end result have a fixed runtime -- rep, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete? -- -- Examples: -- -- resultHasFixedRuntimeRep :: Type -> Bool -- | Returns True if a type has a fixed runtime rep, as per Note [Fixed -- RuntimeRep] in GHC.Tc.Utils.Concrete. -- -- This function is equivalent to (isFixedRuntimeRepKind . -- typeKind), but much faster. -- -- Precondition: The type has kind (TYPE blah) typeHasFixedRuntimeRep :: Type -> Bool tcReturnsConstraintKind :: Kind -> Bool -- | Is this kind equivalent to TYPE r (for some unknown r)? -- -- This considers Constraint to be distinct from *. tcIsRuntimeTypeKind :: Kind -> Bool -- | Is this kind equivalent to TYPE (BoxedRep l) for some l -- :: Levity? -- -- This considers Constraint to be distinct from Type. -- For a version that treats them as the same type, see -- isLiftedTypeKind. tcIsBoxedTypeKind :: Kind -> Bool -- | Is this kind equivalent to Type? -- -- This considers Constraint to be distinct from Type. -- For a version that treats them as the same type, see -- isLiftedTypeKind. tcIsLiftedTypeKind :: Kind -> Bool tcIsConstraintKind :: Kind -> Bool tcTypeKind :: HasDebugCallStack => Type -> Kind typeKind :: HasDebugCallStack => Type -> Kind -- | Compare two TyCons. NB: This should never see -- Constraint (as recognized by Kind.isConstraintKindCon) which -- is considered a synonym for Type in Core. See Note [Kind -- Constraint and kind Type] in GHC.Core.Type. See Note -- [nonDetCmpType nondeterminism] nonDetCmpTc :: TyCon -> TyCon -> Ordering nonDetCmpTypesX :: RnEnv2 -> [Type] -> [Type] -> Ordering nonDetCmpTypeX :: RnEnv2 -> Type -> Type -> Ordering nonDetCmpTypes :: [Type] -> [Type] -> Ordering nonDetCmpType :: Type -> Type -> Ordering eqVarBndrs :: RnEnv2 -> [Var] -> [Var] -> Maybe RnEnv2 -- | Type equality on lists of types, looking through type synonyms but not -- newtypes. eqTypes :: [Type] -> [Type] -> Bool -- | Compare types with respect to a (presumably) non-empty RnEnv2. eqTypeX :: RnEnv2 -> Type -> Type -> Bool -- | Type equality on source types. Does not look through -- newtypes, PredTypes or type families, but it does look -- through type synonyms. This first checks that the kinds of the types -- are equal and then checks whether the types are equal, ignoring casts -- and coercions. (The kind check is a recursive call, but since all -- kinds have type Type, there is no need to check the types of -- kinds.) See also Note [Non-trivial definitional equality] in -- GHC.Core.TyCo.Rep. eqType :: Type -> Type -> Bool seqTypes :: [Type] -> () seqType :: Type -> () -- | Determine whether a type could be the type of a join point of given -- total arity, according to the polymorphism rule. A join point cannot -- be polymorphic in its return type, since given join j a b x y -- z = e1 in e2, the types of e1 and e2 must be the same, and a and b are -- not in scope for e2. (See Note [The polymorphism rule of join points] -- in GHC.Core.) Returns False also if the type simply doesn't -- have enough arguments. -- -- Note that we need to know how many arguments (type *and* value) the -- putative join point takes; for instance, if j :: forall a. a -> Int -- then j could be a binary join point returning an Int, but it could -- *not* be a unary join point returning a -> Int. -- -- TODO: See Note [Excess polymorphism and join points] isValidJoinPointType :: JoinArity -> Type -> Bool -- | Returns true of types that are opaque to Haskell. isPrimitiveType :: Type -> Bool -- | Computes whether an argument (or let right hand side) should be -- computed strictly or lazily, based only on its type. Currently, it's -- just isUnliftedType. Panics on representation-polymorphic -- types. isStrictType :: HasDebugCallStack => Type -> Bool -- | Check whether a type is a data family type isDataFamilyAppType :: Type -> Bool -- | See Type#type_classification for what an algebraic type is. -- Should only be applied to types, as opposed to e.g. partially -- saturated type constructors isAlgType :: Type -> Bool isUnboxedSumType :: Type -> Bool isUnboxedTupleType :: Type -> Bool -- | Extract the Levity of a type. For example, getLevity_maybe -- Int = Just Lifted, getLevity (Array# Int) = Just -- Unlifted, getLevity Float# = Nothing. -- -- Returns Nothing if this is not possible. Does not look through -- type family applications. getLevity_maybe :: HasDebugCallStack => Type -> Maybe Type -- | Extract the RuntimeRep classifier of a type. For instance, -- getRuntimeRep_maybe Int = LiftedRep. Panics if this is not -- possible. getRuntimeRep :: HasDebugCallStack => Type -> Type -- | Extract the RuntimeRep classifier of a type. For instance, -- getRuntimeRep_maybe Int = Just LiftedRep. Returns -- Nothing if this is not possible. getRuntimeRep_maybe :: HasDebugCallStack => Type -> Maybe Type -- | Drops prefix of RuntimeRep constructors in TyConApps. Useful -- for e.g. dropping 'LiftedRep arguments of unboxed tuple TyCon -- applications: -- -- dropRuntimeRepArgs [ 'LiftedRep, 'IntRep , String, Int] dropRuntimeRepArgs :: [Type] -> [Type] -- | Is this a type of kind RuntimeRep? (e.g. LiftedRep) isRuntimeRepKindedTy :: Type -> Bool -- | See Type#type_classification for what a boxed type is. Panics -- on representation-polymorphic types; See mightBeUnliftedType -- for a more approximate predicate that behaves better in the presence -- of representation polymorphism. isBoxedType :: Type -> Bool -- | Returns: -- -- mightBeUnliftedType :: Type -> Bool -- | Returns: -- -- mightBeLiftedType :: Type -> Bool -- | State token type. isStateType :: Type -> Bool -- | Is the given type definitely unlifted? See -- Type#type_classification for what an unlifted type is. -- -- Panics on representation-polymorphic types; See -- mightBeUnliftedType for a more approximate predicate that -- behaves better in the presence of representation polymorphism. isUnliftedType :: HasDebugCallStack => Type -> Bool -- | Tries to compute the Levity of the given type. Returns either a -- definite Levity, or Nothing if we aren't sure (e.g. the -- type is representation-polymorphic). -- -- Panics if the kind does not have the shape TYPE r. typeLevity_maybe :: HasDebugCallStack => Type -> Maybe Levity buildSynTyCon :: Name -> [KnotTied TyConBinder] -> Kind -> [Role] -> KnotTied Type -> TyCon -- | Does this type classify a core (unlifted) Coercion? At either role -- nominal or representational (t1 ~ t2) See Note [Types for coercions, -- predicates, and evidence] in GHC.Core.TyCo.Rep isCoVarType :: Type -> Bool isFamFreeTy :: Type -> Bool -- | Get the type on the LHS of a coercion induced by a type/data family -- instance. coAxNthLHS :: forall (br :: BranchFlag). CoAxiom br -> Int -> Type -- | Given a family instance TyCon and its arg types, return the -- corresponding family type. E.g: -- --
--   data family T a
--   data instance T (Maybe b) = MkT b
--   
-- -- Where the instance tycon is :RTL, so: -- --
--   mkFamilyTyConApp :RTL Int  =  T (Maybe Int)
--   
mkFamilyTyConApp :: TyCon -> [Type] -> Type -- | Extract a relevant type, if there is one. binderRelevantType_maybe :: TyCoBinder -> Maybe Type tyBinderType :: TyBinder -> Type tyCoBinderType :: TyCoBinder -> Type tyCoBinderVar_maybe :: TyCoBinder -> Maybe TyCoVar -- | Does this binder bind a variable that is not erased? Returns -- True for anonymous binders. isAnonTyCoBinder :: TyCoBinder -> Bool -- | Make an anonymous binder mkAnonBinder :: AnonArgFlag -> Scaled Type -> TyCoBinder isAtomicTy :: Type -> Bool isTauTy :: Type -> Bool -- | Given a Type and a list of argument types to which the -- Type is applied, determine each argument's visibility -- (Inferred, Specified, or Required). -- -- Most of the time, the arguments will be Required, but not -- always. Consider f :: forall a. a -> Type. In f Type -- Bool, the first argument (Type) is Specified and -- the second argument (Bool) is Required. It is -- precisely this sort of higher-rank situation in which -- appTyArgFlags comes in handy, since f Type Bool would -- be represented in Core using AppTys. (See also #15792). appTyArgFlags :: Type -> [Type] -> [ArgFlag] -- | Given a TyCon and a list of argument types to which the -- TyCon is applied, determine each argument's visibility -- (Inferred, Specified, or Required). -- -- Wrinkle: consider the following scenario: -- --
--   T :: forall k. k -> k
--   tyConArgFlags T [forall m. m -> m -> m, S, R, Q]
--   
-- -- After substituting, we get -- --
--   T (forall m. m -> m -> m) :: (forall m. m -> m -> m) -> forall n. n -> n -> n
--   
-- -- Thus, the first argument is invisible, S is visible, -- R is invisible again, and Q is visible. tyConArgFlags :: TyCon -> [Type] -> [ArgFlag] -- | Given a list of things paired with their visibilities, partition the -- things into (invisible things, visible things). partitionInvisibles :: [(a, ArgFlag)] -> ([a], [a]) -- | Given a TyCon and a list of argument types, filter out any -- Inferred arguments. filterOutInferredTypes :: TyCon -> [Type] -> [Type] -- | Given a TyCon and a list of argument types, filter out any -- invisible (i.e., Inferred or Specified) arguments. filterOutInvisibleTypes :: TyCon -> [Type] -> [Type] -- | Same as splitInvisPiTys, but stop when - you have found -- n TyCoBinders, - or you run out of invisible binders splitInvisPiTysN :: Int -> Type -> ([TyCoBinder], Type) -- | Like splitPiTys, but returns only *invisible* binders, -- including constraints. Stops at the first visible binder. splitInvisPiTys :: Type -> ([TyCoBinder], Type) invisibleTyBndrCount :: Type -> Int -- | Like splitPiTys but split off only named binders and -- returns TyCoVarBinders rather than TyCoBinders splitForAllTyCoVarBinders :: Type -> ([TyCoVarBinder], Type) -- | Extracts a list of run-time arguments from a function type, looking -- through newtypes to the right of arrows. -- -- Examples: -- --
--   newtype Identity a = I a
--   
--   getRuntimeArgTys (Int -> Bool -> Double) == [(Int, VisArg), (Bool, VisArg)]
--   getRuntimeArgTys (Identity Int -> Bool -> Double) == [(Identity Int, VisArg), (Bool, VisArg)]
--   getRuntimeArgTys (Int -> Identity (Bool -> Identity Double)) == [(Int, VisArg), (Bool, VisArg)]
--   getRuntimeArgTys (forall a. Show a => Identity a -> a -> Int -> Bool) == [(Show a, InvisArg), (Identity a, VisArg),(a, VisArg),(Int, VisArg)]
--   
-- -- Note that, in the last case, the returned types might mention an -- out-of-scope type variable. This function is used only when we really -- care about the kinds of the returned types, so this is OK. -- -- -- --
--   newtype N a = MkN (a -> N a)
--   getRuntimeArgTys (N a) == repeat (a, VisArg)
--   
getRuntimeArgTys :: Type -> [(Type, AnonArgFlag)] -- | Split off all TyCoBinders to a type, splitting both proper foralls and -- functions splitPiTys :: Type -> ([TyCoBinder], Type) -- | Takes a forall type apart, or panics splitPiTy :: Type -> (TyCoBinder, Type) -- | Attempts to take a forall type apart; works with proper foralls and -- functions splitPiTy_maybe :: Type -> Maybe (TyCoBinder, Type) -- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a -- covar binder. splitForAllCoVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Like splitForAllTyCoVar_maybe, but only returns Just if it is a -- tyvar binder. splitForAllTyVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Attempts to take a forall type apart, but only if it's a proper -- forall, with a named binder splitForAllTyCoVar_maybe :: Type -> Maybe (TyCoVar, Type) -- | Drops all ForAllTys dropForAlls :: Type -> Type -- | Take a forall type apart, or panics if that is not possible. splitForAllTyCoVar :: Type -> (TyCoVar, Type) -- | Is this a function? isFunTy :: Type -> Bool -- | Is this a function or forall? isPiTy :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a covar binder isForAllTy_co :: Type -> Bool -- | Like isForAllTy, but returns True only if it is a tyvar binder isForAllTy_ty :: Type -> Bool -- | Checks whether this is a proper forall (with a named binder) isForAllTy :: Type -> Bool -- | Like splitForAllTyCoVars, but only splits ForAllTys with -- Invisible type variable binders. Furthermore, each returned -- tyvar is annotated with its Specificity. splitForAllInvisTVBinders :: Type -> ([InvisTVBinder], Type) -- | Like splitForAllTyCoVars, but only splits ForAllTys with -- Required type variable binders. Furthermore, each returned -- tyvar is annotated with (). splitForAllReqTVBinders :: Type -> ([ReqTVBinder], Type) -- | Take a ForAllTy apart, returning the list of tycovars and the result -- type. This always succeeds, even if it returns only an empty list. -- Note that the result type returned may have free variables that were -- bound by a forall. splitForAllTyCoVars :: Type -> ([TyCoVar], Type) -- | Given a list of type-level vars and the free vars of a result kind, -- makes TyCoBinders, preferring anonymous binders if the variable is, in -- fact, not dependent. e.g. mkTyConBindersPreferAnon -- (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon -- -- All non-coercion binders are visible. mkTyConBindersPreferAnon :: [TyVar] -> TyCoVarSet -> [TyConBinder] -- | Like mkForAllTys, but assumes all variables are dependent and visible mkVisForAllTys :: [TyVar] -> Type -> Type -- | Like mkForAllTys, but assumes all variables are dependent and -- Specified, a common case mkSpecForAllTys :: [TyVar] -> Type -> Type -- | Like mkForAllTy, but assumes the variable is dependent and -- Specified, a common case mkSpecForAllTy :: TyVar -> Type -> Type -- | Like mkTyCoInvForAllTys, but tvs should be a list of tyvar mkInfForAllTys :: [TyVar] -> Type -> Type -- | Like mkForAllTys, but assumes all variables are dependent and -- Inferred, a common case mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type -- | Like mkTyCoInvForAllTy, but tv should be a tyvar mkInfForAllTy :: TyVar -> Type -> Type -- | Make a dependent forall over an Inferred variable mkTyCoInvForAllTy :: TyCoVar -> Type -> Type stripCoercionTy :: Type -> Coercion isCoercionTy_maybe :: Type -> Maybe Coercion mkCoercionTy :: Coercion -> Type tyConBindersTyCoBinders :: [TyConBinder] -> [TyCoBinder] splitCastTy_maybe :: Type -> Maybe (Type, Coercion) -- | Unwrap one layer of newtype on a type constructor and its -- arguments, using an eta-reduced version of the newtype if -- possible. This requires tys to have at least newTyConInstArity -- tycon elements. newTyConInstRhs :: TyCon -> [Type] -> Type -- | Attempts to tease a list type apart and gives the type of the elements -- if successful (looks through type synonyms) splitListTyConApp_maybe :: Type -> Maybe Type -- | Like tcSplitTyConApp_maybe, but doesn't look through synonyms. -- This assumes the synonyms have already been dealt with. -- -- Moreover, for a FunTy, it only succeeds if the argument types have -- enough info to extract the runtime-rep arguments that the funTyCon -- requires. This will usually be true; but may be temporarily false -- during canonicalization: see Note [Decomposing FunTy] in -- GHC.Tc.Solver.Canonical and Note [The Purely Kinded Type Invariant -- (PKTI)] in GHC.Tc.Gen.HsType, Wrinkle around FunTy tcRepSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) -- | Like splitTyConApp_maybe, but doesn't look through synonyms. -- This assumes the synonyms have already been dealt with. repSplitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) -- | Split a type constructor application into its type constructor and -- applied types. Note that this may fail in the case of a FunTy -- with an argument of unknown kind FunTy (e.g. FunTy (a :: k) -- Int. since the kind of a isn't of the form TYPE -- rep). Consequently, you may need to zonk your type before using -- this function. -- -- This does *not* split types headed with (=>), as that's not a TyCon -- in the type-checker. -- -- If you only need the TyCon, consider using -- tcTyConAppTyCon_maybe. tcSplitTyConApp_maybe :: HasCallStack => Type -> Maybe (TyCon, [Type]) -- | Attempts to tease a type apart into a type constructor and the -- application of a number of arguments to that constructor. Panics if -- that is not possible. See also splitTyConApp_maybe splitTyConApp :: Type -> (TyCon, [Type]) tyConAppArgN :: Int -> Type -> Type tyConAppArgs :: Type -> [Type] -- | The same as snd . splitTyConApp tyConAppArgs_maybe :: Type -> Maybe [Type] tyConAppTyCon :: HasDebugCallStack => Type -> TyCon -- | Retrieve the tycon heading this type, if there is one. Does not -- look through synonyms. tyConAppTyConPicky_maybe :: Type -> Maybe TyCon applyTysX :: [TyVar] -> Type -> [Type] -> Type -- | (piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn) -- where f :: f_ty piResultTys is interesting because: 1. -- f_ty may have more for-alls than there are args 2. Less -- obviously, it may have fewer for-alls For case 2. think of: -- piResultTys (forall a.a) [forall b.b, Int] This really can happen, but -- only (I think) in situations involving undefined. For example: -- undefined :: forall a. a Term: undefined (forall b. b->b) -- Int This term should have type (Int -> Int), but notice that -- there are more type args than foralls in undefineds type. piResultTys :: HasDebugCallStack => Type -> [Type] -> Type -- | Just like piResultTys but for a single argument Try not to -- iterate piResultTy, because it's inefficient to substitute one -- variable at a time; instead use 'piResultTys" -- -- Extract the function argument type and panic if that is not possible funArgTy :: Type -> Type -- | Extract the function result type and panic if that is not possible funResultTy :: Type -> Type splitFunTys :: Type -> ([Scaled Type], Type) -- | Attempts to extract the multiplicity, argument and result types from a -- type splitFunTy_maybe :: Type -> Maybe (Mult, Type, Type) -- | Attempts to extract the multiplicity, argument and result types from a -- type, and panics if that is not possible. See also -- splitFunTy_maybe splitFunTy :: Type -> (Mult, Type, Type) -- | Render a type corresponding to a user type error into a SDoc. pprUserTypeErrorTy :: Type -> SDoc -- | Is this type a custom user error? If so, give us the kind and the -- error message. userTypeError_maybe :: Type -> Maybe Type -- | Is this a type literal (symbol, numeric, or char)? isLitTy :: Type -> Maybe TyLit -- | Is this a char literal? We also look through type synonyms. isCharLitTy :: Type -> Maybe Char mkCharLitTy :: Char -> Type -- | Is this a symbol literal. We also look through type synonyms. isStrLitTy :: Type -> Maybe FastString mkStrLitTy :: FastString -> Type -- | Is this a numeric literal. We also look through type synonyms. isNumLitTy :: Type -> Maybe Integer mkNumLitTy :: Integer -> Type -- | Like splitAppTys, but doesn't look through type synonyms repSplitAppTys :: HasDebugCallStack => Type -> (Type, [Type]) -- | Recursively splits a type as far as is possible, leaving a residual -- type being applied to and the type arguments applied to it. Never -- fails, even if that means returning an empty list of type -- applications. splitAppTys :: Type -> (Type, [Type]) -- | Attempts to take a type application apart, as in -- splitAppTy_maybe, and panics if this is not possible splitAppTy :: Type -> (Type, Type) -- | Does the AppTy split as in tcSplitAppTy_maybe, but assumes -- that any coreView stuff is already done. Refuses to look through (c -- => t) tcRepSplitAppTy_maybe :: Type -> Maybe (Type, Type) -- | Does the AppTy split as in splitAppTy_maybe, but assumes that -- any Core view stuff is already done repSplitAppTy_maybe :: HasDebugCallStack => Type -> Maybe (Type, Type) -- | Attempt to take a type application apart, whether it is a function, -- type constructor, or plain type application. Note that type family -- applications are NEVER unsaturated by this! splitAppTy_maybe :: Type -> Maybe (Type, Type) mkAppTys :: Type -> [Type] -> Type -- | Attempts to obtain the type variable underlying a Type, without -- any expansion repGetTyVar_maybe :: Type -> Maybe TyVar -- | If the type is a tyvar, possibly under a cast, returns it, along with -- the coercion. Thus, the co is :: kind tv ~N kind ty getCastedTyVar_maybe :: Type -> Maybe (TyVar, CoercionN) -- | Attempts to obtain the type variable underlying a Type getTyVar_maybe :: Type -> Maybe TyVar isTyVarTy :: Type -> Bool -- | Attempts to obtain the type variable underlying a Type, and -- panics with the given message if this is not a type variable type. See -- also getTyVar_maybe getTyVar :: String -> Type -> TyVar mapTyCoX :: Monad m => TyCoMapper env m -> (env -> Type -> m Type, env -> [Type] -> m [Type], env -> Coercion -> m Coercion, env -> [Coercion] -> m [Coercion]) mapTyCo :: Monad m => TyCoMapper () m -> (Type -> m Type, [Type] -> m [Type], Coercion -> m Coercion, [Coercion] -> m [Coercion]) -- | Is a tyvar of type Multiplicity? isMultiplicityVar :: TyVar -> Bool -- | Is a tyvar of type Levity? isLevityVar :: TyVar -> Bool -- | Is a tyvar of type RuntimeRep? isRuntimeRepVar :: TyVar -> Bool isUnliftedLevity :: Type -> Bool isLiftedLevity :: Type -> Bool -- | Check whether a type of kind RuntimeRep is unlifted. -- -- isUnliftedRuntimeRep :: Type -> Bool -- | Check whether a type of kind RuntimeRep is lifted. -- -- isLiftedRuntimeRep is: -- -- isLiftedRuntimeRep :: Type -> Bool -- | Check whether a type of kind RuntimeRep is lifted, unlifted, or -- unknown. -- -- isLiftedRuntimeRep rr returns: -- -- runtimeRepLevity_maybe :: Type -> Maybe Levity -- | See isBoxedRuntimeRep_maybe. isBoxedRuntimeRep :: Type -> Bool -- | Returns True if the kind classifies unlifted types (like 'Int#') and -- False otherwise. Note that this returns False for -- representation-polymorphic kinds, which may be specialized to a kind -- that classifies unlifted types. isUnliftedTypeKind :: Kind -> Bool pickyIsLiftedTypeKind :: Kind -> Bool -- | Returns True if the kind classifies types which are allocated on the -- GC'd heap and False otherwise. Note that this returns False for -- representation-polymorphic kinds, which may be specialized to a kind -- that classifies AddrRep or even unboxed kinds. isBoxedTypeKind :: Kind -> Bool -- | Given a kind (TYPE rr), extract its RuntimeRep classifier rr. For -- example, kindRep_maybe * = Just LiftedRep Returns -- Nothing if the kind is not of form (TYPE rr) Treats * and -- Constraint as the same kindRep_maybe :: HasDebugCallStack => Kind -> Maybe Type -- | Extract the RuntimeRep classifier of a type from its kind. For -- example, kindRep * = LiftedRep; Panics if this is not -- possible. Treats * and Constraint as the same kindRep :: HasDebugCallStack => Kind -> Type -- | Expand out all type synonyms. Actually, it'd suffice to expand out -- just the ones that discard type variables (e.g. type Funny a = Int) -- But we don't know which those are currently, so we just expand all. -- -- expandTypeSynonyms only expands out type synonyms mentioned in -- the type, not in the kinds of any TyCon or TyVar mentioned in the -- type. -- -- Keep this synchronized with synonymTyConsOfType expandTypeSynonyms :: Type -> Type pattern One :: Mult pattern Many :: Mult -- | This describes how a "map" operation over a type/coercion should -- behave data TyCoMapper env (m :: Type -> Type) TyCoMapper :: (env -> TyVar -> m Type) -> (env -> CoVar -> m Coercion) -> (env -> CoercionHole -> m Coercion) -> (env -> TyCoVar -> ArgFlag -> m (env, TyCoVar)) -> (TyCon -> m TyCon) -> TyCoMapper env (m :: Type -> Type) [tcm_tyvar] :: TyCoMapper env (m :: Type -> Type) -> env -> TyVar -> m Type [tcm_covar] :: TyCoMapper env (m :: Type -> Type) -> env -> CoVar -> m Coercion -- | What to do with coercion holes. See Note [Coercion holes] in -- GHC.Core.TyCo.Rep. [tcm_hole] :: TyCoMapper env (m :: Type -> Type) -> env -> CoercionHole -> m Coercion -- | The returned env is used in the extended scope [tcm_tycobinder] :: TyCoMapper env (m :: Type -> Type) -> env -> TyCoVar -> ArgFlag -> m (env, TyCoVar) -- | This is used only for TcTyCons a) To zonk TcTyCons b) To turn TcTyCons -- into TyCons. See Note [Type checking recursive type and class -- declarations] in GHC.Tc.TyCl [tcm_tycon] :: TyCoMapper env (m :: Type -> Type) -> TyCon -> m TyCon -- | The FUN type constructor. -- --
--   FUN :: forall (m :: Multiplicity) ->
--          forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}.
--          TYPE rep1 -> TYPE rep2 -> *
--   
-- -- The runtime representations quantification is left inferred. This -- means they cannot be specified with -XTypeApplications. -- -- This is a deliberate choice to allow future extensions to the function -- arrow. To allow visible application a type synonym can be defined: -- --
--   type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep).
--               TYPE rep1 -> TYPE rep2 -> Type
--   type Arr = FUN 'Many
--   
funTyCon :: TyCon substTyCoBndr :: TCvSubst -> TyCoBinder -> (TCvSubst, TyCoBinder) cloneTyVarBndrs :: TCvSubst -> [TyVar] -> UniqSupply -> (TCvSubst, [TyVar]) cloneTyVarBndr :: TCvSubst -> TyVar -> Unique -> (TCvSubst, TyVar) substVarBndrs :: HasDebugCallStack => TCvSubst -> [TyCoVar] -> (TCvSubst, [TyCoVar]) substVarBndr :: HasDebugCallStack => TCvSubst -> TyCoVar -> (TCvSubst, TyCoVar) substTyVarBndrs :: HasDebugCallStack => TCvSubst -> [TyVar] -> (TCvSubst, [TyVar]) substTyVarBndr :: HasDebugCallStack => TCvSubst -> TyVar -> (TCvSubst, TyVar) -- | Substitute within a Coercion disabling sanity checks. The -- problems that the sanity checks in substCo catch are described in Note -- [The substitution invariant]. The goal of #11371 is to migrate all the -- calls of substCoUnchecked to substCo and remove this function. Please -- don't use in new code. substCoUnchecked :: TCvSubst -> Coercion -> Coercion lookupTyVar :: TCvSubst -> TyVar -> Maybe Type substTyVars :: TCvSubst -> [TyVar] -> [Type] substTyVar :: TCvSubst -> TyVar -> Type -- | Substitute within a ThetaType disabling the sanity checks. The -- problems that the sanity checks in substTys catch are described in -- Note [The substitution invariant]. The goal of #11371 is to migrate -- all the calls of substThetaUnchecked to substTheta and remove this -- function. Please don't use in new code. substThetaUnchecked :: TCvSubst -> ThetaType -> ThetaType -- | Substitute within a ThetaType The substitution has to satisfy -- the invariants described in Note [The substitution invariant]. substTheta :: HasDebugCallStack => TCvSubst -> ThetaType -> ThetaType substScaledTysUnchecked :: TCvSubst -> [Scaled Type] -> [Scaled Type] -- | Substitute within several Types disabling the sanity checks. -- The problems that the sanity checks in substTys catch are described in -- Note [The substitution invariant]. The goal of #11371 is to migrate -- all the calls of substTysUnchecked to substTys and remove this -- function. Please don't use in new code. substTysUnchecked :: TCvSubst -> [Type] -> [Type] substScaledTys :: HasDebugCallStack => TCvSubst -> [Scaled Type] -> [Scaled Type] -- | Substitute within several Types The substitution has to satisfy -- the invariants described in Note [The substitution invariant]. substTys :: HasDebugCallStack => TCvSubst -> [Type] -> [Type] substScaledTyUnchecked :: HasDebugCallStack => TCvSubst -> Scaled Type -> Scaled Type substScaledTy :: HasDebugCallStack => TCvSubst -> Scaled Type -> Scaled Type -- | Substitute within a Type disabling the sanity checks. The -- problems that the sanity checks in substTy catch are described in Note -- [The substitution invariant]. The goal of #11371 is to migrate all the -- calls of substTyUnchecked to substTy and remove this function. Please -- don't use in new code. substTyUnchecked :: TCvSubst -> Type -> Type -- | Substitute within a Type after adding the free variables of the -- type to the in-scope set. This is useful for the case when the free -- variables aren't already in the in-scope set or easily available. See -- also Note [The substitution invariant]. substTyAddInScope :: TCvSubst -> Type -> Type -- | Type substitution, see zipTvSubst substTysWith :: [TyVar] -> [Type] -> [Type] -> [Type] -- | Coercion substitution, see zipTvSubst. Disables sanity checks. -- The problems that the sanity checks in substCo catch are described in -- Note [The substitution invariant]. The goal of #11371 is to migrate -- all the calls of substCoUnchecked to substCo and remove this function. -- Please don't use in new code. substCoWithUnchecked :: [TyVar] -> [Type] -> Coercion -> Coercion -- | Type substitution, see zipTvSubst. Disables sanity checks. The -- problems that the sanity checks in substTy catch are described in Note -- [The substitution invariant]. The goal of #11371 is to migrate all the -- calls of substTyUnchecked to substTy and remove this function. Please -- don't use in new code. substTyWithUnchecked :: [TyVar] -> [Type] -> Type -> Type -- | Type substitution, see zipTvSubst substTyWith :: HasDebugCallStack => [TyVar] -> [Type] -> Type -> Type zipCoEnv :: HasDebugCallStack => [CoVar] -> [Coercion] -> CvSubstEnv zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv -- | Generates the in-scope set for the TCvSubst from the types in -- the incoming environment. No CoVars, please! mkTvSubstPrs :: [(TyVar, Type)] -> TCvSubst zipTCvSubst :: HasDebugCallStack => [TyCoVar] -> [Type] -> TCvSubst -- | Generates the in-scope set for the TCvSubst from the types in -- the incoming environment. No CoVars, please! zipTvSubst :: HasDebugCallStack => [TyVar] -> [Type] -> TCvSubst unionTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst extendTCvSubstList :: TCvSubst -> [Var] -> [Type] -> TCvSubst extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst extendCvSubst :: TCvSubst -> CoVar -> Coercion -> TCvSubst extendTvSubstWithClone :: TCvSubst -> TyVar -> TyVar -> TCvSubst extendTvSubstBinderAndInScope :: TCvSubst -> TyCoBinder -> Type -> TCvSubst extendTCvSubstWithClone :: TCvSubst -> TyCoVar -> TyCoVar -> TCvSubst extendTCvSubst :: TCvSubst -> TyCoVar -> Type -> TCvSubst extendTCvInScopeSet :: TCvSubst -> VarSet -> TCvSubst extendTCvInScopeList :: TCvSubst -> [Var] -> TCvSubst extendTCvInScope :: TCvSubst -> Var -> TCvSubst zapTCvSubst :: TCvSubst -> TCvSubst setTvSubstEnv :: TCvSubst -> TvSubstEnv -> TCvSubst notElemTCvSubst :: Var -> TCvSubst -> Bool -- | Returns the free variables of the types in the range of a substitution -- as a non-deterministic set. getTCvSubstRangeFVs :: TCvSubst -> VarSet getTCvInScope :: TCvSubst -> InScopeSet getTvSubstEnv :: TCvSubst -> TvSubstEnv mkTCvSubst :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> TCvSubst isEmptyTCvSubst :: TCvSubst -> Bool mkEmptyTCvSubst :: InScopeSet -> TCvSubst emptyTCvSubst :: TCvSubst -- | Composes two substitutions, applying the second one provided first, -- like in function composition. composeTCvSubst :: TCvSubst -> TCvSubst -> TCvSubst -- | (compose env1 env2)(x) is env1(env2(x)); i.e. apply -- env2 then env1. It assumes that both are idempotent. -- Typically, env1 is the refinement to a base substitution -- env2 composeTCvSubstEnv :: InScopeSet -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv) -> (TvSubstEnv, CvSubstEnv) emptyTvSubstEnv :: TvSubstEnv -- | Type & coercion substitution -- -- The following invariants must hold of a TCvSubst: -- --
    --
  1. The in-scope set is needed only to guide the generation of -- fresh uniques
  2. --
  3. In particular, the kind of the type variables in the -- in-scope set is not relevant
  4. --
  5. The substitution is only applied ONCE! This is because in general -- such application will not reach a fixed point.
  6. --
data TCvSubst TCvSubst :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> TCvSubst -- | A substitution of Types for TyVars and Kinds for -- KindVars type TvSubstEnv = TyVarEnv Type -- | Calls tidyType on a top-level type (i.e. with an empty tidying -- environment) tidyTopType :: Type -> Type tidyOpenType :: TidyEnv -> Type -> (TidyEnv, Type) -- | Grabs the free type variables, tidies them and then uses -- tidyType to work over the type itself tidyOpenTypes :: TidyEnv -> [Type] -> (TidyEnv, [Type]) -- | Tidy a Type -- -- See Note [Strictness in tidyType and friends] tidyType :: TidyEnv -> Type -> Type -- | Tidy a list of Types -- -- See Note [Strictness in tidyType and friends] tidyTypes :: TidyEnv -> [Type] -> [Type] tidyTyCoVarOcc :: TidyEnv -> TyCoVar -> TyCoVar -- | Treat a new TyCoVar as a binder, and give it a fresh tidy name -- using the environment if one has not already been allocated. See also -- tidyVarBndr tidyOpenTyCoVar :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) tidyOpenTyCoVars :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) -- | Add the free TyVars to the env in tidy form, so that we can -- tidy the type they are free in tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv tidyTyCoVarBinders :: TidyEnv -> [VarBndr TyCoVar vis] -> (TidyEnv, [VarBndr TyCoVar vis]) tidyTyCoVarBinder :: TidyEnv -> VarBndr TyCoVar vis -> (TidyEnv, VarBndr TyCoVar vis) tidyVarBndr :: TidyEnv -> TyCoVar -> (TidyEnv, TyCoVar) -- | This tidies up a type for printing in an error message, or in an -- interface file. -- -- It doesn't change the uniques at all, just the print names. tidyVarBndrs :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar]) -- | Get the free vars of types in scoped order tyCoVarsOfTypesWellScoped :: [Type] -> [TyVar] -- | Get the free vars of a type in scoped order tyCoVarsOfTypeWellScoped :: Type -> [TyVar] -- | Do a topological sort on a list of tyvars, so that binders occur -- before occurrences E.g. given [ a::k, k::*, b::k ] it'll return a -- well-scoped list [ k::*, a::k, b::k ] -- -- This is a deterministic sorting operation (that is, doesn't depend on -- Uniques). -- -- It is also meant to be stable: that is, variables should not be -- reordered unnecessarily. This is specified in Note [ScopedSort] See -- also Note [Ordering of implicit variables] in GHC.Rename.HsType scopedSort :: [TyCoVar] -> [TyCoVar] noFreeVarsOfType :: Type -> Bool anyFreeVarsOfTypes :: (TyCoVar -> Bool) -> [Type] -> Bool anyFreeVarsOfType :: (TyCoVar -> Bool) -> Type -> Bool tyCoFVsVarBndr :: Var -> FV -> FV tyCoFVsVarBndrs :: [Var] -> FV -> FV tyCoFVsBndr :: TyCoVarBinder -> FV -> FV -- | The worker for tyCoFVsOfType and tyCoFVsOfTypeList. -- The previous implementation used unionVarSet which is O(n+m) -- and can make the function quadratic. It's exported, so that it can be -- composed with other functions that compute free variables. See Note -- [FV naming conventions] in GHC.Utils.FV. -- -- Eta-expanded because that makes it run faster (apparently) See Note -- [FV eta expansion] in GHC.Utils.FV for explanation. tyCoFVsOfType :: Type -> FV -- | tyCoFVsOfType that returns free variables of a type in a -- deterministic set. For explanation of why using VarSet is not -- deterministic see Note [Deterministic FV] in GHC.Utils.FV. tyCoVarsOfTypeDSet :: Type -> DTyCoVarSet -- | Add the kind variables free in the kinds of the tyvars in the given -- set. Returns a deterministic set. closeOverKindsDSet :: DTyVarSet -> DTyVarSet -- | Add the kind variables free in the kinds of the tyvars in the given -- set. Returns a deterministically ordered list. closeOverKindsList :: [TyVar] -> [TyVar] closeOverKinds :: TyCoVarSet -> TyCoVarSet coVarsOfTypes :: [Type] -> CoVarSet coVarsOfType :: Type -> CoVarSet tyCoVarsOfTypes :: [Type] -> TyCoVarSet tyCoVarsOfType :: Type -> TyCoVarSet typeSize :: Type -> Int -- | A view function that looks through nothing. noView :: Type -> Maybe Type foldTyCo :: Monoid a => TyCoFolder env a -> env -> (Type -> a, [Type] -> a, Coercion -> a, [Coercion] -> a) mkPiTys :: [TyCoBinder] -> Type -> Type mkPiTy :: TyCoBinder -> Type -> Type -- | Wraps foralls over the type using the provided InvisTVBinders -- from left to right mkInvisForAllTys :: [InvisTVBinder] -> Type -> Type -- | Wraps foralls over the type using the provided TyCoVars from -- left to right mkForAllTys :: [TyCoVarBinder] -> Type -> Type mkInvisFunTysMany :: [Type] -> Type -> Type mkVisFunTysMany :: [Type] -> Type -> Type -- | Make nested arrow types mkVisFunTys :: [Scaled Type] -> Type -> Type mkInvisFunTyMany :: Type -> Type -> Type infixr 3 `mkInvisFunTyMany` -- | Special, common, case: Arrow type with mult Many mkVisFunTyMany :: Type -> Type -> Type infixr 3 `mkVisFunTyMany` mkInvisFunTy :: Mult -> Type -> Type -> Type infixr 3 `mkInvisFunTy` mkVisFunTy :: Mult -> Type -> Type -> Type infixr 3 `mkVisFunTy` mkFunTy :: AnonArgFlag -> Mult -> Type -> Type -> Type infixr 3 `mkFunTy` mkTyVarTys :: [TyVar] -> [Type] mkTyVarTy :: TyVar -> Type isNamedBinder :: TyCoBinder -> Bool -- | Does this binder bind a visible argument? isVisibleBinder :: TyCoBinder -> Bool -- | Does this binder bind an invisible argument? isInvisibleBinder :: TyCoBinder -> Bool -- | The key representation of types within the compiler type KindOrType = Type -- | A type labeled KnotTied might have knot-tied tycons in it. See -- Note [Type checking recursive type and class declarations] in -- GHC.Tc.TyCl type KnotTied ty = ty data TyCoFolder env a TyCoFolder :: (Type -> Maybe Type) -> (env -> TyVar -> a) -> (env -> CoVar -> a) -> (env -> CoercionHole -> a) -> (env -> TyCoVar -> ArgFlag -> env) -> TyCoFolder env a [tcf_view] :: TyCoFolder env a -> Type -> Maybe Type [tcf_tyvar] :: TyCoFolder env a -> env -> TyVar -> a [tcf_covar] :: TyCoFolder env a -> env -> CoVar -> a -- | What to do with coercion holes. See Note [Coercion holes] in -- GHC.Core.TyCo.Rep. [tcf_hole] :: TyCoFolder env a -> env -> CoercionHole -> a -- | The returned env is used in the extended scope [tcf_tycobinder] :: TyCoFolder env a -> env -> TyCoVar -> ArgFlag -> env -- | Returns True for the TyCon of the Constraint -- kind. isConstraintKindCon :: TyCon -> Bool -- | Is this a type-level (i.e., computationally irrelevant, thus erasable) -- variable? Satisfies isTyVar = not . isId. isTyVar :: Var -> Bool tyVarKind :: TyVar -> Kind -- | Make many named binders Input vars should be type variables mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis] -- | Make many named binders mkTyCoVarBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis] -- | Make a named binder var should be a type variable mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis -- | Make a named binder mkTyCoVarBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis binderType :: VarBndr TyCoVar argf -> Type binderArgFlag :: VarBndr tv argf -> argf binderVars :: [VarBndr tv argf] -> [tv] binderVar :: VarBndr tv argf -> tv tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ArgFlag] -- | Do these denote the same level of visibility? Required -- arguments are visible, others are not. So this function equates -- Specified and Inferred. Used for printing. sameVis :: ArgFlag -> ArgFlag -> Bool -- | Does this ArgFlag classify an argument that is not written in -- Haskell? isInvisibleArgFlag :: ArgFlag -> Bool -- | Does this ArgFlag classify an argument that is written in -- Haskell? isVisibleArgFlag :: ArgFlag -> Bool -- | Variable Binder -- -- A TyCoVarBinder is the binder of a ForAllTy It's convenient to -- define this synonym here rather its natural home in -- GHC.Core.TyCo.Rep, because it's used in -- GHC.Core.DataCon.hs-boot -- -- A TyVarBinder is a binder with only TyVar type TyCoVarBinder = VarBndr TyCoVar ArgFlag type TyVarBinder = VarBndr TyVar ArgFlag unliftedTypeKind :: Type liftedTypeKind :: Type unrestrictedFunTyCon :: TyCon isPredTy :: HasDebugCallStack => Type -> Bool isCoercionTy :: Type -> Bool -- | Applies a type to another, as in e.g. k a mkAppTy :: Type -> Type -> Type -- | Make a CastTy. The Coercion must be nominal. Checks the -- Coercion for reflexivity, dropping it if it's reflexive. See Note -- [Respecting definitional equality] in GHC.Core.TyCo.Rep mkCastTy :: Type -> Coercion -> Type -- | (mkTyConTy tc) returns (TyConApp tc []) but arranges to share that -- TyConApp among all calls See Note [Sharing nullary TyConApps] in -- GHC.Core.TyCon mkTyConTy :: TyCon -> Type -- | A key function: builds a TyConApp or FunTy as -- appropriate to its arguments. Applies its arguments to the constructor -- from left to right. mkTyConApp :: TyCon -> [Type] -> Type piResultTy :: HasDebugCallStack => Type -> Type -> Type -- | This function strips off the top layer only of a type synonym -- application (if any) its underlying representation type. Returns -- Nothing if there is nothing to look through. This function -- considers Constraint to be a synonym of Type. -- -- This function does not look through type family applications. -- -- By being non-recursive and inlined, this case analysis gets -- efficiently joined onto the case analysis that the caller is already -- doing coreView :: Type -> Maybe Type -- | Gives the typechecker view of a type. This unwraps synonyms but leaves -- Constraint alone. c.f. coreView, which turns -- Constraint into Type. Returns Nothing if no -- unwrapping happens. See also Note [coreView vs tcView] tcView :: Type -> Maybe Type -- | Is this the type RuntimeRep? isRuntimeRepTy :: Type -> Bool -- | Is this the type Levity? isLevityTy :: Type -> Bool -- | Is this the type Multiplicity? isMultiplicityTy :: Type -> Bool -- | This version considers Constraint to be the same as *. Returns True if -- the argument is equivalent to Type/Constraint and False otherwise. See -- Note [Kind Constraint and kind Type] isLiftedTypeKind :: Kind -> Bool mkTYPEapp :: Type -> Type -- | Attempts to tease a type apart into a type constructor and the -- application of a number of arguments to that constructor splitTyConApp_maybe :: HasDebugCallStack => Type -> Maybe (TyCon, [Type]) -- | The same as fst . splitTyConApp tyConAppTyCon_maybe :: Type -> Maybe TyCon -- | Extract the Levity of a type. For example, getLevity Int = -- Lifted, or getLevity (Array# Int) = Unlifted. -- -- Panics if this is not possible. Does not look through type family -- applications. getLevity :: HasDebugCallStack => Type -> Type -- | Given a TyCon and a list of argument types, partition the -- arguments into: -- --
    --
  1. Inferred or Specified (i.e., invisible) arguments -- and
  2. --
  3. Required (i.e., visible) arguments
  4. --
partitionInvisibleTypes :: TyCon -> [Type] -> ([Type], [Type]) -- | Like mkTyCoForAllTy, but does not check the occurrence of the -- binder See Note [Unused coercion variable in ForAllTy] mkForAllTy :: TyCoVar -> ArgFlag -> Type -> Type data Type -- | A TyCoBinder represents an argument to a function. TyCoBinders -- can be dependent (Named) or nondependent (Anon). They -- may also be visible or not. See Note [TyCoBinders] data TyCoBinder -- | A shorthand for data with an attached Mult element (the -- multiplicity). data Scaled a -- | Mult is a type alias for Type. -- -- Mult must contain Type because multiplicity variables are mere type -- variables (of kind Multiplicity) in Haskell. So the simplest -- implementation is to make Mult be Type. -- -- Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) -- - Many: GHC.Types.Many (= manyDataCon) - Multiplication: -- GHC.Types.MultMul (= multMulTyCon) -- -- So that Mult feels a bit more structured, we provide pattern synonyms -- and smart constructors for these. type Mult = Type -- | A type of the form p of constraint kind represents a value -- whose type is the Haskell predicate p, where a predicate is -- what occurs before the => in a Haskell type. -- -- We use PredType as documentation to mark those types that we -- guarantee to have this kind. -- -- It can be expanded into its representation, but: -- -- -- -- Consider these examples: -- --
--   f :: (Eq a) => a -> Int
--   g :: (?x :: Int -> Int) => a -> Int
--   h :: (r\l) => {r} => {l::Int | r}
--   
-- -- Here the Eq a and ?x :: Int -> Int and -- rl are all called "predicates" type PredType = Type -- | The key type representing kinds in the compiler. type Kind = Type -- | A collection of PredTypes type ThetaType = [PredType] -- | Argument Flag -- -- Is something required to appear in source Haskell (Required), -- permitted by request (Specified) (visible type application), or -- prohibited entirely from appearing in source Haskell -- (Inferred)? See Note [VarBndrs, TyCoVarBinders, TyConBinders, -- and visibility] in GHC.Core.TyCo.Rep data ArgFlag Invisible :: Specificity -> ArgFlag Required :: ArgFlag pattern Inferred :: ArgFlag pattern Specified :: ArgFlag -- | The non-dependent version of ArgFlag. See Note [AnonArgFlag] -- Appears here partly so that it's together with its friends ArgFlag and -- ForallVisFlag, but also because it is used in IfaceType, rather early -- in the compilation chain data AnonArgFlag -- | Used for (->): an ordinary non-dependent arrow. The -- argument is visible in source code. VisArg :: AnonArgFlag -- | Used for (=>): a non-dependent predicate arrow. The -- argument is invisible in source code. InvisArg :: AnonArgFlag -- | Variable -- -- Essentially a typed Name, that may also contain some additional -- information about the Var and its use sites. data Var -- | Whether an Invisible argument may appear in source Haskell. data Specificity -- | the argument may not appear in source Haskell, it is only inferred. InferredSpec :: Specificity -- | the argument may appear in source Haskell, but isn't required. SpecifiedSpec :: Specificity -- | Type or kind Variable type TyVar = Var -- | Type or Coercion Variable type TyCoVar = Id -- | Set the type of a CoercionHole setCoHoleType :: CoercionHole -> Type -> CoercionHole hasThisCoercionHoleTy :: Type -> CoercionHole -> Bool -- | Is there a coercion hole in this coercion? hasCoercionHoleCo :: Coercion -> Bool -- | Is there a coercion hole in this type? hasCoercionHoleTy :: Type -> Bool -- | Assuming that two types are the same, ignoring coercions, find a -- nominal coercion between the types. This is useful when optimizing -- transitivity over coercion applications, where splitting two AppCos -- might yield different kinds. See Note [EtaAppCo] in -- GHC.Core.Coercion.Opt. buildCoercion :: Type -> Type -> CoercionN mkReprPrimEqPred :: Type -> Type -> Type -- | Creates a primitive representational type equality predicate with -- explicit kinds mkHeteroReprPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | Creates a primitive type equality predicate with explicit kinds mkHeteroPrimEqPred :: Kind -> Kind -> Type -> Type -> Type -- | Makes a lifted equality predicate at the given role mkPrimEqPredRole :: Role -> Type -> Type -> PredType -- | Creates a primitive type equality predicate. Invariant: the types are -- not Coercions mkPrimEqPred :: Type -> Type -> Type mkHeteroCoercionType :: Role -> Kind -> Kind -> Type -> Type -> Type -- | Retrieve the role from a coercion. coercionRole :: Coercion -> Role -- | Get a coercion's kind and role. coercionKindRole :: Coercion -> (Pair Type, Role) -- | Apply coercionKind to multiple Coercions coercionKinds :: [Coercion] -> Pair [Type] -- | Get the InScopeSet from a LiftingContext lcInScopeSet :: LiftingContext -> InScopeSet -- | Extract the underlying substitution from the LiftingContext lcTCvSubst :: LiftingContext -> TCvSubst liftEnvSubstRight :: TCvSubst -> LiftCoEnv -> TCvSubst liftEnvSubstLeft :: TCvSubst -> LiftCoEnv -> TCvSubst lcSubstRight :: LiftingContext -> TCvSubst lcSubstLeft :: LiftingContext -> TCvSubst -- | Apply "sym" to all coercions in a LiftCoEnv swapLiftCoEnv :: LiftCoEnv -> LiftCoEnv substRightCo :: LiftingContext -> Coercion -> Coercion substLeftCo :: LiftingContext -> Coercion -> Coercion -- | Is a var in the domain of a lifting context? isMappedByLC :: TyCoVar -> LiftingContext -> Bool liftCoSubstVarBndrUsing :: (r -> CoercionN) -> (LiftingContext -> Type -> r) -> LiftingContext -> TyCoVar -> (LiftingContext, TyCoVar, r) liftCoSubstTyVar :: LiftingContext -> Role -> TyVar -> Maybe Coercion -- | Like substForAllCoBndr, but works on a lifting context substForAllCoBndrUsingLC :: Bool -> (Coercion -> Coercion) -> LiftingContext -> TyCoVar -> Coercion -> (LiftingContext, TyCoVar, Coercion) -- | Erase the environments in a lifting context zapLiftingContext :: LiftingContext -> LiftingContext -- | Extend a lifting context with a new mapping, and extend the in-scope -- set extendLiftingContextAndInScope :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext -- | Extend a lifting context with a new mapping. extendLiftingContext :: LiftingContext -> TyCoVar -> Coercion -> LiftingContext mkSubstLiftingContext :: TCvSubst -> LiftingContext emptyLiftingContext :: InScopeSet -> LiftingContext liftCoSubstWith :: Role -> [TyCoVar] -> [Coercion] -> Type -> Coercion liftCoSubstWithEx :: Role -> [TyVar] -> [Coercion] -> [TyCoVar] -> [Type] -> (Type -> Coercion, [Type]) -- | Compare two Coercions, with respect to an RnEnv2 eqCoercionX :: RnEnv2 -> Coercion -> Coercion -> Bool -- | Syntactic equality of coercions eqCoercion :: Coercion -> Coercion -> Bool -- | A general function for normalising the top-level of a type. It -- continues to use the provided NormaliseStepper until that -- function fails, and then this function returns. The roles of the -- coercions produced by the NormaliseStepper must all be the -- same, which is the role returned from the call to -- topNormaliseTypeX. -- -- Typically ev is Coercion. -- -- If topNormaliseTypeX step plus ty = Just (ev, ty') then ty ~ev1~ t1 -- ~ev2~ t2 ... ~evn~ ty' and ev = ev1 plus ev2 plus -- ... plus evn If it returns Nothing then no newtype unwrapping -- could happen topNormaliseTypeX :: NormaliseStepper ev -> (ev -> ev -> ev) -> Type -> Maybe (ev, Type) -- | A NormaliseStepper that unwraps newtypes, careful not to fall -- into a loop. If it would fall into a loop, it produces -- NS_Abort. unwrapNewTypeStepper :: NormaliseStepper Coercion -- | Try one stepper and then try the next, if the first doesn't make -- progress. So if it returns NS_Done, it means that both steppers are -- satisfied composeSteppers :: NormaliseStepper ev -> NormaliseStepper ev -> NormaliseStepper ev mapStepResult :: (ev1 -> ev2) -> NormaliseStepResult ev1 -> NormaliseStepResult ev2 -- | If co :: T ts ~ rep_ty then: -- --
--   instNewTyCon_maybe T ts = Just (rep_ty, co)
--   
-- -- Checks for a newtype, and for being saturated instNewTyCon_maybe :: TyCon -> [Type] -> Maybe (Type, Coercion) mkCoCast :: Coercion -> CoercionR -> Coercion mkFunResCo :: Role -> Scaled Type -> Coercion -> Coercion -- | Make a forall Coercion, where both types related by the -- coercion are quantified over the same variable. mkPiCo :: Role -> Var -> Coercion -> Coercion mkPiCos :: Role -> [Var] -> Coercion -> Coercion -- | Given a family instance TyCon and its arg Coercions, -- return the corresponding family Coercion. E.g: -- --
--   data family T a
--   data instance T (Maybe b) = MkT b
--   
-- -- Where the instance TyCon is :RTL, so: -- --
--   mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int)
--   
-- -- cf. mkFamilyTyConApp mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind g h1 h2, where g :: t1 ~r t2, -- has type (t1 |> h1) ~r (t2 |> h2). h1 and -- h2 must be nominal. It calls coercionKindRole, so -- it's quite inefficient (which I stands for) Use -- castCoercionKind2 instead if t1, t2, and -- r are known beforehand. castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion -- | castCoercionKind1 g r t1 t2 h = coercionKind g r t1 t2 h -- h That is, it's a specialised form of castCoercionKind, where the -- two kind coercions are identical castCoercionKind1 g r t1 t2 -- h, where g :: t1 ~r t2, has type (t1 |> h) ~r (t2 -- |> h). h must be nominal. See Note -- [castCoercionKind1] castCoercionKind1 :: Coercion -> Role -> Type -> Type -> CoercionN -> Coercion -- | Creates a new coercion with both of its types casted by different -- casts castCoercionKind2 g r t1 t2 h1 h2, where g :: t1 ~r -- t2, has type (t1 |> h1) ~r (t2 |> h2). h1 -- and h2 must be nominal. castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -- | like mkKindCo, but aggressively & recursively optimizes to avoid -- using a KindCo constructor. The output role is nominal. promoteCoercion :: Coercion -> CoercionN ltRole :: Role -> Role -> Bool nthRole :: Role -> TyCon -> Int -> Role tyConRolesRepresentational :: TyCon -> [Role] tyConRolesX :: Role -> TyCon -> [Role] -- | Converts a coercion to be nominal, if possible. See Note [Role -- twiddling functions] setNominalRole_maybe :: Role -> Coercion -> Maybe Coercion -- | Like downgradeRole_maybe, but panics if the change isn't a -- downgrade. See Note [Role twiddling functions] downgradeRole :: Role -> Role -> Coercion -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty' ~r -- ty, produces @co' :: ty' ~r (ty |> co) It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceRightCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, co2:: ty ~r -- ty', produces @co' :: (ty |> co) ~r ty' It is not only a -- utility function, but it saves allocation when co is a GRefl coercion. mkCoherenceLeftCo :: Role -> Type -> CoercionN -> Coercion -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- (ty |> co) ~r ty mkGReflLeftCo :: Role -> Type -> CoercionN -> Coercion -- | Given ty :: k1, co :: k1 ~ k2, produces co' :: -- ty ~r (ty |> co) mkGReflRightCo :: Role -> Type -> CoercionN -> Coercion -- | If you're about to call mkNthCo r n co, then r -- should be whatever nthCoRole n co returns. nthCoRole :: Int -> Coercion -> Role -- | Extract the nth field of a FunCo mkNthCoFunCo :: Int -> CoercionN -> Coercion -> Coercion -> Coercion -- | Make a coercion from a coercion hole mkHoleCo :: CoercionHole -> Coercion -- | Instantiate the left-hand side of an unbranched axiom mkUnbranchedAxInstLHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type -- | Return the left-hand type of the axiom, when the axiom is instantiated -- at the types given. mkAxInstLHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type mkUnbranchedAxInstRHS :: CoAxiom Unbranched -> [Type] -> [Coercion] -> Type mkAxInstRHS :: forall (br :: BranchFlag). CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Type mkUnbranchedAxInstCo :: Role -> CoAxiom Unbranched -> [Type] -> [Coercion] -> Coercion mkAxInstCo :: forall (br :: BranchFlag). Role -> CoAxiom br -> BranchIndex -> [Type] -> [Coercion] -> Coercion -- | Extract a covar, if possible. This check is dirty. Be ashamed of -- yourself. (It's dirty because it cares about the structure of a -- coercion, which is morally reprehensible.) isCoVar_maybe :: Coercion -> Maybe CoVar mkCoVarCos :: [CoVar] -> [Coercion] -- | Make a Coercion quantified over a type/coercion variable; the variable -- has the same type in both sides of the coercion mkHomoForAllCos :: [TyCoVar] -> Coercion -> Coercion -- | Make nested ForAllCos mkForAllCos :: [(TyCoVar, CoercionN)] -> Coercion -> Coercion -- | Applies multiple Coercions to another Coercion, from -- left to right. See also mkAppCo. mkAppCos :: Coercion -> [Coercion] -> Coercion -- | Make a representational reflexive coercion mkRepReflCo :: Type -> Coercion -- | Extracts the coerced type from a reflexive coercion. This potentially -- walks over the entire coercion, so avoid doing this in a loop. isReflexiveCo_maybe :: Coercion -> Maybe (Type, Role) -- | Returns the type coerced if this coercion is reflexive. Guaranteed to -- work very quickly. Sometimes a coercion can be reflexive, but not -- obviously so. c.f. isReflexiveCo_maybe isReflCo_maybe :: Coercion -> Maybe (Type, Role) -- | Returns the type coerced if this coercion is a generalized reflexive -- coercion. Guaranteed to work very quickly. isGReflCo_maybe :: Coercion -> Maybe (Type, Role) isReflCoVar_maybe :: Var -> Maybe Coercion coVarKind :: CoVar -> Type coVarTypes :: HasDebugCallStack => CoVar -> Pair Type coVarRType :: HasDebugCallStack => CoVar -> Type coVarLType :: HasDebugCallStack => CoVar -> Type -- | Like splitForAllCo_maybe, but only returns Just for covar -- binder splitForAllCo_co_maybe :: Coercion -> Maybe (CoVar, Coercion, Coercion) -- | Like splitForAllCo_maybe, but only returns Just for tyvar -- binder splitForAllCo_ty_maybe :: Coercion -> Maybe (TyVar, Coercion, Coercion) splitForAllCo_maybe :: Coercion -> Maybe (TyCoVar, Coercion, Coercion) splitFunCo_maybe :: Coercion -> Maybe (Coercion, Coercion) -- | Attempt to take a coercion application apart. splitAppCo_maybe :: Coercion -> Maybe (Coercion, Coercion) multToCo :: Mult -> Coercion -- | Attempts to tease a coercion apart into a type constructor and the -- application of a number of coercion arguments to that constructor splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) -- | Attempts to obtain the type variable underlying a Coercion getCoVar_maybe :: Coercion -> Maybe CoVar decomposeFunCo :: HasDebugCallStack => Role -> Coercion -> (CoercionN, Coercion, Coercion) -- | This breaks a Coercion with type T A B C ~ T D E F -- into a list of Coercions of kinds A ~ D, B ~ -- E and E ~ F. Hence: -- --
--   decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c]
--   
decomposeCo :: Arity -> Coercion -> [Role] -> [Coercion] isReflMCo :: MCoercion -> Bool -- | Like mkCoherenceRightCo, but with an MCoercion mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion mkFunResMCo :: Scaled Type -> MCoercionR -> MCoercionR mkPiMCos :: [Var] -> MCoercion -> MCoercion mkHomoForAllMCo :: TyCoVar -> MCoercion -> MCoercion -- | Cast a type by an MCoercion mkCastTyMCo :: Type -> MCoercion -> Type -- | Get the reverse of an MCoercion mkSymMCo :: MCoercion -> MCoercion mkTransMCoR :: Coercion -> MCoercion -> MCoercion mkTransMCoL :: MCoercion -> Coercion -> MCoercion -- | Compose two MCoercions via transitivity mkTransMCo :: MCoercion -> MCoercion -> MCoercion -- | Tests if this MCoercion is obviously generalized reflexive Guaranteed -- to work very quickly. isGReflMCo :: MCoercion -> Bool checkReflexiveMCo :: MCoercion -> MCoercion coToMCo :: Coercion -> MCoercion tidyCoAxBndrsForUser :: TidyEnv -> [Var] -> (TidyEnv, [Var]) pprCoAxBranch :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchLHS :: TyCon -> CoAxBranch -> SDoc pprCoAxBranchUser :: TyCon -> CoAxBranch -> SDoc pprCoAxiom :: forall (br :: BranchFlag). CoAxiom br -> SDoc etaExpandCoAxBranch :: CoAxBranch -> ([TyVar], [Type], Type) setCoVarName :: CoVar -> Name -> CoVar setCoVarUnique :: CoVar -> Unique -> CoVar coVarName :: CoVar -> Name -- | A function to check if we can reduce a type by one step. Used with -- topNormaliseTypeX. type NormaliseStepper ev = RecTcChecker -> TyCon -> [Type] -> NormaliseStepResult ev -- | The result of stepping in a normalisation function. See -- topNormaliseTypeX. data NormaliseStepResult ev -- | Nothing more to do NS_Done :: NormaliseStepResult ev -- | Utter failure. The outer function should fail too. NS_Abort :: NormaliseStepResult ev -- | We stepped, yielding new bits; ^ ev is evidence; Usually a co :: old -- type ~ new type NS_Step :: RecTcChecker -> Type -> ev -> NormaliseStepResult ev type LiftCoEnv = VarEnv Coercion pprParendCo :: Coercion -> SDoc substCoVarBndr :: HasDebugCallStack => TCvSubst -> CoVar -> (TCvSubst, CoVar) lookupCoVar :: TCvSubst -> Var -> Maybe Coercion substCoVars :: TCvSubst -> [CoVar] -> [Coercion] substCoVar :: TCvSubst -> CoVar -> Coercion -- | Substitute within several Coercions The substitution has to -- satisfy the invariants described in Note [The substitution invariant]. substCos :: HasDebugCallStack => TCvSubst -> [Coercion] -> [Coercion] -- | Coercion substitution, see zipTvSubst substCoWith :: HasDebugCallStack => [TyVar] -> [Type] -> Coercion -> Coercion extendTvSubstAndInScope :: TCvSubst -> TyVar -> Type -> TCvSubst getCvSubstEnv :: TCvSubst -> CvSubstEnv emptyCvSubstEnv :: CvSubstEnv -- | A substitution of Coercions for CoVars type CvSubstEnv = CoVarEnv Coercion tidyCos :: TidyEnv -> [Coercion] -> [Coercion] -- | Tidy a Coercion -- -- See Note [Strictness in tidyType and friends] tidyCo :: TidyEnv -> Coercion -> Coercion anyFreeVarsOfCo :: (TyCoVar -> Bool) -> Coercion -> Bool tyCoFVsOfCos :: [Coercion] -> FV tyCoFVsOfCo :: Coercion -> FV -- | Get a deterministic set of the vars free in a coercion tyCoVarsOfCoDSet :: Coercion -> DTyCoVarSet coVarsOfCo :: Coercion -> CoVarSet tyCoVarsOfCos :: [Coercion] -> TyCoVarSet tyCoVarsOfCo :: Coercion -> TyCoVarSet coercionSize :: Coercion -> Int setCoHoleCoVar :: CoercionHole -> CoVar -> CoercionHole coHoleCoVar :: CoercionHole -> CoVar type CoercionR = Coercion type CoercionP = Coercion type MCoercionR = MCoercion -- | A coercion to be filled in by the type-checker. See Note [Coercion -- holes] data CoercionHole CoercionHole :: CoVar -> IORef (Maybe Coercion) -> CoercionHole [ch_co_var] :: CoercionHole -> CoVar [ch_ref] :: CoercionHole -> IORef (Maybe Coercion) -- | Make a reflexive coercion mkReflCo :: Role -> Type -> Coercion -- | Apply a type constructor to a list of coercions. It is the caller's -- responsibility to get the roles correct on argument coercions. mkTyConAppCo :: HasDebugCallStack => Role -> TyCon -> [Coercion] -> Coercion -- | Apply a Coercion to another Coercion. The second -- coercion must be Nominal, unless the first is Phantom. If the first is -- Phantom, then the second can be either Phantom or Nominal. mkAppCo :: Coercion -> Coercion -> Coercion -- | Make a Coercion from a tycovar, a kind coercion, and a body coercion. -- The kind of the tycovar should be the left-hand kind of the kind -- coercion. See Note [Unused coercion variable in ForAllCo] mkForAllCo :: TyCoVar -> CoercionN -> Coercion -> Coercion -- | Build a function Coercion from two other Coercions. That -- is, given co1 :: a ~ b and co2 :: x ~ y produce -- co :: (a -> x) ~ (b -> y). mkFunCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion mkCoVarCo :: CoVar -> Coercion mkAxiomInstCo :: CoAxiom Branched -> BranchIndex -> [Coercion] -> Coercion -- | Make a phantom coercion between two types. The coercion passed in must -- be a nominal coercion between the kinds of the types. mkPhantomCo :: Coercion -> Type -> Type -> Coercion -- | Make a universal coercion between two arbitrary types. mkUnivCo :: UnivCoProvenance -> Role -> Type -> Type -> Coercion -- | Create a symmetric version of the given Coercion that asserts -- equality between the same types but in the other "direction", so a -- kind of t1 ~ t2 becomes the kind t2 ~ t1. mkSymCo :: Coercion -> Coercion -- | Create a new Coercion by composing the two given -- Coercions transitively. (co1 ; co2) mkTransCo :: Coercion -> Coercion -> Coercion mkNthCo :: HasDebugCallStack => Role -> Int -> Coercion -> Coercion mkLRCo :: LeftOrRight -> Coercion -> Coercion -- | Instantiates a Coercion. mkInstCo :: Coercion -> Coercion -> Coercion -- | Make a generalized reflexive coercion mkGReflCo :: Role -> Type -> MCoercionN -> Coercion -- | Make a nominal reflexive coercion mkNomReflCo :: Type -> Coercion -- | Given co :: (a :: k) ~ (b :: k') produce co' :: k ~ -- k'. mkKindCo :: Coercion -> Coercion mkSubCo :: HasDebugCallStack => Coercion -> Coercion -- | Make a "coercion between coercions". mkProofIrrelCo :: Role -> CoercionN -> Coercion -> Coercion -> Coercion mkAxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion -- | Tests if this coercion is obviously a generalized reflexive coercion. -- Guaranteed to work very quickly. isGReflCo :: Coercion -> Bool -- | Tests if this coercion is obviously reflexive. Guaranteed to work very -- quickly. Sometimes a coercion can be reflexive, but not obviously so. -- c.f. isReflexiveCo isReflCo :: Coercion -> Bool -- | Slowly checks if the coercion is reflexive. Don't call this in a loop, -- as it walks over the entire coercion. isReflexiveCo :: Coercion -> Bool decomposePiCos :: HasDebugCallStack => CoercionN -> Pair Type -> [Type] -> ([CoercionN], CoercionN) coVarKindsTypesRole :: HasDebugCallStack => CoVar -> (Kind, Kind, Type, Type, Role) coVarRole :: CoVar -> Role -- | Makes a coercion type from two types: the types whose equality is -- proven by the relevant Coercion mkCoercionType :: Role -> Type -> Type -> Type -- | liftCoSubst role lc ty produces a coercion (at role -- role) that coerces between lc_left(ty) and -- lc_right(ty), where lc_left is a substitution -- mapping type variables to the left-hand types of the mapped coercions -- in lc, and similar for lc_right. liftCoSubst :: HasDebugCallStack => Role -> LiftingContext -> Type -> Coercion seqCo :: Coercion -> () -- | If it is the case that -- --
--   c :: (t1 ~ t2)
--   
-- -- i.e. the kind of c relates t1 and t2, then -- coercionKind c = Pair t1 t2. coercionKind :: Coercion -> Pair Type coercionLKind :: Coercion -> Type coercionRKind :: Coercion -> Type coercionType :: Coercion -> Type -- | Sometimes we want to look through a newtype and get its -- associated coercion. This function strips off newtype layers -- enough to reveal something that isn't a newtype. -- Specifically, here's the invariant: -- --
--   topNormaliseNewType_maybe rec_nts ty = Just (co, ty')
--   
-- -- then (a) co : ty ~ ty'. (b) ty' is not a newtype. -- -- The function returns Nothing for non-newtypes, or -- unsaturated applications -- -- This function does *not* look through type families, because it has no -- access to the type family environment. If you do have that at hand, -- consider to use topNormaliseType_maybe, which should be a drop-in -- replacement for topNormaliseNewType_maybe If topNormliseNewType_maybe -- ty = Just (co, ty'), then co : ty ~R ty' topNormaliseNewType_maybe :: Type -> Maybe (Coercion, Type) data LiftingContext LC :: TCvSubst -> LiftCoEnv -> LiftingContext data Role Nominal :: Role Representational :: Role Phantom :: Role -- | Is this a coercion variable? Satisfies isId v ==> -- isCoVar v == not (isNonCoVarId v). isCoVar :: Var -> Bool mkCoVar :: Name -> Type -> CoVar -- | Coercion Variable type CoVar = Id pickLR :: LeftOrRight -> (a, a) -> a data LeftOrRight CLeft :: LeftOrRight CRight :: LeftOrRight pprCo :: Coercion -> SDoc -- | A Coercion is concrete evidence of the equality/convertibility -- of two types. data Coercion -- | For simplicity, we have just one UnivCo that represents a coercion -- from some type to some other type, with (in general) no restrictions -- on the type. The UnivCoProvenance specifies more exactly what the -- coercion really is and why a program should (or shouldn't!) trust the -- coercion. It is reasonable to consider each constructor of -- UnivCoProvenance as a totally independent coercion form; their -- only commonality is that they don't tell you what types they coercion -- between. (That info is in the UnivCo constructor of -- Coercion. data UnivCoProvenance -- | A semantically more meaningful type to represent what may or may not -- be a useful Coercion. data MCoercion MRefl :: MCoercion MCo :: Coercion -> MCoercion type CoercionN = Coercion type MCoercionN = MCoercion -- | Variable -- -- Essentially a typed Name, that may also contain some additional -- information about the Var and its use sites. data Var -- | Type or Coercion Variable type TyCoVar = Id -- | Unique identifier. -- -- The type of unique identifiers that are used in many places in GHC for -- fast ordering and equality tests. You should generate these with the -- functions from the UniqSupply module -- -- These are sometimes also referred to as "keys" in comments in GHC. data Unique -- | Class of things that we can obtain a Unique from class Uniquable a getUnique :: Uniquable a => a -> Unique type PsWarning = PsMessage type PsError = PsMessage -- | A collection of messages emitted by GHC during error reporting. A -- diagnostic message is typically a warning or an error. See Note -- [Messages]. -- -- INVARIANT: All the messages in this collection must be -- relevant, i.e. their Severity should not be -- SevIgnore. The smart constructor mkMessages will filter -- out any message which Severity is SevIgnore. data Messages e data HsParsedModule -- | Attempt to convert a Template Haskell name to one that GHC can -- understand. Original TH names such as those you get when you use the -- 'foo syntax will be translated to their equivalent GHC name -- exactly. Qualified or unqualified TH names will be dynamically bound -- to names in the module being compiled, if possible. Exact TH names -- will be bound to the name they represent, exactly. thNameToGhcName :: Name -> CoreM (Maybe Name) instance GHC.Types.TyThing.MonadThings GHC.Core.Opt.Monad.CoreM -- | Tidying up Core module GHC.Iface.Tidy data TidyOpts TidyOpts :: !NameCache -> !Bool -> !UnfoldingOpts -> !UnfoldingExposure -> !Bool -> !Bool -> !Maybe StaticPtrOpts -> TidyOpts [opt_name_cache] :: TidyOpts -> !NameCache [opt_collect_ccs] :: TidyOpts -> !Bool [opt_unfolding_opts] :: TidyOpts -> !UnfoldingOpts -- | Which unfoldings to expose [opt_expose_unfoldings] :: TidyOpts -> !UnfoldingExposure -- | trim off the arity, one-shot-ness, strictness etc which were retained -- for the benefit of the code generator [opt_trim_ids] :: TidyOpts -> !Bool -- | Are rules exposed or not? [opt_expose_rules] :: TidyOpts -> !Bool -- | Options for generated static pointers, if enabled (/= Nothing). [opt_static_ptr_opts] :: TidyOpts -> !Maybe StaticPtrOpts data UnfoldingExposure -- | Don't expose unfoldings ExposeNone :: UnfoldingExposure -- | Only expose required unfoldings ExposeSome :: UnfoldingExposure -- | Expose all unfoldings ExposeAll :: UnfoldingExposure tidyProgram :: TidyOpts -> ModGuts -> IO (CgGuts, ModDetails) mkBootModDetailsTc :: Logger -> TcGblEnv -> IO ModDetails instance GHC.Classes.Ord GHC.Iface.Tidy.UnfoldingExposure instance GHC.Classes.Eq GHC.Iface.Tidy.UnfoldingExposure instance GHC.Show.Show GHC.Iface.Tidy.UnfoldingExposure instance GHC.Base.Functor GHC.Iface.Tidy.DFFV instance GHC.Base.Applicative GHC.Iface.Tidy.DFFV instance GHC.Base.Monad GHC.Iface.Tidy.DFFV module GHC.Driver.Config.Tidy initTidyOpts :: HscEnv -> IO TidyOpts initStaticPtrOpts :: HscEnv -> IO StaticPtrOpts module GHC.CoreToStg.Prep corePrepPgm :: HscEnv -> Module -> ModLocation -> CoreProgram -> [TyCon] -> IO CoreProgram corePrepExpr :: HscEnv -> CoreExpr -> IO CoreExpr -- | Create a function that converts Bignum literals into their final -- CoreExpr mkConvertNumLiteral :: HscEnv -> IO (LitNumType -> Integer -> Maybe CoreExpr) instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.Floats instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.OkToSpec instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.FloatingBind instance GHC.Utils.Outputable.Outputable GHC.CoreToStg.Prep.ArgInfo -- | The FamInst type: family instance heads module GHC.Tc.Instance.Family type FamInstEnvs = (FamInstEnv, FamInstEnv) tcGetFamInstEnvs :: TcM FamInstEnvs checkFamInstConsistency :: [Module] -> TcM () tcExtendLocalFamInstEnv :: [FamInst] -> TcM a -> TcM a -- | Like tcLookupDataFamInst_maybe, but returns the arguments back -- if there is no data family to unwrap. Returns a Representational -- coercion tcLookupDataFamInst :: FamInstEnvs -> TyCon -> [TcType] -> (TyCon, [TcType], Coercion) -- | Converts a data family type (eg F [a]) to its representation type (eg -- FList a) and returns a coercion between the two: co :: F [a] ~R FList -- a. tcLookupDataFamInst_maybe :: FamInstEnvs -> TyCon -> [TcType] -> Maybe (TyCon, [TcType], Coercion) -- | If co :: T ts ~ rep_ty then: -- --
--   instNewTyCon_maybe T ts = Just (rep_ty, co)
--   
-- -- Checks for a newtype, and for being saturated Just like -- Coercion.instNewTyCon_maybe, but returns a TcCoercion tcInstNewTyCon_maybe :: TyCon -> [TcType] -> Maybe (TcType, TcCoercion) -- | tcTopNormaliseNewTypeTF_maybe gets rid of top-level newtypes, -- potentially looking through newtype instances. -- -- It is only used by the type inference engine (specifically, when -- solving representational equality), and hence it is careful to unwrap -- only if the relevant data constructor is in scope. That's why it gets -- a GlobalRdrEnv argument. -- -- It is careful not to unwrap data/newtype instances if it can't -- continue unwrapping. Such care is necessary for proper error messages. -- -- It does not look through type families. It does not normalise -- arguments to a tycon. -- -- If the result is Just ((gres, co), rep_ty), then co : ty ~R rep_ty -- gres are the GREs for the data constructors that had to be in scope tcTopNormaliseNewTypeTF_maybe :: FamInstEnvs -> GlobalRdrEnv -> Type -> Maybe ((Bag GlobalRdrElt, TcCoercion), Type) newFamInst :: FamFlavor -> CoAxiom Unbranched -> TcM FamInst -- | Report a list of injectivity errors together with their source -- locations. Looks only at one equation; does not look for conflicts -- *among* equations. reportInjectivityErrors :: DynFlags -> CoAxiom br -> CoAxBranch -> [Bool] -> TcM () -- | Report error message for a pair of equations violating an injectivity -- annotation. No error message if there are no branches. reportConflictingInjectivityErrs :: TyCon -> [CoAxBranch] -> CoAxBranch -> TcM () module GHC.Tc.Errors -- | Report unsolved goals as errors or warnings. We may also turn some -- into deferred run-time errors if `-fdefer-type-errors` is on. reportUnsolved :: WantedConstraints -> TcM (Bag EvBind) -- | Report *all* unsolved goals as errors, even if -fdefer-type-errors is -- on However, do not make any evidence bindings, because we don't have -- any convenient place to put them. NB: Type-level holes are OK, because -- there are no bindings. See Note [Deferring coercion errors to runtime] -- Used by solveEqualities for kind equalities (see Note [Fail fast on -- kind errors] in GHC.Tc.Solver) reportAllUnsolved :: WantedConstraints -> TcM () -- | Report all unsolved goals as warnings (but without deferring any -- errors to run-time). See Note [Safe Haskell Overlapping Instances -- Implementation] in GHC.Tc.Solver warnAllUnsolved :: WantedConstraints -> TcM () warnDefaulting :: TcTyVar -> [Ct] -> Type -> TcM () -- | If the TcSolverReportMsg is a type mismatch between an actual -- and an expected type, return the actual and expected types (in that -- order). -- -- Prefer using this over manually inspecting the -- TcSolverReportMsg datatype if you just want this information, -- as the datatype itself is subject to change across GHC versions. solverReportMsg_ExpectedActuals :: TcSolverReportMsg -> [(Type, Type)] -- | Retrieves all "expected"/"actual" messages from a -- TcSolverReportInfo. -- -- Prefer using this over inspecting the TcSolverReportInfo -- datatype if you just need this information, as the datatype itself is -- subject to change across GHC versions. solverReportInfo_ExpectedActuals :: TcSolverReportInfo -> [(Type, Type)] module GHC.Rename.Fixity type MiniFixityEnv = FastStringEnv (Located Fixity) addLocalFixities :: MiniFixityEnv -> [Name] -> RnM a -> RnM a lookupFixityRn :: Name -> RnM Fixity -- | lookupFixityRn_help returns (True, fixity) if it finds -- a Fixity in a local environment or from an interface file. -- Otherwise, it returns (False, fixity) (e.g., for unbound -- Names or Names without user-supplied fixity -- declarations). lookupFixityRn_help :: Name -> RnM (Bool, Fixity) -- | Look up the fixity of an occurrence of a record field selector. We use -- lookupFixityRn' so that we can specify the OccName as -- the field label, which might be different to the OccName of the -- selector Name if DuplicateRecordFields is in use -- (#1173). lookupFieldFixityRn :: FieldOcc GhcRn -> RnM Fixity lookupTyFixityRn :: LocatedN Name -> RnM Fixity module GHC.Rename.Env newTopSrcBinder :: LocatedN RdrName -> RnM Name lookupLocatedTopBndrRn :: Located RdrName -> RnM (Located Name) lookupLocatedTopBndrRnN :: LocatedN RdrName -> RnM (LocatedN Name) lookupTopBndrRn :: WhatLooking -> RdrName -> RnM Name lookupLocatedTopConstructorRn :: Located RdrName -> RnM (Located Name) lookupLocatedTopConstructorRnN :: LocatedN RdrName -> RnM (LocatedN Name) lookupLocatedOccRn :: GenLocated (SrcSpanAnn' ann) RdrName -> TcRn (GenLocated (SrcSpanAnn' ann) Name) lookupLocatedOccRnConstr :: GenLocated (SrcSpanAnn' ann) RdrName -> TcRn (GenLocated (SrcSpanAnn' ann) Name) lookupLocatedOccRnRecField :: GenLocated (SrcSpanAnn' ann) RdrName -> TcRn (GenLocated (SrcSpanAnn' ann) Name) lookupLocatedOccRnNone :: GenLocated (SrcSpanAnn' ann) RdrName -> TcRn (GenLocated (SrcSpanAnn' ann) Name) lookupOccRn :: RdrName -> RnM Name lookupOccRn_maybe :: RdrName -> RnM (Maybe Name) lookupLocalOccRn_maybe :: RdrName -> RnM (Maybe Name) lookupInfoOccRn :: RdrName -> RnM [Name] lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevel)) lookupLocalOccRn :: RdrName -> RnM Name lookupTypeOccRn :: RdrName -> RnM Name lookupGlobalOccRn :: RdrName -> RnM Name lookupGlobalOccRn_maybe :: RdrName -> RnM (Maybe Name) -- | Result of looking up an occurrence that might be an ambiguous field. data AmbiguousResult -- | Occurrence picked out a single name, which may or may not belong to a -- field (or might be unbound, if an error has been reported already, per -- Note [ Unbound vs Ambiguous Names ]). UnambiguousGre :: GreName -> AmbiguousResult -- | Occurrence picked out two or more fields, and no non-fields. For now -- this is allowed by DuplicateRecordFields in certain circumstances, as -- the type-checker may be able to disambiguate later. AmbiguousFields :: AmbiguousResult -- | Look up a RdrName used as a variable in an expression. -- -- This may be a local variable, global variable, or one or more record -- selector functions. It will not return record fields created with the -- NoFieldSelectors extension (see Note [NoFieldSelectors]). -- -- If the name is not in scope at the term level, but its promoted -- equivalent is in scope at the type level, the lookup will succeed (so -- that the type-checker can report a more informative error later). See -- Note [Promotion]. lookupExprOccRn :: RdrName -> RnM (Maybe GreName) -- | Look up an occurrence of a field in record construction or pattern -- matching (but not update). When the -XDisambiguateRecordFields flag is -- on, take account of the data constructor name to disambiguate which -- field to use. -- -- See Note [DisambiguateRecordFields] and Note [NoFieldSelectors]. lookupRecFieldOcc :: Maybe Name -> RdrName -> RnM Name -- | Look up an occurrence of a field in a record update, returning the -- selector name. -- -- Unlike construction and pattern matching with -- -XDisambiguateRecordFields (see lookupRecFieldOcc), -- there is no data constructor to help disambiguate, so this may be -- ambiguous if the field is in scope multiple times. However we ignore -- non-fields in scope with the same name if -- -XDisambiguateRecordFields is on (see Note -- [DisambiguateRecordFields for updates]). -- -- Here a field is in scope even if NoFieldSelectors was enabled -- at its definition site (see Note [NoFieldSelectors]). lookupRecFieldOcc_update :: DuplicateRecordFields -> RdrName -> RnM AmbiguousResult data ChildLookupResult NameNotFound :: ChildLookupResult IncorrectParent :: Name -> GreName -> [Name] -> ChildLookupResult FoundChild :: Parent -> GreName -> ChildLookupResult -- | Used in export lists to lookup the children. lookupSubBndrOcc_helper :: Bool -> Bool -> Name -> RdrName -> RnM ChildLookupResult -- | Specialised version of msum for RnM ChildLookupResult combineChildLookupResult :: [RnM ChildLookupResult] -> RnM ChildLookupResult data HsSigCtxt TopSigCtxt :: NameSet -> HsSigCtxt LocalBindCtxt :: NameSet -> HsSigCtxt ClsDeclCtxt :: Name -> HsSigCtxt InstDeclCtxt :: NameSet -> HsSigCtxt HsBootCtxt :: NameSet -> HsSigCtxt RoleAnnotCtxt :: NameSet -> HsSigCtxt lookupLocalTcNames :: HsSigCtxt -> SDoc -> RdrName -> RnM [(RdrName, Name)] lookupSigOccRn :: HsSigCtxt -> Sig GhcPs -> LocatedA RdrName -> RnM (LocatedA Name) lookupSigOccRnN :: HsSigCtxt -> Sig GhcPs -> LocatedN RdrName -> RnM (LocatedN Name) -- | Lookup a name in relation to the names in a HsSigCtxt lookupSigCtxtOccRn :: HsSigCtxt -> SDoc -> LocatedA RdrName -> RnM (LocatedA Name) -- | Lookup a name in relation to the names in a HsSigCtxt lookupSigCtxtOccRnN :: HsSigCtxt -> SDoc -> LocatedN RdrName -> RnM (LocatedN Name) lookupInstDeclBndr :: Name -> SDoc -> RdrName -> RnM Name lookupFamInstName :: Maybe Name -> LocatedN RdrName -> RnM (LocatedN Name) lookupConstructorFields :: Name -> RnM [FieldLabel] lookupGreAvailRn :: RdrName -> RnM (Name, AvailInfo) lookupSyntax :: Name -> RnM (SyntaxExpr GhcRn, FreeVars) lookupSyntaxExpr :: Name -> RnM (HsExpr GhcRn, FreeVars) lookupSyntaxNames :: [Name] -> RnM ([HsExpr GhcRn], FreeVars) lookupSyntaxName :: Name -> RnM (Name, FreeVars) lookupIfThenElse :: RnM (Maybe Name) lookupQualifiedDoExpr :: HsStmtContext p -> Name -> RnM (HsExpr GhcRn, FreeVars) lookupQualifiedDo :: HsStmtContext p -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) lookupQualifiedDoName :: HsStmtContext p -> Name -> RnM (Name, FreeVars) lookupNameWithQualifier :: Name -> ModuleName -> RnM (Name, FreeVars) addUsedGRE :: Bool -> GlobalRdrElt -> RnM () addUsedGREs :: [GlobalRdrElt] -> RnM () addUsedDataCons :: GlobalRdrEnv -> TyCon -> RnM () dataTcOccs :: RdrName -> [RdrName] instance GHC.Classes.Eq GHC.Rename.Env.FieldsOrSelectors instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.HsSigCtxt instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.ChildLookupResult instance GHC.Utils.Outputable.Outputable GHC.Rename.Env.DisambigInfo instance GHC.Base.Semigroup GHC.Rename.Env.DisambigInfo instance GHC.Base.Monoid GHC.Rename.Env.DisambigInfo module GHC.Tc.Instance.Class matchGlobalInst :: DynFlags -> Bool -> Class -> [Type] -> TcM ClsInstResult data ClsInstResult NoInstance :: ClsInstResult OneInst :: [TcPredType] -> ([EvExpr] -> EvTerm) -> InstanceWhat -> ClsInstResult [cir_new_theta] :: ClsInstResult -> [TcPredType] [cir_mk_ev] :: ClsInstResult -> [EvExpr] -> EvTerm [cir_what] :: ClsInstResult -> InstanceWhat NotSure :: ClsInstResult data InstanceWhat BuiltinInstance :: InstanceWhat BuiltinEqInstance :: InstanceWhat LocalInstance :: InstanceWhat TopLevInstance :: DFunId -> SafeOverlapping -> InstanceWhat [iw_dfun_id] :: InstanceWhat -> DFunId [iw_safe_over] :: InstanceWhat -> SafeOverlapping safeOverlap :: InstanceWhat -> Bool instanceReturnsDictCon :: InstanceWhat -> Bool -- | Extra information about the parent instance declaration, needed when -- type-checking associated types. The Class is the enclosing -- class, the [TyVar] are the scoped type variable of the instance -- decl. The VarEnv Type maps class variables to their instance -- types. data AssocInstInfo NotAssociated :: AssocInstInfo InClsInst :: Class -> [TyVar] -> VarEnv Type -> AssocInstInfo [ai_class] :: AssocInstInfo -> Class -- | The scoped tyvars of the instance Why scoped? See bind_me in -- checkConsistentFamInst [ai_tyvars] :: AssocInstInfo -> [TyVar] -- | Maps class tyvars to their instance types See Note [Matching in -- the consistent-instantiation check] [ai_inst_env] :: AssocInstInfo -> VarEnv Type isNotAssociated :: AssocInstInfo -> Bool instance GHC.Utils.Outputable.Outputable GHC.Tc.Instance.Class.ClsInstResult instance GHC.Utils.Outputable.Outputable GHC.Tc.Instance.Class.InstanceWhat -- | Monadic definitions for the constraint solver module GHC.Tc.Solver.Monad data TcS a runTcS :: TcS a -> TcM (a, EvBindMap) -- | This variant of runTcS will immediatley fail upon encountering -- an insoluble ct. See Note [Speeding up valid hole-fits]. Its one usage -- site does not need the ev_binds, so we do not return them. runTcSEarlyAbort :: TcS a -> TcM a runTcSWithEvBinds :: EvBindsVar -> TcS a -> TcM a -- | A variant of runTcS that takes and returns an InertSet -- for later resumption of the TcS session. runTcSInerts :: InertSet -> TcS a -> TcM (a, InertSet) failTcS :: TcRnMessage -> TcS a warnTcS :: TcRnMessage -> TcS () addErrTcS :: TcRnMessage -> TcS () wrapTcS :: TcM a -> TcS a -- | This can deal only with equality constraints. runTcSEqualities :: TcS a -> TcM a nestTcS :: TcS a -> TcS a nestImplicTcS :: EvBindsVar -> TcLevel -> TcS a -> TcS a setEvBindsTcS :: EvBindsVar -> TcS a -> TcS a emitImplicationTcS :: TcLevel -> SkolemInfoAnon -> [TcTyVar] -> [EvVar] -> Cts -> TcS TcEvBinds emitTvImplicationTcS :: TcLevel -> SkolemInfoAnon -> [TcTyVar] -> Cts -> TcS () selectNextWorkItem :: TcS (Maybe Ct) getWorkList :: TcS WorkList updWorkListTcS :: (WorkList -> WorkList) -> TcS () pushLevelNoWorkList :: SDoc -> TcS a -> TcS (TcLevel, a) runTcPluginTcS :: TcPluginM a -> TcS a addUsedGRE :: Bool -> GlobalRdrElt -> TcS () addUsedGREs :: [GlobalRdrElt] -> TcS () keepAlive :: Name -> TcS () matchGlobalInst :: DynFlags -> Bool -> Class -> [Type] -> TcS ClsInstResult data ClsInstResult NoInstance :: ClsInstResult OneInst :: [TcPredType] -> ([EvExpr] -> EvTerm) -> InstanceWhat -> ClsInstResult [cir_new_theta] :: ClsInstResult -> [TcPredType] [cir_mk_ev] :: ClsInstResult -> [EvExpr] -> EvTerm [cir_what] :: ClsInstResult -> InstanceWhat NotSure :: ClsInstResult data QCInst QCI :: CtEvidence -> [TcTyVar] -> TcPredType -> Bool -> QCInst [qci_ev] :: QCInst -> CtEvidence [qci_tvs] :: QCInst -> [TcTyVar] [qci_pred] :: QCInst -> TcPredType [qci_pend_sc] :: QCInst -> Bool panicTcS :: SDoc -> TcS a traceTcS :: String -> SDoc -> TcS () traceFireTcS :: CtEvidence -> SDoc -> TcS () bumpStepCountTcS :: TcS () csTraceTcS :: SDoc -> TcS () wrapErrTcS :: TcM a -> TcS a wrapWarnTcS :: TcM a -> TcS a resetUnificationFlag :: TcS Bool setUnificationFlag :: TcLevel -> TcS () data MaybeNew Fresh :: CtEvidence -> MaybeNew Cached :: EvExpr -> MaybeNew freshGoals :: [MaybeNew] -> [CtEvidence] isFresh :: MaybeNew -> Bool getEvExpr :: MaybeNew -> EvExpr newTcEvBinds :: TcS EvBindsVar newNoTcEvBinds :: TcS EvBindsVar -- | Create a new Wanted constraint holding a coercion hole for an equality -- between the two types at the given Role. newWantedEq :: CtLoc -> RewriterSet -> Role -> TcType -> TcType -> TcS (CtEvidence, Coercion) -- | Emit a new Wanted equality into the work-list emitNewWantedEq :: CtLoc -> RewriterSet -> Role -> TcType -> TcType -> TcS Coercion -- | Create a new Wanted constraint, potentially looking up non-equality -- constraints in the cache instead of creating a new one from scratch. -- -- Deals with both equality and non-equality constraints. newWanted :: CtLoc -> RewriterSet -> PredType -> TcS MaybeNew -- | Create a new Wanted constraint. -- -- Deals with both equality and non-equality constraints. -- -- Does not attempt to re-use non-equality constraints that already exist -- in the inert set. newWantedNC :: CtLoc -> RewriterSet -> PredType -> TcS CtEvidence -- | Create a new Wanted constraint holding an evidence variable. -- -- Don't use this for equality constraints: use newWantedEq -- instead. newWantedEvVarNC :: CtLoc -> RewriterSet -> TcPredType -> TcS CtEvidence -- | Make a new Id of the given type, bound (in the monad's EvBinds) -- to the given term newBoundEvVarId :: TcPredType -> EvTerm -> TcS EvVar unifyTyVar :: TcTyVar -> TcType -> TcS () reportUnifications :: TcS a -> TcS (Int, a) touchabilityTest :: CtFlavour -> TcTyVar -> TcType -> TcS TouchabilityTestResult data TouchabilityTestResult TouchableSameLevel :: TouchabilityTestResult TouchableOuterLevel :: [TcTyVar] -> TcLevel -> TouchabilityTestResult Untouchable :: TouchabilityTestResult setEvBind :: EvBind -> TcS () -- | Equalities only setWantedEq :: HasDebugCallStack => TcEvDest -> Coercion -> TcS () -- | Good for both equalities and non-equalities setWantedEvTerm :: TcEvDest -> EvTerm -> TcS () setEvBindIfWanted :: CtEvidence -> EvTerm -> TcS () newEvVar :: TcPredType -> TcS EvVar newGivenEvVar :: CtLoc -> (TcPredType, EvTerm) -> TcS CtEvidence newGivenEvVars :: CtLoc -> [(TcPredType, EvTerm)] -> TcS [CtEvidence] -- | Checks if the depth of the given location is too much. Fails if it's -- too big, with an appropriate error message. checkReductionDepth :: CtLoc -> TcType -> TcS () getSolvedDicts :: TcS (DictMap CtEvidence) setSolvedDicts :: DictMap CtEvidence -> TcS () getInstEnvs :: TcS InstEnvs getFamInstEnvs :: TcS (FamInstEnv, FamInstEnv) getTopEnv :: TcS HscEnv getGblEnv :: TcS TcGblEnv getLclEnv :: TcS TcLclEnv setLclEnv :: TcLclEnv -> TcS a -> TcS a getTcEvBindsVar :: TcS EvBindsVar getTcLevel :: TcS TcLevel getTcEvTyCoVars :: EvBindsVar -> TcS TyCoVarSet getTcEvBindsMap :: EvBindsVar -> TcS EvBindMap setTcEvBindsMap :: EvBindsVar -> EvBindMap -> TcS () tcLookupClass :: Name -> TcS Class tcLookupId :: Name -> TcS Id updInertTcS :: (InertSet -> InertSet) -> TcS () updInertCans :: (InertCans -> InertCans) -> TcS () updInertDicts :: (DictMap Ct -> DictMap Ct) -> TcS () updInertIrreds :: (Cts -> Cts) -> TcS () getHasGivenEqs :: TcLevel -> TcS (HasGivenEqs, Cts) setInertCans :: InertCans -> TcS () getInertEqs :: TcS InertEqs getInertCans :: TcS InertCans getInertGivens :: TcS [Ct] getInertInsols :: TcS Cts getInnermostGivenEqLevel :: TcS TcLevel getTcSInerts :: TcS InertSet setTcSInerts :: InertSet -> TcS () getUnsolvedInerts :: TcS (Bag Implication, Cts) -- | Remove inert constraints from the InertCans, for use when a -- typechecker plugin wishes to discard a given. removeInertCts :: [Ct] -> InertCans -> InertCans getPendingGivenScs :: TcS [Ct] addInertCan :: Ct -> TcS () insertFunEq :: FunEqMap a -> TyCon -> [Type] -> a -> FunEqMap a addInertForAll :: QCInst -> TcS () emitWorkNC :: [CtEvidence] -> TcS () emitWork :: [Ct] -> TcS () -- | Look up a dictionary inert. lookupInertDict :: InertCans -> CtLoc -> Class -> [Type] -> Maybe Ct kickOutAfterUnification :: TcTyVar -> TcS Int addInertSafehask :: InertCans -> Ct -> InertCans insertSafeOverlapFailureTcS :: InstanceWhat -> Ct -> TcS () updInertSafehask :: (DictMap Ct -> DictMap Ct) -> TcS () getSafeOverlapFailures :: TcS Cts addSolvedDict :: InstanceWhat -> CtEvidence -> Class -> [Type] -> TcS () -- | Look up a solved inert. lookupSolvedDict :: InertSet -> CtLoc -> Class -> [Type] -> Maybe CtEvidence foldIrreds :: (Ct -> b -> b) -> Cts -> b -> b -- | Looks up a family application in the inerts. lookupFamAppInert :: (CtFlavourRole -> Bool) -> TyCon -> [Type] -> TcS (Maybe (Reduction, CtFlavourRole)) lookupFamAppCache :: TyCon -> [Type] -> TcS (Maybe Reduction) extendFamAppCache :: TyCon -> [Type] -> Reduction -> TcS () pprKicked :: Int -> SDoc instDFunType :: DFunId -> [DFunInstType] -> TcS ([TcType], TcThetaType) newFlexiTcSTy :: Kind -> TcS TcType instFlexi :: [TKVar] -> TcS TCvSubst instFlexiX :: TCvSubst -> [TKVar] -> TcS TCvSubst cloneMetaTyVar :: TcTyVar -> TcS TcTyVar tcInstSkolTyVarsX :: SkolemInfo -> TCvSubst -> [TyVar] -> TcS (TCvSubst, [TcTyVar]) data TcLevel isFilledMetaTyVar_maybe :: TcTyVar -> TcS (Maybe Type) isFilledMetaTyVar :: TcTyVar -> TcS Bool zonkTyCoVarsAndFV :: TcTyCoVarSet -> TcS TcTyCoVarSet zonkTcType :: TcType -> TcS TcType zonkTcTypes :: [TcType] -> TcS [TcType] zonkTcTyVar :: TcTyVar -> TcS TcType zonkCo :: Coercion -> TcS Coercion zonkTyCoVarsAndFVList :: [TcTyCoVar] -> TcS [TcTyCoVar] zonkSimples :: Cts -> TcS Cts zonkWC :: WantedConstraints -> TcS WantedConstraints zonkTyCoVarKind :: TcTyCoVar -> TcS TcTyCoVar newTcRef :: a -> TcS (TcRef a) readTcRef :: TcRef a -> TcS a writeTcRef :: TcRef a -> a -> TcS () updTcRef :: TcRef a -> (a -> a) -> TcS () getDefaultInfo :: TcS ([Type], (Bool, Bool)) getDynFlags :: HasDynFlags m => m DynFlags getGlobalRdrEnvTcS :: TcS GlobalRdrEnv matchFam :: TyCon -> [Type] -> TcS (Maybe ReductionN) matchFamTcM :: TyCon -> [Type] -> TcM (Maybe ReductionN) checkWellStagedDFun :: CtLoc -> InstanceWhat -> PredType -> TcS () pprEq :: TcType -> TcType -> SDoc -- | Conditionally replace all type family applications in the RHS with -- fresh variables, emitting givens that relate the type family -- application to the variable. See Note [Type variable cycles] in -- GHC.Tc.Solver.Canonical. This only works under conditions as described -- in the Note; otherwise, returns Nothing. breakTyVarCycle_maybe :: CtEvidence -> CheckTyEqResult -> CanEqLHS -> TcType -> TcS (Maybe (TcTyVar, ReductionN)) rewriterView :: TcType -> Maybe TcType instance GHC.Base.Functor GHC.Tc.Solver.Monad.TcS instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Monad.TouchabilityTestResult instance GHC.Base.Applicative GHC.Tc.Solver.Monad.TcS instance GHC.Base.Monad GHC.Tc.Solver.Monad.TcS instance Control.Monad.IO.Class.MonadIO GHC.Tc.Solver.Monad.TcS instance Control.Monad.Fail.MonadFail GHC.Tc.Solver.Monad.TcS instance GHC.Types.Unique.Supply.MonadUnique GHC.Tc.Solver.Monad.TcS instance GHC.Unit.Module.HasModule GHC.Tc.Solver.Monad.TcS instance GHC.Types.TyThing.MonadThings GHC.Tc.Solver.Monad.TcS instance GHC.Driver.Session.HasDynFlags GHC.Tc.Solver.Monad.TcS module GHC.Tc.Solver.Rewrite -- | See Note [Rewriting]. If (xi, co, rewriters) <- rewrite mode ev ty, -- then co :: xi ~r ty where r is the role in ev. rewriters is -- the set of coercion holes that have been used to rewrite See Note -- [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint rewrite :: CtEvidence -> TcType -> TcS (Reduction, RewriterSet) rewriteArgsNom :: CtEvidence -> TyCon -> [TcType] -> TcS (Reductions, RewriterSet) -- | Rewrite a type w.r.t. nominal equality. This is useful to rewrite a -- type w.r.t. any givens. It does not do type-family reduction. This -- will never emit new constraints. Call this when the inert set contains -- only givens. rewriteType :: CtLoc -> TcType -> TcS TcType instance GHC.Base.Functor GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Base.Monad GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Base.Applicative GHC.Tc.Solver.Rewrite.RewriteM instance GHC.Driver.Session.HasDynFlags GHC.Tc.Solver.Rewrite.RewriteM module GHC.Tc.Solver.Canonical canonicalize :: Ct -> TcS (StopOrContinue Ct) unifyWanted :: RewriterSet -> CtLoc -> Role -> TcType -> TcType -> TcS Coercion makeSuperClasses :: [Ct] -> TcS [Ct] data StopOrContinue a ContinueWith :: a -> StopOrContinue a Stop :: CtEvidence -> SDoc -> StopOrContinue a stopWith :: CtEvidence -> String -> TcS (StopOrContinue a) continueWith :: a -> TcS (StopOrContinue a) andWhenContinue :: TcS (StopOrContinue a) -> (a -> TcS (StopOrContinue b)) -> TcS (StopOrContinue b) infixr 0 `andWhenContinue` solveCallStack :: CtEvidence -> EvCallStack -> TcS () instance GHC.Base.Functor GHC.Tc.Solver.Canonical.StopOrContinue instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Tc.Solver.Canonical.StopOrContinue a) -- | This module provides an interface for typechecker plugins to access -- select functions of the TcM, principally those to do with -- reading parts of the state. module GHC.Tc.Plugin -- | TcPluginM is the monad in which type-checking plugins operate. data TcPluginM a -- | Perform some IO, typically to interact with an external tool. tcPluginIO :: IO a -> TcPluginM a -- | Output useful for debugging the compiler. tcPluginTrace :: String -> SDoc -> TcPluginM () -- | This function provides an escape for direct access to the TcM -- monad. It should not be used lightly, and the provided -- TcPluginM API should be favoured instead. unsafeTcPluginTcM :: TcM a -> TcPluginM a -- | The result of searching for an imported module. -- -- NB: FindResult manages both user source-import lookups (which can -- result in Module) as well as direct imports for interfaces -- (which always result in InstalledModule). data FindResult -- | The module was found Found :: ModLocation -> Module -> FindResult -- | The requested unit was not found NoPackage :: Unit -> FindResult -- | _Error_: both in multiple packages FoundMultiple :: [(Module, ModuleOrigin)] -> FindResult -- | Not found NotFound :: [FilePath] -> Maybe Unit -> [Unit] -> [Unit] -> [(Unit, UnusableUnitReason)] -> [ModuleSuggestion] -> FindResult -- | Places where I looked [fr_paths] :: FindResult -> [FilePath] -- | Just p => module is in this unit's manifest, but couldn't find the -- .hi file [fr_pkg] :: FindResult -> Maybe Unit -- | Module is in these units, but the *module* is hidden [fr_mods_hidden] :: FindResult -> [Unit] -- | Module is in these units, but the *unit* is hidden [fr_pkgs_hidden] :: FindResult -> [Unit] -- | Module is in these units, but it is unusable [fr_unusables] :: FindResult -> [(Unit, UnusableUnitReason)] -- | Possible mis-spelled modules [fr_suggestions] :: FindResult -> [ModuleSuggestion] findImportedModule :: ModuleName -> PkgQual -> TcPluginM FindResult lookupOrig :: Module -> OccName -> TcPluginM Name tcLookupGlobal :: Name -> TcPluginM TyThing tcLookupTyCon :: Name -> TcPluginM TyCon tcLookupDataCon :: Name -> TcPluginM DataCon tcLookupClass :: Name -> TcPluginM Class tcLookup :: Name -> TcPluginM TcTyThing tcLookupId :: Name -> TcPluginM Id getTopEnv :: TcPluginM HscEnv getTargetPlatform :: TcPluginM Platform getEnvs :: TcPluginM (TcGblEnv, TcLclEnv) getInstEnvs :: TcPluginM InstEnvs getFamInstEnvs :: TcPluginM (FamInstEnv, FamInstEnv) matchFam :: TyCon -> [Type] -> TcPluginM (Maybe Reduction) newUnique :: TcPluginM Unique newFlexiTyVar :: Kind -> TcPluginM TcTyVar isTouchableTcPluginM :: TcTyVar -> TcPluginM Bool zonkTcType :: TcType -> TcPluginM TcType zonkCt :: Ct -> TcPluginM Ct -- | Create a new Wanted constraint with the given CtLoc. newWanted :: CtLoc -> PredType -> TcPluginM CtEvidence -- | Create a new given constraint, with the supplied evidence. -- -- This should only be invoked within tcPluginSolve. newGiven :: EvBindsVar -> CtLoc -> PredType -> EvExpr -> TcPluginM CtEvidence -- | Create a fresh coercion hole. This should only be invoked within -- tcPluginSolve. newCoercionHole :: PredType -> TcPluginM CoercionHole -- | Create a fresh evidence variable. -- -- This should only be invoked within tcPluginSolve. newEvVar :: PredType -> TcPluginM EvVar -- | Bind an evidence variable. -- -- This should only be invoked within tcPluginSolve. setEvBind :: EvBindsVar -> EvBind -> TcPluginM () module GHC.Tc.Solver.Interact solveSimpleGivens :: [Ct] -> TcS () solveSimpleWanteds :: Cts -> TcS WantedConstraints instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.Interact.InteractResult module GHC.Tc.Solver -- | How should we choose which constraints to quantify over? data InferMode -- | Apply the monomorphism restriction, never quantifying over any -- constraints ApplyMR :: InferMode -- | See Note [TcRnExprMode] in GHC.Tc.Module, the :type +d case; -- this mode refuses to quantify over any defaultable constraint EagerDefaulting :: InferMode -- | Quantify over any constraint that satisfies pickQuantifiablePreds NoRestrictions :: InferMode simplifyInfer :: TcLevel -> InferMode -> [TcIdSigInst] -> [(Name, TcTauType)] -> WantedConstraints -> TcM ([TcTyVar], [EvVar], TcEvBinds, Bool) findInferredDiff :: TcThetaType -> TcThetaType -> TcM TcThetaType growThetaTyVars :: ThetaType -> TyCoVarSet -> TyCoVarSet simplifyAmbiguityCheck :: Type -> WantedConstraints -> TcM () simplifyDefault :: ThetaType -> TcM Bool simplifyTop :: WantedConstraints -> TcM (Bag EvBind) simplifyTopImplic :: Bag Implication -> TcM () simplifyInteractive :: WantedConstraints -> TcM (Bag EvBind) -- | Type-check a thing that emits only equality constraints, solving any -- constraints we can and re-emitting constraints that we can't. Use this -- variant only when we'll get another crack at it later See Note -- [Failure in local type signatures] -- -- Panics if we solve any non-equality constraints. (In runTCSEqualities -- we use an error thunk for the evidence bindings.) solveEqualities :: String -> TcM a -> TcM a pushLevelAndSolveEqualities :: SkolemInfoAnon -> [TyConBinder] -> TcM a -> TcM a pushLevelAndSolveEqualitiesX :: String -> TcM a -> TcM (TcLevel, WantedConstraints, a) reportUnsolvedEqualities :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM () simplifyWantedsTcM :: [CtEvidence] -> TcM WantedConstraints -- | Return (Just new_inerts) if the Givens are satisfiable, Nothing if -- definitely contradictory. -- -- See Note [Pattern match warnings with insoluble Givens] above. tcCheckGivens :: InertSet -> Bag EvVar -> TcM (Maybe InertSet) -- | Return True if the Wanteds are soluble, False if not tcCheckWanteds :: InertSet -> ThetaType -> TcM Bool -- | Normalise a type as much as possible using the given constraints. See -- Note [tcNormalise]. tcNormalise :: InertSet -> Type -> TcM Type captureTopConstraints :: TcM a -> TcM (a, WantedConstraints) -- | Simplify top-level constraints, but without reporting any unsolved -- constraints nor unsafe overlapping. simplifyTopWanteds :: WantedConstraints -> TcS WantedConstraints promoteTyVarSet :: TcTyVarSet -> TcM Bool simplifyAndEmitFlatConstraints :: WantedConstraints -> TcM () solveWanteds :: WantedConstraints -> TcS WantedConstraints approximateWC :: Bool -> WantedConstraints -> Cts instance GHC.Utils.Outputable.Outputable GHC.Tc.Solver.InferMode module GHC.Tc.Validity data Rank ArbitraryRank :: Rank LimitedRank :: Bool -> Rank -> Rank MonoTypeRankZero :: Rank MonoTypeTyConArg :: Rank MonoTypeSynArg :: Rank MonoTypeConstraint :: Rank MustBeMonoType :: Rank -- | UserTypeCtxt describes the origin of the polymorphic type in the -- places where we need an expression to have that type data UserTypeCtxt FunSigCtxt :: Name -> ReportRedundantConstraints -> UserTypeCtxt InfSigCtxt :: Name -> UserTypeCtxt ExprSigCtxt :: ReportRedundantConstraints -> UserTypeCtxt KindSigCtxt :: UserTypeCtxt StandaloneKindSigCtxt :: Name -> UserTypeCtxt TypeAppCtxt :: UserTypeCtxt ConArgCtxt :: Name -> UserTypeCtxt TySynCtxt :: Name -> UserTypeCtxt PatSynCtxt :: Name -> UserTypeCtxt PatSigCtxt :: UserTypeCtxt RuleSigCtxt :: FastString -> Name -> UserTypeCtxt ForSigCtxt :: Name -> UserTypeCtxt DefaultDeclCtxt :: UserTypeCtxt InstDeclCtxt :: Bool -> UserTypeCtxt SpecInstCtxt :: UserTypeCtxt GenSigCtxt :: UserTypeCtxt GhciCtxt :: Bool -> UserTypeCtxt ClassSCCtxt :: Name -> UserTypeCtxt SigmaCtxt :: UserTypeCtxt DataTyCtxt :: Name -> UserTypeCtxt DerivClauseCtxt :: UserTypeCtxt TyVarBndrKindCtxt :: Name -> UserTypeCtxt DataKindCtxt :: Name -> UserTypeCtxt TySynKindCtxt :: Name -> UserTypeCtxt TyFamResKindCtxt :: Name -> UserTypeCtxt checkValidType :: UserTypeCtxt -> Type -> TcM () checkValidMonoType :: Type -> TcM () checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM () checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () checkValidInstHead :: UserTypeCtxt -> Class -> [Type] -> TcM () validDerivPred :: TyVarSet -> PredType -> Bool checkTySynRhs :: UserTypeCtxt -> TcType -> TcM () checkValidCoAxiom :: CoAxiom Branched -> TcM () checkValidCoAxBranch :: TyCon -> CoAxBranch -> TcM () -- | Do validity checks on a type family equation, including consistency -- with any enclosing class instance head, termination, and lack of -- polytypes. checkValidTyFamEqn :: TyCon -> [Var] -> [Type] -> Type -> TcM () -- | Checks that an associated type family default: -- --
    --
  1. Only consists of arguments that are bare type variables, and
  2. --
  3. Has a distinct type variable in each argument.
  4. --
-- -- See Note [Type-checking default assoc decls] in -- GHC.Tc.TyCl. checkValidAssocTyFamDeflt :: TyCon -> [Type] -> TcM () checkConsistentFamInst :: AssocInstInfo -> TyCon -> CoAxBranch -> TcM () arityErr :: Outputable a => SDoc -> a -> Int -> Int -> TcRnMessage checkTyConTelescope :: TyCon -> TcM () allDistinctTyVars :: TyVarSet -> [KindOrType] -> Bool instance GHC.Classes.Eq GHC.Tc.Validity.TypeOrKindCtxt instance GHC.Utils.Outputable.Outputable GHC.Tc.Validity.ValidityEnv instance GHC.Utils.Outputable.Outputable GHC.Tc.Validity.ExpandMode instance GHC.Utils.Outputable.Outputable GHC.Tc.Validity.TypeOrKindCtxt -- | Generating derived instance declarations -- -- This module is nominally `subordinate' to -- GHC.Tc.Deriv, which is the `official' interface to -- deriving-related things. -- -- This is where we do all the grimy bindings' generation. module GHC.Tc.Deriv.Generate -- | A declarative description of an auxiliary binding that should be -- generated. See Note [Auxiliary binders] for a more detailed -- description of how these are used. data AuxBindSpec -- | $tag2con: Given a tag, computes the corresponding data -- constructor DerivTag2Con :: TyCon -> RdrName -> AuxBindSpec -- | $maxtag: The maximum possible tag value among a data type's -- constructors DerivMaxTag :: TyCon -> RdrName -> AuxBindSpec -- | $t: The DataType representation for a Data -- instance DerivDataDataType :: TyCon -> RdrName -> [RdrName] -> AuxBindSpec -- | $c: The Constr representation for a Data -- instance DerivDataConstr :: DataCon -> RdrName -> RdrName -> AuxBindSpec gen_Eq_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec) gen_Ord_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec) gen_Enum_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec) gen_Bounded_binds :: SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Ix_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec) gen_Show_binds :: (Name -> Fixity) -> SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Read_binds :: (Name -> Fixity) -> SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Data_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec) gen_Lift_binds :: SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Newtype_binds :: SrcSpan -> Class -> [TyVar] -> [Type] -> Type -> (LHsBinds GhcPs, [LSig GhcPs]) gen_Newtype_fam_insts :: SrcSpan -> Class -> [TyVar] -> [Type] -> Type -> TcM [FamInst] mkCoerceClassMethEqn :: Class -> [TyVar] -> [Type] -> Type -> Id -> Pair Type -- | Take a Bag of AuxBindSpecs and generate the code for -- auxiliary bindings based on the declarative descriptions in the -- supplied AuxBindSpecs. See Note [Auxiliary binders]. genAuxBinds :: DynFlags -> SrcSpan -> Bag AuxBindSpec -> Bag (LHsBind GhcPs, LSig GhcPs) ordOpTbl :: [(Type, (RdrName, RdrName, RdrName, RdrName, RdrName))] boxConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)] litConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)] mkRdrFunBind :: LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs -- | Produces a function binding. When no equations are given, it generates -- a binding of the given arity and an empty case expression for the last -- argument that it passes to the given function to produce the -- right-hand side. mkRdrFunBindEC :: Arity -> (LHsExpr GhcPs -> LHsExpr GhcPs) -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs -- | Produces a function binding. When there are no equations, it generates -- a binding with the given arity that produces an error based on the -- name of the type of the last argument. mkRdrFunBindSE :: Arity -> LocatedN RdrName -> [LMatch GhcPs (LHsExpr GhcPs)] -> LHsBind GhcPs error_Expr :: String -> LHsExpr GhcPs -- | getPossibleDataCons tycon tycon_args returns the constructors -- of tycon whose return types match when checked against -- tycon_args. -- -- See Note [Filter out impossible GADT data constructors] getPossibleDataCons :: TyCon -> [Type] -> [DataCon] -- | Information about the arguments to the class in a stock- or -- newtype-derived instance. For a deriving-generated instance -- declaration such as this one: -- --
--   instance Ctx => Cls cls_ty_1 ... cls_ty_m (TC tc_arg_1 ... tc_arg_n) where ...
--   
-- -- -- -- See Note [DerivEnv and DerivSpecMechanism] in -- GHC.Tc.Deriv.Utils for a more in-depth explanation, including -- the relationship between dit_tcdit_rep_tc and -- dit_tc_argsdit_rep_tc_args. -- -- A DerivInstTys value can be seen as a more structured -- representation of the denv_inst_tys in a DerivEnv, -- as the denv_inst_tys is equal to dit_cls_tys ++ -- [mkTyConApp dit_tc dit_tc_args]. Other parts of the -- instance declaration can be found in the DerivEnv. For -- example, the Cls in the example above corresponds to the -- denv_cls field of DerivEnv. -- -- Similarly, the type variables that appear in a DerivInstTys -- value are the same type variables as the denv_tvs in the -- parent DerivEnv. Accordingly, if we are inferring an instance -- context, the type variables will be TcTyVar skolems. Otherwise, -- they will be ordinary TyVars. See Note [Overlap and -- deriving] in GHC.Tc.Deriv.Infer. data DerivInstTys DerivInstTys :: [Type] -> TyCon -> [Type] -> TyCon -> [Type] -> DataConEnv [Type] -> DerivInstTys -- | Other arguments to the class except the last [dit_cls_tys] :: DerivInstTys -> [Type] -- | Type constructor for which the instance is requested (last arguments -- to the type class) [dit_tc] :: DerivInstTys -> TyCon -- | Arguments to the type constructor [dit_tc_args] :: DerivInstTys -> [Type] -- | The representation tycon for dit_tc (for data family -- instances). Otherwise the same as dit_tc. [dit_rep_tc] :: DerivInstTys -> TyCon -- | The representation types for dit_tc_args (for data family -- instances). Otherwise the same as dit_tc_args. [dit_rep_tc_args] :: DerivInstTys -> [Type] -- | The cached results of instantiating each data constructor's field -- types using dataConInstUnivs data_con -- dit_rep_tc_args. See Note [Instantiating field types -- in stock deriving]. -- -- This field is only used for stock-derived instances and goes unused -- for newtype-derived instances. It is put here mainly for the sake of -- convenience. [dit_dc_inst_arg_env] :: DerivInstTys -> DataConEnv [Type] -- | buildDataConInstArgEnv tycon arg_tys constructs a -- cache that maps each of tycon's data constructors to their -- field types, with are to be instantiated with arg_tys. See -- Note [Instantiating field types in stock deriving]. buildDataConInstArgEnv :: TyCon -> [Type] -> DataConEnv [Type] -- | Look up a data constructor's instantiated field types in a -- DerivInstTys. See Note [Instantiating field types in stock -- deriving]. derivDataConInstArgTys :: DataCon -> DerivInstTys -> [Type] -- | Apply a substitution to all of the Types contained in a -- DerivInstTys. See Note [Instantiating field types in stock -- deriving] for why we need to substitute into a -- DerivInstTys in the first place. substDerivInstTys :: TCvSubst -> DerivInstTys -> DerivInstTys -- | Zonk the TcTyVars in a DerivInstTys value to -- TyVars. See Note [What is zonking?] in -- GHC.Tc.Utils.TcMType. -- -- This is only used in the final zonking step when inferring the context -- for a derived instance. See Note [Overlap and deriving] in -- GHC.Tc.Deriv.Infer. zonkDerivInstTys :: ZonkEnv -> DerivInstTys -> TcM DerivInstTys instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Generate.DerivInstTys -- | The deriving code for the Functor, Foldable, and Traversable classes module GHC.Tc.Deriv.Functor data FFoldType a FT :: a -> a -> a -> (a -> a -> a) -> (TyCon -> [a] -> a) -> (Type -> Type -> a -> a) -> a -> (TcTyVar -> a -> a) -> FFoldType a -- | Does not contain variable [ft_triv] :: FFoldType a -> a -- | The variable itself [ft_var] :: FFoldType a -> a -- | The variable itself, contravariantly [ft_co_var] :: FFoldType a -> a -- | Function type [ft_fun] :: FFoldType a -> a -> a -> a -- | Tuple type. The [a] is the result of folding over the -- arguments of the tuple. [ft_tup] :: FFoldType a -> TyCon -> [a] -> a -- | Type app, variable only in last argument. The two Types are the -- function and argument parts of fun_ty arg_ty, respectively. [ft_ty_app] :: FFoldType a -> Type -> Type -> a -> a -- | Type app, variable other than in last argument [ft_bad_app] :: FFoldType a -> a -- | Forall type [ft_forall] :: FFoldType a -> TcTyVar -> a -> a functorLikeTraverse :: forall a. TyVar -> FFoldType a -> Type -> a deepSubtypesContaining :: TyVar -> Type -> [TcType] foldDataConArgs :: FFoldType a -> DataCon -> DerivInstTys -> [a] gen_Functor_binds :: SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Foldable_binds :: SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) gen_Traversable_binds :: SrcSpan -> DerivInstTys -> (LHsBinds GhcPs, Bag AuxBindSpec) -- | The deriving code for the Generic class module GHC.Tc.Deriv.Generics canDoGenerics :: DerivInstTys -> Validity' [DeriveGenericsErrReason] canDoGenerics1 :: DerivInstTys -> Validity' [DeriveGenericsErrReason] data GenericKind Gen0 :: GenericKind Gen1 :: GenericKind gen_Generic_binds :: GenericKind -> SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, [LSig GhcPs]) gen_Generic_fam_inst :: GenericKind -> (Name -> Fixity) -> SrcSpan -> DerivInstTys -> TcM FamInst get_gen1_constrained_tys :: TyVar -> Type -> [Type] -- | Error-checking and other utilities for deriving clauses or -- declarations. module GHC.Tc.Deriv.Utils -- | To avoid having to manually plumb everything in DerivEnv -- throughout various functions in GHC.Tc.Deriv and -- GHC.Tc.Deriv.Infer, we use DerivM, which is a simple -- reader around TcRn. type DerivM = ReaderT DerivEnv TcRn -- | Contains all of the information known about a derived instance when -- determining what its EarlyDerivSpec should be. See Note -- [DerivEnv and DerivSpecMechanism]. data DerivEnv DerivEnv :: Maybe OverlapMode -> [TyVar] -> Class -> [Type] -> DerivContext -> SkolemInfo -> Maybe (DerivStrategy GhcTc) -> DerivEnv -- | Is this an overlapping instance? [denv_overlap_mode] :: DerivEnv -> Maybe OverlapMode -- | Universally quantified type variables in the instance. If the -- denv_ctxt is InferContext, these will be -- TcTyVar skolems. If the denv_ctxt is -- SupplyContext, these will be ordinary TyVars. See -- Note [Overlap and deriving] in GHC.Tc.Deriv.Infer. -- -- All type variables that appear in the denv_inst_tys, -- denv_ctxt, denv_skol_info, and denv_strat should -- come from denv_tvs. [denv_tvs] :: DerivEnv -> [TyVar] -- | Class for which we need to derive an instance [denv_cls] :: DerivEnv -> Class -- | All arguments to denv_cls in the derived instance. [denv_inst_tys] :: DerivEnv -> [Type] -- | SupplyContext theta for standalone deriving (where -- theta is the context of the instance). InferContext -- for deriving clauses, or for standalone deriving that uses a -- wildcard constraint. See Note [Inferring the instance -- context]. [denv_ctxt] :: DerivEnv -> DerivContext -- | The SkolemInfo used to skolemise the denv_tvs in the -- case where the denv_ctxt is InferContext. [denv_skol_info] :: DerivEnv -> SkolemInfo -- | Just if user requests a particular deriving strategy. -- Otherwise, Nothing. [denv_strat] :: DerivEnv -> Maybe (DerivStrategy GhcTc) data DerivSpec theta DS :: SrcSpan -> Name -> [TyVar] -> theta -> Class -> [Type] -> SkolemInfo -> UserTypeCtxt -> Maybe OverlapMode -> Maybe SrcSpan -> DerivSpecMechanism -> DerivSpec theta [ds_loc] :: DerivSpec theta -> SrcSpan [ds_name] :: DerivSpec theta -> Name [ds_tvs] :: DerivSpec theta -> [TyVar] [ds_theta] :: DerivSpec theta -> theta [ds_cls] :: DerivSpec theta -> Class [ds_tys] :: DerivSpec theta -> [Type] [ds_skol_info] :: DerivSpec theta -> SkolemInfo [ds_user_ctxt] :: DerivSpec theta -> UserTypeCtxt [ds_overlap] :: DerivSpec theta -> Maybe OverlapMode [ds_standalone_wildcard] :: DerivSpec theta -> Maybe SrcSpan [ds_mechanism] :: DerivSpec theta -> DerivSpecMechanism pprDerivSpec :: Outputable theta => DerivSpec theta -> SDoc -- | Set the ds_theta in a DerivSpec. setDerivSpecTheta :: theta' -> DerivSpec theta -> DerivSpec theta' -- | Zonk the TcTyVars in a DerivSpec to TyVars. See -- Note [What is zonking?] in GHC.Tc.Utils.TcMType. -- -- This is only used in the final zonking step when inferring the context -- for a derived instance. See Note [Overlap and deriving] in -- GHC.Tc.Deriv.Infer. zonkDerivSpec :: DerivSpec ThetaType -> TcM (DerivSpec ThetaType) -- | What action to take in order to derive a class instance. See Note -- [DerivEnv and DerivSpecMechanism], as well as Note [Deriving -- strategies] in GHC.Tc.Deriv. data DerivSpecMechanism -- | "Standard" classes DerivSpecStock :: DerivInstTys -> StockGenFns -> DerivSpecMechanism -- | Information about the arguments to the class in the derived instance, -- including what type constructor the last argument is headed by. See -- Note [DerivEnv and DerivSpecMechanism]. [dsm_stock_dit] :: DerivSpecMechanism -> DerivInstTys -- | How to generate the instance bindings and associated type family -- instances. [dsm_stock_gen_fns] :: DerivSpecMechanism -> StockGenFns -- |
--   GeneralizedNewtypeDeriving
--   
DerivSpecNewtype :: DerivInstTys -> Type -> DerivSpecMechanism -- | Information about the arguments to the class in the derived instance, -- including what type constructor the last argument is headed by. See -- Note [DerivEnv and DerivSpecMechanism]. [dsm_newtype_dit] :: DerivSpecMechanism -> DerivInstTys -- | The newtype rep type. [dsm_newtype_rep_ty] :: DerivSpecMechanism -> Type -- |
--   DeriveAnyClass
--   
DerivSpecAnyClass :: DerivSpecMechanism -- |
--   DerivingVia
--   
DerivSpecVia :: [Type] -> Type -> Type -> DerivSpecMechanism -- | All arguments to the class besides the last one. [dsm_via_cls_tys] :: DerivSpecMechanism -> [Type] -- | The last argument to the class. [dsm_via_inst_ty] :: DerivSpecMechanism -> Type -- | The via type [dsm_via_ty] :: DerivSpecMechanism -> Type -- | Convert a DerivSpecMechanism to its corresponding -- DerivStrategy. derivSpecMechanismToStrategy :: DerivSpecMechanism -> DerivStrategy GhcTc isDerivSpecStock :: DerivSpecMechanism -> Bool isDerivSpecNewtype :: DerivSpecMechanism -> Bool isDerivSpecAnyClass :: DerivSpecMechanism -> Bool isDerivSpecVia :: DerivSpecMechanism -> Bool -- | Zonk the TcTyVars in a DerivSpecMechanism to -- TyVars. See Note [What is zonking?] in -- GHC.Tc.Utils.TcMType. -- -- This is only used in the final zonking step when inferring the context -- for a derived instance. See Note [Overlap and deriving] in -- GHC.Tc.Deriv.Infer. zonkDerivSpecMechanism :: ZonkEnv -> DerivSpecMechanism -> TcM DerivSpecMechanism -- | Whether GHC is processing a deriving clause or a standalone -- deriving declaration. data DerivContext -- | 'InferContext mb_wildcard is either: -- -- -- -- GHC should infer the context. InferContext :: Maybe SrcSpan -> DerivContext -- | SupplyContext theta is a standalone deriving -- declaration, where theta is the context supplied by the user. SupplyContext :: ThetaType -> DerivContext -- | Records whether a particular class can be derived by way of an -- originative deriving strategy (i.e., stock or -- anyclass). -- -- See Note [Deriving strategies] in GHC.Tc.Deriv. data OriginativeDerivStatus CanDeriveStock :: StockGenFns -> OriginativeDerivStatus StockClassError :: !DeriveInstanceErrReason -> OriginativeDerivStatus CanDeriveAnyClass :: OriginativeDerivStatus NonDerivableClass :: OriginativeDerivStatus -- | Describes how to generate instance bindings (stock_gen_binds) -- and associated type family instances (stock_gen_fam_insts) for -- a particular stock-derived instance. data StockGenFns StockGenFns :: (SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, [LSig GhcPs], Bag AuxBindSpec, [Name])) -> (SrcSpan -> DerivInstTys -> TcM [FamInst]) -> StockGenFns -- | Describes how to generate instance bindings for a stock-derived -- instance. -- -- This function takes two arguments: -- --
    --
  1. SrcSpan: the source location where the instance is being -- derived. This will eventually be instantiated with the ds_loc -- field of a DerivSpec.
  2. --
  3. DerivInstTys: information about the argument types to which -- a class is applied in a derived instance. This will eventually be -- instantiated with the dsm_stock_dit field of a -- DerivSpecMechanism.
  4. --
-- -- This function returns four things: -- --
    --
  1. LHsBinds GhcPs: The derived instance's -- function bindings (e.g., compare (T x) (T y) = compare x -- y)
  2. --
  3. [LSig GhcPs]: A list of instance specific -- signatures/pragmas. Most likely INLINE pragmas for class -- methods.
  4. --
  5. Bag AuxBindSpec: Auxiliary bindings needed -- to support the derived instance. As examples, derived Eq and -- Ord instances sometimes require top-level con2tag -- functions. See Note [Auxiliary binders] in -- GHC.Tc.Deriv.Generate.
  6. --
  7. [Name]: A list of Names for which -- -Wunused-binds should be suppressed. This is used to suppress -- unused warnings for record selectors when deriving Read, -- Show, or Generic. See Note [Deriving and unused -- record selectors].
  8. --
[stock_gen_binds] :: StockGenFns -> SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, [LSig GhcPs], Bag AuxBindSpec, [Name]) -- | Describes how to generate associated type family instances for a -- stock-derived instance. This function takes the same arguments as the -- stock_gen_binds function but returns a list of FamInsts -- instead. Generating type family instances is done separately from -- stock_gen_binds since the type family instances must be -- generated before the instance bindings can be typechecked. See -- Note [Staging of tcDeriving] in GHC.Tc.Deriv. [stock_gen_fam_insts] :: StockGenFns -> SrcSpan -> DerivInstTys -> TcM [FamInst] -- | Is GHC processing a standalone deriving declaration? isStandaloneDeriv :: DerivM Bool -- | Is GHC processing a standalone deriving declaration with an -- extra-constraints wildcard as the context? (e.g., deriving -- instance _ => Eq (Foo a)) isStandaloneWildcardDeriv :: DerivM Bool -- | Return InstDeclCtxt if processing with a standalone -- deriving declaration or DerivClauseCtxt if processing -- a deriving clause. askDerivUserTypeCtxt :: DerivM UserTypeCtxt -- | mkDerivOrigin wc returns StandAloneDerivOrigin -- if wc is True, and DerivClauseOrigin if -- wc is False. Useful for error-reporting. mkDerivOrigin :: Bool -> CtOrigin -- | A PredSpec specifies a constraint to emitted when inferring the -- instance context for a derived instance in simplifyInfer. data PredSpec -- | An ordinary PredSpec that directly stores a PredType, -- which will be emitted as a wanted constraint in the constraint solving -- machinery. This is the simple case, as there are no skolems, -- metavariables, or given constraints involved. SimplePredSpec :: TcPredType -> CtOrigin -> TypeOrKind -> PredSpec -- | The constraint to emit as a wanted [sps_pred] :: PredSpec -> TcPredType -- | The origin of the constraint [sps_origin] :: PredSpec -> CtOrigin -- | Whether the constraint is a type or kind [sps_type_or_kind] :: PredSpec -> TypeOrKind -- | A special PredSpec that is only used by -- DeriveAnyClass. This will check if stps_ty_actual is -- a subtype of (i.e., more polymorphic than) stps_ty_expected -- in the constraint solving machinery, emitting an implication -- constraint as a side effect. For more details on how this works, see -- Note [Gathering and simplifying constraints for -- DeriveAnyClass] in GHC.Tc.Deriv.Infer. SubTypePredSpec :: TcSigmaType -> TcSigmaType -> CtOrigin -> PredSpec -- | The actual type. In the context of DeriveAnyClass, this is -- the default method type signature. [stps_ty_actual] :: PredSpec -> TcSigmaType -- | The expected type. In the context of DeriveAnyClass, this is -- the original method type signature. [stps_ty_expected] :: PredSpec -> TcSigmaType -- | The origin of the constraint [stps_origin] :: PredSpec -> CtOrigin -- | A list of PredSpec constraints to simplify when inferring a -- derived instance's context. For the stock, newtype, -- and via deriving strategies, these will consist of -- SimplePredSpecs, and for DeriveAnyClass, these will -- consist of SubTypePredSpecs. Here is an example to illustrate -- the latter: -- --
--   class Foo a where
--     bar :: forall b. Ix b => a -> b -> String
--     default bar :: forall y. (Show a, Ix y) => a -> y -> String
--     bar x y = show x ++ show (range (y, y))
--   
--     baz :: Eq a => a -> a -> Bool
--     default baz :: Ord a => a -> a -> Bool
--     baz x y = compare x y == EQ
--   
--   data Quux q = Quux deriving anyclass Foo
--   
-- -- Then it would generate two SubTypePredSpecs, one for each -- method: -- --
--   [ SubTypePredSpec
--       { stps_ty_actual   = forall y. (Show (Quux q), Ix y) => Quux q -> y -> String
--       , stps_ty_expected = forall b.                (Ix b) => Quux q -> b -> String
--       , stps_ty_origin   = DerivClauseCtxt
--       }
--   , SubTypePredSpec
--       { stps_ty_actual   = Ord (Quux q) => Quux q -> Quux q -> Bool
--       , stps_ty_expected = Eq  (Quux q) => Quux q -> Quux q -> Bool
--       , stps_ty_origin   = DerivClauseCtxt
--       }
--   ]
--   
-- -- (Note that the type variable q is bound by the data type -- Quux, and thus appears free in the stps_ty_actuals and -- stps_ty_expecteds.) -- -- See Note [Gathering and simplifying constraints for -- DeriveAnyClass] in GHC.Tc.Deriv.Infer for an explanation -- of how these SubTypePredSpecs are used to compute implication -- constraints. type ThetaSpec = [PredSpec] -- | Build a list of SimplePredSpecs, using the supplied -- CtOrigin and TypeOrKind values for each PredType. mkDirectThetaSpec :: CtOrigin -> TypeOrKind -> ThetaType -> ThetaSpec substPredSpec :: HasCallStack => TCvSubst -> PredSpec -> PredSpec -- | Capture wanted constraints from a ThetaSpec. captureThetaSpecConstraints :: UserTypeCtxt -> ThetaSpec -> TcM (TcLevel, WantedConstraints) checkOriginativeSideConditions :: DerivInstTys -> DerivM OriginativeDerivStatus hasStockDeriving :: Class -> Maybe StockGenFns std_class_via_coercible :: Class -> Bool non_coercible_class :: Class -> Bool newDerivClsInst :: DerivSpec ThetaType -> TcM ClsInst extendLocalInstEnv :: [ClsInst] -> TcM a -> TcM a instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.PredSpec instance GHC.Utils.Outputable.Outputable theta => GHC.Utils.Outputable.Outputable (GHC.Tc.Deriv.Utils.DerivSpec theta) instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivSpecMechanism instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivEnv instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.Utils.DerivContext module GHC.Tc.Errors.Hole findValidHoleFits :: TidyEnv -> [Implication] -> [CtEvidence] -> Hole -> TcM (TidyEnv, ValidHoleFits) -- | A tcSubsumes which takes into account relevant constraints, to fix -- trac #14273. This makes sure that when checking whether a type fits -- the hole, the type has to be subsumed by type of the hole as well as -- fulfill all constraints on the type of the hole. tcCheckHoleFit :: TypedHole -> TcSigmaType -> TcSigmaType -> TcM (Bool, HsWrapper) -- | Takes a list of free variables and restores any Flexi type variables -- in free_vars after the action is run. withoutUnification :: FV -> TcM a -> TcM a -- | Reports whether first type (ty_a) subsumes the second type (ty_b), -- discarding any errors. Subsumption here means that the ty_b can fit -- into the ty_a, i.e. `tcSubsumes a b == True` if b is a subtype of a. tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool -- | Checks whether a MetaTyVar is flexible or not. isFlexiTyVar :: TcTyVar -> TcM Bool -- | tcFilterHoleFits filters the candidates by whether, given the -- implications and the relevant constraints, they can be made to match -- the type by running the type checker. Stops after finding limit -- matches. tcFilterHoleFits :: Maybe Int -> TypedHole -> (TcType, [TcTyVar]) -> [HoleFitCandidate] -> TcM (Bool, [HoleFit]) getLocalBindings :: TidyEnv -> CtLoc -> TcM [Id] pprHoleFit :: HoleFitDispConfig -> HoleFit -> SDoc addHoleFitDocs :: [HoleFit] -> TcM [HoleFit] getHoleFitSortingAlg :: TcM HoleFitSortingAlg getHoleFitDispConfig :: TcM HoleFitDispConfig -- | Configuration for pretty-printing valid hole fits. data HoleFitDispConfig HFDC :: Bool -> Bool -> Bool -> Bool -> Bool -> HoleFitDispConfig [showWrap] :: HoleFitDispConfig -> Bool [showWrapVars] :: HoleFitDispConfig -> Bool [showType] :: HoleFitDispConfig -> Bool [showProv] :: HoleFitDispConfig -> Bool [showMatches] :: HoleFitDispConfig -> Bool data HoleFitSortingAlg HFSNoSorting :: HoleFitSortingAlg HFSBySize :: HoleFitSortingAlg HFSBySubsumption :: HoleFitSortingAlg relevantCtEvidence :: Type -> [CtEvidence] -> [CtEvidence] zonkSubs :: TidyEnv -> [HoleFit] -> TcM (TidyEnv, [HoleFit]) sortHoleFitsByGraph :: [HoleFit] -> TcM [HoleFit] -- | Sort by size uses as a measure for relevance the sizes of the -- different types needed to instantiate the fit to the type of the hole. -- This is much quicker than sorting by subsumption, and gives reasonable -- results in most cases. sortHoleFitsBySize :: [HoleFit] -> TcM [HoleFit] -- | A HoleFitPlugin is a pair of candidate and fit plugins. data HoleFitPlugin HoleFitPlugin :: CandPlugin -> FitPlugin -> HoleFitPlugin [candPlugin] :: HoleFitPlugin -> CandPlugin [fitPlugin] :: HoleFitPlugin -> FitPlugin -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can -- track internal state. Note the existential quantification, ensuring -- that the state cannot be modified from outside the plugin. data HoleFitPluginR HoleFitPluginR :: TcM (TcRef s) -> (TcRef s -> HoleFitPlugin) -> (TcRef s -> TcM ()) -> HoleFitPluginR -- | Initializes the TcRef to be passed to the plugin [hfPluginInit] :: HoleFitPluginR -> TcM (TcRef s) -- | The function defining the plugin itself [hfPluginRun] :: HoleFitPluginR -> TcRef s -> HoleFitPlugin -- | Cleanup of state, guaranteed to be called even on error [hfPluginStop] :: HoleFitPluginR -> TcRef s -> TcM () instance GHC.Classes.Ord GHC.Tc.Errors.Hole.HoleFitSortingAlg instance GHC.Classes.Eq GHC.Tc.Errors.Hole.HoleFitSortingAlg -- | Functions for inferring (and simplifying) the context for derived -- instances. module GHC.Tc.Deriv.Infer inferConstraints :: DerivSpecMechanism -> DerivM (ThetaSpec, [TyVar], [TcType], DerivSpecMechanism) simplifyInstanceContexts :: [DerivSpec ThetaSpec] -> TcM [DerivSpec ThetaType] module GHC.Rename.Names -- | Process Import Decls. See rnImportDecl for a description of -- what the return types represent. Note: Do the non SOURCE ones first, -- so that we get a helpful warning for SOURCE ones that are unnecessary rnImports :: [(LImportDecl GhcPs, SDoc)] -> RnM ([LImportDecl GhcRn], GlobalRdrEnv, ImportAvails, AnyHpcUsage) getLocalNonValBinders :: MiniFixityEnv -> HsGroup GhcPs -> RnM ((TcGblEnv, TcLclEnv), NameSet) newRecordSelector :: DuplicateRecordFields -> FieldSelectors -> [Name] -> LFieldOcc GhcPs -> RnM FieldLabel extendGlobalRdrEnvRn :: [AvailInfo] -> MiniFixityEnv -> RnM (TcGblEnv, TcLclEnv) -- | make a GlobalRdrEnv where all the elements point to the same -- Provenance (useful for "hiding" imports, or imports with no details). gresFromAvails :: Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt] -- | Calculate the ImportAvails induced by an import of a particular -- interface, but without imp_mods. calculateAvails :: HomeUnit -> Set UnitId -> ModIface -> IsSafeImport -> IsBootInterface -> ImportedBy -> ImportAvails reportUnusedNames :: TcGblEnv -> HscSource -> RnM () checkConName :: RdrName -> TcRn () mkChildEnv :: [GlobalRdrElt] -> NameEnv [GlobalRdrElt] findChildren :: NameEnv [a] -> Name -> [a] findImportUsage :: [LImportDecl GhcRn] -> [GlobalRdrElt] -> [ImportDeclUsage] getMinimalImports :: [ImportDeclUsage] -> RnM [LImportDecl GhcRn] printMinimalImports :: HscSource -> [ImportDeclUsage] -> RnM () -- | Rename raw package imports renamePkgQual :: UnitEnv -> ModuleName -> Maybe FastString -> PkgQual -- | Rename raw package imports renameRawPkgQual :: UnitEnv -> ModuleName -> RawPkgQual -> PkgQual type ImportDeclUsage = (LImportDecl GhcRn, [GlobalRdrElt], [Name]) module GHC.Rename.Doc rnHsDoc :: WithHsDocIdentifiers a GhcPs -> RnM (WithHsDocIdentifiers a GhcRn) rnLHsDoc :: LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLDocDecl :: LDocDecl GhcPs -> RnM (LDocDecl GhcRn) rnDocDecl :: DocDecl GhcPs -> RnM (DocDecl GhcRn) module GHC.Tc.Gen.Export rnExports :: Bool -> Maybe (LocatedL [LIE GhcPs]) -> RnM TcGblEnv exports_from_avail :: Maybe (LocatedL [LIE GhcPs]) -> GlobalRdrEnv -> ImportAvails -> Module -> RnM (Maybe [(LIE GhcRn, Avails)], Avails) module GHC.Rename.HsType rnHsType :: HsDocContext -> HsType GhcPs -> RnM (HsType GhcRn, FreeVars) rnLHsType :: HsDocContext -> LHsType GhcPs -> RnM (LHsType GhcRn, FreeVars) rnLHsTypes :: HsDocContext -> [LHsType GhcPs] -> RnM ([LHsType GhcRn], FreeVars) rnContext :: HsDocContext -> LHsContext GhcPs -> RnM (LHsContext GhcRn, FreeVars) rnMaybeContext :: HsDocContext -> Maybe (LHsContext GhcPs) -> RnM (Maybe (LHsContext GhcRn), FreeVars) rnHsKind :: HsDocContext -> HsKind GhcPs -> RnM (HsKind GhcRn, FreeVars) rnLHsKind :: HsDocContext -> LHsKind GhcPs -> RnM (LHsKind GhcRn, FreeVars) rnLHsTypeArgs :: HsDocContext -> [LHsTypeArg GhcPs] -> RnM ([LHsTypeArg GhcRn], FreeVars) rnHsSigType :: HsDocContext -> TypeOrKind -> LHsSigType GhcPs -> RnM (LHsSigType GhcRn, FreeVars) rnHsWcType :: HsDocContext -> LHsWcType GhcPs -> RnM (LHsWcType GhcRn, FreeVars) rnHsPatSigTypeBindingVars :: HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (r, FreeVars)) -> RnM (r, FreeVars) data HsPatSigTypeScoping -- | Always bind any free tyvars of the given type, regardless of whether -- we have a forall at the top. -- -- For pattern type sigs, we do want to bring those type variables -- into scope, even if there's a forall at the top which usually stops -- that happening, e.g: -- --
--   \ (x :: forall a. a -> b) -> e
--   
-- -- Here we do bring b into scope. -- -- RULES can also use AlwaysBind, such as in the following -- example: -- --
--   {-# RULES \"f\" forall (x :: forall a. a -> b). f x = ... b ... #-}
--   
-- -- This only applies to RULES that do not explicitly bind their type -- variables. If a RULE explicitly quantifies its type variables, then -- NeverBind is used instead. See also Note [Pattern signature -- binders and scoping] in GHC.Hs.Type. AlwaysBind :: HsPatSigTypeScoping -- | Never bind any free tyvars. This is used for RULES that have both -- explicit type and term variable binders, e.g.: -- --
--   {-# RULES \"const\" forall a. forall (x :: a) y. const x y = x #-}
--   
-- -- The presence of the type variable binder forall a. implies -- that the free variables in the types of the term variable binders -- x and y are not bound. In the example above, -- there are no such free variables, but if the user had written (y -- :: b) instead of y in the term variable binders, then -- b would be rejected for being out of scope. See also Note -- [Pattern signature binders and scoping] in GHC.Hs.Type. NeverBind :: HsPatSigTypeScoping rnHsSigWcType :: HsDocContext -> LHsSigWcType GhcPs -> RnM (LHsSigWcType GhcRn, FreeVars) rnHsPatSigType :: HsPatSigTypeScoping -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) newTyVarNameRn :: Maybe a -> LocatedN RdrName -> RnM Name rnConDeclFields :: HsDocContext -> [FieldLabel] -> [LConDeclField GhcPs] -> RnM ([LConDeclField GhcRn], FreeVars) lookupField :: FastStringEnv FieldLabel -> FieldOcc GhcPs -> FieldOcc GhcRn rnLTyVar :: LocatedN RdrName -> RnM (LocatedN Name) rnScaledLHsType :: HsDocContext -> HsScaled GhcPs (LHsType GhcPs) -> RnM (HsScaled GhcRn (LHsType GhcRn), FreeVars) data NegationHandling ReassociateNegation :: NegationHandling KeepNegationIntact :: NegationHandling mkOpAppRn :: NegationHandling -> LHsExpr GhcRn -> LHsExpr GhcRn -> Fixity -> LHsExpr GhcRn -> RnM (HsExpr GhcRn) mkNegAppRn :: LHsExpr GhcRn -> SyntaxExpr GhcRn -> RnM (HsExpr GhcRn) mkOpFormRn :: LHsCmdTop GhcRn -> LHsExpr GhcRn -> Fixity -> LHsCmdTop GhcRn -> RnM (HsCmd GhcRn) mkConOpPatRn :: LocatedN Name -> Fixity -> LPat GhcRn -> LPat GhcRn -> RnM (Pat GhcRn) checkPrecMatch :: Name -> MatchGroup GhcRn body -> RnM () checkSectionPrec :: FixityDirection -> HsExpr GhcPs -> LHsExpr GhcRn -> LHsExpr GhcRn -> RnM () bindHsOuterTyVarBndrs :: OutputableBndrFlag flag 'Renamed => HsDocContext -> Maybe assoc -> FreeKiTyVars -> HsOuterTyVarBndrs flag GhcPs -> (HsOuterTyVarBndrs flag GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) bindHsForAllTelescope :: HsDocContext -> HsForAllTelescope GhcPs -> (HsForAllTelescope GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) bindLHsTyVarBndr :: HsDocContext -> Maybe a -> LHsTyVarBndr flag GhcPs -> (LHsTyVarBndr flag GhcRn -> RnM (b, FreeVars)) -> RnM (b, FreeVars) bindLHsTyVarBndrs :: OutputableBndrFlag flag 'Renamed => HsDocContext -> WarnUnusedForalls -> Maybe a -> [LHsTyVarBndr flag GhcPs] -> ([LHsTyVarBndr flag GhcRn] -> RnM (b, FreeVars)) -> RnM (b, FreeVars) -- | Should GHC warn if a quantified type variable goes unused? Usually, -- the answer is "yes", but in the particular case of binding -- LHsQTyVars, we avoid emitting warnings. See Note [Suppress -- -Wunused-foralls when binding LHsQTyVars]. data WarnUnusedForalls WarnUnusedForalls :: WarnUnusedForalls NoWarnUnusedForalls :: WarnUnusedForalls -- | Create new renamed type variables corresponding to source-level ones. -- Duplicates are permitted, but will be removed. This is intended -- especially for the case of handling the implicitly bound free -- variables of a type signature. rnImplicitTvOccs :: Maybe assoc -> FreeKiTyVars -> ([Name] -> RnM (a, FreeVars)) -> RnM (a, FreeVars) bindSigTyVarsFV :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars) bindHsQTyVars :: forall a b. HsDocContext -> Maybe a -> FreeKiTyVars -> LHsQTyVars GhcPs -> (LHsQTyVars GhcRn -> Bool -> RnM (b, FreeVars)) -> RnM (b, FreeVars) type FreeKiTyVars = [LocatedN RdrName] -- | Filter out any type and kind variables that are already in scope in -- the the environment's LocalRdrEnv. Note that this includes named -- wildcards, which look like perfectly ordinary type variables at this -- point. filterInScopeM :: FreeKiTyVars -> RnM FreeKiTyVars -- | extractHsTyRdrTyVars finds the type/kind variables of a -- HsType/HsKind. It's used when making the foralls explicit. -- See Note [Kind and type-variable binders] extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars -- | Extracts the free type/kind variables from the kind signature of a -- HsType. This is used to implicitly quantify over k in -- type T = Nothing :: Maybe k. The left-to-right order of -- variables is preserved. See Note [Kind and type-variable binders] and -- Note [Ordering of implicit variables] and Note [Implicit -- quantification in type synonyms]. extractHsTyRdrTyVarsKindVars :: LHsType GhcPs -> FreeKiTyVars -- | Extracts free type and kind variables from types in a list. When the -- same name occurs multiple times in the types, all occurrences are -- returned. extractHsTysRdrTyVars :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extractRdrKindSigVars :: LFamilyResultSig GhcPs -> FreeKiTyVars -- | Extracts free type and kind variables from an argument in a GADT -- constructor, returning variable occurrences in left-to-right order. -- See Note [Ordering of implicit variables]. extractConDeclGADTDetailsTyVars :: HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- -- -- -- See Note [Ordering of implicit variables]. extractDataDefnKindVars :: HsDataDefn GhcPs -> FreeKiTyVars extractHsOuterTvBndrs :: HsOuterTyVarBndrs flag GhcPs -> FreeKiTyVars -> FreeKiTyVars extractHsTyArgRdrKiTyVars :: [LHsTypeArg GhcPs] -> FreeKiTyVars nubL :: Eq a => [GenLocated l a] -> [GenLocated l a] nubN :: Eq a => [LocatedN a] -> [LocatedN a] instance GHC.Utils.Outputable.Outputable GHC.Rename.HsType.OpName instance GHC.Utils.Outputable.Outputable GHC.Rename.HsType.WarnUnusedForalls instance GHC.Utils.Outputable.Outputable GHC.Rename.HsType.RnTyKiEnv instance GHC.Utils.Outputable.Outputable GHC.Rename.HsType.RnTyKiWhat module GHC.Rename.Pat rnPat :: HsMatchContext GhcRn -> LPat GhcPs -> (LPat GhcRn -> RnM (a, FreeVars)) -> RnM (a, FreeVars) rnPats :: HsMatchContext GhcRn -> [LPat GhcPs] -> ([LPat GhcRn] -> RnM (a, FreeVars)) -> RnM (a, FreeVars) rnBindPat :: NameMaker -> LPat GhcPs -> RnM (LPat GhcRn, FreeVars) rnPatAndThen :: NameMaker -> Pat GhcPs -> CpsRn (Pat GhcRn) data NameMaker applyNameMaker :: NameMaker -> LocatedN RdrName -> RnM (LocatedN Name) localRecNameMaker :: MiniFixityEnv -> NameMaker topRecNameMaker :: MiniFixityEnv -> NameMaker isTopRecNameMaker :: NameMaker -> Bool rnHsRecFields :: forall arg. HsRecFieldContext -> (SrcSpan -> RdrName -> arg) -> HsRecFields GhcPs (LocatedA arg) -> RnM ([LHsRecField GhcRn (LocatedA arg)], FreeVars) data HsRecFieldContext HsRecFieldCon :: Name -> HsRecFieldContext HsRecFieldPat :: Name -> HsRecFieldContext HsRecFieldUpd :: HsRecFieldContext rnHsRecUpdFields :: [LHsRecUpdField GhcPs] -> RnM ([LHsRecUpdField GhcRn], FreeVars) data CpsRn b liftCps :: RnM a -> CpsRn a liftCpsWithCont :: (forall r. (b -> RnM (r, FreeVars)) -> RnM (r, FreeVars)) -> CpsRn b rnLit :: HsLit p -> RnM () rnOverLit :: HsOverLit t -> RnM ((HsOverLit GhcRn, Maybe (HsExpr GhcRn)), FreeVars) instance GHC.Base.Functor GHC.Rename.Pat.CpsRn instance GHC.Base.Applicative GHC.Rename.Pat.CpsRn instance GHC.Base.Monad GHC.Rename.Pat.CpsRn module GHC.Rename.Bind rnTopBindsLHS :: MiniFixityEnv -> HsValBinds GhcPs -> RnM (HsValBindsLR GhcRn GhcPs) rnTopBindsLHSBoot :: MiniFixityEnv -> HsValBinds GhcPs -> RnM (HsValBindsLR GhcRn GhcPs) rnTopBindsBoot :: NameSet -> HsValBindsLR GhcRn GhcPs -> RnM (HsValBinds GhcRn, DefUses) rnValBindsRHS :: HsSigCtxt -> HsValBindsLR GhcRn GhcPs -> RnM (HsValBinds GhcRn, DefUses) rnLocalBindsAndThen :: HsLocalBinds GhcPs -> (HsLocalBinds GhcRn -> FreeVars -> RnM (result, FreeVars)) -> RnM (result, FreeVars) rnLocalValBindsLHS :: MiniFixityEnv -> HsValBinds GhcPs -> RnM ([Name], HsValBindsLR GhcRn GhcPs) rnLocalValBindsRHS :: NameSet -> HsValBindsLR GhcRn GhcPs -> RnM (HsValBinds GhcRn, DefUses) rnMethodBinds :: Bool -> Name -> [Name] -> LHsBinds GhcPs -> [LSig GhcPs] -> RnM (LHsBinds GhcRn, [LSig GhcRn], FreeVars) renameSigs :: HsSigCtxt -> [LSig GhcPs] -> RnM ([LSig GhcRn], FreeVars) rnMatchGroup :: (Outputable (body GhcPs), AnnoBody body) => HsMatchContext GhcRn -> (LocatedA (body GhcPs) -> RnM (LocatedA (body GhcRn), FreeVars)) -> MatchGroup GhcPs (LocatedA (body GhcPs)) -> RnM (MatchGroup GhcRn (LocatedA (body GhcRn)), FreeVars) rnGRHSs :: AnnoBody body => HsMatchContext GhcRn -> (LocatedA (body GhcPs) -> RnM (LocatedA (body GhcRn), FreeVars)) -> GRHSs GhcPs (LocatedA (body GhcPs)) -> RnM (GRHSs GhcRn (LocatedA (body GhcRn)), FreeVars) rnGRHS :: AnnoBody body => HsMatchContext GhcRn -> (LocatedA (body GhcPs) -> RnM (LocatedA (body GhcRn), FreeVars)) -> LGRHS GhcPs (LocatedA (body GhcPs)) -> RnM (LGRHS GhcRn (LocatedA (body GhcRn)), FreeVars) rnSrcFixityDecl :: HsSigCtxt -> FixitySig GhcPs -> RnM (FixitySig GhcRn) makeMiniFixityEnv :: [LFixitySig GhcPs] -> RnM MiniFixityEnv type MiniFixityEnv = FastStringEnv (Located Fixity) data HsSigCtxt TopSigCtxt :: NameSet -> HsSigCtxt LocalBindCtxt :: NameSet -> HsSigCtxt ClsDeclCtxt :: Name -> HsSigCtxt InstDeclCtxt :: NameSet -> HsSigCtxt HsBootCtxt :: NameSet -> HsSigCtxt RoleAnnotCtxt :: NameSet -> HsSigCtxt module GHC.Rename.Module -- | rnSourceDecl "renames" declarations. It simultaneously -- performs dependency analysis and precedence parsing. It also does the -- following error checks: -- -- -- -- Brings the binders of the group into scope in the appropriate places; -- does NOT assume that anything is in scope already rnSrcDecls :: HsGroup GhcPs -> RnM (TcGblEnv, HsGroup GhcRn) addTcgDUs :: TcGblEnv -> DefUses -> TcGblEnv findSplice :: [LHsDecl GhcPs] -> RnM (HsGroup GhcPs, Maybe (SpliceDecl GhcPs, [LHsDecl GhcPs])) rnWarningTxt :: WarningTxt GhcPs -> RnM (WarningTxt GhcRn) module GHC.Rename.Splice rnTopSpliceDecls :: HsSplice GhcPs -> RnM ([LHsDecl GhcPs], FreeVars) rnSpliceType :: HsSplice GhcPs -> RnM (HsType GhcRn, FreeVars) rnSpliceExpr :: HsSplice GhcPs -> RnM (HsExpr GhcRn, FreeVars) -- | Rename a splice pattern. See Note [rnSplicePat] rnSplicePat :: HsSplice GhcPs -> RnM (Either (Pat GhcPs) (Pat GhcRn), FreeVars) rnSpliceDecl :: SpliceDecl GhcPs -> RnM (SpliceDecl GhcRn, FreeVars) rnTypedBracket :: HsExpr GhcPs -> LHsExpr GhcPs -> RnM (HsExpr GhcRn, FreeVars) rnUntypedBracket :: HsExpr GhcPs -> HsQuote GhcPs -> RnM (HsExpr GhcRn, FreeVars) checkThLocalName :: Name -> RnM () -- | outputs splice information for 2 flags which have different output -- formats: `-ddump-splices` and `-dth-dec-file` traceSplice :: SpliceInfo -> TcM () -- | The splice data to be logged data SpliceInfo SpliceInfo :: String -> Maybe (LHsExpr GhcRn) -> Bool -> SDoc -> SpliceInfo [spliceDescription] :: SpliceInfo -> String [spliceSource] :: SpliceInfo -> Maybe (LHsExpr GhcRn) [spliceIsDecl] :: SpliceInfo -> Bool [spliceGenerated] :: SpliceInfo -> SDoc module GHC.Rename.Expr rnLExpr :: LHsExpr GhcPs -> RnM (LHsExpr GhcRn, FreeVars) rnExpr :: HsExpr GhcPs -> RnM (HsExpr GhcRn, FreeVars) -- | Rename some Stmts rnStmts :: AnnoBody body => HsStmtContext GhcRn -> (body GhcPs -> RnM (body GhcRn, FreeVars)) -> [LStmt GhcPs (LocatedA (body GhcPs))] -> ([Name] -> RnM (thing, FreeVars)) -> RnM (([LStmt GhcRn (LocatedA (body GhcRn))], thing), FreeVars) type AnnoBody body = (Outputable (body GhcPs), Anno (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ~ SrcSpanAnnA, Anno (StmtLR GhcRn GhcPs (LocatedA (body GhcPs))) ~ SrcSpanAnnA, Anno (StmtLR GhcRn GhcRn (LocatedA (body GhcRn))) ~ SrcSpanAnnA) instance GHC.Utils.Outputable.Outputable a => GHC.Utils.Outputable.Outputable (GHC.Rename.Expr.StmtTree a) instance GHC.Utils.Outputable.Outputable GHC.Rename.Expr.MonadNames module GHC.IfaceToCore tcLookupImported_maybe :: Name -> TcM (MaybeErr SDoc TyThing) importDecl :: Name -> IfM lcl (MaybeErr SDoc TyThing) checkWiredInTyCon :: TyCon -> TcM () tcHiBootIface :: HscSource -> Module -> TcRn SelfBootInfo typecheckIface :: ModIface -> IfG ModDetails -- | This is a very interesting function. Like typecheckIface, we want to -- type check an interface file into a ModDetails. However, the use-case -- for these ModDetails is different: we want to compare all of the -- ModDetails to ensure they define compatible declarations, and then -- merge them together. So in particular, we have to take a different -- strategy for knot-tying: we first speculatively merge the declarations -- to get the "base" truth for what we believe the types will be (this is -- "type computation.") Then we read everything in relative to this truth -- and check for compatibility. -- -- During the merge process, we may need to nondeterministically pick a -- particular declaration to use, if multiple signatures define the -- declaration (mergeIfaceDecl). If, for all choices, there are no -- type synonym cycles in the resulting merged graph, then we can show -- that our choice cannot matter. Consider the set of entities which the -- declarations depend on: by assumption of acyclicity, we can assume -- that these have already been shown to be equal to each other -- (otherwise merging will fail). Then it must be the case that all -- candidate declarations here are type-equal (the choice doesn't matter) -- or there is an inequality (in which case merging will fail.) -- -- Unfortunately, the choice can matter if there is a cycle. Consider the -- following merge: -- -- signature H where { type A = C; type B = A; data C } signature H where -- { type A = (); data B; type C = B } -- -- If we pick type A = C as our representative, there will be a -- cycle and merging will fail. But if we pick type A = () as -- our representative, no cycle occurs, and we instead conclude that all -- of the types are unit. So it seems that we either (a) need a stronger -- acyclicity check which considers *all* possible choices from a merge, -- or (b) we must find a selection of declarations which is acyclic, and -- show that this is always the "best" choice we could have made (ezyang -- conjectures this is the case but does not have a proof). For now this -- is not implemented. -- -- It's worth noting that at the moment, a data constructor and a type -- synonym are never compatible. Consider: -- -- signature H where { type Int=C; type B = Int; data C = Int} signature -- H where { export Prelude.Int; data B; type C = B; } -- -- This will be rejected, because the reexported Int in the second -- signature (a proper data type) is never considered equal to a type -- synonym. Perhaps this should be relaxed, where a type synonym in a -- signature is considered implemented by a data type declaration which -- matches the reference of the type synonym. typecheckIfacesForMerging :: Module -> [ModIface] -> KnotVars (IORef TypeEnv) -> IfM lcl (TypeEnv, [ModDetails]) -- | Typecheck a signature ModIface under the assumption that we -- have instantiated it under some implementation (recorded in -- mi_semantic_module) and want to check if the implementation -- fills the signature. -- -- This needs to operate slightly differently than typecheckIface -- because (1) we have a NameShape, from the exports of the -- implementing module, which we will use to give our top-level -- declarations the correct Names even when the implementor -- provided them with a reexport, and (2) we have to deal with DFun -- silliness (see Note [rnIfaceNeverExported]) typecheckIfaceForInstantiate :: NameShape -> ModIface -> IfM lcl ModDetails tcIfaceDecl :: Bool -> IfaceDecl -> IfL TyThing tcIfaceDecls :: Bool -> [(Fingerprint, IfaceDecl)] -> IfL [(Name, TyThing)] tcIfaceInst :: IfaceClsInst -> IfL ClsInst tcIfaceFamInst :: IfaceFamInst -> IfL FamInst tcIfaceRules :: Bool -> [IfaceRule] -> IfL [CoreRule] tcIfaceAnnotations :: [IfaceAnnotation] -> IfL [Annotation] tcIfaceCompleteMatches :: [IfaceCompleteMatch] -> IfL [CompleteMatch] tcIfaceExpr :: IfaceExpr -> IfL CoreExpr tcIfaceGlobal :: Name -> IfL TyThing tcIfaceOneShot :: IfaceOneShot -> OneShotInfo -- | Typechecking user-specified MonoTypes module GHC.Tc.Gen.HsType kcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM () tcClassSigType :: [LocatedN Name] -> LHsSigType GhcRn -> TcM Type tcHsSigType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], Maybe TcType, [(Name, InvisTVBinder)], TcThetaType, TcType) tcStandaloneKindSig :: LStandaloneKindSig GhcRn -> TcM (Name, Kind) funsSigCtxt :: [LocatedN Name] -> UserTypeCtxt addSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> TcM a -> TcM a pprSigCtxt :: Outputable hs_ty => UserTypeCtxt -> LocatedA hs_ty -> SDoc tcHsClsInstType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], Class, [Type], [Kind]) -- | Typecheck a deriving strategy. For most deriving strategies, this is a -- no-op, but for the via strategy, this requires typechecking -- the via type. tcDerivStrategy :: Maybe (LDerivStrategy GhcRn) -> TcM (Maybe (LDerivStrategy GhcTc), [TcTyVar]) -- | Type-check a visible type application tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type -- | UserTypeCtxt describes the origin of the polymorphic type in the -- places where we need an expression to have that type data UserTypeCtxt FunSigCtxt :: Name -> ReportRedundantConstraints -> UserTypeCtxt InfSigCtxt :: Name -> UserTypeCtxt ExprSigCtxt :: ReportRedundantConstraints -> UserTypeCtxt KindSigCtxt :: UserTypeCtxt StandaloneKindSigCtxt :: Name -> UserTypeCtxt TypeAppCtxt :: UserTypeCtxt ConArgCtxt :: Name -> UserTypeCtxt TySynCtxt :: Name -> UserTypeCtxt PatSynCtxt :: Name -> UserTypeCtxt PatSigCtxt :: UserTypeCtxt RuleSigCtxt :: FastString -> Name -> UserTypeCtxt ForSigCtxt :: Name -> UserTypeCtxt DefaultDeclCtxt :: UserTypeCtxt InstDeclCtxt :: Bool -> UserTypeCtxt SpecInstCtxt :: UserTypeCtxt GenSigCtxt :: UserTypeCtxt GhciCtxt :: Bool -> UserTypeCtxt ClassSCCtxt :: Name -> UserTypeCtxt SigmaCtxt :: UserTypeCtxt DataTyCtxt :: Name -> UserTypeCtxt DerivClauseCtxt :: UserTypeCtxt TyVarBndrKindCtxt :: Name -> UserTypeCtxt DataKindCtxt :: Name -> UserTypeCtxt TySynKindCtxt :: Name -> UserTypeCtxt TyFamResKindCtxt :: Name -> UserTypeCtxt bindImplicitTKBndrs_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a) bindImplicitTKBndrs_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) bindImplicitTKBndrs_Q_Tv :: [Name] -> TcM a -> TcM ([TcTyVar], a) bindImplicitTKBndrs_Q_Skol :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) bindExplicitTKBndrs_Tv :: OutputableBndrFlag flag 'Renamed => [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) -- | Skolemise the HsTyVarBndrs in an HsForAllTelescope with -- the supplied TcTyMode. bindExplicitTKBndrs_Skol :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) bindExplicitTKBndrs_Q_Tv :: ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a) bindExplicitTKBndrs_Q_Skol :: SkolemInfo -> ContextKind -> [LHsTyVarBndr () GhcRn] -> TcM a -> TcM ([TcTyVar], a) bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a) bindOuterFamEqnTKBndrs :: SkolemInfo -> HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterFamEqnTyVarBndrs GhcTc, a) tcOuterTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> HsOuterTyVarBndrs flag GhcRn -> TcM a -> TcM (HsOuterTyVarBndrs flag GhcTc, a) scopedSortOuter :: HsOuterTyVarBndrs flag GhcTc -> TcM (HsOuterTyVarBndrs flag GhcTc) outerTyVars :: HsOuterTyVarBndrs flag GhcTc -> [TcTyVar] outerTyVarBndrs :: HsOuterTyVarBndrs Specificity GhcTc -> [InvisTVBinder] bindOuterSigTKBndrs_Tv :: HsOuterSigTyVarBndrs GhcRn -> TcM a -> TcM (HsOuterSigTyVarBndrs GhcTc, a) tcExplicitTKBndrs :: OutputableBndrFlag flag 'Renamed => SkolemInfo -> [LHsTyVarBndr flag GhcRn] -> TcM a -> TcM ([VarBndr TyVar flag], a) bindNamedWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a -- | Bring into scope the binders of a PolyTcTyCon Used for the type -- variables of a type or class decl in the "kind checking" and "type -- checking" pass, but not in the initial-kind run. bindTyClTyVars :: Name -> ([TcTyConBinder] -> TcKind -> TcM a) -> TcM a bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a tcFamTyPats :: TyCon -> HsTyPats GhcRn -> TcM (TcType, TcKind) etaExpandAlgTyCon :: TyConFlavour -> SkolemInfo -> [TcTyConBinder] -> Kind -> TcM ([TcTyConBinder], Kind) tcbVisibilities :: TyCon -> [Type] -> [TyConBndrVis] zonkAndScopedSort :: [TcTyVar] -> TcM [TcTyVar] data InitialKindStrategy InitialKindCheck :: SAKS_or_CUSK -> InitialKindStrategy InitialKindInfer :: InitialKindStrategy data SAKS_or_CUSK SAKS :: Kind -> SAKS_or_CUSK CUSK :: SAKS_or_CUSK -- | Describes the kind expected in a certain context. data ContextKind -- | a specific kind TheKind :: TcKind -> ContextKind -- | any kind will do AnyKind :: ContextKind -- | something of the form TYPE _ OpenKind :: ContextKind kcDeclHeader :: InitialKindStrategy -> Name -> TyConFlavour -> LHsQTyVars GhcRn -> TcM ContextKind -> TcM TcTyCon checkForDuplicateScopedTyVars :: [(Name, TcTyVar)] -> TcM () tcHsLiftedType :: LHsType GhcRn -> TcM TcType tcHsOpenType :: LHsType GhcRn -> TcM TcType tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType tcInferLHsType :: LHsType GhcRn -> TcM TcType tcInferLHsTypeKind :: LHsType GhcRn -> TcM (TcType, TcKind) tcInferLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) tcCheckLHsType :: LHsType GhcRn -> ContextKind -> TcM TcType tcHsContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] tcLHsPredType :: LHsType GhcRn -> TcM PredType -- | kindGeneralizeAll :: SkolemInfo -> TcType -> TcM [KindVar] tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind -- | Checks that the return kind in a data declaration's kind signature is -- permissible. There are three cases: -- -- If dealing with a data, newtype, data -- instance, or newtype instance declaration, check that -- the return kind is Type. -- -- If the declaration is a newtype or newtype instance -- and the UnliftedNewtypes extension is enabled, this check is -- slightly relaxed so that a return kind of the form TYPE r -- (for some r) is permitted. See Note [Implementation of -- UnliftedNewtypes] in GHC.Tc.TyCl. -- -- If dealing with a data family declaration, check that the -- return kind is either of the form: -- --
    --
  1. TYPE r (for some r), or
  2. --
  3. k (where k is a bare kind variable; see -- #12369)
  4. --
-- -- See also Note [Datatype return kinds] in GHC.Tc.TyCl checkDataKindSig :: DataSort -> Kind -> TcM () -- | A description of whether something is a -- -- -- -- At present, this data type is only consumed by -- checkDataKindSig. data DataSort DataDeclSort :: NewOrData -> DataSort DataInstanceSort :: NewOrData -> DataSort DataFamilySort :: DataSort -- | Checks that the result kind of a class is exactly Constraint, -- rejecting type synonyms and type families that reduce to -- Constraint. See #16826. checkClassKindSig :: Kind -> TcM () tcMult :: HsArrow GhcRn -> TcM Mult tcHsPatSigType :: UserTypeCtxt -> HoleMode -> HsPatSigType GhcRn -> ContextKind -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) data HoleMode HM_Sig :: HoleMode HM_FamPat :: HoleMode HM_VTA :: HoleMode HM_TyAppPat :: HoleMode -- | Make an appropriate message for an error in a function argument. Used -- for both expressions and types. funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc -- | Add a "In the data declaration for T" or some such. addTyConFlavCtxt :: Name -> TyConFlavour -> TcM a -> TcM a instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.HsType.SAKS_or_CUSK instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.HsType.TcTyMode instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.HsType.HoleMode module GHC.Tc.Gen.Sig data TcSigInfo TcIdSig :: TcIdSigInfo -> TcSigInfo TcPatSynSig :: TcPatSynInfo -> TcSigInfo data TcIdSigInfo CompleteSig :: TcId -> UserTypeCtxt -> SrcSpan -> TcIdSigInfo [sig_bndr] :: TcIdSigInfo -> TcId [sig_ctxt] :: TcIdSigInfo -> UserTypeCtxt [sig_loc] :: TcIdSigInfo -> SrcSpan PartialSig :: Name -> LHsSigWcType GhcRn -> UserTypeCtxt -> SrcSpan -> TcIdSigInfo [psig_name] :: TcIdSigInfo -> Name [psig_hs_ty] :: TcIdSigInfo -> LHsSigWcType GhcRn [sig_ctxt] :: TcIdSigInfo -> UserTypeCtxt [sig_loc] :: TcIdSigInfo -> SrcSpan data TcIdSigInst data TcPatSynInfo TPSI :: Name -> [InvisTVBinder] -> [InvisTVBinder] -> TcThetaType -> [InvisTVBinder] -> TcThetaType -> TcSigmaType -> TcPatSynInfo [patsig_name] :: TcPatSynInfo -> Name [patsig_implicit_bndrs] :: TcPatSynInfo -> [InvisTVBinder] [patsig_univ_bndrs] :: TcPatSynInfo -> [InvisTVBinder] [patsig_req] :: TcPatSynInfo -> TcThetaType [patsig_ex_bndrs] :: TcPatSynInfo -> [InvisTVBinder] [patsig_prov] :: TcPatSynInfo -> TcThetaType [patsig_body_ty] :: TcPatSynInfo -> TcSigmaType type TcSigFun = Name -> Maybe TcSigInfo isPartialSig :: TcIdSigInst -> Bool -- | No signature or a partial signature hasCompleteSig :: TcSigFun -> Name -> Bool tcIdSigName :: TcIdSigInfo -> Name tcSigInfoName :: TcSigInfo -> Name completeSigPolyId_maybe :: TcSigInfo -> Maybe TcId -- | If there are no wildcards, return a LHsSigWcType isCompleteHsSig :: LHsSigWcType GhcRn -> Bool -- | Find the location of the top-level context of a HsType. For example: -- --
--   forall a b. (Eq a, Ord b) => blah
--               ^^^^^^^^^^^^^
--   
-- -- If there is none, return Nothing lhsSigWcTypeContextSpan :: LHsSigWcType GhcRn -> ReportRedundantConstraints lhsSigTypeContextSpan :: LHsSigType GhcRn -> ReportRedundantConstraints tcTySigs :: [LSig GhcRn] -> TcM ([TcId], TcSigFun) tcUserTypeSig :: SrcSpan -> LHsSigWcType GhcRn -> Maybe Name -> TcM TcIdSigInfo completeSigFromId :: UserTypeCtxt -> Id -> TcIdSigInfo tcInstSig :: TcIdSigInfo -> TcM TcIdSigInst type TcPragEnv = NameEnv [LSig GhcRn] emptyPragEnv :: TcPragEnv lookupPragEnv :: TcPragEnv -> Name -> [LSig GhcRn] extendPragEnv :: TcPragEnv -> (Name, LSig GhcRn) -> TcPragEnv mkPragEnv :: [LSig GhcRn] -> LHsBinds GhcRn -> TcPragEnv tcSpecPrags :: Id -> [LSig GhcRn] -> TcM [LTcSpecPrag] tcSpecWrapper :: UserTypeCtxt -> TcType -> TcType -> TcM HsWrapper tcImpPrags :: [LSig GhcRn] -> TcM [LTcSpecPrag] addInlinePrags :: TcId -> [LSig GhcRn] -> TcM TcId -- | Typechecking patterns module GHC.Tc.Gen.Pat tcLetPat :: (Name -> Maybe TcId) -> LetBndrSpec -> LPat GhcRn -> Scaled ExpSigmaTypeFRR -> TcM a -> TcM (LPat GhcTc, a) newLetBndr :: LetBndrSpec -> Name -> Mult -> TcType -> TcM TcId data LetBndrSpec LetLclBndr :: LetBndrSpec LetGblBndr :: TcPragEnv -> LetBndrSpec tcCheckPat :: HsMatchContext GhcTc -> LPat GhcRn -> Scaled TcSigmaTypeFRR -> TcM a -> TcM (LPat GhcTc, a) -- | A variant of tcPat that takes a custom origin tcCheckPat_O :: HsMatchContext GhcTc -> CtOrigin -> LPat GhcRn -> Scaled TcSigmaTypeFRR -> TcM a -> TcM (LPat GhcTc, a) tcInferPat :: HsMatchContext GhcTc -> LPat GhcRn -> TcM a -> TcM ((LPat GhcTc, a), TcSigmaType) tcPats :: HsMatchContext GhcTc -> [LPat GhcRn] -> [Scaled ExpSigmaTypeFRR] -> TcM a -> TcM ([LPat GhcTc], a) addDataConStupidTheta :: DataCon -> [TcType] -> TcM () polyPatSig :: TcType -> SDoc instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.Pat.LetBndrSpec -- | Typechecking default declarations module GHC.Tc.Gen.Default tcDefaults :: [LDefaultDecl GhcRn] -> TcM (Maybe [Type]) module GHC.Tc.Gen.Bind tcLocalBinds :: HsLocalBinds GhcRn -> TcM thing -> TcM (HsLocalBinds GhcTc, thing) tcTopBinds :: [(RecFlag, LHsBinds GhcRn)] -> [LSig GhcRn] -> TcM (TcGblEnv, TcLclEnv) tcValBinds :: TopLevelFlag -> [(RecFlag, LHsBinds GhcRn)] -> [LSig GhcRn] -> TcM thing -> TcM ([(RecFlag, LHsBinds GhcTc)], thing) tcHsBootSigs :: [(RecFlag, LHsBinds GhcRn)] -> [LSig GhcRn] -> TcM [Id] tcPolyCheck :: TcPragEnv -> TcIdSigInfo -> LHsBind GhcRn -> TcM (LHsBinds GhcTc, [TcId]) chooseInferredQuantifiers :: WantedConstraints -> TcThetaType -> TcTyVarSet -> [TcTyVar] -> Maybe TcIdSigInst -> TcM ([InvisTVBinder], TcThetaType) instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.Bind.GeneralisationPlan -- | Analysis functions over data types. Specifically, detecting recursive -- types. -- -- This stuff is only used for source-code decls; it's recorded in -- interface files for imported data types. module GHC.Tc.TyCl.Utils type RolesInfo = Name -> [Role] inferRoles :: HscSource -> RoleAnnotEnv -> [TyCon] -> Name -> [Role] -- | Checks if any of the passed in TyCons have cycles. Takes the -- Unit of the home package (as we can avoid checking those -- TyCons: cycles never go through foreign packages) and the -- corresponding LTyClDecl Name for each TyCon, so we can -- give better error messages. checkSynCycles :: Unit -> [TyCon] -> [LTyClDecl GhcRn] -> TcM () checkClassCycles :: Class -> Maybe SDoc addTyConsToGblEnv :: [TyCon] -> TcM (TcGblEnv, ThBindEnv) mkDefaultMethodType :: Class -> Id -> DefMethSpec Type -> Type tcRecSelBinds :: [(Id, LHsBind GhcRn)] -> TcM TcGblEnv mkRecSelBinds :: [TyCon] -> [(Id, LHsBind GhcRn)] mkOneRecordSelector :: [ConLike] -> RecSelParent -> FieldLabel -> FieldSelectors -> (Id, LHsBind GhcRn) instance GHC.Base.Functor GHC.Tc.TyCl.Utils.SynCycleM instance GHC.Base.Functor GHC.Tc.TyCl.Utils.RoleM instance GHC.Base.Applicative GHC.Tc.TyCl.Utils.RoleM instance GHC.Base.Monad GHC.Tc.TyCl.Utils.RoleM instance GHC.Base.Applicative GHC.Tc.TyCl.Utils.SynCycleM instance GHC.Base.Monad GHC.Tc.TyCl.Utils.SynCycleM module GHC.Tc.Utils.Backpack -- | For a module modname of type HscSource, determine the -- list of extra "imports" of other requirements which should be -- considered part of the import of the requirement, because it -- transitively depends on those requirements by imports of modules from -- other packages. The situation is something like this: -- -- unit p where signature X signature Y import X -- -- unit q where dependency p[X=<A>,Y=<B>] signature A -- signature B -- -- Although q's B does not directly import A, we still have to make sure -- we process A first, because the merging process will cause B to -- indirectly import A. This function finds the TRANSITIVE closure of all -- such imports we need to make. findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [ModuleName] implicitRequirements :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO [ModuleName] -- | Like implicitRequirements', but returns either the module -- name, if it is a free hole, or the instantiated unit the imported -- module is from, so that that instantiated unit can be processed and -- via the batch mod graph (rather than a transitive closure done here) -- all the free holes are still reachable. implicitRequirementsShallow :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO ([ModuleName], [InstantiatedUnit]) -- | Given a Unit, make sure it is well typed. This is because unit -- IDs come from Cabal, which does not know if things are well-typed or -- not; a component may have been filled with implementations for the -- holes that don't actually fulfill the requirements. checkUnit :: Unit -> TcM () -- | Top-level driver for signature instantiation (run when compiling an -- hsig file.) tcRnCheckUnit :: HscEnv -> Unit -> IO (Messages TcRnMessage, Maybe ()) -- | Top-level driver for signature merging (run after typechecking an -- hsig file). tcRnMergeSignatures :: HscEnv -> HsParsedModule -> TcGblEnv -> ModIface -> IO (Messages TcRnMessage, Maybe TcGblEnv) -- | Given a local ModIface, merge all inherited requirements from -- requirementMerges into this signature, producing a final -- TcGblEnv that matches the local signature and all required -- signatures. mergeSignatures :: HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv -- | Top-level driver for signature instantiation (run when compiling an -- hsig file.) tcRnInstantiateSignature :: HscEnv -> Module -> RealSrcSpan -> IO (Messages TcRnMessage, Maybe TcGblEnv) -- | Given tcg_mod, instantiate a ModIface from the -- indefinite library to use the actual implementations of the relevant -- entities, checking that the implementation matches the signature. instantiateSignature :: TcRn TcGblEnv -- | Typechecking pattern synonym declarations module GHC.Tc.TyCl.PatSyn tcPatSynDecl :: PatSynBind GhcRn GhcRn -> Maybe TcSigInfo -> TcPragEnv -> TcM (LHsBinds GhcTc, TcGblEnv) tcPatSynBuilderBind :: TcPragEnv -> PatSynBind GhcRn GhcRn -> TcM (LHsBinds GhcTc) patSynBuilderOcc :: PatSyn -> Maybe (HsExpr GhcTc, TcSigmaType) -- | Typechecking class declarations module GHC.Tc.TyCl.Class tcClassSigs :: Name -> [LSig GhcRn] -> LHsBinds GhcRn -> TcM [TcMethInfo] tcClassDecl2 :: LTyClDecl GhcRn -> TcM (LHsBinds GhcTc) findMethodBind :: Name -> LHsBinds GhcRn -> TcPragEnv -> Maybe (LHsBind GhcRn, SrcSpan, [LSig GhcRn]) instantiateMethod :: Class -> TcId -> [TcType] -> TcType tcClassMinimalDef :: Name -> [LSig GhcRn] -> [TcMethInfo] -> TcM ClassMinimalDef type HsSigFun = Name -> Maybe (LHsSigType GhcRn) mkHsSigFun :: [LSig GhcRn] -> HsSigFun badMethodErr :: Outputable a => a -> Name -> TcRnMessage instDeclCtxt1 :: LHsSigType GhcRn -> SDoc instDeclCtxt2 :: Type -> SDoc instDeclCtxt3 :: Class -> [Type] -> SDoc -- | Construct default instances for any associated types that aren't given -- a user definition Returns [] or singleton tcATDefault :: SrcSpan -> TCvSubst -> NameSet -> ClassATItem -> TcM [FamInst] module GHC.Tc.Gen.Head data HsExprArg (p :: TcPass) EValArg :: AppCtxt -> EValArg p -> !XEVAType p -> HsExprArg (p :: TcPass) [eva_ctxt] :: HsExprArg (p :: TcPass) -> AppCtxt [eva_arg] :: HsExprArg (p :: TcPass) -> EValArg p [eva_arg_ty] :: HsExprArg (p :: TcPass) -> !XEVAType p ETypeArg :: AppCtxt -> LHsWcType GhcRn -> !XETAType p -> HsExprArg (p :: TcPass) [eva_ctxt] :: HsExprArg (p :: TcPass) -> AppCtxt [eva_hs_ty] :: HsExprArg (p :: TcPass) -> LHsWcType GhcRn [eva_ty] :: HsExprArg (p :: TcPass) -> !XETAType p EPrag :: AppCtxt -> HsPragE (GhcPass (XPass p)) -> HsExprArg (p :: TcPass) EWrap :: EWrap -> HsExprArg (p :: TcPass) data EValArg (p :: TcPass) [ValArg] :: LHsExpr (GhcPass (XPass p)) -> EValArg p [ValArgQL] :: {va_expr :: LHsExpr GhcRn, va_fun :: (HsExpr GhcTc, AppCtxt), va_args :: [HsExprArg 'TcpInst], va_ty :: TcRhoType} -> EValArg 'TcpInst data TcPass TcpRn :: TcPass TcpInst :: TcPass TcpTc :: TcPass data AppCtxt VAExpansion :: HsExpr GhcRn -> SrcSpan -> AppCtxt VACall :: HsExpr GhcRn -> Int -> SrcSpan -> AppCtxt appCtxtLoc :: AppCtxt -> SrcSpan insideExpansion :: AppCtxt -> Bool splitHsApps :: HsExpr GhcRn -> ((HsExpr GhcRn, AppCtxt), [HsExprArg 'TcpRn]) rebuildHsApps :: HsExpr GhcTc -> AppCtxt -> [HsExprArg 'TcpTc] -> HsExpr GhcTc addArgWrap :: HsWrapper -> [HsExprArg 'TcpInst] -> [HsExprArg 'TcpInst] isHsValArg :: HsExprArg id -> Bool countLeadingValArgs :: [HsExprArg id] -> Int isVisibleArg :: HsExprArg id -> Bool pprHsExprArgTc :: HsExprArg 'TcpInst -> SDoc -- | Count visible and invisible value arguments in a list of -- HsExprArg arguments. countVisAndInvisValArgs :: [HsExprArg id] -> Arity -- | Counts the number of invisible term-level arguments applied by an -- HsWrapper. Precondition: this wrapper contains no abstractions. countHsWrapperInvisArgs :: HsWrapper -> Arity tcInferAppHead :: (HsExpr GhcRn, AppCtxt) -> [HsExprArg 'TcpRn] -> TcM (HsExpr GhcTc, TcSigmaType) tcInferAppHead_maybe :: HsExpr GhcRn -> [HsExprArg 'TcpRn] -> TcM (Maybe (HsExpr GhcTc, TcSigmaType)) tcInferId :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tcCheckId :: Name -> ExpRhoType -> TcM (HsExpr GhcTc) obviousSig :: HsExpr GhcRn -> Maybe (LHsSigWcType GhcRn) tyConOf :: FamInstEnvs -> TcSigmaType -> Maybe TyCon tyConOfET :: FamInstEnvs -> ExpRhoType -> Maybe TyCon lookupParents :: Bool -> RdrName -> RnM [(RecSelParent, GlobalRdrElt)] fieldNotInType :: RecSelParent -> RdrName -> TcRnMessage notSelector :: Name -> TcRnMessage nonBidirectionalErr :: Outputable name => name -> TcRnMessage addExprCtxt :: HsExpr GhcRn -> TcRn a -> TcRn a addFunResCtxt :: HsExpr GhcRn -> [HsExprArg 'TcpRn] -> TcType -> ExpRhoType -> TcM a -> TcM a instance GHC.Hs.Extension.OutputableBndrId (GHC.Tc.Gen.Head.XPass p) => GHC.Utils.Outputable.Outputable (GHC.Tc.Gen.Head.HsExprArg p) instance GHC.Hs.Extension.OutputableBndrId (GHC.Tc.Gen.Head.XPass p) => GHC.Utils.Outputable.Outputable (GHC.Tc.Gen.Head.EValArg p) instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.Head.EWrap instance GHC.Utils.Outputable.Outputable GHC.Tc.Gen.Head.AppCtxt -- | Typecheck some Matches module GHC.Tc.Gen.Match tcMatchesFun :: LocatedN Id -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) tcGRHS :: TcMatchCtxt body -> ExpRhoType -> GRHS GhcRn (LocatedA (body GhcRn)) -> TcM (GRHS GhcTc (LocatedA (body GhcTc))) tcGRHSsPat :: GRHSs GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (GRHSs GhcTc (LHsExpr GhcTc)) tcMatchesCase :: AnnoBody body => TcMatchCtxt body -> Scaled TcSigmaTypeFRR -> MatchGroup GhcRn (LocatedA (body GhcRn)) -> ExpRhoType -> TcM (MatchGroup GhcTc (LocatedA (body GhcTc))) tcMatchLambda :: ExpectedFunTyOrigin -> TcMatchCtxt HsExpr -> MatchGroup GhcRn (LHsExpr GhcRn) -> ExpRhoType -> TcM (HsWrapper, MatchGroup GhcTc (LHsExpr GhcTc)) data TcMatchCtxt body MC :: HsMatchContext GhcTc -> (LocatedA (body GhcRn) -> ExpRhoType -> TcM (LocatedA (body GhcTc))) -> TcMatchCtxt body [mc_what] :: TcMatchCtxt body -> HsMatchContext GhcTc [mc_body] :: TcMatchCtxt body -> LocatedA (body GhcRn) -> ExpRhoType -> TcM (LocatedA (body GhcTc)) type TcStmtChecker body rho_type = forall thing. HsStmtContext GhcTc -> Stmt GhcRn (LocatedA (body GhcRn)) -> rho_type -> (rho_type -> TcM thing) -> TcM (Stmt GhcTc (LocatedA (body GhcTc)), thing) type TcExprStmtChecker = TcStmtChecker HsExpr ExpRhoType type TcCmdStmtChecker = TcStmtChecker HsCmd TcRhoType tcStmts :: AnnoBody body => HsStmtContext GhcTc -> TcStmtChecker body rho_type -> [LStmt GhcRn (LocatedA (body GhcRn))] -> rho_type -> TcM [LStmt GhcTc (LocatedA (body GhcTc))] tcStmtsAndThen :: AnnoBody body => HsStmtContext GhcTc -> TcStmtChecker body rho_type -> [LStmt GhcRn (LocatedA (body GhcRn))] -> rho_type -> (rho_type -> TcM thing) -> TcM ([LStmt GhcTc (LocatedA (body GhcTc))], thing) tcDoStmts :: HsDoFlavour -> LocatedL [LStmt GhcRn (LHsExpr GhcRn)] -> ExpRhoType -> TcM (HsExpr GhcTc) tcBody :: LHsExpr GhcRn -> ExpRhoType -> TcM (LHsExpr GhcTc) tcDoStmt :: TcExprStmtChecker tcGuardStmt :: TcExprStmtChecker -- | Typecheck arrow notation module GHC.Tc.Gen.Arrow tcProc :: LPat GhcRn -> LHsCmdTop GhcRn -> ExpRhoType -> TcM (LPat GhcTc, LHsCmdTop GhcTc, TcCoercion) module GHC.Tc.Gen.App tcApp :: HsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcInferSigma :: Bool -> LHsExpr GhcRn -> TcM TcSigmaType tcExprPrag :: HsPragE GhcRn -> HsPragE GhcTc module GHC.Tc.Gen.Expr tcCheckPolyExpr :: LHsExpr GhcRn -> TcSigmaType -> TcM (LHsExpr GhcTc) tcCheckPolyExprNC :: LHsExpr GhcRn -> TcSigmaType -> TcM (LHsExpr GhcTc) tcCheckMonoExpr :: LHsExpr GhcRn -> TcRhoType -> TcM (LHsExpr GhcTc) tcCheckMonoExprNC :: LHsExpr GhcRn -> TcRhoType -> TcM (LHsExpr GhcTc) tcMonoExpr :: LHsExpr GhcRn -> ExpRhoType -> TcM (LHsExpr GhcTc) tcMonoExprNC :: LHsExpr GhcRn -> ExpRhoType -> TcM (LHsExpr GhcTc) tcInferRho :: LHsExpr GhcRn -> TcM (LHsExpr GhcTc, TcRhoType) tcInferRhoNC :: LHsExpr GhcRn -> TcM (LHsExpr GhcTc, TcRhoType) tcPolyExpr :: HsExpr GhcRn -> ExpSigmaType -> TcM (HsExpr GhcTc) tcExpr :: HsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) -- | Typecheck a syntax operator The operator is a variable or a lambda at -- this stage (i.e. renamer output)t tcSyntaxOp :: CtOrigin -> SyntaxExprRn -> [SyntaxOpType] -> ExpRhoType -> ([TcSigmaType] -> [Mult] -> TcM a) -> TcM (a, SyntaxExprTc) -- | Slightly more general version of tcSyntaxOp that allows the -- caller to specify the shape of the result of the syntax operator tcSyntaxOpGen :: CtOrigin -> SyntaxExprRn -> [SyntaxOpType] -> SyntaxOpType -> ([TcSigmaTypeFRR] -> [Mult] -> TcM a) -> TcM (a, SyntaxExprTc) -- | What to expect for an argument to a rebindable-syntax operator. Quite -- like Type, but allows for holes to be filled in by tcSyntaxOp. -- The callback called from tcSyntaxOp gets a list of types; the meaning -- of these types is determined by a left-to-right depth-first traversal -- of the SyntaxOpType tree. So if you pass in -- --
--   SynAny `SynFun` (SynList `SynFun` SynType Int) `SynFun` SynAny
--   
-- -- you'll get three types back: one for the first SynAny, the -- element type of the list, and one for the last SynAny. -- You don't get anything for the SynType, because you've said -- positively that it should be an Int, and so it shall be. -- -- You'll also get three multiplicities back: one for each function -- arrow. See also Note [Linear types] in Multiplicity. -- -- This is defined here to avoid defining it in GHC.Tc.Gen.Expr -- boot file. data SyntaxOpType -- | Any type SynAny :: SyntaxOpType -- | A rho type, skolemised or instantiated as appropriate SynRho :: SyntaxOpType -- | A list type. You get back the element type of the list SynList :: SyntaxOpType -- | A function. SynFun :: SyntaxOpType -> SyntaxOpType -> SyntaxOpType -- | A known type. SynType :: ExpType -> SyntaxOpType infixr 0 `SynFun` -- | Like SynType but accepts a regular TcType synKnownType :: TcType -> SyntaxOpType tcCheckId :: Name -> ExpRhoType -> TcM (HsExpr GhcTc) getFixedTyVars :: [FieldLabelString] -> [TyVar] -> [ConLike] -> TyVarSet -- | Typechecking rewrite rules module GHC.Tc.Gen.Rule tcRules :: [LRuleDecls GhcRn] -> TcM [LRuleDecls GhcTc] -- | Typechecking foreign declarations -- -- A foreign declaration is used to either give an externally implemented -- function a Haskell type (and calling interface) or give a Haskell -- function an external calling interface. Either way, the range of -- argument and result types these functions can accommodate is -- restricted to what the outside world understands (read C), and this -- module checks to see if a foreign declaration has got a legal type. module GHC.Tc.Gen.Foreign tcForeignImports :: [LForeignDecl GhcRn] -> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt) tcForeignExports :: [LForeignDecl GhcRn] -> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt) isForeignImport :: forall name. UnXRec name => LForeignDecl name -> Bool isForeignExport :: forall name. UnXRec name => LForeignDecl name -> Bool tcFImport :: LForeignDecl GhcRn -> TcM (Id, LForeignDecl GhcTc, Bag GlobalRdrElt) tcFExport :: ForeignDecl GhcRn -> TcM (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt) tcForeignImports' :: [LForeignDecl GhcRn] -> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt) tcCheckFIType :: [Scaled Type] -> Type -> ForeignImport -> TcM ForeignImport checkCTarget :: ForeignImport -> CCallTarget -> TcM () checkForeignArgs :: (Type -> Validity' IllegalForeignTypeReason) -> [Scaled Type] -> TcM () -- | Check that the type has the form (IO t) or (t) , and that t satisfies -- the given predicate. When calling this function, any newtype wrappers -- (should) have been already dealt with by normaliseFfiType. -- -- We also check that the Safe Haskell condition of FFI imports having -- results in the IO monad holds. checkForeignRes :: Bool -> Bool -> (Type -> Validity' IllegalForeignTypeReason) -> Type -> TcM () normaliseFfiType :: Type -> TcM (Reduction, Bag GlobalRdrElt) nonIOok :: Bool mustBeIO :: Bool checkSafe :: Bool noCheckSafe :: Bool tcForeignExports' :: [LForeignDecl GhcRn] -> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt) tcCheckFEType :: Type -> ForeignExport -> TcM ForeignExport -- | Handles deriving clauses on data declarations. module GHC.Tc.Deriv tcDeriving :: [DerivInfo] -> [LDerivDecl GhcRn] -> TcM (TcGblEnv, Bag (InstInfo GhcRn), HsValBinds GhcRn) -- | Stuff needed to process a datatype's `deriving` clauses data DerivInfo DerivInfo :: TyCon -> ![(Name, TyVar)] -> [LHsDerivingClause GhcRn] -> SDoc -> DerivInfo -- | The data tycon for normal datatypes, or the *representation* tycon for -- data families [di_rep_tc] :: DerivInfo -> TyCon -- | Variables that scope over the deriving clause. See Note [Scoped -- tyvars in a TcTyCon] in GHC.Core.TyCon. [di_scoped_tvs] :: DerivInfo -> ![(Name, TyVar)] [di_clauses] :: DerivInfo -> [LHsDerivingClause GhcRn] -- | error context [di_ctxt] :: DerivInfo -> SDoc instance GHC.Utils.Outputable.Outputable GHC.Tc.Deriv.EarlyDerivSpec -- | Typecheck type and class declarations module GHC.Tc.TyCl tcTyAndClassDecls :: [TyClGroup GhcRn] -> TcM (TcGblEnv, [InstInfo GhcRn], [DerivInfo], ThBindEnv) kcConDecls :: NewOrData -> TcKind -> [LConDecl GhcRn] -> TcM () tcConDecls :: NewOrData -> DataDeclInfo -> KnotTied TyCon -> [TcTyConBinder] -> TcKind -> [LConDecl GhcRn] -> TcM [DataCon] data DataDeclInfo DDataType :: DataDeclInfo DDataInstance :: Type -> DataDeclInfo dataDeclChecks :: Name -> NewOrData -> Maybe (LHsContext GhcRn) -> [LConDecl GhcRn] -> TcM Bool checkValidTyCon :: TyCon -> TcM () tcFamTyPats :: TyCon -> HsTyPats GhcRn -> TcM (TcType, TcKind) tcTyFamInstEqn :: TcTyCon -> AssocInstInfo -> LTyFamInstEqn GhcRn -> TcM (KnotTied CoAxBranch) tcAddTyFamInstCtxt :: TyFamInstDecl GhcRn -> TcM a -> TcM a tcMkDataFamInstCtxt :: DataFamInstDecl GhcRn -> SDoc tcAddDataFamInstCtxt :: DataFamInstDecl GhcRn -> TcM a -> TcM a unravelFamInstPats :: TcType -> [TcType] addConsistencyConstraints :: AssocInstInfo -> TcType -> TcM () wrongKindOfFamily :: TyCon -> TcRnMessage checkFamTelescope :: TcLevel -> HsOuterFamEqnTyVarBndrs GhcRn -> [TcTyVar] -> TcM () -- | Typechecking instance declarations module GHC.Tc.TyCl.Instance tcInstDecls1 :: [LInstDecl GhcRn] -> TcM (TcGblEnv, [InstInfo GhcRn], [DerivInfo], ThBindEnv) -- | Use DerivInfo for data family instances (produced by tcInstDecls1), -- datatype declarations (TyClDecl), and standalone deriving declarations -- (DerivDecl) to check and process all derived class instances. tcInstDeclsDeriv :: [DerivInfo] -> [LDerivDecl GhcRn] -> TcM (TcGblEnv, [InstInfo GhcRn], HsValBinds GhcRn) tcInstDecls2 :: [LTyClDecl GhcRn] -> [InstInfo GhcRn] -> TcM (LHsBinds GhcTc) module GHC.HsToCore.Monad -- | Desugaring monad. See also TcM. type DsM = TcRnIf DsGblEnv DsLclEnv -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) -- | The mapAndUnzipM function maps its first argument over a list, -- returning the result as a pair of lists. This function is mainly used -- with complicated data structures or a state monad. mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) -- | Run a DsM action inside the IO monad. initDs :: HscEnv -> TcGblEnv -> DsM a -> IO (Messages DsMessage, Maybe a) -- | Run a DsM action inside the TcM monad. initDsTc :: DsM a -> TcM (Messages DsMessage, Maybe a) initTcDsForSolver :: TcM a -> DsM a -- | Run a DsM action in the context of an existing ModGuts initDsWithModGuts :: HscEnv -> ModGuts -> DsM a -> IO (Messages DsMessage, Maybe a) fixDs :: (a -> DsM a) -> DsM a -- | Monadic fold over the elements of a structure, associating to the -- left, i.e. from left to right. foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b -- | Monadic fold over the elements of a structure, associating to the -- right, i.e. from right to left. foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b whenGOptM :: GeneralFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () unsetGOptM :: GeneralFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a unsetWOptM :: WarningFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a xoptM :: Extension -> TcRnIf gbl lcl Bool -- | A functor with application, providing operations to -- -- -- -- A minimal complete definition must include implementations of -- pure and of either <*> or liftA2. If it -- defines both, then they must behave the same as their default -- definitions: -- --
--   (<*>) = liftA2 id
--   
-- --
--   liftA2 f x y = f <$> x <*> y
--   
-- -- Further, any definition must satisfy the following: -- -- -- -- The other methods have the following default definitions, which may be -- overridden with equivalent specialized implementations: -- -- -- -- As a consequence of these laws, the Functor instance for -- f will satisfy -- -- -- -- It may be useful to note that supposing -- --
--   forall x y. p (q x y) = f x . g y
--   
-- -- it follows from the above that -- --
--   liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v
--   
-- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- -- Using ApplicativeDo: 'fs <*> as' can be -- understood as the do expression -- --
--   do f <- fs
--      a <- as
--      pure (f a)
--   
(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. -- -- This became a typeclass method in 4.10.0.0. Prior to that, it was a -- function defined in terms of <*> and fmap. -- -- Using ApplicativeDo: 'liftA2 f as bs' can be -- understood as the do expression -- --
--   do a <- as
--      b <- bs
--      pure (f a b)
--   
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. -- -- 'as *> bs' can be understood as the do -- expression -- --
--   do as
--      bs
--   
-- -- This is a tad complicated for our ApplicativeDo extension -- which will give it a Monad constraint. For an -- Applicative constraint we write it of the form -- --
--   do _ <- as
--      b <- bs
--      pure b
--   
(*>) :: Applicative f => f a -> f b -> f b -- | Sequence actions, discarding the value of the second argument. -- -- Using ApplicativeDo: 'as <* bs' can be -- understood as the do expression -- --
--   do a <- as
--      bs
--      pure a
--   
(<*) :: Applicative f => f a -> f b -> f a infixl 4 <*> infixl 4 *> infixl 4 <* -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
-- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --

Examples

-- -- Convert from a Maybe Int to a Maybe -- String using show: -- --
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
-- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
-- -- Double each element of a list: -- --
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
-- -- Apply even to the second element of a pair: -- --
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> duplicateLocalDs :: Id -> DsM Id newSysLocalDs :: Mult -> Type -> DsM Id newSysLocalsDs :: [Scaled Type] -> DsM [Id] newUniqueId :: Id -> Mult -> Type -> DsM Id newFailLocalDs :: Mult -> Type -> DsM Id newPredVarDs :: PredType -> DsM Var getSrcSpanDs :: DsM SrcSpan putSrcSpanDs :: SrcSpan -> DsM a -> DsM a putSrcSpanDsA :: SrcSpanAnn' ann -> DsM a -> DsM a mkPrintUnqualifiedDs :: DsM PrintUnqualified newUnique :: TcRnIf gbl lcl Unique -- | Unique Supply -- -- A value of type UniqSupply is unique, and it can supply -- one distinct Unique. Also, from the supply, one can also -- manufacture an arbitrary number of further UniqueSupply -- values, which will be distinct from the first and from all others. data UniqSupply newUniqueSupply :: TcRnIf gbl lcl UniqSupply getGhcModeDs :: DsM GhcMode dsGetFamInstEnvs :: DsM FamInstEnvs dsLookupGlobal :: Name -> DsM TyThing dsLookupGlobalId :: Name -> DsM Id dsLookupTyCon :: Name -> DsM TyCon dsLookupDataCon :: Name -> DsM DataCon dsLookupConLike :: Name -> DsM ConLike -- | See getCCIndexM. getCCIndexDsM :: FastString -> DsM CostCentreIndex type DsMetaEnv = NameEnv DsMetaVal data DsMetaVal DsBound :: Id -> DsMetaVal DsSplice :: HsExpr GhcTc -> DsMetaVal dsGetMetaEnv :: DsM (NameEnv DsMetaVal) dsLookupMetaEnv :: Name -> DsM (Maybe DsMetaVal) dsExtendMetaEnv :: DsMetaEnv -> DsM a -> DsM a -- | Get the current pattern match oracle state. See dsl_nablas. getPmNablas :: DsM Nablas -- | Set the pattern match oracle state within the scope of the given -- action. See dsl_nablas. updPmNablas :: Nablas -> DsM a -> DsM a -- | The COMPLETE pragmas that are in scope. dsGetCompleteMatches :: DsM CompleteMatches type DsWarning = (SrcSpan, SDoc) -- | Emit a diagnostic for the current source location. In case the -- diagnostic is a warning, the latter will be ignored and discarded if -- the relevant WarningFlag is not set in the DynFlags. See Note -- [Discarding Messages] in Error. diagnosticDs :: DsMessage -> DsM () -- | Issue an error, but return the expression for (), so that we can -- continue reporting errors. errDsCoreExpr :: DsMessage -> DsM CoreExpr failWithDs :: DsMessage -> DsM a failDs :: DsM a discardWarningsDs :: DsM a -> DsM a data DsMatchContext DsMatchContext :: HsMatchContext GhcRn -> SrcSpan -> DsMatchContext data EquationInfo EqnInfo :: [Pat GhcTc] -> Origin -> MatchResult CoreExpr -> EquationInfo -- | The patterns for an equation -- -- NB: We have already applied decideBangHood to these -- patterns. See Note [decideBangHood] in GHC.HsToCore.Utils [eqn_pats] :: EquationInfo -> [Pat GhcTc] -- | Was this equation present in the user source? -- -- This helps us avoid warnings on patterns that GHC elaborated. -- -- For instance, the pattern -1 :: Word gets desugared into -- W# :: Word, but we shouldn't warn about an overflowed literal -- for both of these cases. [eqn_orig] :: EquationInfo -> Origin -- | What to do after match [eqn_rhs] :: EquationInfo -> MatchResult CoreExpr -- | This is a value of type a with potentially a CoreExpr-shaped hole in -- it. This is used to deal with cases where we are potentially handling -- pattern match failure, and want to later specify how failure is -- handled. data MatchResult a -- | We represent the case where there is no hole without a function from -- CoreExpr, like this, because sometimes we have nothing to put -- in the hole and so want to be sure there is in fact no hole. MR_Infallible :: DsM a -> MatchResult a MR_Fallible :: (CoreExpr -> DsM a) -> MatchResult a runMatchResult :: CoreExpr -> MatchResult a -> DsM a type DsWrapper = CoreExpr -> CoreExpr idDsWrapper :: DsWrapper -- | Inject a trace message into the compiled program. Whereas pprTrace -- prints out information *while compiling*, pprRuntimeTrace captures -- that information and causes it to be printed *at runtime* using -- Debug.Trace.trace. -- -- pprRuntimeTrace hdr doc expr -- -- will produce an expression that looks like -- -- trace (hdr + doc) expr -- -- When using this to debug a module that Debug.Trace depends on, it is -- necessary to import {--} Debug.Trace () in that module. We could avoid -- this inconvenience by wiring in Debug.Trace.trace, but that doesn't -- seem worth the effort and maintenance cost. pprRuntimeTrace :: String -> SDoc -> CoreExpr -> DsM CoreExpr instance GHC.Base.Functor GHC.HsToCore.Monad.MatchResult instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Monad.EquationInfo instance GHC.Base.Applicative GHC.HsToCore.Monad.MatchResult instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Monad.DsMatchContext instance GHC.Types.TyThing.MonadThings (GHC.Data.IOEnv.IOEnv (GHC.Tc.Types.Env GHC.HsToCore.Types.DsGblEnv GHC.HsToCore.Types.DsLclEnv)) -- | Utility module for the pattern-match coverage checker. module GHC.HsToCore.Pmc.Utils tracePm :: String -> SDoc -> DsM () traceWhenFailPm :: String -> SDoc -> MaybeT DsM a -> MaybeT DsM a -- | Generate a fresh Id of a given type mkPmId :: Type -> DsM Id -- | All warning flags that need to run the pattern match checker. allPmCheckWarnings :: [WarningFlag] -- | Check whether the redundancy checker should run (redundancy only) overlapping :: DynFlags -> HsMatchContext id -> Bool -- | Check whether the exhaustiveness checker should run (exhaustiveness -- only) exhaustive :: DynFlags -> HsMatchContext id -> Bool -- | Check whether unnecessary bangs should be warned about redundantBang :: DynFlags -> Bool -- | Denotes whether an exhaustiveness check is supported, and if so, via -- which WarningFlag it's controlled. Returns Nothing if -- check is not supported. exhaustiveWarningFlag :: HsMatchContext id -> Maybe WarningFlag -- | Check whether any part of pattern match checking is enabled for this -- HsMatchContext (does not matter whether it is the redundancy -- check or the exhaustiveness check). isMatchContextPmChecked :: DynFlags -> Origin -> HsMatchContext id -> Bool -- | Return True when any of the pattern match warnings -- (allPmCheckWarnings) are enabled, in which case we need to run -- the pattern match checker. needToRunPmCheck :: DynFlags -> Origin -> Bool -- | Model refinements type as per the Lower Your Guards paper. The -- main export of the module are the functions addPhiCtsNablas for -- adding facts to the oracle, isInhabited to check if a -- refinement type is inhabited and generateInhabitingPatterns to -- turn a Nabla into a concrete pattern for an equation. -- -- In terms of the LYG paper, this module is concerned with Sections 3.4, -- 3.6 and 3.7. E.g., it represents refinement types directly as a bunch -- of normalised refinement types Nabla. module GHC.HsToCore.Pmc.Solver -- | A normalised refinement type ∇ ("nabla"), comprised of an inert set of -- canonical (i.e. mutually compatible) term and type constraints that -- form the refinement type's predicate. data Nabla -- | A disjunctive bag of Nablas, representing a refinement type. newtype Nablas MkNablas :: Bag Nabla -> Nablas initNablas :: Nablas -- | A high-level pattern-match constraint. Corresponds to φ from Figure 3 -- of the LYG paper. data PhiCt -- | A type constraint "T ~ U". PhiTyCt :: !PredType -> PhiCt -- | PhiCoreCt x e encodes "x ~ e", equating x with the -- CoreExpr e. PhiCoreCt :: !Id -> !CoreExpr -> PhiCt -- | PhiConCt x K tvs dicts ys encodes K @tvs dicts ys <- -- x, matching x against the PmAltCon application -- K @tvs dicts ys, binding tvs, dicts and -- possibly unlifted fields ys in the process. See Note [Strict -- fields and variables of unlifted type]. PhiConCt :: !Id -> !PmAltCon -> ![TyVar] -> ![PredType] -> ![Id] -> PhiCt -- | PhiNotConCt x K encodes "x ≁ K", asserting that x -- can't be headed by K. PhiNotConCt :: !Id -> !PmAltCon -> PhiCt -- | PhiBotCt x encodes "x ~ ⊥", equating x to ⊥. by -- K. PhiBotCt :: !Id -> PhiCt -- | PhiNotBotCt x y encodes "x ≁ ⊥", asserting that x -- can't be ⊥. PhiNotBotCt :: !Id -> PhiCt type PhiCts = Bag PhiCt -- | addPmCtsNablas for a single PmCt. addPhiCtNablas :: Nablas -> PhiCt -> DsM Nablas -- | Add a bunch of PhiCts to all the Nablas. Lifts -- addPhiCts over many Nablas. addPhiCtsNablas :: Nablas -> PhiCts -> DsM Nablas -- | Test if any of the Nablas is inhabited. Currently this is pure, -- because we preserve the invariant that there are no uninhabited -- Nablas. But that could change in the future, for example by -- implementing this function in terms of notNull $ -- generateInhabitingPatterns 1 ds. isInhabited :: Nablas -> DsM Bool -- | generateInhabitingPatterns vs n nabla returns a list of at -- most n (but perhaps empty) refinements of nabla that -- represent inhabited patterns. Negative information is only retained if -- literals are involved or for recursive GADTs. generateInhabitingPatterns :: GenerateInhabitingPatternsMode -> [Id] -> Int -> Nabla -> DsM [Nabla] -- | See Note [Case split inhabiting patterns] data GenerateInhabitingPatternsMode CaseSplitTopLevel :: GenerateInhabitingPatternsMode MinimalCover :: GenerateInhabitingPatternsMode instance GHC.Show.Show GHC.HsToCore.Pmc.Solver.GenerateInhabitingPatternsMode instance GHC.Classes.Eq GHC.HsToCore.Pmc.Solver.GenerateInhabitingPatternsMode instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Solver.GenerateInhabitingPatternsMode instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Solver.PhiCt instance GHC.Utils.Outputable.Outputable GHC.HsToCore.Pmc.Solver.TopNormaliseTypeResult -- | Coverage checking step of the Lower Your Guards paper. -- -- Coverage check guard trees (like PmMatch Pre) -- to get a CheckResult, containing -- --
    --
  1. The set of uncovered values, cr_uncov
  2. --
  3. And an annotated tree variant (like PmMatch -- Post) that captures redundancy and inaccessibility -- information as RedSets annotations
  4. --
-- -- Basically the UA function from Section 5.1, which is an optimised -- interleaving of U and A from Section 3.2 (Figure 5). The Normalised -- Refinement Types Nablas are maintained in -- GHC.HsToCore.Pmc.Solver. module GHC.HsToCore.Pmc.Check -- | Coverage checking action. Can be composed leftToRight or -- topToBottom. newtype CheckAction a CA :: (Nablas -> DsM (CheckResult a)) -> CheckAction a [unCA] :: CheckAction a -> Nablas -> DsM (CheckResult a) checkMatchGroup :: PmMatchGroup Pre -> CheckAction (PmMatchGroup Post) checkGRHSs :: PmGRHSs Pre -> CheckAction (PmGRHSs Post) checkPatBind :: PmPatBind Pre -> CheckAction (PmPatBind Post) checkEmptyCase :: PmEmptyCase -> CheckAction PmEmptyCase instance GHC.Base.Functor GHC.HsToCore.Pmc.Check.CheckAction -- | Utility functions for constructing Core syntax, principally for -- desugaring module GHC.HsToCore.Utils data EquationInfo EqnInfo :: [Pat GhcTc] -> Origin -> MatchResult CoreExpr -> EquationInfo -- | The patterns for an equation -- -- NB: We have already applied decideBangHood to these -- patterns. See Note [decideBangHood] in GHC.HsToCore.Utils [eqn_pats] :: EquationInfo -> [Pat GhcTc] -- | Was this equation present in the user source? -- -- This helps us avoid warnings on patterns that GHC elaborated. -- -- For instance, the pattern -1 :: Word gets desugared into -- W# :: Word, but we shouldn't warn about an overflowed literal -- for both of these cases. [eqn_orig] :: EquationInfo -> Origin -- | What to do after match [eqn_rhs] :: EquationInfo -> MatchResult CoreExpr firstPat :: EquationInfo -> Pat GhcTc shiftEqns :: Functor f => f EquationInfo -> f EquationInfo -- | This is a value of type a with potentially a CoreExpr-shaped hole in -- it. This is used to deal with cases where we are potentially handling -- pattern match failure, and want to later specify how failure is -- handled. data MatchResult a -- | We represent the case where there is no hole without a function from -- CoreExpr, like this, because sometimes we have nothing to put -- in the hole and so want to be sure there is in fact no hole. MR_Infallible :: DsM a -> MatchResult a MR_Fallible :: (CoreExpr -> DsM a) -> MatchResult a data CaseAlt a MkCaseAlt :: a -> [Var] -> HsWrapper -> MatchResult CoreExpr -> CaseAlt a [alt_pat] :: CaseAlt a -> a [alt_bndrs] :: CaseAlt a -> [Var] [alt_wrapper] :: CaseAlt a -> HsWrapper [alt_result] :: CaseAlt a -> MatchResult CoreExpr cantFailMatchResult :: CoreExpr -> MatchResult CoreExpr alwaysFailMatchResult :: MatchResult CoreExpr extractMatchResult :: MatchResult CoreExpr -> CoreExpr -> DsM CoreExpr combineMatchResults :: MatchResult CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr adjustMatchResultDs :: (a -> DsM b) -> MatchResult a -> MatchResult b shareFailureHandler :: MatchResult CoreExpr -> MatchResult CoreExpr dsHandleMonadicFailure :: HsDoFlavour -> LPat GhcTc -> MatchResult CoreExpr -> FailOperator GhcTc -> DsM CoreExpr mkCoLetMatchResult :: CoreBind -> MatchResult CoreExpr -> MatchResult CoreExpr mkViewMatchResult :: Id -> CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr mkGuardedMatchResult :: CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr matchCanFail :: MatchResult a -> Bool mkEvalMatchResult :: Id -> Type -> MatchResult CoreExpr -> MatchResult CoreExpr mkCoPrimCaseMatchResult :: Id -> Type -> [(Literal, MatchResult CoreExpr)] -> MatchResult CoreExpr mkCoAlgCaseMatchResult :: Id -> Type -> NonEmpty (CaseAlt DataCon) -> MatchResult CoreExpr mkCoSynCaseMatchResult :: Id -> Type -> CaseAlt PatSyn -> MatchResult CoreExpr wrapBind :: Var -> Var -> CoreExpr -> CoreExpr wrapBinds :: [(Var, Var)] -> CoreExpr -> CoreExpr mkErrorAppDs :: Id -> Type -> SDoc -> DsM CoreExpr mkCoreAppDs :: SDoc -> CoreExpr -> CoreExpr -> CoreExpr mkCoreAppsDs :: SDoc -> CoreExpr -> [CoreExpr] -> CoreExpr mkCastDs :: CoreExpr -> Coercion -> CoreExpr mkFailExpr :: HsMatchContext GhcRn -> Type -> DsM CoreExpr seqVar :: Var -> CoreExpr -> CoreExpr mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc mkVanillaTuplePat :: [LPat GhcTc] -> Boxity -> Pat GhcTc mkBigLHsVarTupId :: [Id] -> LHsExpr GhcTc mkBigLHsTupId :: [LHsExpr GhcTc] -> LHsExpr GhcTc mkBigLHsVarPatTupId :: [Id] -> LPat GhcTc mkBigLHsPatTupId :: [LPat GhcTc] -> LPat GhcTc mkSelectorBinds :: [[CoreTickish]] -> LPat GhcTc -> CoreExpr -> DsM (Id, [(Id, CoreExpr)]) selectSimpleMatchVarL :: Mult -> LPat GhcTc -> DsM Id selectMatchVars :: [(Mult, Pat GhcTc)] -> DsM [Id] selectMatchVar :: Mult -> Pat GhcTc -> DsM Id mkOptTickBox :: [CoreTickish] -> CoreExpr -> CoreExpr mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr -- | Use -XStrict to add a ! or remove a ~ See Note [decideBangHood] decideBangHood :: DynFlags -> LPat GhcTc -> LPat GhcTc isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr) module GHC.HsToCore.Foreign.Call dsCCall :: CLabelString -> [CoreExpr] -> Safety -> Type -> DsM CoreExpr mkFCall :: Unique -> ForeignCall -> [CoreExpr] -> Type -> CoreExpr unboxArg :: CoreExpr -> DsM (CoreExpr, CoreExpr -> CoreExpr) boxResult :: Type -> DsM (Type, CoreExpr -> CoreExpr) resultWrapper :: Type -> DsM (Maybe Type, CoreExpr -> CoreExpr) module GHC.HsToCore.Foreign.Decl dsForeigns :: [LForeignDecl GhcTc] -> DsM (ForeignStubs, OrdList Binding) module GHC.HsToCore.Match.Literal dsLit :: HsLit GhcRn -> DsM CoreExpr -- | Post-typechecker, the HsExpr field of an OverLit -- contains (an expression for) the literal value itself. dsOverLit :: HsOverLit GhcTc -> DsM CoreExpr hsLitKey :: Platform -> HsLit GhcTc -> Literal tidyLitPat :: HsLit GhcTc -> Pat GhcTc tidyNPat :: HsOverLit GhcTc -> Maybe (SyntaxExpr GhcTc) -> SyntaxExpr GhcTc -> Type -> Pat GhcTc matchLiterals :: NonEmpty Id -> Type -> NonEmpty (NonEmpty EquationInfo) -> DsM (MatchResult CoreExpr) matchNPlusKPats :: NonEmpty Id -> Type -> NonEmpty EquationInfo -> DsM (MatchResult CoreExpr) matchNPats :: NonEmpty Id -> Type -> NonEmpty EquationInfo -> DsM (MatchResult CoreExpr) warnAboutIdentities :: DynFlags -> Id -> Type -> DsM () -- | Emit warnings on overloaded integral literals which overflow the -- bounds implied by their type. warnAboutOverflowedOverLit :: HsOverLit GhcTc -> DsM () -- | Emit warnings on integral literals which overflow the bounds implied -- by their type. warnAboutOverflowedLit :: HsLit GhcTc -> DsM () -- | Warns about [2,3 .. 1] or [b .. a] -- which return the empty list. For numeric literals, only works for -- integral types, not floating point. warnAboutEmptyEnumerations :: FamInstEnvs -> DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc) -> LHsExpr GhcTc -> DsM () module GHC.HsToCore.GuardedRHSs dsGuarded :: GRHSs GhcTc (LHsExpr GhcTc) -> Type -> NonEmpty Nablas -> DsM CoreExpr dsGRHSs :: HsMatchContext GhcRn -> GRHSs GhcTc (LHsExpr GhcTc) -> Type -> NonEmpty Nablas -> DsM (MatchResult CoreExpr) isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr) -- | Desugaring step of the Lower Your Guards paper. -- -- Desugars Haskell source syntax into guard tree variants Pm*. In terms -- of the paper, this module is concerned with Sections 3.1, Figure 4, in -- particular. module GHC.HsToCore.Pmc.Desugar desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre) desugarGRHSs :: SrcSpan -> SDoc -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (PmGRHSs Pre) -- | Desugar the non-empty Matches of a MatchGroup. desugarMatches :: [Id] -> NonEmpty (LMatch GhcTc (LHsExpr GhcTc)) -> DsM (PmMatchGroup Pre) desugarEmptyCase :: Id -> DsM PmEmptyCase -- | This module coverage checks pattern matches. It finds -- -- -- -- The algorithm is based on the paper Lower Your Guards: A -- Compositional Pattern-Match Coverage Checker" -- -- There is an overview Figure 2 in there that's probably helpful. Here -- is an overview of how it's implemented, which follows the structure of -- the entry points such as pmcMatches: -- --
    --
  1. Desugar source syntax (like LMatch) to guard tree variants -- (like GrdMatch), with one of the desugaring functions (like -- desugarMatch). See GHC.HsToCore.Pmc.Desugar. Follows -- Section 3.1 in the paper.
  2. --
  3. Coverage check guard trees (with a function like -- checkMatch) to get a CheckResult. See -- GHC.HsToCore.Pmc.Check. The normalised refinement types -- Nabla are tested for inhabitants by -- GHC.HsToCore.Pmc.Solver.
  4. --
  5. Collect redundancy information into a CIRB with a function -- such as cirbsMatch. Follows the R function from Figure 6 of the -- paper.
  6. --
  7. Format and report uncovered patterns and redundant equations -- (CIRB) with formatReportWarnings. Basically job of the G -- function, plus proper pretty printing of the warnings (Section 5.4 of -- the paper).
  8. --
  9. Return Nablas reaching syntactic sub-components for Note -- [Long-distance information]. Collected by functions such as -- ldiMatch. See Section 4.1 of the paper.
  10. --
module GHC.HsToCore.Pmc -- | Check a pattern binding (let, where) for exhaustiveness. pmcPatBind :: DsMatchContext -> Id -> Pat GhcTc -> DsM () -- | Check a list of syntactic Matches (part of case, functions, -- etc.), each with a Pat and one or more GRHSs: -- --
--   f x y | x == y    = 1   -- match on x and y with two guarded RHSs
--         | otherwise = 2
--   f _ _             = 3   -- clause with a single, un-guarded RHS
--   
-- -- Returns one non-empty Nablas for 1.) each pattern of a -- Match and 2.) each of a Matches GRHS for Note -- [Long-distance information]. -- -- Special case: When there are no matches, then the -- functionassumes it checks and -XEmptyCase with only a single -- match variable. See Note [Checking EmptyCase]. pmcMatches :: DsMatchContext -> [Id] -> [LMatch GhcTc (LHsExpr GhcTc)] -> DsM [(Nablas, NonEmpty Nablas)] -- | Exhaustive for guard matches, is used for guards in pattern bindings -- and in MultiIf expressions. Returns the Nablas covered -- by the RHSs. pmcGRHSs :: HsMatchContext GhcRn -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (NonEmpty Nablas) -- | Check whether any part of pattern match checking is enabled for this -- HsMatchContext (does not matter whether it is the redundancy -- check or the exhaustiveness check). isMatchContextPmChecked :: DynFlags -> Origin -> HsMatchContext id -> Bool -- | Add in-scope type constraints if the coverage checker might run and -- then run the given action. addTyCs :: Origin -> Bag EvVar -> DsM a -> DsM a -- | Add equalities for the CoreExpr scrutinee to the local -- DsM environment when checking a case expression: case e of x { -- matches } When checking matches we record that (x ~ e) where x is the -- initial uncovered. All matches will have to satisfy this equality. addCoreScrutTmCs :: Maybe CoreExpr -> [Id] -> DsM a -> DsM a -- | addCoreScrutTmCs, but desugars the LHsExpr first. addHsScrutTmCs :: Maybe (LHsExpr GhcTc) -> [Id] -> DsM a -> DsM a instance GHC.Classes.Eq (GHC.HsToCore.Pmc.FormatReportWarningsMode ann) instance GHC.Base.Semigroup GHC.HsToCore.Pmc.CIRB instance GHC.Base.Monoid GHC.HsToCore.Pmc.CIRB module GHC.HsToCore.Binds -- | Desugar top level binds, strict binds are treated like normal binds -- since there is no good time to force before first usage. dsTopLHsBinds :: LHsBinds GhcTc -> DsM (OrdList (Id, CoreExpr)) -- | Desugar all other kind of bindings, Ids of strict binds are returned -- to later be forced in the binding group body, see Note [Desugar Strict -- binds] dsLHsBinds :: LHsBinds GhcTc -> DsM ([Id], [(Id, CoreExpr)]) decomposeRuleLhs :: DynFlags -> [Var] -> CoreExpr -> Either DsMessage ([Var], Id, [CoreExpr]) dsSpec :: Maybe CoreExpr -> Located TcSpecPrag -> DsM (Maybe (OrdList (Id, CoreExpr), CoreRule)) dsHsWrapper :: HsWrapper -> DsM (CoreExpr -> CoreExpr) dsEvTerm :: EvTerm -> DsM CoreExpr dsTcEvBinds :: TcEvBinds -> DsM [CoreBind] dsTcEvBinds_s :: [TcEvBinds] -> DsM [CoreBind] dsEvBinds :: Bag EvBind -> DsM [CoreBind] dsMkUserRule :: Module -> Bool -> RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> DsM CoreRule module GHC.HsToCore.Quote dsBracket :: Maybe QuoteWrapper -> HsQuote GhcRn -> [PendingTcSplice] -> DsM CoreExpr instance GHC.HsToCore.Quote.RepTV () () instance GHC.HsToCore.Quote.RepTV GHC.Types.Var.Specificity Language.Haskell.TH.Syntax.Specificity module GHC.HsToCore.Match.Constructor matchConFamily :: NonEmpty Id -> Type -> NonEmpty (NonEmpty EquationInfo) -> DsM (MatchResult CoreExpr) matchPatSyn :: NonEmpty Id -> Type -> NonEmpty EquationInfo -> DsM (MatchResult CoreExpr) module GHC.HsToCore.Match match :: [MatchId] -> Type -> [EquationInfo] -> DsM (MatchResult CoreExpr) matchEquations :: HsMatchContext GhcRn -> [MatchId] -> [EquationInfo] -> Type -> DsM CoreExpr matchWrapper :: HsMatchContext GhcRn -> Maybe (LHsExpr GhcTc) -> MatchGroup GhcTc (LHsExpr GhcTc) -> DsM ([Id], CoreExpr) -- | matchSimply is a wrapper for match which deals with -- the situation where we want to match a single expression against a -- single pattern. It returns an expression. matchSimply :: CoreExpr -> HsMatchContext GhcRn -> LPat GhcTc -> CoreExpr -> CoreExpr -> DsM CoreExpr matchSinglePat :: CoreExpr -> HsMatchContext GhcRn -> LPat GhcTc -> Type -> MatchResult CoreExpr -> DsM (MatchResult CoreExpr) matchSinglePatVar :: Id -> Maybe CoreExpr -> HsMatchContext GhcRn -> LPat GhcTc -> Type -> MatchResult CoreExpr -> DsM (MatchResult CoreExpr) module GHC.HsToCore.ListComp dsListComp :: [ExprLStmt GhcTc] -> Type -> DsM CoreExpr dsMonadComp :: [ExprLStmt GhcTc] -> DsM CoreExpr module GHC.HsToCore.Arrows dsProcExpr :: LPat GhcTc -> LHsCmdTop GhcTc -> DsM CoreExpr module GHC.HsToCore.Expr dsExpr :: HsExpr GhcTc -> DsM CoreExpr -- | Replace the body of the function with this block to test the -- hsExprType function in GHC.Tc.Utils.Zonk: putSrcSpanDs loc $ do { -- core_expr <- dsExpr e ; massertPpr (exprType core_expr -- eqType hsExprType e) (ppr e + dcolon + ppr -- (hsExprType e) $$ ppr core_expr + dcolon + ppr (exprType -- core_expr)) ; return core_expr } dsLExpr :: LHsExpr GhcTc -> DsM CoreExpr dsLocalBinds :: HsLocalBinds GhcTc -> CoreExpr -> DsM CoreExpr dsValBinds :: HsValBinds GhcTc -> CoreExpr -> DsM CoreExpr dsLit :: HsLit GhcRn -> DsM CoreExpr dsSyntaxExpr :: SyntaxExpr GhcTc -> [CoreExpr] -> DsM CoreExpr -- | Module for detecting if recompilation is required module GHC.Iface.Recomp -- | Top level function to check if the version of an old interface file is -- equivalent to the current source file the user asked us to compile. If -- the same, we can avoid recompilation. -- -- We return on the outside whether the interface file is up to date, -- providing evidence that is with a ModIface. In the case that it -- isn't, we may also return a found or provided ModIface. Why we -- don't always return the old one, if it exists, is unclear to me, -- except that I tried it and some tests failed (see #18205). checkOldIface :: HscEnv -> ModSummary -> Maybe ModIface -> IO (MaybeValidated ModIface) data RecompileRequired -- | everything is up to date, recompilation is not required UpToDate :: RecompileRequired -- | Need to compile the module NeedsRecompile :: !CompileReason -> RecompileRequired needsRecompileBecause :: RecompReason -> RecompileRequired recompThen :: Monad m => m RecompileRequired -> m RecompileRequired -> m RecompileRequired data MaybeValidated a -- | The item contained is validated to be up to date UpToDateItem :: a -> MaybeValidated a -- | The item is are absent altogether or out of date, for the reason -- given. OutOfDateItem :: !CompileReason -> Maybe a -> MaybeValidated a outOfDateItemBecause :: RecompReason -> Maybe a -> MaybeValidated a data RecompReason UnitDepRemoved :: UnitId -> RecompReason ModulePackageChanged :: String -> RecompReason SourceFileChanged :: RecompReason ThisUnitIdChanged :: RecompReason ImpurePlugin :: RecompReason PluginsChanged :: RecompReason PluginFingerprintChanged :: RecompReason ModuleInstChanged :: RecompReason HieMissing :: RecompReason HieOutdated :: RecompReason SigsMergeChanged :: RecompReason ModuleChanged :: ModuleName -> RecompReason ModuleRemoved :: (UnitId, ModuleName) -> RecompReason ModuleAdded :: (UnitId, ModuleName) -> RecompReason ModuleChangedRaw :: ModuleName -> RecompReason ModuleChangedIface :: ModuleName -> RecompReason FileChanged :: FilePath -> RecompReason CustomReason :: String -> RecompReason FlagsChanged :: RecompReason OptimFlagsChanged :: RecompReason HpcFlagsChanged :: RecompReason MissingBytecode :: RecompReason MissingObjectFile :: RecompReason MissingDynObjectFile :: RecompReason MissingDynHiFile :: RecompReason MismatchedDynHiFile :: RecompReason ObjectsChanged :: RecompReason LibraryChanged :: RecompReason data CompileReason -- | The .hs file has been touched, or the .o/.hi file does not exist MustCompile :: CompileReason -- | The .o/.hi files are up to date, but something else has changed to -- force recompilation; the String says what (one-line summary) RecompBecause :: !RecompReason -> CompileReason recompileRequired :: RecompileRequired -> Bool -- | Add fingerprints for top-level declarations to a ModIface. -- -- See Note [Fingerprinting IfaceDecls] addFingerprints :: HscEnv -> PartialModIface -> IO ModIface instance GHC.Classes.Eq GHC.Iface.Recomp.RecompReason instance GHC.Classes.Eq GHC.Iface.Recomp.CompileReason instance GHC.Base.Functor GHC.Iface.Recomp.MaybeValidated instance GHC.Classes.Eq GHC.Iface.Recomp.RecompileRequired instance GHC.Utils.Outputable.Outputable GHC.Iface.Recomp.IfaceDeclExtras instance GHC.Utils.Binary.Binary GHC.Iface.Recomp.IfaceDeclExtras instance GHC.Utils.Binary.Binary GHC.Iface.Recomp.IfaceIdExtras instance GHC.Utils.Outputable.Outputable GHC.Iface.Recomp.RecompileRequired instance GHC.Base.Semigroup GHC.Iface.Recomp.RecompileRequired instance GHC.Base.Monoid GHC.Iface.Recomp.RecompileRequired instance GHC.Utils.Outputable.Outputable GHC.Iface.Recomp.CompileReason instance GHC.Utils.Outputable.Outputable GHC.Iface.Recomp.RecompReason module GHC.HsToCore.Usage mkUsageInfo :: HscEnv -> Module -> ImportedMods -> NameSet -> [FilePath] -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IO [Usage] mkUsedNames :: TcGblEnv -> NameSet -- | Module for constructing ModIface values (interface files), -- writing them to disk and comparing two versions to see if -- recompilation is required. module GHC.Iface.Make mkPartialIface :: HscEnv -> ModDetails -> ModSummary -> ModGuts -> PartialModIface -- | Fully instantiate an interface. Adds fingerprints and potentially code -- generator produced information. -- -- CgInfos is not available when not generating code (-fno-code), or when -- not generating interface pragmas (-fomit-interface-pragmas). See also -- Note [Conveying CAF-info and LFInfo between modules] in -- GHC.StgToCmm.Types. mkFullIface :: HscEnv -> PartialModIface -> Maybe CgInfos -> IO ModIface -- | Make an interface from the results of typechecking only. Useful for -- non-optimising compilation, or where we aren't generating any object -- code at all (NoBackend). mkIfaceTc :: HscEnv -> SafeHaskellMode -> ModDetails -> ModSummary -> TcGblEnv -> IO ModIface mkIfaceExports :: [AvailInfo] -> [IfaceExport] coAxiomToIfaceDecl :: CoAxiom br -> IfaceDecl tyThingToIfaceDecl :: Bool -> TyThing -> IfaceDecl module GHC.Types.TyThing.Ppr -- | Pretty-prints a TyThing. pprTyThing :: ShowSub -> TyThing -> SDoc -- | Pretty-prints a TyThing in context: that is, if the entity is a -- data constructor, record selector, or class method, then the entity's -- parent declaration is pretty-printed with irrelevant parts omitted. pprTyThingInContext :: ShowSub -> TyThing -> SDoc -- | Pretty-prints a TyThing with its defining location. pprTyThingLoc :: TyThing -> SDoc -- | Like pprTyThingInContext, but adds the defining location. pprTyThingInContextLoc :: TyThing -> SDoc -- | Pretty-prints the TyThing header. For functions and data -- constructors the function is equivalent to pprTyThing but for -- type constructors and classes it prints only the header part of the -- declaration. pprTyThingHdr :: TyThing -> SDoc -- | Pretty-prints a FamInst (type/data family instance) with its -- defining location. pprFamInst :: FamInst -> SDoc -- | Typechecking a whole module -- -- -- https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/type-checker module GHC.Tc.Module -- | The returned [Id] is the list of new Ids bound by this statement. It -- can be used to extend the InteractiveContext via -- extendInteractiveContext. -- -- The returned TypecheckedHsExpr is of type IO [ () ], a list of the -- bound values, coerced to (). tcRnStmt :: HscEnv -> GhciLStmt GhcPs -> IO (Messages TcRnMessage, Maybe ([Id], LHsExpr GhcTc, FixityEnv)) -- | tcRnExpr just finds the type of an expression for :type tcRnExpr :: HscEnv -> TcRnExprMode -> LHsExpr GhcPs -> IO (Messages TcRnMessage, Maybe Type) -- | How should we infer a type? See Note [TcRnExprMode] data TcRnExprMode -- | Instantiate inferred quantifiers only (:type) TM_Inst :: TcRnExprMode -- | Instantiate all quantifiers, and do eager defaulting (:type +d) TM_Default :: TcRnExprMode tcRnType :: HscEnv -> ZonkFlexi -> Bool -> LHsType GhcPs -> IO (Messages TcRnMessage, Maybe (Type, Kind)) tcRnImportDecls :: HscEnv -> [LImportDecl GhcPs] -> IO (Messages TcRnMessage, Maybe GlobalRdrEnv) -- | Find all the Names that this RdrName could mean, in GHCi tcRnLookupRdrName :: HscEnv -> LocatedN RdrName -> IO (Messages TcRnMessage, Maybe [Name]) -- | ASSUMES that the module is either in the HomePackageTable or -- is a package module with an interface on disk. If neither of these is -- true, then the result will be an error indicating the interface could -- not be found. getModuleInterface :: HscEnv -> Module -> IO (Messages TcRnMessage, Maybe ModIface) tcRnDeclsi :: HscEnv -> [LHsDecl GhcPs] -> IO (Messages TcRnMessage, Maybe TcGblEnv) isGHCiMonad :: HscEnv -> String -> IO (Messages TcRnMessage, Maybe Name) runTcInteractive :: HscEnv -> TcRn a -> IO (Messages TcRnMessage, Maybe a) withTcPlugins :: HscEnv -> TcM a -> TcM a withHoleFitPlugins :: HscEnv -> TcM a -> TcM a tcRnLookupName :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe TyThing) tcRnGetInfo :: HscEnv -> Name -> IO (Messages TcRnMessage, Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) -- | Top level entry point for typechecker and renamer tcRnModule :: HscEnv -> ModSummary -> Bool -> HsParsedModule -> IO (Messages TcRnMessage, Maybe TcGblEnv) tcRnModuleTcRnM :: HscEnv -> ModSummary -> HsParsedModule -> (Module, SrcSpan) -> TcRn TcGblEnv tcTopSrcDecls :: HsGroup GhcRn -> TcM (TcGblEnv, TcLclEnv) rnTopSrcDecls :: HsGroup GhcPs -> TcM (TcGblEnv, HsGroup GhcRn) -- | Compares the two things for equivalence between boot-file and normal -- code. Returns Nothing on success or Just "some helpful -- info for user" failure. If the difference will be apparent to the -- user, Just empty is perfectly suitable. checkBootDecl :: Bool -> TyThing -> TyThing -> Maybe SDoc checkHiBootIface' :: [ClsInst] -> TypeEnv -> [AvailInfo] -> ModDetails -> TcM [(Id, Id)] -- | For a module modname of type HscSource, determine the -- list of extra "imports" of other requirements which should be -- considered part of the import of the requirement, because it -- transitively depends on those requirements by imports of modules from -- other packages. The situation is something like this: -- -- unit p where signature X signature Y import X -- -- unit q where dependency p[X=<A>,Y=<B>] signature A -- signature B -- -- Although q's B does not directly import A, we still have to make sure -- we process A first, because the merging process will cause B to -- indirectly import A. This function finds the TRANSITIVE closure of all -- such imports we need to make. findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [ModuleName] implicitRequirements :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO [ModuleName] -- | Given a Unit, make sure it is well typed. This is because unit -- IDs come from Cabal, which does not know if things are well-typed or -- not; a component may have been filled with implementations for the -- holes that don't actually fulfill the requirements. checkUnit :: Unit -> TcM () -- | Given a local ModIface, merge all inherited requirements from -- requirementMerges into this signature, producing a final -- TcGblEnv that matches the local signature and all required -- signatures. mergeSignatures :: HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv -- | Top-level driver for signature merging (run after typechecking an -- hsig file). tcRnMergeSignatures :: HscEnv -> HsParsedModule -> TcGblEnv -> ModIface -> IO (Messages TcRnMessage, Maybe TcGblEnv) -- | Given tcg_mod, instantiate a ModIface from the -- indefinite library to use the actual implementations of the relevant -- entities, checking that the implementation matches the signature. instantiateSignature :: TcRn TcGblEnv -- | Top-level driver for signature instantiation (run when compiling an -- hsig file.) tcRnInstantiateSignature :: HscEnv -> Module -> RealSrcSpan -> IO (Messages TcRnMessage, Maybe TcGblEnv) loadUnqualIfaces :: HscEnv -> InteractiveContext -> TcM () badReexportedBootThing :: Bool -> Name -> Name -> TcRnMessage -- | Compares two things for equivalence between boot-file and normal code, -- reporting an error if they don't match up. checkBootDeclM :: Bool -> TyThing -> TyThing -> TcM () missingBootThing :: Bool -> Name -> String -> TcRnMessage -- | Extract the renamed information from TcGblEnv. getRenamedStuff :: TcGblEnv -> RenamedStuff type RenamedStuff = (Maybe (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], Maybe (LHsDoc GhcRn))) module GHC.Iface.Ext.Ast -- | Construct an HieFile from the outputs of the typechecker. mkHieFile :: MonadIO m => ModSummary -> TcGblEnv -> RenamedSource -> m HieFile -- | Construct an HieFile from the outputs of the typechecker but -- don't read the source file again from disk. mkHieFileWithSource :: FilePath -> ByteString -> ModSummary -> TcGblEnv -> RenamedSource -> HieFile getCompressedAsts :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> (HieASTs TypeIndex, Array TypeIndex HieTypeFlat) enrichHie :: TypecheckedSource -> RenamedSource -> Bag EvBind -> [ClsInst] -> [TyCon] -> HieASTs Type instance Data.Data.Data a => Data.Data.Data (GHC.Iface.Ext.Ast.PScoped a) instance (GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.MatchGroup (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) instance (GHC.Iface.Ext.Ast.HiePass p, Data.Data.Data (body (GHC.Hs.Extension.GhcPass p)), GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.Match (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.GRHSs (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.HiePass p, GHC.Iface.Ext.Ast.AnnoBody p body) => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Expr.GRHS (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))))) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p))), GHC.Iface.Ext.Ast.AnnoBody p body, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.Stmt (GHC.Hs.Extension.GhcPass p) (GHC.Parser.Annotation.LocatedA (body (GHC.Hs.Extension.GhcPass p)))))) instance (GHC.Iface.Ext.Ast.HasLoc a, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Decls.FamEqn (GHC.Hs.Extension.GhcPass p) a) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.HsBind (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.Pat (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.HasType (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsExpr (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass 'GHC.Hs.Extension.Renamed instance GHC.Iface.Ext.Ast.HiePass 'GHC.Hs.Extension.Typechecked instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.BindContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.HsBind (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located (Language.Haskell.Syntax.Binds.PatSynBind (GHC.Hs.Extension.GhcPass p) (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Binds.HsPatSynDir (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsMatchContext (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsStmtContext (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.PScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.Pat (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsExpr (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsTupArg (GHC.Hs.Extension.GhcPass p)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Binds.HsLocalBinds (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.IPBind (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Binds.HsValBindsLR (GHC.Hs.Extension.GhcPass p) (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Hs.Binds.NHsValBindsLR (GHC.Hs.Extension.GhcPass p))) instance (GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.HasLoc arg, Data.Data.Data arg, GHC.Iface.Ext.Ast.HiePass p) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RContext (Language.Haskell.Syntax.Pat.HsRecFields (GHC.Hs.Extension.GhcPass p) arg)) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Type.FieldOcc (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Type.AmbiguousFieldOcc (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (Language.Haskell.Syntax.Expr.ApplicativeArg (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Expr.HsCmdTop (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsCmd (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.SigContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.Sig (GHC.Hs.Extension.GhcPass p)))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Expr.HsSplice (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (Language.Haskell.Syntax.Type.FieldOcc (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.HiePass p => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.PatSynFieldContext (Language.Haskell.Syntax.Binds.RecordPatSynField (GHC.Hs.Extension.GhcPass p))) instance GHC.Iface.Ext.Ast.ToHie Data.Void.Void instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie [a] instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (GHC.Data.Bag.Bag a) instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (GHC.Maybe.Maybe a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Parser.Annotation.LocatedA GHC.Unit.Module.Name.ModuleName)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located a)) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Parser.Annotation.LocatedN a)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located a)) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Parser.Annotation.LocatedA a)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located GHC.Types.Var.Var)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.EvBindContext (GHC.Parser.Annotation.LocatedA GHC.Tc.Types.Evidence.TcEvBinds)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA GHC.Tc.Types.Evidence.HsWrapper) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.Context (GHC.Types.SrcLoc.Located Language.Haskell.Syntax.Extension.NoExtField)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsPatSigType GHC.Hs.Extension.GhcRn)) instance (GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RFContext label), GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.HasLoc arg, Data.Data.Data arg, Data.Data.Data label) => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RContext (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Pat.HsFieldBind label arg))) instance (GHC.Iface.Ext.Ast.ToHie tyarg, GHC.Iface.Ext.Ast.ToHie arg, GHC.Iface.Ext.Ast.ToHie rec) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsConDetails tyarg arg rec) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.HsConDeclGADTDetails GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.TyClGroup GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.TyClDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.FamilyDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.FamilyInfo GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.FamilyResultSig GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.FunDep GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)))) instance (GHC.Iface.Ext.Ast.ToHie rhs, GHC.Iface.Ext.Ast.HasLoc rhs) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.FamEqn GHC.Hs.Extension.GhcRn rhs) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.InjectivityAnn GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Types.SrcLoc.Located [GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.HsDerivingClause GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.HsDerivingClause GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedC (Language.Haskell.Syntax.Decls.DerivClauseTys GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.DerivStrategy GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedP GHC.Types.Basic.OverlapMode) instance GHC.Iface.Ext.Ast.ToHie a => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsScaled GHC.Hs.Extension.GhcRn a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ConDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedL [GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.ConDeclField GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsWildCardBndrs GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsSigType GHC.Hs.Extension.GhcRn)))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.HsWildCardBndrs GHC.Hs.Extension.GhcRn (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.StandaloneKindSig GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.StandaloneKindSig GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsSigType GHC.Hs.Extension.GhcRn))) instance Data.Data.Data flag => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TVScoped (Language.Haskell.Syntax.Type.HsOuterTyVarBndrs flag GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)) instance (GHC.Iface.Ext.Ast.ToHie tm, GHC.Iface.Ext.Ast.ToHie ty) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Type.HsArg tm ty) instance Data.Data.Data flag => GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TVScoped (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsTyVarBndr flag GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.TScoped (Language.Haskell.Syntax.Type.LHsQTyVars GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedC [GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.HsType GHC.Hs.Extension.GhcRn)]) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Type.ConDeclField GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.LHsExpr a) => GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.ArithSeqInfo a) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.SpliceDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Expr.HsQuote a) instance GHC.Iface.Ext.Ast.ToHie GHC.Hs.Expr.PendingRnSplice instance GHC.Iface.Ext.Ast.ToHie GHC.Hs.Expr.PendingTcSplice instance GHC.Iface.Ext.Ast.ToHie (GHC.Data.BooleanFormula.LBooleanFormula (GHC.Parser.Annotation.LocatedN GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns Language.Haskell.Syntax.Type.HsIPName) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RoleAnnotDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.InstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ClsInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DataFamInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.TyFamInstDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DerivDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Binds.FixitySig GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DefaultDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.ForeignDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie Language.Haskell.Syntax.Decls.ForeignImport instance GHC.Iface.Ext.Ast.ToHie Language.Haskell.Syntax.Decls.ForeignExport instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.WarnDecls GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.WarnDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.AnnDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (Language.Haskell.Syntax.Decls.AnnProvenance GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RuleDecls GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.RuleDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.RScoped (GHC.Parser.Annotation.LocatedAn GHC.Parser.Annotation.NoEpAnns (Language.Haskell.Syntax.Decls.RuleBndr GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (GHC.Hs.ImpExp.ImportDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Parser.Annotation.LocatedA (GHC.Hs.ImpExp.IE GHC.Hs.Extension.GhcRn))) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Hs.ImpExp.LIEWrappedName GHC.Types.Name.Name)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Iface.Ext.Ast.IEContext (GHC.Types.SrcLoc.Located GHC.Types.FieldLabel.FieldLabel)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Parser.Annotation.LocatedA (Language.Haskell.Syntax.Decls.DocDecl GHC.Hs.Extension.GhcRn)) instance GHC.Iface.Ext.Ast.ToHie (GHC.Hs.Doc.LHsDoc GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.HasLoc thing => GHC.Iface.Ext.Ast.HasLoc (GHC.Iface.Ext.Ast.PScoped thing) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Types.SrcLoc.Located a) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Parser.Annotation.LocatedA a) instance GHC.Iface.Ext.Ast.HasLoc (GHC.Parser.Annotation.LocatedN a) instance GHC.Iface.Ext.Ast.HasLoc a => GHC.Iface.Ext.Ast.HasLoc [a] instance (GHC.Iface.Ext.Ast.HasLoc tm, GHC.Iface.Ext.Ast.HasLoc ty) => GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Type.HsArg tm ty) instance GHC.Iface.Ext.Ast.HasLoc (Language.Haskell.Syntax.Decls.HsDataDefn GHC.Hs.Extension.GhcRn) instance GHC.Iface.Ext.Ast.ModifyState GHC.Types.Name.Name instance GHC.Iface.Ext.Ast.ModifyState GHC.Types.Var.Id module GHC.HsToCore -- | Main entry point to the desugarer. deSugar :: HscEnv -> ModLocation -> TcGblEnv -> IO (Messages DsMessage, Maybe ModGuts) deSugarExpr :: HscEnv -> LHsExpr GhcTc -> IO (Messages DsMessage, Maybe CoreExpr) -- | Various utilities used in generating assembler. -- -- These are used not only by the native code generator, but also by the -- GHC.Driver.Pipeline module GHC.Utils.Asm -- | Generate a section type (e.g. @progbits). See #13937. sectionType :: Platform -> String -> SDoc module GHC.SysTools.Elf -- | Given a section name, read its contents as a ByteString. -- -- If the section isn't found or if there is any parsing error, we return -- Nothing readElfSectionByName :: Logger -> ByteString -> String -> IO (Maybe ByteString) -- | read a Note as a String -- -- If you try to read a note from a section which does not support the -- Note format, the parsing is likely to fail and Nothing will be -- returned readElfNoteAsString :: Logger -> FilePath -> String -> String -> IO (Maybe String) -- | Generate the GAS code to create a Note section -- -- Header fields for notes are 32-bit long (see Note [ELF -- specification]). makeElfNote :: Platform -> String -> String -> Word32 -> String -> SDoc module GHC.CmmToAsm.Ppr -- | Get bytes of a Double representation doubleToBytes :: Double -> [Word8] -- | Get bytes of a Float representation floatToBytes :: Float -> [Word8] pprASCII :: ByteString -> SDoc -- | Emit a ".string" directive pprString :: ByteString -> SDoc -- | Emit a ".incbin" directive -- -- A NULL byte is added after the binary data. pprFileEmbed :: FilePath -> SDoc pprSectionHeader :: NCGConfig -> Section -> SDoc -- | The LLVM Type System. module GHC.Llvm.Types -- | A global mutable variable. Maybe defined or external data LMGlobal LMGlobal :: LlvmVar -> Maybe LlvmStatic -> LMGlobal -- | Returns the variable of the LMGlobal [getGlobalVar] :: LMGlobal -> LlvmVar -- | Return the value of the LMGlobal [getGlobalValue] :: LMGlobal -> Maybe LlvmStatic -- | A String in LLVM type LMString = FastString -- | A type alias type LlvmAlias = (LMString, LlvmType) -- | Llvm Types data LlvmType -- | An integer with a given width in bits. LMInt :: Int -> LlvmType -- | 32 bit floating point LMFloat :: LlvmType -- | 64 bit floating point LMDouble :: LlvmType -- | 80 bit (x86 only) floating point LMFloat80 :: LlvmType -- | 128 bit floating point LMFloat128 :: LlvmType -- | A pointer to a LlvmType LMPointer :: LlvmType -> LlvmType -- | An array of LlvmType LMArray :: Int -> LlvmType -> LlvmType -- | A vector of LlvmType LMVector :: Int -> LlvmType -> LlvmType -- | A LlvmVar can represent a label (address) LMLabel :: LlvmType -- | Void type LMVoid :: LlvmType -- | Packed structure type LMStruct :: [LlvmType] -> LlvmType -- | Unpacked structure type LMStructU :: [LlvmType] -> LlvmType -- | A type alias LMAlias :: LlvmAlias -> LlvmType -- | LLVM Metadata LMMetadata :: LlvmType -- | Function type, used to create pointers to functions LMFunction :: LlvmFunctionDecl -> LlvmType ppType :: LlvmType -> SDoc ppParams :: LlvmParameterListType -> [LlvmParameter] -> SDoc -- | An LLVM section definition. If Nothing then let LLVM decide the -- section type LMSection = Maybe LMString type LMAlign = Maybe Int data LMConst -- | Mutable global variable Global :: LMConst -- | Constant global variable Constant :: LMConst -- | Alias of another variable Alias :: LMConst -- | LLVM Variables data LlvmVar -- | Variables with a global scope. LMGlobalVar :: LMString -> LlvmType -> LlvmLinkageType -> LMSection -> LMAlign -> LMConst -> LlvmVar -- | Variables local to a function or parameters. LMLocalVar :: Unique -> LlvmType -> LlvmVar -- | Named local variables. Sometimes we need to be able to explicitly name -- variables (e.g for function arguments). LMNLocalVar :: LMString -> LlvmType -> LlvmVar -- | A constant variable LMLitVar :: LlvmLit -> LlvmVar -- | Llvm Literal Data. -- -- These can be used inline in expressions. data LlvmLit -- | Refers to an integer constant (i64 42). LMIntLit :: Integer -> LlvmType -> LlvmLit -- | Floating point literal LMFloatLit :: Double -> LlvmType -> LlvmLit -- | Literal NULL, only applicable to pointer types LMNullLit :: LlvmType -> LlvmLit -- | Vector literal LMVectorLit :: [LlvmLit] -> LlvmLit -- | Undefined value, random bit pattern. Useful for optimisations. LMUndefLit :: LlvmType -> LlvmLit -- | Llvm Static Data. -- -- These represent the possible global level variables and constants. data LlvmStatic -- | A comment in a static section LMComment :: LMString -> LlvmStatic -- | A static variant of a literal value LMStaticLit :: LlvmLit -> LlvmStatic -- | For uninitialised data LMUninitType :: LlvmType -> LlvmStatic -- | Defines a static LMString LMStaticStr :: LMString -> LlvmType -> LlvmStatic -- | A static array LMStaticArray :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStruc :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStrucU :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A pointer to other data LMStaticPointer :: LlvmVar -> LlvmStatic -- | Truncate LMTrunc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Pointer conversion LMBitc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Integer conversion LMPtoI :: LlvmStatic -> LlvmType -> LlvmStatic -- | Constant addition operation LMAdd :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Constant subtraction operation LMSub :: LlvmStatic -> LlvmStatic -> LlvmStatic garbageLit :: LlvmType -> Maybe LlvmLit -- | Return the LlvmType of the LlvmVar getVarType :: LlvmVar -> LlvmType -- | Return the LlvmType of a LlvmLit getLitType :: LlvmLit -> LlvmType -- | Return the LlvmType of the LlvmStatic getStatType :: LlvmStatic -> LlvmType -- | Return the LlvmLinkageType for a LlvmVar getLink :: LlvmVar -> LlvmLinkageType -- | Add a pointer indirection to the supplied type. LMLabel and -- LMVoid cannot be lifted. pLift :: LlvmType -> LlvmType -- | Lift a variable to LMPointer type. pVarLift :: LlvmVar -> LlvmVar -- | Remove the pointer indirection of the supplied type. Only -- LMPointer constructors can be lowered. pLower :: LlvmType -> LlvmType -- | Lower a variable of LMPointer type. pVarLower :: LlvmVar -> LlvmVar -- | Test if the given LlvmType is an integer isInt :: LlvmType -> Bool -- | Test if the given LlvmType is a floating point type isFloat :: LlvmType -> Bool -- | Test if the given LlvmType is an LMPointer construct isPointer :: LlvmType -> Bool -- | Test if the given LlvmType is an LMVector construct isVector :: LlvmType -> Bool -- | Test if a LlvmVar is global. isGlobal :: LlvmVar -> Bool -- | Width in bits of an LlvmType, returns 0 if not applicable llvmWidthInBits :: Platform -> LlvmType -> Int i128 :: LlvmType i64 :: LlvmType i32 :: LlvmType i16 :: LlvmType i8 :: LlvmType i1 :: LlvmType i8Ptr :: LlvmType -- | The target architectures word size llvmWord :: Platform -> LlvmType -- | The target architectures word size llvmWordPtr :: Platform -> LlvmType -- | An LLVM Function data LlvmFunctionDecl LlvmFunctionDecl :: LMString -> LlvmLinkageType -> LlvmCallConvention -> LlvmType -> LlvmParameterListType -> [LlvmParameter] -> LMAlign -> LlvmFunctionDecl -- | Unique identifier of the function [decName] :: LlvmFunctionDecl -> LMString -- | LinkageType of the function [funcLinkage] :: LlvmFunctionDecl -> LlvmLinkageType -- | The calling convention of the function [funcCc] :: LlvmFunctionDecl -> LlvmCallConvention -- | Type of the returned value [decReturnType] :: LlvmFunctionDecl -> LlvmType -- | Indicates if this function uses varargs [decVarargs] :: LlvmFunctionDecl -> LlvmParameterListType -- | Parameter types and attributes [decParams] :: LlvmFunctionDecl -> [LlvmParameter] -- | Function align value, must be power of 2 [funcAlign] :: LlvmFunctionDecl -> LMAlign type LlvmFunctionDecls = [LlvmFunctionDecl] type LlvmParameter = (LlvmType, [LlvmParamAttr]) -- | LLVM Parameter Attributes. -- -- Parameter attributes are used to communicate additional information -- about the result or parameters of a function data LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be zero-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). ZeroExt :: LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be sign-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). SignExt :: LlvmParamAttr -- | This indicates that this parameter or return value should be treated -- in a special target-dependent fashion during while emitting code for a -- function call or return (usually, by putting it in a register as -- opposed to memory). InReg :: LlvmParamAttr -- | This indicates that the pointer parameter should really be passed by -- value to the function. ByVal :: LlvmParamAttr -- | This indicates that the pointer parameter specifies the address of a -- structure that is the return value of the function in the source -- program. SRet :: LlvmParamAttr -- | This indicates that the pointer does not alias any global or any other -- parameter. NoAlias :: LlvmParamAttr -- | This indicates that the callee does not make any copies of the pointer -- that outlive the callee itself NoCapture :: LlvmParamAttr -- | This indicates that the pointer parameter can be excised using the -- trampoline intrinsics. Nest :: LlvmParamAttr -- | Llvm Function Attributes. -- -- Function attributes are set to communicate additional information -- about a function. Function attributes are considered to be part of the -- function, not of the function type, so functions with different -- parameter attributes can have the same function type. Functions can -- have multiple attributes. -- -- Descriptions taken from -- http://llvm.org/docs/LangRef.html#fnattrs data LlvmFuncAttr -- | This attribute indicates that the inliner should attempt to inline -- this function into callers whenever possible, ignoring any active -- inlining size threshold for this caller. AlwaysInline :: LlvmFuncAttr -- | This attribute indicates that the source code contained a hint that -- inlining this function is desirable (such as the "inline" keyword in -- C/C++). It is just a hint; it imposes no requirements on the inliner. InlineHint :: LlvmFuncAttr -- | This attribute indicates that the inliner should never inline this -- function in any situation. This attribute may not be used together -- with the alwaysinline attribute. NoInline :: LlvmFuncAttr -- | This attribute suggests that optimization passes and code generator -- passes make choices that keep the code size of this function low, and -- otherwise do optimizations specifically to reduce code size. OptSize :: LlvmFuncAttr -- | This function attribute indicates that the function never returns -- normally. This produces undefined behavior at runtime if the function -- ever does dynamically return. NoReturn :: LlvmFuncAttr -- | This function attribute indicates that the function never returns with -- an unwind or exceptional control flow. If the function does unwind, -- its runtime behavior is undefined. NoUnwind :: LlvmFuncAttr -- | This attribute indicates that the function computes its result (or -- decides to unwind an exception) based strictly on its arguments, -- without dereferencing any pointer arguments or otherwise accessing any -- mutable state (e.g. memory, control registers, etc) visible to caller -- functions. It does not write through any pointer arguments (including -- byval arguments) and never changes any state visible to callers. This -- means that it cannot unwind exceptions by calling the C++ exception -- throwing methods, but could use the unwind instruction. ReadNone :: LlvmFuncAttr -- | This attribute indicates that the function does not write through any -- pointer arguments (including byval arguments) or otherwise modify any -- state (e.g. memory, control registers, etc) visible to caller -- functions. It may dereference pointer arguments and read state that -- may be set in the caller. A readonly function always returns the same -- value (or unwinds an exception identically) when called with the same -- set of arguments and global state. It cannot unwind an exception by -- calling the C++ exception throwing methods, but may use the unwind -- instruction. ReadOnly :: LlvmFuncAttr -- | This attribute indicates that the function should emit a stack -- smashing protector. It is in the form of a "canary"—a random value -- placed on the stack before the local variables that's checked upon -- return from the function to see if it has been overwritten. A -- heuristic is used to determine if a function needs stack protectors or -- not. -- -- If a function that has an ssp attribute is inlined into a function -- that doesn't have an ssp attribute, then the resulting function will -- have an ssp attribute. Ssp :: LlvmFuncAttr -- | This attribute indicates that the function should always emit a stack -- smashing protector. This overrides the ssp function attribute. -- -- If a function that has an sspreq attribute is inlined into a function -- that doesn't have an sspreq attribute or which has an ssp attribute, -- then the resulting function will have an sspreq attribute. SspReq :: LlvmFuncAttr -- | This attribute indicates that the code generator should not use a red -- zone, even if the target-specific ABI normally permits it. NoRedZone :: LlvmFuncAttr -- | This attributes disables implicit floating point instructions. NoImplicitFloat :: LlvmFuncAttr -- | This attribute disables prologue / epilogue emission for the function. -- This can have very system-specific consequences. Naked :: LlvmFuncAttr -- | Different types to call a function. data LlvmCallType -- | Normal call, allocate a new stack frame. StdCall :: LlvmCallType -- | Tail call, perform the call in the current stack frame. TailCall :: LlvmCallType -- | Different calling conventions a function can use. data LlvmCallConvention -- | The C calling convention. This calling convention (the default if no -- other calling convention is specified) matches the target C calling -- conventions. This calling convention supports varargs function calls -- and tolerates some mismatch in the declared prototype and implemented -- declaration of the function (as does normal C). CC_Ccc :: LlvmCallConvention -- | This calling convention attempts to make calls as fast as possible -- (e.g. by passing things in registers). This calling convention allows -- the target to use whatever tricks it wants to produce fast code for -- the target, without having to conform to an externally specified ABI -- (Application Binary Interface). Implementations of this convention -- should allow arbitrary tail call optimization to be supported. This -- calling convention does not support varargs and requires the prototype -- of al callees to exactly match the prototype of the function -- definition. CC_Fastcc :: LlvmCallConvention -- | This calling convention attempts to make code in the caller as -- efficient as possible under the assumption that the call is not -- commonly executed. As such, these calls often preserve all registers -- so that the call does not break any live ranges in the caller side. -- This calling convention does not support varargs and requires the -- prototype of all callees to exactly match the prototype of the -- function definition. CC_Coldcc :: LlvmCallConvention -- | The GHC-specific registerised calling convention. CC_Ghc :: LlvmCallConvention -- | Any calling convention may be specified by number, allowing -- target-specific calling conventions to be used. Target specific -- calling conventions start at 64. CC_Ncc :: Int -> LlvmCallConvention -- | X86 Specific StdCall convention. LLVM includes a specific alias -- for it rather than just using CC_Ncc. CC_X86_Stdcc :: LlvmCallConvention -- | Functions can have a fixed amount of parameters, or a variable amount. data LlvmParameterListType FixedArgs :: LlvmParameterListType VarArgs :: LlvmParameterListType -- | Linkage type of a symbol. -- -- The description of the constructors is copied from the Llvm Assembly -- Language Reference Manual -- http://www.llvm.org/docs/LangRef.html#linkage, because they -- correspond to the Llvm linkage types. data LlvmLinkageType -- | Global values with internal linkage are only directly accessible by -- objects in the current module. In particular, linking code into a -- module with an internal global value may cause the internal to be -- renamed as necessary to avoid collisions. Because the symbol is -- internal to the module, all references can be updated. This -- corresponds to the notion of the static keyword in C. Internal :: LlvmLinkageType -- | Globals with linkonce linkage are merged with other globals -- of the same name when linkage occurs. This is typically used to -- implement inline functions, templates, or other code which must be -- generated in each translation unit that uses it. Unreferenced linkonce -- globals are allowed to be discarded. LinkOnce :: LlvmLinkageType -- | weak linkage is exactly the same as linkonce linkage, except -- that unreferenced weak globals may not be discarded. This is used for -- globals that may be emitted in multiple translation units, but that -- are not guaranteed to be emitted into every translation unit that uses -- them. One example of this are common globals in C, such as int -- X; at global scope. Weak :: LlvmLinkageType -- | appending linkage may only be applied to global variables of -- pointer to array type. When two global variables with appending -- linkage are linked together, the two global arrays are appended -- together. This is the Llvm, typesafe, equivalent of having the system -- linker append together sections with identical names when .o -- files are linked. Appending :: LlvmLinkageType -- | The semantics of this linkage follow the ELF model: the symbol is weak -- until linked, if not linked, the symbol becomes null instead of being -- an undefined reference. ExternWeak :: LlvmLinkageType -- | The symbol participates in linkage and can be used to resolve external -- symbol references. ExternallyVisible :: LlvmLinkageType -- | Alias for ExternallyVisible but with explicit textual form in -- LLVM assembly. External :: LlvmLinkageType -- | Symbol is private to the module and should not appear in the symbol -- table Private :: LlvmLinkageType -- | Llvm binary operators machine operations. data LlvmMachOp -- | add two integer, floating point or vector values. LM_MO_Add :: LlvmMachOp -- | subtract two ... LM_MO_Sub :: LlvmMachOp -- | multiply .. LM_MO_Mul :: LlvmMachOp -- | unsigned integer or vector division. LM_MO_UDiv :: LlvmMachOp -- | signed integer .. LM_MO_SDiv :: LlvmMachOp -- | unsigned integer or vector remainder (mod) LM_MO_URem :: LlvmMachOp -- | signed ... LM_MO_SRem :: LlvmMachOp -- | add two floating point or vector values. LM_MO_FAdd :: LlvmMachOp -- | subtract two ... LM_MO_FSub :: LlvmMachOp -- | multiply ... LM_MO_FMul :: LlvmMachOp -- | divide ... LM_MO_FDiv :: LlvmMachOp -- | remainder ... LM_MO_FRem :: LlvmMachOp -- | Left shift LM_MO_Shl :: LlvmMachOp -- | Logical shift right Shift right, filling with zero LM_MO_LShr :: LlvmMachOp -- | Arithmetic shift right The most significant bits of the result will be -- equal to the sign bit of the left operand. LM_MO_AShr :: LlvmMachOp -- | AND bitwise logical operation. LM_MO_And :: LlvmMachOp -- | OR bitwise logical operation. LM_MO_Or :: LlvmMachOp -- | XOR bitwise logical operation. LM_MO_Xor :: LlvmMachOp -- | Llvm compare operations. data LlvmCmpOp -- | Equal (Signed and Unsigned) LM_CMP_Eq :: LlvmCmpOp -- | Not equal (Signed and Unsigned) LM_CMP_Ne :: LlvmCmpOp -- | Unsigned greater than LM_CMP_Ugt :: LlvmCmpOp -- | Unsigned greater than or equal LM_CMP_Uge :: LlvmCmpOp -- | Unsigned less than LM_CMP_Ult :: LlvmCmpOp -- | Unsigned less than or equal LM_CMP_Ule :: LlvmCmpOp -- | Signed greater than LM_CMP_Sgt :: LlvmCmpOp -- | Signed greater than or equal LM_CMP_Sge :: LlvmCmpOp -- | Signed less than LM_CMP_Slt :: LlvmCmpOp -- | Signed less than or equal LM_CMP_Sle :: LlvmCmpOp -- | Float equal LM_CMP_Feq :: LlvmCmpOp -- | Float not equal LM_CMP_Fne :: LlvmCmpOp -- | Float greater than LM_CMP_Fgt :: LlvmCmpOp -- | Float greater than or equal LM_CMP_Fge :: LlvmCmpOp -- | Float less than LM_CMP_Flt :: LlvmCmpOp -- | Float less than or equal LM_CMP_Fle :: LlvmCmpOp -- | Llvm cast operations. data LlvmCastOp -- | Integer truncate LM_Trunc :: LlvmCastOp -- | Integer extend (zero fill) LM_Zext :: LlvmCastOp -- | Integer extend (sign fill) LM_Sext :: LlvmCastOp -- | Float truncate LM_Fptrunc :: LlvmCastOp -- | Float extend LM_Fpext :: LlvmCastOp -- | Float to unsigned Integer LM_Fptoui :: LlvmCastOp -- | Float to signed Integer LM_Fptosi :: LlvmCastOp -- | Unsigned Integer to Float LM_Uitofp :: LlvmCastOp -- | Signed Int to Float LM_Sitofp :: LlvmCastOp -- | Pointer to Integer LM_Ptrtoint :: LlvmCastOp -- | Integer to Pointer LM_Inttoptr :: LlvmCastOp -- | Cast between types where no bit manipulation is needed LM_Bitcast :: LlvmCastOp -- | Convert a Haskell Double to an LLVM hex encoded floating point form. -- In Llvm float literals can be printed in a big-endian hexadecimal -- format, regardless of underlying architecture. -- -- See Note [LLVM Float Types]. ppDouble :: Platform -> Double -> SDoc narrowFp :: Double -> Float widenFp :: Float -> Double ppFloat :: Platform -> Float -> SDoc ppCommaJoin :: Outputable a => [a] -> SDoc ppSpaceJoin :: Outputable a => [a] -> SDoc instance GHC.Classes.Eq GHC.Llvm.Types.LMConst instance GHC.Classes.Eq GHC.Llvm.Types.LlvmParamAttr instance GHC.Classes.Eq GHC.Llvm.Types.LlvmFuncAttr instance GHC.Show.Show GHC.Llvm.Types.LlvmCallType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCallType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCallConvention instance GHC.Show.Show GHC.Llvm.Types.LlvmParameterListType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmParameterListType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmLinkageType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmType instance GHC.Classes.Eq GHC.Llvm.Types.LlvmFunctionDecl instance GHC.Classes.Eq GHC.Llvm.Types.LlvmLit instance GHC.Classes.Eq GHC.Llvm.Types.LlvmVar instance GHC.Classes.Eq GHC.Llvm.Types.LlvmMachOp instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCmpOp instance GHC.Classes.Eq GHC.Llvm.Types.LlvmCastOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCastOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCmpOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmMachOp instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmType instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmFunctionDecl instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmLinkageType instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmCallConvention instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmFuncAttr instance GHC.Utils.Outputable.Outputable GHC.Llvm.Types.LlvmParamAttr module GHC.Llvm.MetaData -- | A reference to an un-named metadata node. newtype MetaId MetaId :: Int -> MetaId -- | LLVM metadata expressions data MetaExpr MetaStr :: !LMString -> MetaExpr MetaNode :: !MetaId -> MetaExpr MetaVar :: !LlvmVar -> MetaExpr MetaStruct :: [MetaExpr] -> MetaExpr -- | Associates some metadata with a specific label for attaching to an -- instruction. data MetaAnnot MetaAnnot :: LMString -> MetaExpr -> MetaAnnot -- | Metadata declarations. Metadata can only be declared in global scope. data MetaDecl -- | Named metadata. Only used for communicating module information to -- LLVM. ('!name = !{ [!<n>] }' form). MetaNamed :: !LMString -> [MetaId] -> MetaDecl -- | Metadata node declaration. ('!0 = metadata !{ <metadata -- expression> }' form). MetaUnnamed :: !MetaId -> !MetaExpr -> MetaDecl instance GHC.Enum.Enum GHC.Llvm.MetaData.MetaId instance GHC.Classes.Ord GHC.Llvm.MetaData.MetaId instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaId instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaExpr instance GHC.Classes.Eq GHC.Llvm.MetaData.MetaAnnot instance GHC.Utils.Outputable.Outputable GHC.Llvm.MetaData.MetaId -- | The LLVM abstract syntax. module GHC.Llvm.Syntax -- | Block labels type LlvmBlockId = Unique -- | A block of LLVM code. data LlvmBlock LlvmBlock :: LlvmBlockId -> [LlvmStatement] -> LlvmBlock -- | The code label for this block [blockLabel] :: LlvmBlock -> LlvmBlockId -- | A list of LlvmStatement's representing the code for this block. This -- list must end with a control flow statement. [blockStmts] :: LlvmBlock -> [LlvmStatement] type LlvmBlocks = [LlvmBlock] -- | An LLVM Module. This is a top level container in LLVM. data LlvmModule LlvmModule :: [LMString] -> [LlvmAlias] -> [MetaDecl] -> [LMGlobal] -> LlvmFunctionDecls -> LlvmFunctions -> LlvmModule -- | Comments to include at the start of the module. [modComments] :: LlvmModule -> [LMString] -- | LLVM Alias type definitions. [modAliases] :: LlvmModule -> [LlvmAlias] -- | LLVM meta data. [modMeta] :: LlvmModule -> [MetaDecl] -- | Global variables to include in the module. [modGlobals] :: LlvmModule -> [LMGlobal] -- | LLVM Functions used in this module but defined in other modules. [modFwdDecls] :: LlvmModule -> LlvmFunctionDecls -- | LLVM Functions defined in this module. [modFuncs] :: LlvmModule -> LlvmFunctions -- | An LLVM Function data LlvmFunction LlvmFunction :: LlvmFunctionDecl -> [LMString] -> [LlvmFuncAttr] -> LMSection -> Maybe LlvmStatic -> LlvmBlocks -> LlvmFunction -- | The signature of this declared function. [funcDecl] :: LlvmFunction -> LlvmFunctionDecl -- | The functions arguments [funcArgs] :: LlvmFunction -> [LMString] -- | The function attributes. [funcAttrs] :: LlvmFunction -> [LlvmFuncAttr] -- | The section to put the function into, [funcSect] :: LlvmFunction -> LMSection -- | Prefix data [funcPrefix] :: LlvmFunction -> Maybe LlvmStatic -- | The body of the functions. [funcBody] :: LlvmFunction -> LlvmBlocks type LlvmFunctions = [LlvmFunction] type SingleThreaded = Bool -- | LLVM ordering types for synchronization purposes. (Introduced in LLVM -- 3.0). Please see the LLVM documentation for a better description. data LlvmSyncOrdering -- | Some partial order of operations exists. SyncUnord :: LlvmSyncOrdering -- | A single total order for operations at a single address exists. SyncMonotonic :: LlvmSyncOrdering -- | Acquire synchronization operation. SyncAcquire :: LlvmSyncOrdering -- | Release synchronization operation. SyncRelease :: LlvmSyncOrdering -- | Acquire + Release synchronization operation. SyncAcqRel :: LlvmSyncOrdering -- | Full sequential Consistency operation. SyncSeqCst :: LlvmSyncOrdering -- | LLVM atomic operations. Please see the atomicrmw instruction -- in the LLVM documentation for a complete description. data LlvmAtomicOp LAO_Xchg :: LlvmAtomicOp LAO_Add :: LlvmAtomicOp LAO_Sub :: LlvmAtomicOp LAO_And :: LlvmAtomicOp LAO_Nand :: LlvmAtomicOp LAO_Or :: LlvmAtomicOp LAO_Xor :: LlvmAtomicOp LAO_Max :: LlvmAtomicOp LAO_Min :: LlvmAtomicOp LAO_Umax :: LlvmAtomicOp LAO_Umin :: LlvmAtomicOp -- | Llvm Statements data LlvmStatement -- | Assign an expression to a variable: * dest: Variable to assign to * -- source: Source expression Assignment :: LlvmVar -> LlvmExpression -> LlvmStatement -- | Memory fence operation Fence :: Bool -> LlvmSyncOrdering -> LlvmStatement -- | Always branch to the target label Branch :: LlvmVar -> LlvmStatement -- | Branch to label targetTrue if cond is true otherwise to label -- targetFalse * cond: condition that will be tested, must be of type i1 -- * targetTrue: label to branch to if cond is true * targetFalse: label -- to branch to if cond is false BranchIf :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmStatement -- | Comment Plain comment. Comment :: [LMString] -> LlvmStatement -- | Set a label on this position. * name: Identifier of this label, unique -- for this module MkLabel :: LlvmBlockId -> LlvmStatement -- | Store variable value in pointer ptr. If value is of type t then ptr -- must be of type t*. * value: Variable/Constant to store. * ptr: -- Location to store the value in Store :: LlvmVar -> LlvmVar -> LMAlign -> LlvmStatement -- | Multiway branch * scrutinee: Variable or constant which must be of -- integer type that is determines which arm is chosen. * def: The -- default label if there is no match in target. * target: A list of -- (value,label) where the value is an integer constant and label the -- corresponding label to jump to if the scrutinee matches the value. Switch :: LlvmVar -> LlvmVar -> [(LlvmVar, LlvmVar)] -> LlvmStatement -- | Return a result. * result: The variable or constant to return Return :: Maybe LlvmVar -> LlvmStatement -- | An instruction for the optimizer that the code following is not -- reachable Unreachable :: LlvmStatement -- | Raise an expression to a statement (if don't want result or want to -- use Llvm unnamed values. Expr :: LlvmExpression -> LlvmStatement -- | A nop LLVM statement. Useful as its often more efficient to use this -- then to wrap LLvmStatement in a Just or []. Nop :: LlvmStatement -- | A LLVM statement with metadata attached to it. MetaStmt :: [MetaAnnot] -> LlvmStatement -> LlvmStatement -- | Llvm Expressions data LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the stack * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Alloca :: LlvmType -> Int -> LlvmExpression -- | Perform the machine operator op on the operands left and right * op: -- operator * left: left operand * right: right operand LlvmOp :: LlvmMachOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Perform a compare operation on the operands left and right * op: -- operator * left: left operand * right: right operand Compare :: LlvmCmpOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a vector * val: The vector * idx: The -- index of the scalar within the vector Extract :: LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a structure * val: The structure * idx: -- The index of the scalar within the structure Corresponds to -- "extractvalue" instruction. ExtractV :: LlvmVar -> Int -> LlvmExpression -- | Insert a scalar element into a vector * val: The source vector * elt: -- The scalar to insert * index: The index at which to insert the scalar Insert :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the heap * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Malloc :: LlvmType -> Int -> LlvmExpression -- | Load the value at location ptr Load :: LlvmVar -> LMAlign -> LlvmExpression -- | Atomic load of the value at location ptr ALoad :: LlvmSyncOrdering -> SingleThreaded -> LlvmVar -> LlvmExpression -- | Navigate in a structure, selecting elements * inbound: Is the pointer -- inbounds? (computed pointer doesn't overflow) * ptr: Location of the -- structure * indexes: A list of indexes to select the correct value. GetElemPtr :: Bool -> LlvmVar -> [LlvmVar] -> LlvmExpression -- | Cast the variable from to the to type. This is an abstraction of three -- cast operators in Llvm, inttoptr, ptrtoint and bitcast. * cast: Cast -- type * from: Variable to cast * to: type to cast to Cast :: LlvmCastOp -> LlvmVar -> LlvmType -> LlvmExpression -- | Atomic read-modify-write operation * op: Atomic operation * addr: -- Address to modify * operand: Operand to operation * ordering: Ordering -- requirement AtomicRMW :: LlvmAtomicOp -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmExpression -- | Compare-and-exchange operation * addr: Address to modify * old: -- Expected value * new: New value * suc_ord: Ordering required in -- success case * fail_ord: Ordering required in failure case, can be no -- stronger than suc_ord -- -- Result is an i1, true if store was successful. CmpXChg :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmSyncOrdering -> LlvmExpression -- | Call a function. The result is the value of the expression. * -- tailJumps: CallType to signal if the function should be tail called * -- fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Concrete -- arguments for the parameters * attrs: A list of function attributes -- for the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. Call :: LlvmCallType -> LlvmVar -> [LlvmVar] -> [LlvmFuncAttr] -> LlvmExpression -- | Call a function as above but potentially taking metadata as arguments. -- * tailJumps: CallType to signal if the function should be tail called -- * fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Arguments -- that may include metadata. * attrs: A list of function attributes for -- the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. CallM :: LlvmCallType -> LlvmVar -> [MetaExpr] -> [LlvmFuncAttr] -> LlvmExpression -- | Merge variables from different basic blocks which are predecessors of -- this basic block in a new variable of type tp. * tp: type of the -- merged variable, must match the types of the predecessor variables. * -- predecessors: A list of variables and the basic block that they -- originate from. Phi :: LlvmType -> [(LlvmVar, LlvmVar)] -> LlvmExpression -- | Inline assembly expression. Syntax is very similar to the style used -- by GCC. * assembly: Actual inline assembly code. * constraints: -- Operand constraints. * return ty: Return type of function. * vars: Any -- variables involved in the assembly code. * sideeffect: Does the -- expression have side effects not visible from the constraints list. * -- alignstack: Should the stack be conservatively aligned before this -- expression is executed. Asm :: LMString -> LMString -> LlvmType -> [LlvmVar] -> Bool -> Bool -> LlvmExpression -- | A LLVM expression with metadata attached to it. MExpr :: [MetaAnnot] -> LlvmExpression -> LlvmExpression instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmSyncOrdering instance GHC.Show.Show GHC.Llvm.Syntax.LlvmSyncOrdering instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmAtomicOp instance GHC.Show.Show GHC.Llvm.Syntax.LlvmAtomicOp instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmExpression instance GHC.Classes.Eq GHC.Llvm.Syntax.LlvmStatement -- | Pretty print LLVM IR Code. module GHC.Llvm.Ppr -- | Print out a whole LLVM module. ppLlvmModule :: LlvmCgConfig -> LlvmModule -> SDoc -- | Print out a multi-line comment, can be inside a function or on its own ppLlvmComments :: [LMString] -> SDoc -- | Print out a comment, can be inside a function or on its own ppLlvmComment :: LMString -> SDoc -- | Print out a list of global mutable variable definitions ppLlvmGlobals :: LlvmCgConfig -> [LMGlobal] -> SDoc -- | Print out a global mutable variable definition ppLlvmGlobal :: LlvmCgConfig -> LMGlobal -> SDoc -- | Print out a list of LLVM type aliases. ppLlvmAliases :: [LlvmAlias] -> SDoc -- | Print out an LLVM type alias. ppLlvmAlias :: LlvmAlias -> SDoc -- | Print out a list of LLVM metadata. ppLlvmMetas :: LlvmCgConfig -> [MetaDecl] -> SDoc -- | Print out an LLVM metadata definition. ppLlvmMeta :: LlvmCgConfig -> MetaDecl -> SDoc -- | Print out a list of function declaration. ppLlvmFunctionDecls :: LlvmFunctionDecls -> SDoc -- | Print out a function declaration. Declarations define the function -- type but don't define the actual body of the function. ppLlvmFunctionDecl :: LlvmFunctionDecl -> SDoc -- | Print out a list of function definitions. ppLlvmFunctions :: LlvmCgConfig -> LlvmFunctions -> SDoc -- | Print out a function definition. ppLlvmFunction :: LlvmCgConfig -> LlvmFunction -> SDoc ppVar :: LlvmCgConfig -> LlvmVar -> SDoc -- | Print a literal value. No type. ppLit :: LlvmCgConfig -> LlvmLit -> SDoc ppTypeLit :: LlvmCgConfig -> LlvmLit -> SDoc -- | Return the variable name or value of the LlvmVar in Llvm IR -- textual representation (e.g. @x, %y or 42). ppName :: LlvmCgConfig -> LlvmVar -> SDoc -- | Return the variable name or value of the LlvmVar in a plain -- textual representation (e.g. x, y or 42). ppPlainName :: LlvmCgConfig -> LlvmVar -> SDoc -- | This module supplies bindings to generate Llvm IR from Haskell -- (http://www.llvm.org/docs/LangRef.html). -- -- Note: this module is developed in a demand driven way. It is no -- complete LLVM binding library in Haskell, but enough to generate code -- for GHC. -- -- This code is derived from code taken from the Essential Haskell -- Compiler (EHC) project. module GHC.Llvm -- | An LLVM Module. This is a top level container in LLVM. data LlvmModule LlvmModule :: [LMString] -> [LlvmAlias] -> [MetaDecl] -> [LMGlobal] -> LlvmFunctionDecls -> LlvmFunctions -> LlvmModule -- | Comments to include at the start of the module. [modComments] :: LlvmModule -> [LMString] -- | LLVM Alias type definitions. [modAliases] :: LlvmModule -> [LlvmAlias] -- | LLVM meta data. [modMeta] :: LlvmModule -> [MetaDecl] -- | Global variables to include in the module. [modGlobals] :: LlvmModule -> [LMGlobal] -- | LLVM Functions used in this module but defined in other modules. [modFwdDecls] :: LlvmModule -> LlvmFunctionDecls -- | LLVM Functions defined in this module. [modFuncs] :: LlvmModule -> LlvmFunctions -- | An LLVM Function data LlvmFunction LlvmFunction :: LlvmFunctionDecl -> [LMString] -> [LlvmFuncAttr] -> LMSection -> Maybe LlvmStatic -> LlvmBlocks -> LlvmFunction -- | The signature of this declared function. [funcDecl] :: LlvmFunction -> LlvmFunctionDecl -- | The functions arguments [funcArgs] :: LlvmFunction -> [LMString] -- | The function attributes. [funcAttrs] :: LlvmFunction -> [LlvmFuncAttr] -- | The section to put the function into, [funcSect] :: LlvmFunction -> LMSection -- | Prefix data [funcPrefix] :: LlvmFunction -> Maybe LlvmStatic -- | The body of the functions. [funcBody] :: LlvmFunction -> LlvmBlocks -- | An LLVM Function data LlvmFunctionDecl LlvmFunctionDecl :: LMString -> LlvmLinkageType -> LlvmCallConvention -> LlvmType -> LlvmParameterListType -> [LlvmParameter] -> LMAlign -> LlvmFunctionDecl -- | Unique identifier of the function [decName] :: LlvmFunctionDecl -> LMString -- | LinkageType of the function [funcLinkage] :: LlvmFunctionDecl -> LlvmLinkageType -- | The calling convention of the function [funcCc] :: LlvmFunctionDecl -> LlvmCallConvention -- | Type of the returned value [decReturnType] :: LlvmFunctionDecl -> LlvmType -- | Indicates if this function uses varargs [decVarargs] :: LlvmFunctionDecl -> LlvmParameterListType -- | Parameter types and attributes [decParams] :: LlvmFunctionDecl -> [LlvmParameter] -- | Function align value, must be power of 2 [funcAlign] :: LlvmFunctionDecl -> LMAlign type LlvmFunctions = [LlvmFunction] type LlvmFunctionDecls = [LlvmFunctionDecl] -- | Llvm Statements data LlvmStatement -- | Assign an expression to a variable: * dest: Variable to assign to * -- source: Source expression Assignment :: LlvmVar -> LlvmExpression -> LlvmStatement -- | Memory fence operation Fence :: Bool -> LlvmSyncOrdering -> LlvmStatement -- | Always branch to the target label Branch :: LlvmVar -> LlvmStatement -- | Branch to label targetTrue if cond is true otherwise to label -- targetFalse * cond: condition that will be tested, must be of type i1 -- * targetTrue: label to branch to if cond is true * targetFalse: label -- to branch to if cond is false BranchIf :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmStatement -- | Comment Plain comment. Comment :: [LMString] -> LlvmStatement -- | Set a label on this position. * name: Identifier of this label, unique -- for this module MkLabel :: LlvmBlockId -> LlvmStatement -- | Store variable value in pointer ptr. If value is of type t then ptr -- must be of type t*. * value: Variable/Constant to store. * ptr: -- Location to store the value in Store :: LlvmVar -> LlvmVar -> LMAlign -> LlvmStatement -- | Multiway branch * scrutinee: Variable or constant which must be of -- integer type that is determines which arm is chosen. * def: The -- default label if there is no match in target. * target: A list of -- (value,label) where the value is an integer constant and label the -- corresponding label to jump to if the scrutinee matches the value. Switch :: LlvmVar -> LlvmVar -> [(LlvmVar, LlvmVar)] -> LlvmStatement -- | Return a result. * result: The variable or constant to return Return :: Maybe LlvmVar -> LlvmStatement -- | An instruction for the optimizer that the code following is not -- reachable Unreachable :: LlvmStatement -- | Raise an expression to a statement (if don't want result or want to -- use Llvm unnamed values. Expr :: LlvmExpression -> LlvmStatement -- | A nop LLVM statement. Useful as its often more efficient to use this -- then to wrap LLvmStatement in a Just or []. Nop :: LlvmStatement -- | A LLVM statement with metadata attached to it. MetaStmt :: [MetaAnnot] -> LlvmStatement -> LlvmStatement -- | Llvm Expressions data LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the stack * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Alloca :: LlvmType -> Int -> LlvmExpression -- | Perform the machine operator op on the operands left and right * op: -- operator * left: left operand * right: right operand LlvmOp :: LlvmMachOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Perform a compare operation on the operands left and right * op: -- operator * left: left operand * right: right operand Compare :: LlvmCmpOp -> LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a vector * val: The vector * idx: The -- index of the scalar within the vector Extract :: LlvmVar -> LlvmVar -> LlvmExpression -- | Extract a scalar element from a structure * val: The structure * idx: -- The index of the scalar within the structure Corresponds to -- "extractvalue" instruction. ExtractV :: LlvmVar -> Int -> LlvmExpression -- | Insert a scalar element into a vector * val: The source vector * elt: -- The scalar to insert * index: The index at which to insert the scalar Insert :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmExpression -- | Allocate amount * sizeof(tp) bytes on the heap * tp: LlvmType to -- reserve room for * amount: The nr of tp's which must be allocated Malloc :: LlvmType -> Int -> LlvmExpression -- | Load the value at location ptr Load :: LlvmVar -> LMAlign -> LlvmExpression -- | Atomic load of the value at location ptr ALoad :: LlvmSyncOrdering -> SingleThreaded -> LlvmVar -> LlvmExpression -- | Navigate in a structure, selecting elements * inbound: Is the pointer -- inbounds? (computed pointer doesn't overflow) * ptr: Location of the -- structure * indexes: A list of indexes to select the correct value. GetElemPtr :: Bool -> LlvmVar -> [LlvmVar] -> LlvmExpression -- | Cast the variable from to the to type. This is an abstraction of three -- cast operators in Llvm, inttoptr, ptrtoint and bitcast. * cast: Cast -- type * from: Variable to cast * to: type to cast to Cast :: LlvmCastOp -> LlvmVar -> LlvmType -> LlvmExpression -- | Atomic read-modify-write operation * op: Atomic operation * addr: -- Address to modify * operand: Operand to operation * ordering: Ordering -- requirement AtomicRMW :: LlvmAtomicOp -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmExpression -- | Compare-and-exchange operation * addr: Address to modify * old: -- Expected value * new: New value * suc_ord: Ordering required in -- success case * fail_ord: Ordering required in failure case, can be no -- stronger than suc_ord -- -- Result is an i1, true if store was successful. CmpXChg :: LlvmVar -> LlvmVar -> LlvmVar -> LlvmSyncOrdering -> LlvmSyncOrdering -> LlvmExpression -- | Call a function. The result is the value of the expression. * -- tailJumps: CallType to signal if the function should be tail called * -- fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Concrete -- arguments for the parameters * attrs: A list of function attributes -- for the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. Call :: LlvmCallType -> LlvmVar -> [LlvmVar] -> [LlvmFuncAttr] -> LlvmExpression -- | Call a function as above but potentially taking metadata as arguments. -- * tailJumps: CallType to signal if the function should be tail called -- * fnptrval: An LLVM value containing a pointer to a function to be -- invoked. Can be indirect. Should be LMFunction type. * args: Arguments -- that may include metadata. * attrs: A list of function attributes for -- the call. Only NoReturn, NoUnwind, ReadOnly and ReadNone are valid -- here. CallM :: LlvmCallType -> LlvmVar -> [MetaExpr] -> [LlvmFuncAttr] -> LlvmExpression -- | Merge variables from different basic blocks which are predecessors of -- this basic block in a new variable of type tp. * tp: type of the -- merged variable, must match the types of the predecessor variables. * -- predecessors: A list of variables and the basic block that they -- originate from. Phi :: LlvmType -> [(LlvmVar, LlvmVar)] -> LlvmExpression -- | Inline assembly expression. Syntax is very similar to the style used -- by GCC. * assembly: Actual inline assembly code. * constraints: -- Operand constraints. * return ty: Return type of function. * vars: Any -- variables involved in the assembly code. * sideeffect: Does the -- expression have side effects not visible from the constraints list. * -- alignstack: Should the stack be conservatively aligned before this -- expression is executed. Asm :: LMString -> LMString -> LlvmType -> [LlvmVar] -> Bool -> Bool -> LlvmExpression -- | A LLVM expression with metadata attached to it. MExpr :: [MetaAnnot] -> LlvmExpression -> LlvmExpression type LlvmBlocks = [LlvmBlock] -- | A block of LLVM code. data LlvmBlock LlvmBlock :: LlvmBlockId -> [LlvmStatement] -> LlvmBlock -- | The code label for this block [blockLabel] :: LlvmBlock -> LlvmBlockId -- | A list of LlvmStatement's representing the code for this block. This -- list must end with a control flow statement. [blockStmts] :: LlvmBlock -> [LlvmStatement] -- | Block labels type LlvmBlockId = Unique -- | LLVM Parameter Attributes. -- -- Parameter attributes are used to communicate additional information -- about the result or parameters of a function data LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be zero-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). ZeroExt :: LlvmParamAttr -- | This indicates to the code generator that the parameter or return -- value should be sign-extended to a 32-bit value by the caller (for a -- parameter) or the callee (for a return value). SignExt :: LlvmParamAttr -- | This indicates that this parameter or return value should be treated -- in a special target-dependent fashion during while emitting code for a -- function call or return (usually, by putting it in a register as -- opposed to memory). InReg :: LlvmParamAttr -- | This indicates that the pointer parameter should really be passed by -- value to the function. ByVal :: LlvmParamAttr -- | This indicates that the pointer parameter specifies the address of a -- structure that is the return value of the function in the source -- program. SRet :: LlvmParamAttr -- | This indicates that the pointer does not alias any global or any other -- parameter. NoAlias :: LlvmParamAttr -- | This indicates that the callee does not make any copies of the pointer -- that outlive the callee itself NoCapture :: LlvmParamAttr -- | This indicates that the pointer parameter can be excised using the -- trampoline intrinsics. Nest :: LlvmParamAttr type LlvmParameter = (LlvmType, [LlvmParamAttr]) -- | LLVM atomic operations. Please see the atomicrmw instruction -- in the LLVM documentation for a complete description. data LlvmAtomicOp LAO_Xchg :: LlvmAtomicOp LAO_Add :: LlvmAtomicOp LAO_Sub :: LlvmAtomicOp LAO_And :: LlvmAtomicOp LAO_Nand :: LlvmAtomicOp LAO_Or :: LlvmAtomicOp LAO_Xor :: LlvmAtomicOp LAO_Max :: LlvmAtomicOp LAO_Min :: LlvmAtomicOp LAO_Umax :: LlvmAtomicOp LAO_Umin :: LlvmAtomicOp -- | LLVM ordering types for synchronization purposes. (Introduced in LLVM -- 3.0). Please see the LLVM documentation for a better description. data LlvmSyncOrdering -- | Some partial order of operations exists. SyncUnord :: LlvmSyncOrdering -- | A single total order for operations at a single address exists. SyncMonotonic :: LlvmSyncOrdering -- | Acquire synchronization operation. SyncAcquire :: LlvmSyncOrdering -- | Release synchronization operation. SyncRelease :: LlvmSyncOrdering -- | Acquire + Release synchronization operation. SyncAcqRel :: LlvmSyncOrdering -- | Full sequential Consistency operation. SyncSeqCst :: LlvmSyncOrdering -- | Different calling conventions a function can use. data LlvmCallConvention -- | The C calling convention. This calling convention (the default if no -- other calling convention is specified) matches the target C calling -- conventions. This calling convention supports varargs function calls -- and tolerates some mismatch in the declared prototype and implemented -- declaration of the function (as does normal C). CC_Ccc :: LlvmCallConvention -- | This calling convention attempts to make calls as fast as possible -- (e.g. by passing things in registers). This calling convention allows -- the target to use whatever tricks it wants to produce fast code for -- the target, without having to conform to an externally specified ABI -- (Application Binary Interface). Implementations of this convention -- should allow arbitrary tail call optimization to be supported. This -- calling convention does not support varargs and requires the prototype -- of al callees to exactly match the prototype of the function -- definition. CC_Fastcc :: LlvmCallConvention -- | This calling convention attempts to make code in the caller as -- efficient as possible under the assumption that the call is not -- commonly executed. As such, these calls often preserve all registers -- so that the call does not break any live ranges in the caller side. -- This calling convention does not support varargs and requires the -- prototype of all callees to exactly match the prototype of the -- function definition. CC_Coldcc :: LlvmCallConvention -- | The GHC-specific registerised calling convention. CC_Ghc :: LlvmCallConvention -- | Any calling convention may be specified by number, allowing -- target-specific calling conventions to be used. Target specific -- calling conventions start at 64. CC_Ncc :: Int -> LlvmCallConvention -- | X86 Specific StdCall convention. LLVM includes a specific alias -- for it rather than just using CC_Ncc. CC_X86_Stdcc :: LlvmCallConvention -- | Different types to call a function. data LlvmCallType -- | Normal call, allocate a new stack frame. StdCall :: LlvmCallType -- | Tail call, perform the call in the current stack frame. TailCall :: LlvmCallType -- | Functions can have a fixed amount of parameters, or a variable amount. data LlvmParameterListType FixedArgs :: LlvmParameterListType VarArgs :: LlvmParameterListType -- | Linkage type of a symbol. -- -- The description of the constructors is copied from the Llvm Assembly -- Language Reference Manual -- http://www.llvm.org/docs/LangRef.html#linkage, because they -- correspond to the Llvm linkage types. data LlvmLinkageType -- | Global values with internal linkage are only directly accessible by -- objects in the current module. In particular, linking code into a -- module with an internal global value may cause the internal to be -- renamed as necessary to avoid collisions. Because the symbol is -- internal to the module, all references can be updated. This -- corresponds to the notion of the static keyword in C. Internal :: LlvmLinkageType -- | Globals with linkonce linkage are merged with other globals -- of the same name when linkage occurs. This is typically used to -- implement inline functions, templates, or other code which must be -- generated in each translation unit that uses it. Unreferenced linkonce -- globals are allowed to be discarded. LinkOnce :: LlvmLinkageType -- | weak linkage is exactly the same as linkonce linkage, except -- that unreferenced weak globals may not be discarded. This is used for -- globals that may be emitted in multiple translation units, but that -- are not guaranteed to be emitted into every translation unit that uses -- them. One example of this are common globals in C, such as int -- X; at global scope. Weak :: LlvmLinkageType -- | appending linkage may only be applied to global variables of -- pointer to array type. When two global variables with appending -- linkage are linked together, the two global arrays are appended -- together. This is the Llvm, typesafe, equivalent of having the system -- linker append together sections with identical names when .o -- files are linked. Appending :: LlvmLinkageType -- | The semantics of this linkage follow the ELF model: the symbol is weak -- until linked, if not linked, the symbol becomes null instead of being -- an undefined reference. ExternWeak :: LlvmLinkageType -- | The symbol participates in linkage and can be used to resolve external -- symbol references. ExternallyVisible :: LlvmLinkageType -- | Alias for ExternallyVisible but with explicit textual form in -- LLVM assembly. External :: LlvmLinkageType -- | Symbol is private to the module and should not appear in the symbol -- table Private :: LlvmLinkageType -- | Llvm Function Attributes. -- -- Function attributes are set to communicate additional information -- about a function. Function attributes are considered to be part of the -- function, not of the function type, so functions with different -- parameter attributes can have the same function type. Functions can -- have multiple attributes. -- -- Descriptions taken from -- http://llvm.org/docs/LangRef.html#fnattrs data LlvmFuncAttr -- | This attribute indicates that the inliner should attempt to inline -- this function into callers whenever possible, ignoring any active -- inlining size threshold for this caller. AlwaysInline :: LlvmFuncAttr -- | This attribute indicates that the source code contained a hint that -- inlining this function is desirable (such as the "inline" keyword in -- C/C++). It is just a hint; it imposes no requirements on the inliner. InlineHint :: LlvmFuncAttr -- | This attribute indicates that the inliner should never inline this -- function in any situation. This attribute may not be used together -- with the alwaysinline attribute. NoInline :: LlvmFuncAttr -- | This attribute suggests that optimization passes and code generator -- passes make choices that keep the code size of this function low, and -- otherwise do optimizations specifically to reduce code size. OptSize :: LlvmFuncAttr -- | This function attribute indicates that the function never returns -- normally. This produces undefined behavior at runtime if the function -- ever does dynamically return. NoReturn :: LlvmFuncAttr -- | This function attribute indicates that the function never returns with -- an unwind or exceptional control flow. If the function does unwind, -- its runtime behavior is undefined. NoUnwind :: LlvmFuncAttr -- | This attribute indicates that the function computes its result (or -- decides to unwind an exception) based strictly on its arguments, -- without dereferencing any pointer arguments or otherwise accessing any -- mutable state (e.g. memory, control registers, etc) visible to caller -- functions. It does not write through any pointer arguments (including -- byval arguments) and never changes any state visible to callers. This -- means that it cannot unwind exceptions by calling the C++ exception -- throwing methods, but could use the unwind instruction. ReadNone :: LlvmFuncAttr -- | This attribute indicates that the function does not write through any -- pointer arguments (including byval arguments) or otherwise modify any -- state (e.g. memory, control registers, etc) visible to caller -- functions. It may dereference pointer arguments and read state that -- may be set in the caller. A readonly function always returns the same -- value (or unwinds an exception identically) when called with the same -- set of arguments and global state. It cannot unwind an exception by -- calling the C++ exception throwing methods, but may use the unwind -- instruction. ReadOnly :: LlvmFuncAttr -- | This attribute indicates that the function should emit a stack -- smashing protector. It is in the form of a "canary"—a random value -- placed on the stack before the local variables that's checked upon -- return from the function to see if it has been overwritten. A -- heuristic is used to determine if a function needs stack protectors or -- not. -- -- If a function that has an ssp attribute is inlined into a function -- that doesn't have an ssp attribute, then the resulting function will -- have an ssp attribute. Ssp :: LlvmFuncAttr -- | This attribute indicates that the function should always emit a stack -- smashing protector. This overrides the ssp function attribute. -- -- If a function that has an sspreq attribute is inlined into a function -- that doesn't have an sspreq attribute or which has an ssp attribute, -- then the resulting function will have an sspreq attribute. SspReq :: LlvmFuncAttr -- | This attribute indicates that the code generator should not use a red -- zone, even if the target-specific ABI normally permits it. NoRedZone :: LlvmFuncAttr -- | This attributes disables implicit floating point instructions. NoImplicitFloat :: LlvmFuncAttr -- | This attribute disables prologue / epilogue emission for the function. -- This can have very system-specific consequences. Naked :: LlvmFuncAttr -- | Llvm compare operations. data LlvmCmpOp -- | Equal (Signed and Unsigned) LM_CMP_Eq :: LlvmCmpOp -- | Not equal (Signed and Unsigned) LM_CMP_Ne :: LlvmCmpOp -- | Unsigned greater than LM_CMP_Ugt :: LlvmCmpOp -- | Unsigned greater than or equal LM_CMP_Uge :: LlvmCmpOp -- | Unsigned less than LM_CMP_Ult :: LlvmCmpOp -- | Unsigned less than or equal LM_CMP_Ule :: LlvmCmpOp -- | Signed greater than LM_CMP_Sgt :: LlvmCmpOp -- | Signed greater than or equal LM_CMP_Sge :: LlvmCmpOp -- | Signed less than LM_CMP_Slt :: LlvmCmpOp -- | Signed less than or equal LM_CMP_Sle :: LlvmCmpOp -- | Float equal LM_CMP_Feq :: LlvmCmpOp -- | Float not equal LM_CMP_Fne :: LlvmCmpOp -- | Float greater than LM_CMP_Fgt :: LlvmCmpOp -- | Float greater than or equal LM_CMP_Fge :: LlvmCmpOp -- | Float less than LM_CMP_Flt :: LlvmCmpOp -- | Float less than or equal LM_CMP_Fle :: LlvmCmpOp -- | Llvm binary operators machine operations. data LlvmMachOp -- | add two integer, floating point or vector values. LM_MO_Add :: LlvmMachOp -- | subtract two ... LM_MO_Sub :: LlvmMachOp -- | multiply .. LM_MO_Mul :: LlvmMachOp -- | unsigned integer or vector division. LM_MO_UDiv :: LlvmMachOp -- | signed integer .. LM_MO_SDiv :: LlvmMachOp -- | unsigned integer or vector remainder (mod) LM_MO_URem :: LlvmMachOp -- | signed ... LM_MO_SRem :: LlvmMachOp -- | add two floating point or vector values. LM_MO_FAdd :: LlvmMachOp -- | subtract two ... LM_MO_FSub :: LlvmMachOp -- | multiply ... LM_MO_FMul :: LlvmMachOp -- | divide ... LM_MO_FDiv :: LlvmMachOp -- | remainder ... LM_MO_FRem :: LlvmMachOp -- | Left shift LM_MO_Shl :: LlvmMachOp -- | Logical shift right Shift right, filling with zero LM_MO_LShr :: LlvmMachOp -- | Arithmetic shift right The most significant bits of the result will be -- equal to the sign bit of the left operand. LM_MO_AShr :: LlvmMachOp -- | AND bitwise logical operation. LM_MO_And :: LlvmMachOp -- | OR bitwise logical operation. LM_MO_Or :: LlvmMachOp -- | XOR bitwise logical operation. LM_MO_Xor :: LlvmMachOp -- | Llvm cast operations. data LlvmCastOp -- | Integer truncate LM_Trunc :: LlvmCastOp -- | Integer extend (zero fill) LM_Zext :: LlvmCastOp -- | Integer extend (sign fill) LM_Sext :: LlvmCastOp -- | Float truncate LM_Fptrunc :: LlvmCastOp -- | Float extend LM_Fpext :: LlvmCastOp -- | Float to unsigned Integer LM_Fptoui :: LlvmCastOp -- | Float to signed Integer LM_Fptosi :: LlvmCastOp -- | Unsigned Integer to Float LM_Uitofp :: LlvmCastOp -- | Signed Int to Float LM_Sitofp :: LlvmCastOp -- | Pointer to Integer LM_Ptrtoint :: LlvmCastOp -- | Integer to Pointer LM_Inttoptr :: LlvmCastOp -- | Cast between types where no bit manipulation is needed LM_Bitcast :: LlvmCastOp -- | LLVM Variables data LlvmVar -- | Variables with a global scope. LMGlobalVar :: LMString -> LlvmType -> LlvmLinkageType -> LMSection -> LMAlign -> LMConst -> LlvmVar -- | Variables local to a function or parameters. LMLocalVar :: Unique -> LlvmType -> LlvmVar -- | Named local variables. Sometimes we need to be able to explicitly name -- variables (e.g for function arguments). LMNLocalVar :: LMString -> LlvmType -> LlvmVar -- | A constant variable LMLitVar :: LlvmLit -> LlvmVar -- | Llvm Static Data. -- -- These represent the possible global level variables and constants. data LlvmStatic -- | A comment in a static section LMComment :: LMString -> LlvmStatic -- | A static variant of a literal value LMStaticLit :: LlvmLit -> LlvmStatic -- | For uninitialised data LMUninitType :: LlvmType -> LlvmStatic -- | Defines a static LMString LMStaticStr :: LMString -> LlvmType -> LlvmStatic -- | A static array LMStaticArray :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStruc :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A static structure type LMStaticStrucU :: [LlvmStatic] -> LlvmType -> LlvmStatic -- | A pointer to other data LMStaticPointer :: LlvmVar -> LlvmStatic -- | Truncate LMTrunc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Pointer conversion LMBitc :: LlvmStatic -> LlvmType -> LlvmStatic -- | Pointer to Integer conversion LMPtoI :: LlvmStatic -> LlvmType -> LlvmStatic -- | Constant addition operation LMAdd :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Constant subtraction operation LMSub :: LlvmStatic -> LlvmStatic -> LlvmStatic -- | Llvm Literal Data. -- -- These can be used inline in expressions. data LlvmLit -- | Refers to an integer constant (i64 42). LMIntLit :: Integer -> LlvmType -> LlvmLit -- | Floating point literal LMFloatLit :: Double -> LlvmType -> LlvmLit -- | Literal NULL, only applicable to pointer types LMNullLit :: LlvmType -> LlvmLit -- | Vector literal LMVectorLit :: [LlvmLit] -> LlvmLit -- | Undefined value, random bit pattern. Useful for optimisations. LMUndefLit :: LlvmType -> LlvmLit -- | Llvm Types data LlvmType -- | An integer with a given width in bits. LMInt :: Int -> LlvmType -- | 32 bit floating point LMFloat :: LlvmType -- | 64 bit floating point LMDouble :: LlvmType -- | 80 bit (x86 only) floating point LMFloat80 :: LlvmType -- | 128 bit floating point LMFloat128 :: LlvmType -- | A pointer to a LlvmType LMPointer :: LlvmType -> LlvmType -- | An array of LlvmType LMArray :: Int -> LlvmType -> LlvmType -- | A vector of LlvmType LMVector :: Int -> LlvmType -> LlvmType -- | A LlvmVar can represent a label (address) LMLabel :: LlvmType -- | Void type LMVoid :: LlvmType -- | Packed structure type LMStruct :: [LlvmType] -> LlvmType -- | Unpacked structure type LMStructU :: [LlvmType] -> LlvmType -- | A type alias LMAlias :: LlvmAlias -> LlvmType -- | LLVM Metadata LMMetadata :: LlvmType -- | Function type, used to create pointers to functions LMFunction :: LlvmFunctionDecl -> LlvmType -- | A type alias type LlvmAlias = (LMString, LlvmType) -- | A global mutable variable. Maybe defined or external data LMGlobal LMGlobal :: LlvmVar -> Maybe LlvmStatic -> LMGlobal -- | Returns the variable of the LMGlobal [getGlobalVar] :: LMGlobal -> LlvmVar -- | Return the value of the LMGlobal [getGlobalValue] :: LMGlobal -> Maybe LlvmStatic -- | A String in LLVM type LMString = FastString -- | An LLVM section definition. If Nothing then let LLVM decide the -- section type LMSection = Maybe LMString type LMAlign = Maybe Int data LMConst -- | Mutable global variable Global :: LMConst -- | Constant global variable Constant :: LMConst -- | Alias of another variable Alias :: LMConst i64 :: LlvmType i32 :: LlvmType i16 :: LlvmType i8 :: LlvmType i1 :: LlvmType i8Ptr :: LlvmType -- | The target architectures word size llvmWord :: Platform -> LlvmType -- | The target architectures word size llvmWordPtr :: Platform -> LlvmType -- | LLVM metadata expressions data MetaExpr MetaStr :: !LMString -> MetaExpr MetaNode :: !MetaId -> MetaExpr MetaVar :: !LlvmVar -> MetaExpr MetaStruct :: [MetaExpr] -> MetaExpr -- | Associates some metadata with a specific label for attaching to an -- instruction. data MetaAnnot MetaAnnot :: LMString -> MetaExpr -> MetaAnnot -- | Metadata declarations. Metadata can only be declared in global scope. data MetaDecl -- | Named metadata. Only used for communicating module information to -- LLVM. ('!name = !{ [!<n>] }' form). MetaNamed :: !LMString -> [MetaId] -> MetaDecl -- | Metadata node declaration. ('!0 = metadata !{ <metadata -- expression> }' form). MetaUnnamed :: !MetaId -> !MetaExpr -> MetaDecl -- | A reference to an un-named metadata node. newtype MetaId MetaId :: Int -> MetaId -- | Test if a LlvmVar is global. isGlobal :: LlvmVar -> Bool -- | Return the LlvmType of a LlvmLit getLitType :: LlvmLit -> LlvmType -- | Return the LlvmType of the LlvmVar getVarType :: LlvmVar -> LlvmType -- | Return the LlvmLinkageType for a LlvmVar getLink :: LlvmVar -> LlvmLinkageType -- | Return the LlvmType of the LlvmStatic getStatType :: LlvmStatic -> LlvmType -- | Lift a variable to LMPointer type. pVarLift :: LlvmVar -> LlvmVar -- | Lower a variable of LMPointer type. pVarLower :: LlvmVar -> LlvmVar -- | Add a pointer indirection to the supplied type. LMLabel and -- LMVoid cannot be lifted. pLift :: LlvmType -> LlvmType -- | Remove the pointer indirection of the supplied type. Only -- LMPointer constructors can be lowered. pLower :: LlvmType -> LlvmType -- | Test if the given LlvmType is an integer isInt :: LlvmType -> Bool -- | Test if the given LlvmType is a floating point type isFloat :: LlvmType -> Bool -- | Test if the given LlvmType is an LMPointer construct isPointer :: LlvmType -> Bool -- | Test if the given LlvmType is an LMVector construct isVector :: LlvmType -> Bool -- | Width in bits of an LlvmType, returns 0 if not applicable llvmWidthInBits :: Platform -> LlvmType -> Int ppVar :: LlvmCgConfig -> LlvmVar -> SDoc -- | Print a literal value. No type. ppLit :: LlvmCgConfig -> LlvmLit -> SDoc ppTypeLit :: LlvmCgConfig -> LlvmLit -> SDoc -- | Return the variable name or value of the LlvmVar in Llvm IR -- textual representation (e.g. @x, %y or 42). ppName :: LlvmCgConfig -> LlvmVar -> SDoc -- | Return the variable name or value of the LlvmVar in a plain -- textual representation (e.g. x, y or 42). ppPlainName :: LlvmCgConfig -> LlvmVar -> SDoc -- | Print out a whole LLVM module. ppLlvmModule :: LlvmCgConfig -> LlvmModule -> SDoc -- | Print out a multi-line comment, can be inside a function or on its own ppLlvmComments :: [LMString] -> SDoc -- | Print out a comment, can be inside a function or on its own ppLlvmComment :: LMString -> SDoc -- | Print out a list of global mutable variable definitions ppLlvmGlobals :: LlvmCgConfig -> [LMGlobal] -> SDoc -- | Print out a global mutable variable definition ppLlvmGlobal :: LlvmCgConfig -> LMGlobal -> SDoc -- | Print out a list of function declaration. ppLlvmFunctionDecls :: LlvmFunctionDecls -> SDoc -- | Print out a function declaration. Declarations define the function -- type but don't define the actual body of the function. ppLlvmFunctionDecl :: LlvmFunctionDecl -> SDoc -- | Print out a list of function definitions. ppLlvmFunctions :: LlvmCgConfig -> LlvmFunctions -> SDoc -- | Print out a function definition. ppLlvmFunction :: LlvmCgConfig -> LlvmFunction -> SDoc -- | Print out an LLVM type alias. ppLlvmAlias :: LlvmAlias -> SDoc -- | Print out a list of LLVM type aliases. ppLlvmAliases :: [LlvmAlias] -> SDoc -- | Print out a list of LLVM metadata. ppLlvmMetas :: LlvmCgConfig -> [MetaDecl] -> SDoc -- | Print out an LLVM metadata definition. ppLlvmMeta :: LlvmCgConfig -> MetaDecl -> SDoc -- | Deal with Cmm registers module GHC.CmmToLlvm.Regs -- | Get the LlvmVar function argument storing the real register lmGlobalRegArg :: Platform -> GlobalReg -> LlvmVar -- | Get the LlvmVar function variable storing the real register lmGlobalRegVar :: Platform -> GlobalReg -> LlvmVar -- | A list of STG Registers that should always be considered alive alwaysLive :: [GlobalReg] -- | STG Type Based Alias Analysis hierarchy stgTBAA :: [(Unique, LMString, Maybe Unique)] -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. baseN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. stackN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. heapN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. rxN :: Unique -- | Id values The rootN node is the root (there can be more than -- one) of the TBAA hierarchy and as of LLVM 4.0 should *only* be -- referenced by other nodes. It should never occur in any LLVM -- instruction statement. topN :: Unique -- | The TBAA metadata identifier tbaa :: LMString -- | Get the correct TBAA metadata information for this register type getTBAA :: GlobalReg -> Unique -- | Base LLVM Code Generation module -- -- Contains functions useful through out the code generator. module GHC.CmmToLlvm.Base type LlvmCmmDecl = GenCmmDecl [LlvmData] (Maybe RawCmmStatics) (ListGraph LlvmStatement) type LlvmBasicBlock = GenBasicBlock LlvmStatement -- | Global registers live on proc entry type LiveGlobalRegs = [GlobalReg] -- | Unresolved code. Of the form: (data label, data type, unresolved data) type LlvmUnresData = (CLabel, Section, LlvmType, [UnresStatic]) -- | Top level LLVM Data (globals and type aliases) type LlvmData = ([LMGlobal], [LlvmType]) -- | An unresolved Label. -- -- Labels are unresolved when we haven't yet determined if they are -- defined in the module we are currently compiling, or an external one. type UnresLabel = CmmLit type UnresStatic = Either UnresLabel LlvmStatic data LlvmVersion -- | The (inclusive) lower bound on the LLVM Version that is currently -- supported. supportedLlvmVersionLowerBound :: LlvmVersion -- | The (not-inclusive) upper bound bound on the LLVM Version that is -- currently supported. supportedLlvmVersionUpperBound :: LlvmVersion llvmVersionSupported :: LlvmVersion -> Bool parseLlvmVersion :: String -> Maybe LlvmVersion llvmVersionStr :: LlvmVersion -> String llvmVersionList :: LlvmVersion -> [Int] -- | The Llvm monad. Wraps LlvmEnv state as well as the -- IO monad data LlvmM a -- | Get initial Llvm environment. runLlvm :: Logger -> LlvmCgConfig -> LlvmVersion -> BufHandle -> LlvmM a -> IO a -- | Clear variables from the environment for a subcomputation withClearVars :: LlvmM a -> LlvmM a -- | Lookup variables or functions in the environment. varLookup :: Uniquable key => key -> LlvmM (Maybe LlvmType) -- | Insert variables or functions into the environment. varInsert :: Uniquable key => key -> LlvmType -> LlvmM () -- | Set a register as allocated on the stack markStackReg :: GlobalReg -> LlvmM () -- | Check whether a register is allocated on the stack checkStackReg :: GlobalReg -> LlvmM Bool -- | Lookup variables or functions in the environment. funLookup :: Uniquable key => key -> LlvmM (Maybe LlvmType) -- | Insert variables or functions into the environment. funInsert :: Uniquable key => key -> LlvmType -> LlvmM () -- | Get the LLVM version we are generating code for getLlvmVer :: LlvmM LlvmVersion -- | Dumps the document if the corresponding flag has been set by the user dumpIfSetLlvm :: DumpFlag -> String -> DumpFormat -> SDoc -> LlvmM () -- | Prints the given contents to the output handle renderLlvm :: SDoc -> LlvmM () -- | Marks a variable as "used" markUsedVar :: LlvmVar -> LlvmM () -- | Return all variables marked as "used" so far getUsedVars :: LlvmM [LlvmVar] -- | Here we pre-initialise some functions that are used internally by GHC -- so as to make sure they have the most general type in the case that -- user code also uses these functions but with a different type than GHC -- internally. (Main offender is treating return type as void -- instead of 'void *'). Fixes trac #5486. ghcInternalFunctions :: LlvmM () -- | Get target platform getPlatform :: LlvmM Platform getConfig :: LlvmM LlvmCgConfig -- | Allocate a new global unnamed metadata identifier getMetaUniqueId :: LlvmM MetaId -- | Sets metadata node for a given unique setUniqMeta :: Unique -> MetaId -> LlvmM () -- | Gets metadata node for given unique getUniqMeta :: Unique -> LlvmM (Maybe MetaId) -- | Lifting of IO actions. Not exported, as we want to encapsulate IO. liftIO :: IO a -> LlvmM a -- | Translate a basic CmmType to an LlvmType. cmmToLlvmType :: CmmType -> LlvmType -- | Translate a Cmm Float Width to a LlvmType. widthToLlvmFloat :: Width -> LlvmType -- | Translate a Cmm Bit Width to a LlvmType. widthToLlvmInt :: Width -> LlvmType -- | Llvm Function type for Cmm function llvmFunTy :: LiveGlobalRegs -> LlvmM LlvmType -- | Llvm Function signature llvmFunSig :: LiveGlobalRegs -> CLabel -> LlvmLinkageType -> LlvmM LlvmFunctionDecl -- | A Function's arguments llvmFunArgs :: Platform -> LiveGlobalRegs -> [LlvmVar] -- | Llvm standard fun attributes llvmStdFunAttrs :: [LlvmFuncAttr] -- | Alignment to use for functions llvmFunAlign :: Platform -> LMAlign -- | Alignment to use for into tables llvmInfAlign :: Platform -> LMAlign -- | Pointer width llvmPtrBits :: Platform -> Int -- | Convert a list of types to a list of function parameters (each with no -- parameter attributes) tysToParams :: [LlvmType] -> [LlvmParameter] -- | Section to use for a function llvmFunSection :: LlvmCgConfig -> LMString -> LMSection -- | Return a list of "padding" registers for LLVM function calls. -- -- When we generate LLVM function signatures, we can't just make any -- register alive on function entry. Instead, we need to insert fake -- arguments of the same register class until we are sure that one of -- them is mapped to the register we want alive. E.g. to ensure that F5 -- is alive, we may need to insert fake arguments mapped to F1, F2, F3 -- and F4. -- -- Invariant: Cmm FPR regs with number "n" maps to real registers with -- number "n" If the calling convention uses registers in a different -- order or if the invariant doesn't hold, this code probably won't be -- correct. padLiveArgs :: Platform -> LiveGlobalRegs -> LiveGlobalRegs isFPR :: GlobalReg -> Bool -- | Pretty print a CLabel. strCLabel_llvm :: CLabel -> LlvmM LMString -- | Create/get a pointer to a global value. Might return an alias if the -- value in question hasn't been defined yet. We especially make no -- guarantees on the type of the returned pointer. getGlobalPtr :: LMString -> LlvmM LlvmVar -- | Generate definitions for aliases forward-referenced by -- getGlobalPtr. -- -- Must be called at a point where we are sure that no new global -- definitions will be generated anymore! generateExternDecls :: LlvmM ([LMGlobal], [LlvmType]) -- | Here we take a global variable definition, rename it with a -- $def suffix, and generate the appropriate alias. aliasify :: LMGlobal -> LlvmM [LMGlobal] -- | Derive the definition label. It has an identified structure type. llvmDefLabel :: LMString -> LMString instance GHC.Base.Functor GHC.CmmToLlvm.Base.LlvmM instance GHC.Base.Applicative GHC.CmmToLlvm.Base.LlvmM instance GHC.Base.Monad GHC.CmmToLlvm.Base.LlvmM instance GHC.Utils.Logger.HasLogger GHC.CmmToLlvm.Base.LlvmM instance GHC.Types.Unique.Supply.MonadUnique GHC.CmmToLlvm.Base.LlvmM module GHC.SysTools.Tasks runUnlit :: Logger -> DynFlags -> [Option] -> IO () -- | Prepend the working directory to the search path. Note [Filepaths and -- Multiple Home Units] augmentImports :: DynFlags -> [FilePath] -> [FilePath] runCpp :: Logger -> DynFlags -> [Option] -> IO () runPp :: Logger -> DynFlags -> [Option] -> IO () -- | Run compiler of C-like languages and raw objects (such as gcc or -- clang). runCc :: Maybe ForeignSrcLang -> Logger -> TmpFs -> DynFlags -> [Option] -> IO () isContainedIn :: String -> String -> Bool -- | Run the linker with some arguments and return the output askLd :: Logger -> DynFlags -> [Option] -> IO String runAs :: Logger -> DynFlags -> [Option] -> IO () -- | Run the LLVM Optimiser runLlvmOpt :: Logger -> DynFlags -> [Option] -> IO () -- | Run the LLVM Compiler runLlvmLlc :: Logger -> DynFlags -> [Option] -> IO () -- | Run the clang compiler (used as an assembler for the LLVM backend on -- OS X as LLVM doesn't support the OS X system assembler) runClang :: Logger -> DynFlags -> [Option] -> IO () -- | Figure out which version of LLVM we are running this session figureLlvmVersion :: Logger -> DynFlags -> IO (Maybe LlvmVersion) runLink :: Logger -> TmpFs -> DynFlags -> [Option] -> IO () runMergeObjects :: Logger -> TmpFs -> DynFlags -> [Option] -> IO () runLibtool :: Logger -> DynFlags -> [Option] -> IO () runAr :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO () askOtool :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO String runInstallNameTool :: Logger -> DynFlags -> [Option] -> IO () runRanlib :: Logger -> DynFlags -> [Option] -> IO () runWindres :: Logger -> DynFlags -> [Option] -> IO () touch :: Logger -> DynFlags -> String -> String -> IO () -- | Record in the eventlog when the given tool command starts and -- finishes, prepending the given String with "systool:", to -- easily be able to collect and process all the systool events. -- -- For those events to show up in the eventlog, you need to run GHC with -- -v2 or -ddump-timings. traceToolCommand :: Logger -> String -> IO a -> IO a module GHC.Linker.MacOS -- | On macOS we rely on the linkers -dead_strip_dylibs flag to -- remove unused libraries from the dynamic library. We do this to reduce -- the number of load commands that end up in the dylib, and has been -- limited to 32K (32768) since macOS Sierra (10.14). -- -- -dead_strip_dylibs does not dead strip -rpath -- entries, as such passing -l and -rpath to the linker -- will result in the unnecesasry libraries not being included in the -- load commands, however the -rpath entries are all forced to -- be included. This can lead to 100s of -rpath entries being -- included when only a handful of libraries end up being truly linked. -- -- Thus after building the library, we run a fixup phase where we inject -- the -rpath for each found library (in the given library -- search paths) into the dynamic library through -add_rpath. -- -- See Note [Dynamic linking on macOS] runInjectRPaths :: Logger -> DynFlags -> [FilePath] -> FilePath -> IO () getUnitFrameworkOpts :: UnitEnv -> [UnitId] -> IO [String] getFrameworkOpts :: DynFlags -> Platform -> [String] loadFramework :: Interp -> [FilePath] -> FilePath -> IO (Maybe String) module GHC.Linker.ExtraObj mkExtraObj :: Logger -> TmpFs -> DynFlags -> UnitState -> Suffix -> String -> IO FilePath mkExtraObjToLinkIntoBinary :: Logger -> TmpFs -> DynFlags -> UnitState -> IO (Maybe FilePath) mkNoteObjsToLinkIntoBinary :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [UnitId] -> IO [FilePath] checkLinkInfo :: Logger -> DynFlags -> UnitEnv -> [UnitId] -> FilePath -> IO Bool -- | Return the "link info" string -- -- See Note [LinkInfo section] getLinkInfo :: DynFlags -> UnitEnv -> [UnitId] -> IO String -- | Grab compiler info and cache it in DynFlags. getCompilerInfo :: Logger -> DynFlags -> IO CompilerInfo ghcLinkInfoSectionName :: String ghcLinkInfoNoteName :: String platformSupportsSavingLinkOpts :: OS -> Bool haveRtsOptsFlags :: DynFlags -> Bool module GHC.SysTools initSysTools :: String -> IO Settings lazyInitLlvmConfig :: String -> IO LlvmConfig -- | Copy a file with its permissions. If the destination file already -- exists, it is replaced atomically. Neither path may refer to an -- existing directory. No exceptions are thrown if the permissions could -- not be copied. copyFile :: FilePath -> FilePath -> IO () -- | Copy remaining bytes from the first Handle to the second one copyHandle :: Handle -> Handle -> IO () -- | Copy file after printing the given header copyWithHeader :: String -> FilePath -> FilePath -> IO () -- | When invoking external tools as part of the compilation pipeline, we -- pass these a sequence of options on the command-line. Rather than just -- using a list of Strings, we use a type that allows us to distinguish -- between filepaths and 'other stuff'. The reason for this is that this -- type gives us a handle on transforming filenames, and filenames only, -- to whatever format they're expected to be on a particular platform. data Option FileOption :: String -> String -> Option Option :: String -> Option -- | Expand occurrences of the $topdir interpolation in a string. expandTopDir :: FilePath -> String -> String module GHC.Linker.Windows maybeCreateManifest :: Logger -> TmpFs -> DynFlags -> FilePath -> IO [FilePath] -- | Dynamic linker module GHC.Linker.Dynamic linkDynLib :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () -- | Some platforms require that we explicitly link against libm -- if any math-y things are used (which we assume to include all -- programs). See #14022. libmLinkOpts :: Platform -> [Option] module GHC.Linker.Static linkBinary :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [FilePath] -> [UnitId] -> IO () linkBinary' :: Bool -> Logger -> TmpFs -> DynFlags -> UnitEnv -> [FilePath] -> [UnitId] -> IO () -- | Linking a static lib will not really link anything. It will merely -- produce a static archive of all dependent static libraries. The -- resulting library will still need to be linked with any remaining link -- flags. linkStaticLib :: Logger -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () -- | The loader -- -- This module deals with the top-level issues of dynamic linking -- (loading), calling the object-code linker and the byte-code linker -- where necessary. module GHC.Linker.Loader newtype Loader Loader :: MVar (Maybe LoaderState) -> Loader [loader_state] :: Loader -> MVar (Maybe LoaderState) data LoaderState LoaderState :: ClosureEnv -> !ItblEnv -> !LinkableSet -> !LinkableSet -> !PkgsLoaded -> ![(FilePath, String)] -> LoaderState -- | Current global mapping from Names to their true values [closure_env] :: LoaderState -> ClosureEnv -- | The current global mapping from RdrNames of DataCons to info table -- addresses. When a new Unlinked is linked into the running image, or an -- existing module in the image is replaced, the itbl_env must be updated -- appropriately. [itbl_env] :: LoaderState -> !ItblEnv -- | The currently loaded interpreted modules (home package) [bcos_loaded] :: LoaderState -> !LinkableSet -- | And the currently-loaded compiled modules (home package) [objs_loaded] :: LoaderState -> !LinkableSet -- | The currently-loaded packages; always object code haskell libraries, -- system libraries, transitive dependencies [pkgs_loaded] :: LoaderState -> !PkgsLoaded -- | We need to remember the name of previous temporary DLL/.so libraries -- so we can link them (see #10322) [temp_sos] :: LoaderState -> ![(FilePath, String)] -- | Initialise the dynamic linker. This entails -- -- a) Calling the C initialisation procedure, -- -- b) Loading any packages specified on the command line, -- -- c) Loading any packages specified on the command line, now held in the -- -l options in v_Opt_l, -- -- d) Loading any .o/.dll files specified on the command line, -- now held in ldInputs, -- -- e) Loading any MacOS frameworks. -- -- NOTE: This function is idempotent; if called more than once, it does -- nothing. This is useful in Template Haskell, where we call it before -- trying to link. initLoaderState :: Interp -> HscEnv -> IO () uninitializedLoader :: IO Loader -- | Display the loader state. showLoaderState :: Interp -> IO SDoc getLoaderState :: Interp -> IO (Maybe LoaderState) -- | Load a single expression, including first loading packages and -- modules that this expression depends on. -- -- Raises an IO exception (ProgramError) if it can't find a -- compiled version of the dependents to load. loadExpr :: Interp -> HscEnv -> SrcSpan -> UnlinkedBCO -> IO ForeignHValue loadDecls :: Interp -> HscEnv -> SrcSpan -> CompiledByteCode -> IO ([(Name, ForeignHValue)], [Linkable], PkgsLoaded) -- | Load exactly the specified packages, and their dependents (unless of -- course they are already loaded). The dependents are loaded -- automatically, and it doesn't matter what order you specify the input -- packages. loadPackages :: Interp -> HscEnv -> [UnitId] -> IO () loadModule :: Interp -> HscEnv -> Module -> IO () loadCmdLineLibs :: Interp -> HscEnv -> IO () -- | Load the module containing the given Name and get its associated -- HValue. -- -- Throws a ProgramError if loading fails or the name cannot be -- found. loadName :: Interp -> HscEnv -> Name -> IO (ForeignHValue, [Linkable], PkgsLoaded) -- | Unloading old objects ready for a new compilation sweep. -- -- The compilation manager provides us with a list of linkables that it -- considers "stable", i.e. won't be recompiled this time around. For -- each of the modules current linked in memory, -- -- unload :: Interp -> HscEnv -> [Linkable] -> IO () -- | Temporarily extend the loaded env. withExtendedLoadedEnv :: ExceptionMonad m => Interp -> [(Name, ForeignHValue)] -> m a -> m a extendLoadedEnv :: Interp -> [(Name, ForeignHValue)] -> IO () deleteFromLoadedEnv :: Interp -> [Name] -> IO () -- | Dynamically lookup up values from modules and loading them. module GHC.Runtime.Loader -- | Loads the plugins specified in the pluginModNames field of the dynamic -- flags. Should be called after command line arguments are parsed, but -- before actual compilation starts. Idempotent operation. Should be -- re-called if pluginModNames or pluginModNameOpts changes. initializePlugins :: HscEnv -> IO HscEnv loadFrontendPlugin :: HscEnv -> ModuleName -> IO (FrontendPlugin, [Linkable], PkgsLoaded) -- | Force the interfaces for the given modules to be loaded. The -- SDoc parameter is used for debugging (-ddump-if-trace) -- only: it is shown as the reason why the module is being loaded. forceLoadModuleInterfaces :: HscEnv -> SDoc -> [Module] -> IO () -- | Force the interface for the module containing the name to be loaded. -- The SDoc parameter is used for debugging -- (-ddump-if-trace) only: it is shown as the reason why the -- module is being loaded. forceLoadNameModuleInterface :: HscEnv -> SDoc -> Name -> IO () -- | Load the TyCon associated with the given name, come hell or -- high water. Fails if: -- -- forceLoadTyCon :: HscEnv -> Name -> IO TyCon -- | Finds the Name corresponding to the given RdrName in the -- context of the ModuleName. Returns Nothing if no such -- Name could be found. Any other condition results in an -- exception: -- -- -- -- Can only be used for looking up names while loading plugins (and is -- *not* suitable for use within plugins). The interface file is loaded -- very partially: just enough that it can be used, without its rules and -- instances affecting (and being linked from!) the module being -- compiled. This was introduced by 57d6798. -- -- Need the module as well to record information in the interface file lookupRdrNameInModuleForPlugins :: HscEnv -> ModuleName -> RdrName -> IO (Maybe (Name, ModIface)) -- | Loads the value corresponding to a Name if that value has the -- given Type. This only provides limited safety in that it is up -- to the user to ensure that that type corresponds to the type you try -- to use the return value at! -- -- If the value found was not of the correct type, returns Left -- actual_type. Any other condition results in an exception: -- -- getValueSafely :: HscEnv -> Name -> Type -> IO (Either Type (a, [Linkable], PkgsLoaded)) getHValueSafely :: Interp -> HscEnv -> Name -> Type -> IO (Either Type (HValue, [Linkable], PkgsLoaded)) -- | Coerce a value as usual, but: -- -- 1) Evaluate it immediately to get a segfault early if the coercion was -- wrong -- -- 2) Wrap it in some debug messages at verbosity 3 or higher so we can -- see what happened if it does segfault lessUnsafeCoerce :: Logger -> String -> a -> IO b module GHC.Driver.Config.CmmToLlvm -- | Initialize the Llvm code generator configuration from DynFlags initLlvmCgConfig :: Logger -> DynFlags -> IO LlvmCgConfig -- | Handle conversion of CmmData to LLVM code. module GHC.CmmToLlvm.Data -- | Pass a CmmStatic section to an equivalent Llvm code. genLlvmData :: (Section, RawCmmStatics) -> LlvmM LlvmData -- | Handle static data genData :: CmmStatic -> LlvmM LlvmStatic -- | Pretty print helpers for the LLVM Code generator. module GHC.CmmToLlvm.Ppr -- | Pretty print LLVM code pprLlvmCmmDecl :: LlvmCmmDecl -> LlvmM (SDoc, [LlvmVar]) -- | Pretty print LLVM data code pprLlvmData :: LlvmCgConfig -> LlvmData -> SDoc -- | The section we are putting info tables and their entry code into, -- should be unique since we process the assembly pattern matching this. infoSection :: String -- | Handle conversion of CmmProc to LLVM code. module GHC.CmmToLlvm.CodeGen -- | Top-level of the LLVM proc Code generator genLlvmProc :: RawCmmDecl -> LlvmM [LlvmCmmDecl] instance GHC.Show.Show GHC.CmmToLlvm.CodeGen.Signage instance GHC.Classes.Eq GHC.CmmToLlvm.CodeGen.Signage instance GHC.Base.Semigroup GHC.CmmToLlvm.CodeGen.LlvmAccum instance GHC.Base.Monoid GHC.CmmToLlvm.CodeGen.LlvmAccum -- | This is the top-level module in the LLVM code generator. module GHC.CmmToLlvm data LlvmVersion llvmVersionList :: LlvmVersion -> [Int] -- | Top-level of the LLVM Code generator llvmCodeGen :: Logger -> LlvmCgConfig -> Handle -> Stream IO RawCmmGroup a -> IO a -- | Read in assembly file and process llvmFixupAsm :: Platform -> FilePath -> FilePath -> IO () module GHC.CmmToAsm.X86.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl (Alignment, RawCmmStatics) Instr -> SDoc pprData :: NCGConfig -> CmmStatic -> SDoc pprInstr :: Platform -> Instr -> SDoc pprFormat :: Format -> SDoc pprImm :: Platform -> Imm -> SDoc pprDataItem :: NCGConfig -> CmmLit -> SDoc module GHC.CmmToAsm.X86.CodeGen cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl (Alignment, RawCmmStatics) Instr] generateJumpTableForInstr :: NCGConfig -> Instr -> Maybe (NatCmmDecl (Alignment, RawCmmStatics) Instr) extractUnwindPoints :: [Instr] -> [UnwindPoint] -- | This works on the invariant that all jumps in the given blocks are -- required. Starting from there we try to make a few more jumps -- redundant by reordering them. We depend on the information in the CFG -- to do so so without a given CFG we do nothing. invertCondBranches :: Maybe CFG -> LabelMap a -> [NatBasicBlock Instr] -> [NatBasicBlock Instr] -- | InstrBlocks are the insn sequences generated by the insn -- selectors. They are really trees of insns to facilitate fast -- appending, where a left-to-right traversal yields the insns in the -- correct order. type InstrBlock = OrdList Instr -- | Native code generator for x86 and x86-64 architectures module GHC.CmmToAsm.X86 ncgX86_64 :: NCGConfig -> NcgImpl (Alignment, RawCmmStatics) Instr JumpDest ncgX86 :: NCGConfig -> NcgImpl (Alignment, RawCmmStatics) Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.X86.Instr.Instr module GHC.CmmToAsm.PPC.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc pprInstr :: Platform -> Instr -> SDoc -- | Native code generator for PPC architectures module GHC.CmmToAsm.PPC ncgPPC :: NCGConfig -> NcgImpl RawCmmStatics Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.PPC.Instr.Instr module GHC.CmmToAsm.AArch64.Ppr pprNatCmmDecl :: NCGConfig -> NatCmmDecl RawCmmStatics Instr -> SDoc pprInstr :: Platform -> Instr -> SDoc instance GHC.Utils.Outputable.Outputable GHC.CmmToAsm.AArch64.Instr.Instr -- | Native code generator for x86 and x86-64 architectures module GHC.CmmToAsm.AArch64 ncgAArch64 :: NCGConfig -> NcgImpl RawCmmStatics Instr JumpDest instance GHC.CmmToAsm.Instr.Instruction GHC.CmmToAsm.AArch64.Instr.Instr -- | Constants describing the DWARF format. Most of this simply mirrors -- /usr/include/dwarf.h. module GHC.CmmToAsm.Dwarf.Constants -- | Language ID used for Haskell. dW_LANG_Haskell :: Word dW_TAG_compile_unit :: Word dW_TAG_subroutine_type :: Word dW_TAG_file_type :: Word dW_TAG_subprogram :: Word dW_TAG_lexical_block :: Word dW_TAG_base_type :: Word dW_TAG_structure_type :: Word dW_TAG_pointer_type :: Word dW_TAG_array_type :: Word dW_TAG_subrange_type :: Word dW_TAG_typedef :: Word dW_TAG_variable :: Word dW_TAG_arg_variable :: Word dW_TAG_auto_variable :: Word dW_TAG_ghc_src_note :: Word dW_AT_name :: Word dW_AT_stmt_list :: Word dW_AT_low_pc :: Word dW_AT_high_pc :: Word dW_AT_language :: Word dW_AT_comp_dir :: Word dW_AT_producer :: Word dW_AT_external :: Word dW_AT_frame_base :: Word dW_AT_use_UTF8 :: Word dW_AT_linkage_name :: Word dW_AT_ghc_tick_parent :: Word dW_AT_ghc_span_file :: Word dW_AT_ghc_span_start_line :: Word dW_AT_ghc_span_start_col :: Word dW_AT_ghc_span_end_line :: Word dW_AT_ghc_span_end_col :: Word dW_CHILDREN_no :: Word8 dW_CHILDREN_yes :: Word8 dW_FORM_addr :: Word dW_FORM_data2 :: Word dW_FORM_data4 :: Word dW_FORM_string :: Word dW_FORM_flag :: Word dW_FORM_block1 :: Word dW_FORM_ref4 :: Word dW_FORM_ref_addr :: Word dW_FORM_flag_present :: Word dW_ATE_address :: Word dW_ATE_boolean :: Word dW_ATE_float :: Word dW_ATE_signed :: Word dW_ATE_signed_char :: Word dW_ATE_unsigned :: Word dW_ATE_unsigned_char :: Word dW_CFA_set_loc :: Word8 dW_CFA_undefined :: Word8 dW_CFA_same_value :: Word8 dW_CFA_def_cfa :: Word8 dW_CFA_def_cfa_offset :: Word8 dW_CFA_def_cfa_expression :: Word8 dW_CFA_expression :: Word8 dW_CFA_offset_extended_sf :: Word8 dW_CFA_def_cfa_offset_sf :: Word8 dW_CFA_def_cfa_sf :: Word8 dW_CFA_val_offset :: Word8 dW_CFA_val_expression :: Word8 dW_CFA_offset :: Word8 dW_OP_addr :: Word8 dW_OP_deref :: Word8 dW_OP_consts :: Word8 dW_OP_minus :: Word8 dW_OP_mul :: Word8 dW_OP_plus :: Word8 dW_OP_lit0 :: Word8 dW_OP_breg0 :: Word8 dW_OP_call_frame_cfa :: Word8 dwarfInfoSection :: Platform -> SDoc dwarfAbbrevSection :: Platform -> SDoc dwarfLineSection :: Platform -> SDoc dwarfFrameSection :: Platform -> SDoc dwarfGhcSection :: Platform -> SDoc dwarfARangesSection :: Platform -> SDoc dwarfSection :: Platform -> String -> SDoc dwarfInfoLabel :: SDoc dwarfAbbrevLabel :: SDoc dwarfLineLabel :: SDoc dwarfFrameLabel :: SDoc -- | Mapping of registers to DWARF register numbers dwarfRegNo :: Platform -> Reg -> Word8 -- | Virtual register number to use for return address. dwarfReturnRegNo :: Platform -> Word8 module GHC.CmmToAsm.Dwarf.Types -- | Individual dwarf records. Each one will be encoded as an entry in the -- .debug_info section. data DwarfInfo DwarfCompileUnit :: [DwarfInfo] -> String -> String -> String -> SDoc -> SDoc -> SDoc -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwName] :: DwarfInfo -> String [dwProducer] :: DwarfInfo -> String [dwCompDir] :: DwarfInfo -> String [dwLowLabel] :: DwarfInfo -> SDoc [dwHighLabel] :: DwarfInfo -> SDoc [dwLineLabel] :: DwarfInfo -> SDoc DwarfSubprogram :: [DwarfInfo] -> String -> CLabel -> Maybe CLabel -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwName] :: DwarfInfo -> String [dwLabel] :: DwarfInfo -> CLabel -- | label of DIE belonging to the parent tick [dwParent] :: DwarfInfo -> Maybe CLabel DwarfBlock :: [DwarfInfo] -> CLabel -> Maybe CLabel -> DwarfInfo [dwChildren] :: DwarfInfo -> [DwarfInfo] [dwLabel] :: DwarfInfo -> CLabel [dwMarker] :: DwarfInfo -> Maybe CLabel DwarfSrcNote :: RealSrcSpan -> DwarfInfo [dwSrcSpan] :: DwarfInfo -> RealSrcSpan -- | Generate assembly for DWARF data pprDwarfInfo :: Platform -> Bool -> DwarfInfo -> SDoc -- | Abbreviation declaration. This explains the binary encoding we use for -- representing DwarfInfo. Be aware that this must be updated -- along with pprDwarfInfo. pprAbbrevDecls :: Platform -> Bool -> SDoc -- | A DWARF address range. This is used by the debugger to quickly locate -- which compilation unit a given address belongs to. This type assumes a -- non-segmented address-space. data DwarfARange DwarfARange :: CLabel -> CLabel -> DwarfARange [dwArngStartLabel] :: DwarfARange -> CLabel [dwArngEndLabel] :: DwarfARange -> CLabel -- | Print assembler directives corresponding to a DWARF -- .debug_aranges address table entry. pprDwarfARanges :: Platform -> [DwarfARange] -> Unique -> SDoc -- | Information about unwind instructions for a procedure. This -- corresponds to a "Common Information Entry" (CIE) in DWARF. data DwarfFrame DwarfFrame :: CLabel -> UnwindTable -> [DwarfFrameProc] -> DwarfFrame [dwCieLabel] :: DwarfFrame -> CLabel [dwCieInit] :: DwarfFrame -> UnwindTable [dwCieProcs] :: DwarfFrame -> [DwarfFrameProc] -- | Unwind instructions for an individual procedure. Corresponds to a -- "Frame Description Entry" (FDE) in DWARF. data DwarfFrameProc DwarfFrameProc :: CLabel -> Bool -> [DwarfFrameBlock] -> DwarfFrameProc [dwFdeProc] :: DwarfFrameProc -> CLabel [dwFdeHasInfo] :: DwarfFrameProc -> Bool -- | List of blocks. Order must match asm! [dwFdeBlocks] :: DwarfFrameProc -> [DwarfFrameBlock] -- | Unwind instructions for a block. Will become part of the containing -- FDE. data DwarfFrameBlock DwarfFrameBlock :: Bool -> [UnwindPoint] -> DwarfFrameBlock [dwFdeBlkHasInfo] :: DwarfFrameBlock -> Bool -- | these unwind points must occur in the same order as they occur in the -- block [dwFdeUnwind] :: DwarfFrameBlock -> [UnwindPoint] -- | Header for the .debug_frame section. Here we emit the "Common -- Information Entry" record that establishes general call frame -- parameters and the default stack layout. pprDwarfFrame :: Platform -> DwarfFrame -> SDoc -- | Assembly for a single byte of constant DWARF data pprByte :: Word8 -> SDoc -- | Assembly for a two-byte constant integer pprHalf :: Word16 -> SDoc -- | Assembly for 4 bytes of dynamic DWARF data pprData4' :: SDoc -> SDoc -- | Assembly for a DWARF word of dynamic data. This means 32 bit, as we -- are generating 32 bit DWARF. pprDwWord :: SDoc -> SDoc -- | Assembly for a machine word of dynamic data. Depends on the -- architecture we are currently generating code for. pprWord :: Platform -> SDoc -> SDoc -- | Prints a number in "little endian base 128" format. The idea is to -- optimize for small numbers by stopping once all further bytes would be -- 0. The highest bit in every byte signals whether there are further -- bytes to read. pprLEBWord :: Word -> SDoc -- | Same as pprLEBWord, but for a signed number pprLEBInt :: Int -> SDoc -- | Align assembly at (machine) word boundary wordAlign :: Platform -> SDoc -- | Generate an offset into another section. This is tricky because this -- is handled differently depending on platform: Mac Os expects us to -- calculate the offset using assembler arithmetic. Linux expects us to -- just reference the target directly, and will figure out on their own -- that we actually need an offset. Finally, Windows has a special -- directive to refer to relative offsets. Fun. sectionOffset :: Platform -> SDoc -> SDoc -> SDoc instance GHC.Enum.Enum GHC.CmmToAsm.Dwarf.Types.DwarfAbbrev instance GHC.Classes.Eq GHC.CmmToAsm.Dwarf.Types.DwarfAbbrev instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.CmmToAsm.Dwarf.Types.DwarfFrameBlock module GHC.CmmToAsm.Dwarf -- | Generate DWARF/debug information dwarfGen :: NCGConfig -> ModLocation -> UniqSupply -> [DebugBlock] -> IO (SDoc, UniqSupply) -- | Native code generator -- -- The native-code generator has machine-independent and -- machine-dependent modules. -- -- This module (GHC.CmmToAsm) is the top-level machine-independent -- module. Before entering machine-dependent land, we do some -- machine-independent optimisations (defined below) on the -- CmmStmtss. -- -- We convert to the machine-specific Instr datatype with -- cmmCodeGen, assuming an infinite supply of registers. We then -- use a machine-independent register allocator (regAlloc) to -- rejoin reality. Obviously, regAlloc has machine-specific -- helper functions (see about RegAllocInfo below). -- -- Finally, we order the basic blocks of the function so as to minimise -- the number of jumps between blocks, by utilising fallthrough wherever -- possible. -- -- The machine-dependent bits break down as follows: -- -- -- -- The RegAllocInfo module collects together the -- machine-specific info needed to do register allocation. -- -- module GHC.CmmToAsm nativeCodeGen :: forall a. Logger -> NCGConfig -> ModLocation -> Handle -> UniqSupply -> Stream IO RawCmmGroup a -> IO a -- | Complete native code generation phase for a single top-level chunk of -- Cmm. Dumping the output of each stage along the way. Global conflict -- graph and NGC stats cmmNativeGen :: forall statics instr jumpDest. (Instruction instr, OutputableP Platform statics, Outputable jumpDest) => Logger -> ModLocation -> NcgImpl statics instr jumpDest -> UniqSupply -> DwarfFiles -> LabelMap DebugBlock -> RawCmmDecl -> Int -> IO (UniqSupply, DwarfFiles, [NatCmmDecl statics instr], [CLabel], Maybe [RegAllocStats statics instr], Maybe [RegAllocStats], LabelMap [UnwindPoint]) data NcgImpl statics instr jumpDest NcgImpl :: !NCGConfig -> (RawCmmDecl -> NatM [NatCmmDecl statics instr]) -> (instr -> Maybe (NatCmmDecl statics instr)) -> (jumpDest -> Maybe BlockId) -> (instr -> Maybe jumpDest) -> ((BlockId -> Maybe jumpDest) -> statics -> statics) -> ((BlockId -> Maybe jumpDest) -> instr -> instr) -> (NatCmmDecl statics instr -> SDoc) -> Int -> [RealReg] -> (Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)])) -> (LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> ([instr] -> [UnwindPoint]) -> (Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr]) -> NcgImpl statics instr jumpDest [ncgConfig] :: NcgImpl statics instr jumpDest -> !NCGConfig [cmmTopCodeGen] :: NcgImpl statics instr jumpDest -> RawCmmDecl -> NatM [NatCmmDecl statics instr] [generateJumpTableForInstr] :: NcgImpl statics instr jumpDest -> instr -> Maybe (NatCmmDecl statics instr) [getJumpDestBlockId] :: NcgImpl statics instr jumpDest -> jumpDest -> Maybe BlockId [canShortcut] :: NcgImpl statics instr jumpDest -> instr -> Maybe jumpDest [shortcutStatics] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> statics -> statics [shortcutJump] :: NcgImpl statics instr jumpDest -> (BlockId -> Maybe jumpDest) -> instr -> instr -- | Module is only for printing internal labels. See Note [Internal -- proc labels] in CLabel. [pprNatCmmDecl] :: NcgImpl statics instr jumpDest -> NatCmmDecl statics instr -> SDoc [maxSpillSlots] :: NcgImpl statics instr jumpDest -> Int [allocatableRegs] :: NcgImpl statics instr jumpDest -> [RealReg] -- | The list of block ids records the redirected jumps to allow us to -- update the CFG. [ncgAllocMoreStack] :: NcgImpl statics instr jumpDest -> Int -> NatCmmDecl statics instr -> UniqSM (NatCmmDecl statics instr, [(BlockId, BlockId)]) [ncgMakeFarBranches] :: NcgImpl statics instr jumpDest -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] -- | given the instruction sequence of a block, produce a list of the -- block's UnwindPoints See Note [What is this unwinding -- business?] in GHC.Cmm.DebugBlock and Note [Unwinding -- information in the NCG] in this module. [extractUnwindPoints] :: NcgImpl statics instr jumpDest -> [instr] -> [UnwindPoint] -- | Turn the sequence of jcc l1; jmp l2 into jncc l2; -- <block_l1> when possible. [invertCondBranches] :: NcgImpl statics instr jumpDest -> Maybe CFG -> LabelMap RawCmmStatics -> [NatBasicBlock instr] -> [NatBasicBlock instr] instance GHC.Base.Functor GHC.CmmToAsm.CmmOptM instance GHC.Base.Applicative GHC.CmmToAsm.CmmOptM instance GHC.Base.Monad GHC.CmmToAsm.CmmOptM instance GHC.CmmToAsm.PIC.CmmMakeDynamicReferenceM GHC.CmmToAsm.CmmOptM module GHC.Driver.CodeOutput codeOutput :: forall a. Logger -> TmpFs -> DynFlags -> UnitState -> Module -> FilePath -> ModLocation -> (a -> ForeignStubs) -> [(ForeignSrcLang, FilePath)] -> Set UnitId -> Stream IO RawCmmGroup a -> IO (FilePath, (Bool, Maybe FilePath), [(ForeignSrcLang, FilePath)], a) outputForeignStubs :: Logger -> TmpFs -> DynFlags -> UnitState -> Module -> ModLocation -> ForeignStubs -> IO (Bool, Maybe FilePath) -- | Generate code to initialise cost centres profilingInitCode :: Platform -> Module -> CollectedCCs -> CStub -- | Generate code to initialise info pointer origin See Note [Mapping Info -- Tables to Source Positions] ipInitCode :: Bool -> Platform -> Module -> [InfoProvEnt] -> CStub module GHC.StgToCmm.Prof initCostCentres :: CollectedCCs -> FCode () ccType :: Platform -> CmmType ccsType :: Platform -> CmmType mkCCostCentre :: CostCentre -> CmmLit mkCCostCentreStack :: CostCentreStack -> CmmLit initInfoTableProv :: [CmmInfoTable] -> InfoTableProvMap -> FCode CStub emitInfoTableProv :: InfoProvEnt -> FCode () -- | Profiling header words in a dynamic closure dynProfHdr :: Profile -> CmmExpr -> [CmmExpr] -- | Record the allocation of a closure. The CmmExpr is the cost centre -- stack to which to attribute the allocation. profDynAlloc :: SMRep -> CmmExpr -> FCode () -- | Record the allocation of a closure (size is given by a CmmExpr) The -- size must be in words, because the allocation counter in a CCS counts -- in words. profAlloc :: CmmExpr -> CmmExpr -> FCode () -- | The profiling header words in a static closure staticProfHdr :: Profile -> CostCentreStack -> [CmmLit] -- | Initialise the profiling field of an update frame initUpdFrameProf :: CmmExpr -> FCode () enterCostCentreThunk :: CmmExpr -> FCode () enterCostCentreFun :: CostCentreStack -> CmmExpr -> FCode () costCentreFrom :: Platform -> CmmExpr -> CmmExpr storeCurCCS :: CmmExpr -> CmmAGraph emitSetCCC :: CostCentre -> Bool -> Bool -> FCode () saveCurrentCostCentre :: FCode (Maybe LocalReg) restoreCurrentCostCentre :: Maybe LocalReg -> FCode () ldvEnter :: CmmExpr -> FCode () -- | Called when a closure is entered, marks the closure as having been -- "used". The closure is not an "inherently used" one. The closure is -- not IND because that is not considered for LDV profiling. ldvEnterClosure :: ClosureInfo -> CmmReg -> FCode () ldvRecordCreate :: CmmExpr -> FCode () module GHC.StgToCmm.Heap getVirtHp :: FCode VirtualHpOffset setVirtHp :: VirtualHpOffset -> FCode () setRealHp :: VirtualHpOffset -> FCode () getHpRelOffset :: VirtualHpOffset -> FCode CmmExpr entryHeapCheck :: ClosureInfo -> Maybe LocalReg -> Int -> [LocalReg] -> FCode () -> FCode () altHeapCheck :: [LocalReg] -> FCode a -> FCode a noEscapeHeapCheck :: [LocalReg] -> FCode a -> FCode a altHeapCheckReturnsTo :: [LocalReg] -> Label -> ByteOff -> FCode a -> FCode a heapStackCheckGen :: Maybe CmmExpr -> Maybe CmmExpr -> FCode () -- | lower-level version for GHC.Cmm.Parser entryHeapCheck' :: Bool -> CmmExpr -> Int -> [LocalReg] -> FCode () -> FCode () mkStaticClosureFields :: Profile -> CmmInfoTable -> CostCentreStack -> CafInfo -> [CmmLit] -> [CmmLit] mkStaticClosure :: Profile -> CLabel -> CostCentreStack -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] -> [CmmLit] allocDynClosure :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(NonVoid StgArg, VirtualHpOffset)] -> FCode CmmExpr allocDynClosureCmm :: Maybe Id -> CmmInfoTable -> LambdaFormInfo -> CmmExpr -> CmmExpr -> [(CmmExpr, ByteOff)] -> FCode CmmExpr -- | Low-level heap object allocation. allocHeapClosure :: SMRep -> CmmExpr -> CmmExpr -> [(CmmExpr, ByteOff)] -> FCode CmmExpr emitSetDynHdr :: CmmExpr -> CmmExpr -> CmmExpr -> FCode () module GHC.StgToCmm.DataCon cgTopRhsCon :: StgToCmmConfig -> Id -> DataCon -> ConstructorNumber -> [NonVoid StgArg] -> (CgIdInfo, FCode ()) buildDynCon :: Id -> ConstructorNumber -> Bool -> CostCentreStack -> DataCon -> [NonVoid StgArg] -> FCode (CgIdInfo, FCode CmmAGraph) bindConArgs :: AltCon -> LocalReg -> [NonVoid Id] -> FCode [LocalReg] module GHC.Cmm.Info.Build type CAFSet = Set CAFLabel type CAFEnv = LabelMap CAFSet -- | For each code block: - collect the references reachable from this code -- block to FUN, THUNK or RET labels for which hasCAF == True -- -- This gives us a CAFEnv: a mapping from code block to sets of -- labels cafAnal :: Platform -> LabelSet -> CLabel -> CmmGraph -> CAFEnv cafAnalData :: Platform -> CmmStatics -> CAFSet -- | Attach SRTs to all info tables in the CmmDecls, and add SRT -- declarations to the ModuleSRTInfo. doSRTs :: CmmConfig -> ModuleSRTInfo -> [(CAFEnv, [CmmDecl])] -> [(CAFSet, CmmDecl)] -> IO (ModuleSRTInfo, [CmmDeclSRTs]) data ModuleSRTInfo ModuleSRTInfo :: Module -> Map (Set SRTEntry) SRTEntry -> Map SRTEntry (Set SRTEntry) -> SRTMap -> ModuleSRTInfo -- | Current module being compiled. Required for calling labelDynamic. [thisModule] :: ModuleSRTInfo -> Module -- | previous SRTs we've emitted, so we can de-duplicate. Used to implement -- the [Common] optimisation. [dedupSRTs] :: ModuleSRTInfo -> Map (Set SRTEntry) SRTEntry -- | The reverse mapping, so that we can remove redundant entries. e.g. if -- we have an SRT [a,b,c], and we know that b points to [c,d], we can -- omit c and emit [a,b]. Used to implement the [Filter] optimisation. [flatSRTs] :: ModuleSRTInfo -> Map SRTEntry (Set SRTEntry) [moduleSRTMap] :: ModuleSRTInfo -> SRTMap emptySRT :: Module -> ModuleSRTInfo -- | Maps labels from cafAnal to the final CLabel that will appear -- in the SRT. - closures with singleton SRTs resolve to their single -- entry - closures with larger SRTs map to the label for that SRT - CAFs -- must not map to anything! - if a labels maps to Nothing, we found that -- this label's SRT is empty, so we don't need to refer to it from other -- SRTs. type SRTMap = Map CAFLabel (Maybe SRTEntry) -- | Given SRTMap of a module, returns the set of non-CAFFY names in -- the module. Any Names not in the set are CAFFY. srtMapNonCAFs :: SRTMap -> NonCaffySet instance GHC.Classes.Ord GHC.Cmm.Info.Build.CAFLabel instance GHC.Classes.Eq GHC.Cmm.Info.Build.CAFLabel instance GHC.Classes.Ord GHC.Cmm.Info.Build.SRTEntry instance GHC.Classes.Eq GHC.Cmm.Info.Build.SRTEntry instance GHC.Classes.Ord GHC.Cmm.Info.Build.SomeLabel instance GHC.Classes.Eq GHC.Cmm.Info.Build.SomeLabel instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.CAFLabel instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.SRTEntry instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.ModuleSRTInfo instance GHC.Utils.Outputable.OutputableP env GHC.Cmm.CLabel.CLabel => GHC.Utils.Outputable.OutputableP env GHC.Cmm.Info.Build.SomeLabel module GHC.StgToCmm.Foreign -- | Emit code for a foreign call, and return the results to the sequel. -- Precondition: the length of the arguments list is the same as the -- arity of the foreign function. cgForeignCall :: ForeignCall -> Type -> [StgArg] -> Type -> FCode ReturnKind emitPrimCall :: [CmmFormal] -> CallishMachOp -> [CmmActual] -> FCode () emitCCall :: [(CmmFormal, ForeignHint)] -> CmmExpr -> [(CmmActual, ForeignHint)] -> FCode () emitForeignCall :: Safety -> [CmmFormal] -> ForeignTarget -> [CmmActual] -> FCode ReturnKind emitSaveThreadState :: FCode () -- | Produce code to save the current thread state to CurrentTSO saveThreadState :: MonadUnique m => Profile -> m CmmAGraph emitLoadThreadState :: FCode () -- | Save STG registers -- -- STG registers must be saved around a C call, just in case the STG -- register is mapped to a caller-saves machine register. Normally we -- don't need to worry about this the code generator has already loaded -- any live STG registers into variables for us, but in hand-written -- low-level Cmm code where we don't know which registers are live, we -- might have to save them all. emitSaveRegs :: FCode () -- | Restore STG registers (see emitSaveRegs) emitRestoreRegs :: FCode () -- | Push a subset of STG registers onto the stack, specified by the bitmap -- -- Sometimes, a "live" subset of the STG registers needs to be saved on -- the stack, for example when storing an unboxed tuple to be used in the -- GHCi bytecode interpreter. -- -- The "live registers" bitmap corresponds to the list of registers given -- by tupleRegsCover, with the least significant bit indicating -- liveness of the first register in the list. -- -- Each register is saved to a stack slot of one or more machine words, -- even if the register size itself is smaller. -- -- The resulting Cmm code looks like this, with a line for each real or -- virtual register used for returning tuples: -- -- ... if((mask & 2) != 0) { Sp_adj(-1); Sp(0) = R2; } if((mask & -- 1) != 0) { Sp_adj(-1); Sp(0) = R1; } -- -- See Note [GHCi tuple layout] emitPushTupleRegs :: CmmExpr -> FCode () -- | Pop a subset of STG registers from the stack (see -- emitPushTupleRegs) emitPopTupleRegs :: CmmExpr -> FCode () -- | Produce code to load the current thread state from CurrentTSO loadThreadState :: MonadUnique m => Profile -> m CmmAGraph emitOpenNursery :: FCode () emitCloseNursery :: FCode () module GHC.StgToCmm.Prim cgOpApp :: StgOp -> [StgArg] -> Type -> FCode ReturnKind shouldInlinePrimOp :: StgToCmmConfig -> PrimOp -> [CmmExpr] -> Bool module GHC.Cmm.LayoutStack cmmLayoutStack :: CmmConfig -> ProcPointSet -> ByteOff -> CmmGraph -> UniqSM (CmmGraph, LabelMap StackMap) setInfoTableStackMap :: Platform -> LabelMap StackMap -> CmmDecl -> CmmDecl instance GHC.Utils.Outputable.Outputable GHC.Cmm.LayoutStack.StackSlot instance GHC.Utils.Outputable.Outputable GHC.Cmm.LayoutStack.StackMap module GHC.Cmm.Pipeline -- | Top level driver for C-- pipeline cmmPipeline :: HscEnv -> ModuleSRTInfo -> CmmGroup -> IO (ModuleSRTInfo, CmmGroupSRTs) module GHC.StgToCmm.Expr cgExpr :: CgStgExpr -> FCode ReturnKind cgLit :: Literal -> FCode CmmExpr module GHC.StgToCmm.Bind cgTopRhsClosure :: Platform -> RecFlag -> Id -> CostCentreStack -> UpdateFlag -> [Id] -> CgStgExpr -> (CgIdInfo, FCode ()) cgBind :: CgStgBinding -> FCode () emitBlackHoleCode :: CmmExpr -> FCode () pushUpdateFrame :: CLabel -> CmmExpr -> FCode () -> FCode () emitUpdateFrame :: CmmExpr -> CLabel -> CmmExpr -> FCode () module GHC.StgToCmm codeGen :: Logger -> TmpFs -> StgToCmmConfig -> InfoTableProvMap -> [TyCon] -> CollectedCCs -> [CgStgTopBinding] -> HpcInfo -> Stream IO CmmGroup ModuleLFInfos module GHC.Driver.GenerateCgIPEStub generateCgIPEStub :: HscEnv -> Module -> InfoTableProvMap -> NameEnv TagSig -> Stream IO CmmGroupSRTs (NonCaffySet, ModuleLFInfos) -> Stream IO CmmGroupSRTs CgInfos module GHC.Cmm.Parser parseCmmFile :: DynFlags -> Module -> HomeUnit -> FilePath -> IO (Messages PsMessage, Messages PsMessage, Maybe (CmmGroup, [InfoProvEnt])) -- | Main API for compiling plain Haskell source code. -- -- This module implements compilation of a Haskell source. It is -- not concerned with preprocessing of source files; this is -- handled in GHC.Driver.Pipeline -- -- There are various entry points depending on what mode we're in: -- "batch" mode (--make), "one-shot" mode (-c, -- -S etc.), and "interactive" mode (GHCi). There are also entry -- points for individual passes: parsing, typechecking/renaming, -- desugaring, and simplification. -- -- All the functions here take an HscEnv as a parameter, but none -- of them return a new one: HscEnv is treated as an immutable -- value from here on in (although it has mutable components, for the -- caches). -- -- We use the Hsc monad to deal with warning messages consistently: -- specifically, while executing within an Hsc monad, warnings are -- collected. When a Hsc monad returns to an IO monad, the warnings are -- printed, or compilation aborts if the -Werror flag is -- enabled. -- -- (c) The GRASP/AQUA Project, Glasgow University, 1993-2000 module GHC.Driver.Main newHscEnv :: DynFlags -> IO HscEnv newHscEnvWithHUG :: DynFlags -> UnitId -> HomeUnitGraph -> IO HscEnv type Messager = HscEnv -> (Int, Int) -> RecompileRequired -> ModuleGraphNode -> IO () batchMsg :: Messager batchMultiMsg :: Messager -- | Action to perform in backend compilation data HscBackendAction -- | Update the boot and signature file results. HscUpdate :: ModIface -> HscBackendAction -- | Recompile this module. HscRecomp :: CgGuts -> !ModLocation -> !PartialModIface -> !Maybe Fingerprint -> HscBackendAction -- | Information for the code generator. [hscs_guts] :: HscBackendAction -> CgGuts -- | Module info [hscs_mod_location] :: HscBackendAction -> !ModLocation -- | Partial interface [hscs_partial_iface] :: HscBackendAction -> !PartialModIface -- | Old interface hash for this compilation, if an old interface file -- exists. Pass to hscMaybeWriteIface when writing the interface -- to avoid updating the existing interface when the interface isn't -- changed. [hscs_old_iface_hash] :: HscBackendAction -> !Maybe Fingerprint -- | Status of a module in incremental compilation data HscRecompStatus -- | Nothing to do because code already exists. HscUpToDate :: ModIface -> Maybe Linkable -> HscRecompStatus -- | Recompilation of module, or update of interface is required. -- Optionally pass the old interface hash to avoid updating the existing -- interface when it has not changed. HscRecompNeeded :: Maybe Fingerprint -> HscRecompStatus initModDetails :: HscEnv -> ModSummary -> ModIface -> IO ModDetails -- | Write interface files hscMaybeWriteIface :: Logger -> DynFlags -> Bool -> ModIface -> Maybe Fingerprint -> ModLocation -> IO () hscCompileCmmFile :: HscEnv -> FilePath -> FilePath -> IO (Maybe FilePath) -- | Compile to hard-code. hscGenHardCode :: HscEnv -> CgGuts -> ModLocation -> FilePath -> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], Maybe CgInfos) hscInteractive :: HscEnv -> CgGuts -> ModLocation -> IO (Maybe FilePath, CompiledByteCode, [SptEntry]) -- | Do the recompilation avoidance checks for both one-shot and --make -- modes This function is the *only* place in the compiler where we -- decide whether to recompile a module or not! hscRecompStatus :: Maybe Messager -> HscEnv -> ModSummary -> Maybe ModIface -> Maybe Linkable -> (Int, Int) -> IO HscRecompStatus -- | parse a file, returning the abstract syntax hscParse :: HscEnv -> ModSummary -> IO HsParsedModule -- | Rename and typecheck a module, additionally returning the renamed -- syntax hscTypecheckRename :: HscEnv -> ModSummary -> HsParsedModule -> IO (TcGblEnv, RenamedStuff) -- | Do Typechecking without throwing SourceError exception with -Werror hscTypecheckAndGetWarnings :: HscEnv -> ModSummary -> IO (FrontendResult, WarningMessages) -- | Convert a typechecked module to Core hscDesugar :: HscEnv -> ModSummary -> TcGblEnv -> IO ModGuts -- | Make a ModDetails from the results of typechecking. Used when -- typechecking only, as opposed to full compilation. makeSimpleDetails :: Logger -> TcGblEnv -> IO ModDetails -- | Run Core2Core simplifier. The list of String is a list of (Core) -- plugin module names added via TH (cf addCorePlugin). hscSimplify :: HscEnv -> [String] -> ModGuts -> IO ModGuts hscDesugarAndSimplify :: ModSummary -> FrontendResult -> Messages GhcMessage -> Maybe Fingerprint -> Hsc HscBackendAction -- | Check that a module is safe to import. -- -- We return True to indicate the import is safe and False otherwise -- although in the False case an exception may be thrown first. hscCheckSafe :: HscEnv -> Module -> SrcSpan -> IO Bool -- | Return if a module is trusted and the pkgs it depends on to be -- trusted. hscGetSafe :: HscEnv -> Module -> SrcSpan -> IO (Bool, Set UnitId) hscParseIdentifier :: HscEnv -> String -> IO (LocatedN RdrName) hscTcRcLookupName :: HscEnv -> Name -> IO (Maybe TyThing) hscTcRnGetInfo :: HscEnv -> Name -> IO (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) hscIsGHCiMonad :: HscEnv -> String -> IO Name hscGetModuleInterface :: HscEnv -> Module -> IO ModIface -- | Rename some import declarations hscRnImportDecls :: HscEnv -> [LImportDecl GhcPs] -> IO GlobalRdrEnv -- | Lookup things in the compiler's environment hscTcRnLookupRdrName :: HscEnv -> LocatedN RdrName -> IO [Name] -- | Compile a stmt all the way to an HValue, but don't run it -- -- We return Nothing to indicate an empty statement (or comment only), -- not a parse error. hscStmt :: HscEnv -> String -> IO (Maybe ([Id], ForeignHValue, FixityEnv)) hscParseStmtWithLocation :: String -> Int -> String -> Hsc (Maybe (GhciLStmt GhcPs)) -- | Compile a stmt all the way to an HValue, but don't run it -- -- We return Nothing to indicate an empty statement (or comment only), -- not a parse error. hscStmtWithLocation :: HscEnv -> String -> String -> Int -> IO (Maybe ([Id], ForeignHValue, FixityEnv)) hscParsedStmt :: HscEnv -> GhciLStmt GhcPs -> IO (Maybe ([Id], ForeignHValue, FixityEnv)) -- | Compile a decls hscDecls :: HscEnv -> String -> IO ([TyThing], InteractiveContext) hscParseDeclsWithLocation :: HscEnv -> String -> Int -> String -> IO [LHsDecl GhcPs] -- | Compile a decls hscDeclsWithLocation :: HscEnv -> String -> String -> Int -> IO ([TyThing], InteractiveContext) hscParsedDecls :: HscEnv -> [LHsDecl GhcPs] -> IO ([TyThing], InteractiveContext) hscParseModuleWithLocation :: HscEnv -> String -> Int -> String -> IO HsModule -- | Typecheck an expression (but don't run it) hscTcExpr :: HscEnv -> TcRnExprMode -> String -> IO Type -- | How should we infer a type? See Note [TcRnExprMode] data TcRnExprMode -- | Instantiate inferred quantifiers only (:type) TM_Inst :: TcRnExprMode -- | Instantiate all quantifiers, and do eager defaulting (:type +d) TM_Default :: TcRnExprMode hscImport :: HscEnv -> String -> IO (ImportDecl GhcPs) -- | Find the kind of a type, after generalisation hscKcType :: HscEnv -> Bool -> String -> IO (Type, Kind) hscParseExpr :: String -> Hsc (LHsExpr GhcPs) hscParseType :: String -> Hsc (LHsType GhcPs) hscCompileCoreExpr :: HscEnv -> SrcSpan -> CoreExpr -> IO (ForeignHValue, [Linkable], PkgsLoaded) hscTidy :: HscEnv -> ModGuts -> IO (CgGuts, ModDetails) hscCompileCoreExpr' :: HscEnv -> SrcSpan -> CoreExpr -> IO (ForeignHValue, [Linkable], PkgsLoaded) hscParse' :: ModSummary -> Hsc HsParsedModule -- | Run Core2Core simplifier. The list of String is a list of (Core) -- plugin module names added via TH (cf addCorePlugin). hscSimplify' :: [String] -> ModGuts -> Hsc ModGuts hscDesugar' :: ModLocation -> TcGblEnv -> Hsc ModGuts tcRnModule' :: ModSummary -> Bool -> HsParsedModule -> Hsc TcGblEnv doCodeGen :: HscEnv -> Module -> InfoTableProvMap -> [TyCon] -> CollectedCCs -> [CgStgTopBinding] -> HpcInfo -> IO (Stream IO CmmGroupSRTs CgInfos) getHscEnv :: Hsc HscEnv hscSimpleIface' :: TcGblEnv -> ModSummary -> Hsc (ModIface, ModDetails) oneShotMsg :: Logger -> RecompileRequired -> IO () dumpIfaceStats :: HscEnv -> IO () -- | Deal with errors and warnings returned by a compilation step -- -- In order to reduce dependencies to other parts of the compiler, -- functions outside the "main" parts of GHC return warnings and errors -- as a parameter and signal success via by wrapping the result in a -- Maybe type. This function logs the returned warnings and -- propagates errors as exceptions (of type SourceError). -- -- This function assumes the following invariants: -- --
    --
  1. If the second result indicates success (is of the form 'Just x'), -- there must be no error messages in the first result.
  2. --
  3. If there are no error messages, but the second result indicates -- failure there should be warnings in the first result. That is, if the -- action failed, it must have been due to the warnings (i.e., -- -Werror).
  4. --
ioMsgMaybe :: IO (Messages GhcMessage, Maybe a) -> Hsc a showModuleIndex :: (Int, Int) -> SDoc -- | Load the given static-pointer table entries into the interpreter. See -- Note [Grand plan for static forms] in -- GHC.Iface.Tidy.StaticPtrTable. hscAddSptEntries :: HscEnv -> [SptEntry] -> IO () writeInterfaceOnlyMode :: DynFlags -> Bool -- | Template Haskell splices module GHC.Tc.Gen.Splice tcSpliceExpr :: HsSplice GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcTypedBracket :: HsExpr GhcRn -> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc) tcUntypedBracket :: HsExpr GhcRn -> HsQuote GhcRn -> [PendingRnSplice] -> ExpRhoType -> TcM (HsExpr GhcTc) runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation runMetaE :: LHsExpr GhcTc -> TcM (LHsExpr GhcPs) runMetaP :: LHsExpr GhcTc -> TcM (LPat GhcPs) runMetaT :: LHsExpr GhcTc -> TcM (LHsType GhcPs) runMetaD :: LHsExpr GhcTc -> TcM [LHsDecl GhcPs] runQuasi :: Q a -> TcM a tcTopSpliceExpr :: SpliceType -> TcM (LHsExpr GhcTc) -> TcM (LHsExpr GhcTc) lookupThName_maybe :: Name -> TcM (Maybe Name) defaultRunMeta :: MetaHook TcM runMeta' :: Bool -> (hs_syn -> SDoc) -> (SrcSpan -> ForeignHValue -> TcM (Either SDoc hs_syn)) -> LHsExpr GhcTc -> TcM hs_syn runRemoteModFinalizers :: ThModFinalizers -> TcM () -- | Releases the external interpreter state. finishTH :: TcM () runTopSplice :: DelayedSplice -> TcM (HsExpr GhcTc) instance GHC.Tc.Gen.Splice.ReifyFlag () () instance GHC.Tc.Gen.Splice.ReifyFlag GHC.Types.Var.Specificity Language.Haskell.TH.Syntax.Specificity instance Language.Haskell.TH.Syntax.Quasi GHC.Tc.Types.TcM module GHC.Runtime.Eval data Resume Resume :: String -> ForeignRef (ResumeContext [HValueRef]) -> ResumeBindings -> [Id] -> ForeignHValue -> Maybe BreakInfo -> SrcSpan -> String -> RemotePtr CostCentreStack -> [History] -> Int -> Resume [resumeStmt] :: Resume -> String [resumeContext] :: Resume -> ForeignRef (ResumeContext [HValueRef]) [resumeBindings] :: Resume -> ResumeBindings [resumeFinalIds] :: Resume -> [Id] [resumeApStack] :: Resume -> ForeignHValue [resumeBreakInfo] :: Resume -> Maybe BreakInfo [resumeSpan] :: Resume -> SrcSpan [resumeDecl] :: Resume -> String [resumeCCS] :: Resume -> RemotePtr CostCentreStack [resumeHistory] :: Resume -> [History] [resumeHistoryIx] :: Resume -> Int data History History :: ForeignHValue -> BreakInfo -> [String] -> History [historyApStack] :: History -> ForeignHValue [historyBreakInfo] :: History -> BreakInfo [historyEnclosingDecls] :: History -> [String] -- | Run a statement in the current interactive context. execStmt :: GhcMonad m => String -> ExecOptions -> m ExecResult -- | Like execStmt, but takes a parsed statement as argument. Useful -- when doing preprocessing on the AST before execution, e.g. in GHCi -- (see GHCi.UI.runStmt). execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult data ExecOptions ExecOptions :: SingleStep -> String -> Int -> (ForeignHValue -> EvalExpr ForeignHValue) -> ExecOptions -- | stepping mode [execSingleStep] :: ExecOptions -> SingleStep -- | filename (for errors) [execSourceFile] :: ExecOptions -> String -- | line number (for errors) [execLineNumber] :: ExecOptions -> Int [execWrap] :: ExecOptions -> ForeignHValue -> EvalExpr ForeignHValue -- | default ExecOptions execOptions :: ExecOptions data ExecResult ExecComplete :: Either SomeException [Name] -> Word64 -> ExecResult [execResult] :: ExecResult -> Either SomeException [Name] [execAllocation] :: ExecResult -> Word64 ExecBreak :: [Name] -> Maybe BreakInfo -> ExecResult [breakNames] :: ExecResult -> [Name] [breakInfo] :: ExecResult -> Maybe BreakInfo resumeExec :: GhcMonad m => (SrcSpan -> Bool) -> SingleStep -> Maybe Int -> m ExecResult runDecls :: GhcMonad m => String -> m [Name] -- | Run some declarations and return any user-visible names that were -- brought into scope. runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name] -- | Like runDeclsWithLocation, but takes parsed declarations as -- argument. Useful when doing preprocessing on the AST before execution, -- e.g. in GHCi (see GHCi.UI.runStmt). runParsedDecls :: GhcMonad m => [LHsDecl GhcPs] -> m [Name] parseImportDecl :: GhcMonad m => String -> m (ImportDecl GhcPs) data SingleStep RunToCompletion :: SingleStep SingleStep :: SingleStep RunAndLogSteps :: SingleStep abandon :: GhcMonad m => m Bool abandonAll :: GhcMonad m => m Bool getResumeContext :: GhcMonad m => m [Resume] getHistorySpan :: HscEnv -> History -> SrcSpan getModBreaks :: HomeModInfo -> ModBreaks getHistoryModule :: History -> Module setupBreakpoint :: GhcMonad m => HscEnv -> BreakInfo -> Int -> m () back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) -- | Set the interactive evaluation context. -- -- (setContext imports) sets the ic_imports field (which in turn -- determines what is in scope at the prompt) to imports, and -- updates the icReaderEnv environment to reflect it. -- -- We retain in scope all the things defined at the prompt, and kept in -- ic_tythings. (Indeed, they shadow stuff from ic_imports.) setContext :: GhcMonad m => [InteractiveImport] -> m () -- | Get the interactive evaluation context, consisting of a pair of the -- set of modules from which we take the full top-level scope, and the -- set of modules from which we take just the exports respectively. getContext :: GhcMonad m => m [InteractiveImport] -- | Returns all names in scope in the current interactive context getNamesInScope :: GhcMonad m => m [Name] -- | Returns all RdrNames in scope in the current interactive -- context, excluding any that are internally-generated. getRdrNamesInScope :: GhcMonad m => m [RdrName] -- | Returns True if the specified module is interpreted, and -- hence has its full top-level scope available. moduleIsInterpreted :: GhcMonad m => Module -> m Bool -- | Looks up an identifier in the current interactive context (for :info) -- Filter the instances by the ones whose tycons (or clases resp) are in -- scope (qualified or otherwise). Otherwise we list a whole lot too -- many! The exact choice of which ones to show, and which to hide, is a -- judgement call. (see #1581) getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) -- | Get the type of an expression Returns the type as described by -- TcRnExprMode exprType :: GhcMonad m => TcRnExprMode -> String -> m Type -- | Get the kind of a type typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind) -- | Parses a string as an identifier, and returns the list of Names -- that the identifier can refer to in the current interactive context. parseName :: GhcMonad m => String -> m [Name] parseInstanceHead :: GhcMonad m => String -> m Type getInstancesForType :: GhcMonad m => Type -> m [ClsInst] getDocs :: GhcMonad m => Name -> m (Either GetDocsFailure (Maybe [HsDoc GhcRn], IntMap (HsDoc GhcRn))) -- | Failure modes for getDocs. data GetDocsFailure -- | nameModule_maybe returned Nothing. NameHasNoModule :: Name -> GetDocsFailure -- | True: The module was compiled. False: The module was -- :loaded. NoDocsInIface :: Module -> Bool -> GetDocsFailure -- | The Name was defined interactively. InteractiveName :: GetDocsFailure showModule :: GhcMonad m => ModSummary -> m String moduleIsBootOrNotObjectLinkable :: GhcMonad m => ModSummary -> m Bool -- | Parse an expression, the parsed expression can be further processed -- and passed to compileParsedExpr. parseExpr :: GhcMonad m => String -> m (LHsExpr GhcPs) compileParsedExpr :: GhcMonad m => LHsExpr GhcPs -> m HValue -- | Compile an expression, run it, and deliver the resulting HValue. compileExpr :: GhcMonad m => String -> m HValue -- | Compile an expression, run it and return the result as a Dynamic. dynCompileExpr :: GhcMonad m => String -> m Dynamic -- | Compile an expression, run it, and deliver the resulting HValue. compileExprRemote :: GhcMonad m => String -> m ForeignHValue -- | Compile a parsed expression (before renaming), run it, and deliver the -- resulting HValue. compileParsedExprRemote :: GhcMonad m => LHsExpr GhcPs -> m ForeignHValue data Term Term :: RttiType -> Either String DataCon -> ForeignHValue -> [Term] -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [val] :: Term -> ForeignHValue [subTerms] :: Term -> [Term] Prim :: RttiType -> [Word] -> Term [ty] :: Term -> RttiType [valRaw] :: Term -> [Word] Suspension :: ClosureType -> RttiType -> ForeignHValue -> Maybe Name -> Term [ctype] :: Term -> ClosureType [ty] :: Term -> RttiType [val] :: Term -> ForeignHValue [bound_to] :: Term -> Maybe Name NewtypeWrap :: RttiType -> Either String DataCon -> Term -> Term [ty] :: Term -> RttiType [dc] :: Term -> Either String DataCon [wrapped_term] :: Term -> Term RefWrap :: RttiType -> Term -> Term [ty] :: Term -> RttiType [wrapped_term] :: Term -> Term obtainTermFromId :: HscEnv -> Int -> Bool -> Id -> IO Term obtainTermFromVal :: HscEnv -> Int -> Bool -> Type -> a -> IO Term reconstructType :: HscEnv -> Int -> Id -> IO (Maybe Type) instance GHC.Utils.Outputable.Outputable GHC.Runtime.Eval.GetDocsFailure module GHC.Driver.Pipeline.Execute newtype HookedUse a HookedUse :: ((Hooks, PhaseHook) -> IO a) -> HookedUse a [runHookedUse] :: HookedUse a -> (Hooks, PhaseHook) -> IO a -- | The default mechanism to run a pipeline, see Note [The Pipeline Monad] runPipeline :: Hooks -> HookedUse a -> IO a -- | Default interpretation of each phase, in terms of IO. runPhase :: TPhase out -> IO out runLlvmManglePhase :: PipeEnv -> HscEnv -> FilePath -> IO [Char] runMergeForeign :: PipeEnv -> HscEnv -> FilePath -> [FilePath] -> IO FilePath runLlvmLlcPhase :: PipeEnv -> HscEnv -> FilePath -> IO FilePath runLlvmOptPhase :: PipeEnv -> HscEnv -> FilePath -> IO FilePath runAsPhase :: Bool -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> IO FilePath runCcPhase :: Phase -> PipeEnv -> HscEnv -> FilePath -> IO FilePath runHscBackendPhase :: PipeEnv -> HscEnv -> ModuleName -> HscSource -> ModLocation -> HscBackendAction -> IO ([FilePath], ModIface, Maybe Linkable, FilePath) runUnlitPhase :: HscEnv -> FilePath -> FilePath -> IO FilePath getFileArgs :: HscEnv -> FilePath -> IO (DynFlags, [Warn]) runCppPhase :: HscEnv -> FilePath -> FilePath -> IO FilePath runHscPhase :: PipeEnv -> HscEnv -> FilePath -> HscSource -> IO (HscEnv, ModSummary, HscRecompStatus) -- | Calculate the ModLocation from the provided DynFlags. This function is -- only used in one-shot mode and therefore takes into account the effect -- of -o/-ohi flags (which do nothing in --make mode) mkOneShotModLocation :: PipeEnv -> DynFlags -> HscSource -> ModuleName -> IO ModLocation runHscTcPhase :: HscEnv -> ModSummary -> IO (FrontendResult, Messages GhcMessage) runHscPostTcPhase :: HscEnv -> ModSummary -> FrontendResult -> Messages GhcMessage -> Maybe Fingerprint -> IO HscBackendAction runHsPpPhase :: HscEnv -> FilePath -> FilePath -> FilePath -> IO FilePath phaseOutputFilenameNew :: Phase -> PipeEnv -> HscEnv -> Maybe ModLocation -> IO FilePath -- | Computes the next output filename for something in the compilation -- pipeline. This is controlled by several variables: -- --
    --
  1. Phase: the last phase to be run (e.g. stopPhase). -- This is used to tell if we're in the last phase or not, because in -- that case flags like -o may be important.
  2. --
  3. PipelineOutput: is this intended to be a Temporary -- or Persistent build output? Temporary files just go in a fresh -- temporary name.
  4. --
  5. String: what was the basename of the original input -- file?
  6. --
  7. DynFlags: the obvious thing
  8. --
  9. Phase: the phase we want to determine the output filename -- of.
  10. --
  11. Maybe ModLocation: the ModLocation of the module -- we're compiling; this can be used to override the default output of an -- object file. (TODO: do we actually need this?)
  12. --
getOutputFilename :: Logger -> TmpFs -> Phase -> PipelineOutput -> String -> DynFlags -> Phase -> Maybe ModLocation -> IO FilePath -- | LLVM Options. These are flags to be passed to opt and llc, to ensure -- consistency we list them in pairs, so that they form groups. llvmOptions :: DynFlags -> [(String, String)] offsetIncludePaths :: DynFlags -> IncludeSpecs -> IncludeSpecs -- | Run CPP -- -- UnitEnv is needed to compute MIN_VERSION macros doCpp :: Logger -> TmpFs -> DynFlags -> UnitEnv -> Bool -> FilePath -> FilePath -> IO () getBackendDefs :: Logger -> DynFlags -> IO [String] -- | What phase to run after one of the backend code generators has run hscPostBackendPhase :: HscSource -> Backend -> Phase compileStub :: HscEnv -> FilePath -> IO FilePath joinObjectFiles :: HscEnv -> [FilePath] -> FilePath -> IO () getHCFilePackages :: FilePath -> IO [UnitId] linkDynLibCheck :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () generatePackageVersionMacros :: [UnitInfo] -> String fixchar :: Char -> Char generateMacros :: String -> String -> Version -> String touchObjectFile :: Logger -> DynFlags -> FilePath -> IO () -- | Find out path to ghcversion.h file getGhcVersionPathName :: DynFlags -> UnitEnv -> IO FilePath instance Control.Monad.Catch.MonadCatch GHC.Driver.Pipeline.Execute.HookedUse instance Control.Monad.Catch.MonadThrow GHC.Driver.Pipeline.Execute.HookedUse instance Control.Monad.IO.Class.MonadIO GHC.Driver.Pipeline.Execute.HookedUse instance GHC.Base.Monad GHC.Driver.Pipeline.Execute.HookedUse instance GHC.Base.Applicative GHC.Driver.Pipeline.Execute.HookedUse instance GHC.Base.Functor GHC.Driver.Pipeline.Execute.HookedUse instance GHC.Driver.Pipeline.Monad.MonadUse GHC.Driver.Pipeline.Phases.TPhase GHC.Driver.Pipeline.Execute.HookedUse module GHC.Driver.Pipeline oneShot :: HscEnv -> StopPhase -> [(String, Maybe Phase)] -> IO () compileFile :: HscEnv -> StopPhase -> (FilePath, Maybe Phase) -> IO (Maybe FilePath) -- | Just preprocess a file, put the result in a temp. file (used by the -- compilation manager during the summary phase). -- -- We return the augmented DynFlags, because they contain the result of -- slurping in the OPTIONS pragmas preprocess :: HscEnv -> FilePath -> Maybe InputFileBuffer -> Maybe Phase -> IO (Either DriverMessages (DynFlags, FilePath)) -- | Compile -- -- Compile a single module, under the control of the compilation manager. -- -- This is the interface between the compilation manager and the compiler -- proper (hsc), where we deal with tedious details like reading the -- OPTIONS pragma from the source file, converting the C or assembly that -- GHC produces into an object file, and compiling FFI stub files. -- -- NB. No old interface can also mean that the source has changed. compileOne :: HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> IO HomeModInfo compileOne' :: Maybe Messager -> HscEnv -> ModSummary -> Int -> Int -> Maybe ModIface -> Maybe Linkable -> IO HomeModInfo compileForeign :: HscEnv -> ForeignSrcLang -> FilePath -> IO FilePath compileEmptyStub :: DynFlags -> HscEnv -> FilePath -> ModLocation -> ModuleName -> IO () link :: GhcLink -> Logger -> TmpFs -> Hooks -> DynFlags -> UnitEnv -> Bool -> Maybe (RecompileRequired -> IO ()) -> HomePackageTable -> IO SuccessFlag linkingNeeded :: Logger -> DynFlags -> UnitEnv -> Bool -> [Linkable] -> [UnitId] -> IO RecompileRequired checkLinkInfo :: Logger -> DynFlags -> UnitEnv -> [UnitId] -> FilePath -> IO Bool data PipeEnv PipeEnv :: StopPhase -> String -> String -> String -> PipelineOutput -> PipeEnv -- | Stop just after this phase [stop_phase] :: PipeEnv -> StopPhase -- | basename of original input source [src_filename] :: PipeEnv -> String -- | basename of original input source [src_basename] :: PipeEnv -> String -- | its extension [src_suffix] :: PipeEnv -> String -- | says where to put the pipeline output [output_spec] :: PipeEnv -> PipelineOutput mkPipeEnv :: StopPhase -> FilePath -> PipelineOutput -> PipeEnv phaseOutputFilenameNew :: Phase -> PipeEnv -> HscEnv -> Maybe ModLocation -> IO FilePath data TPhase res [T_Unlit] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_FileArgs] :: HscEnv -> FilePath -> TPhase (DynFlags, [Warn]) [T_Cpp] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_HsPp] :: PipeEnv -> HscEnv -> FilePath -> FilePath -> TPhase [Char] [T_HscRecomp] :: PipeEnv -> HscEnv -> FilePath -> HscSource -> TPhase (HscEnv, ModSummary, HscRecompStatus) [T_Hsc] :: HscEnv -> ModSummary -> TPhase (FrontendResult, Messages GhcMessage) [T_HscPostTc] :: HscEnv -> ModSummary -> FrontendResult -> Messages GhcMessage -> Maybe Fingerprint -> TPhase HscBackendAction [T_HscBackend] :: PipeEnv -> HscEnv -> ModuleName -> HscSource -> ModLocation -> HscBackendAction -> TPhase ([FilePath], ModIface, Maybe Linkable, FilePath) [T_CmmCpp] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_Cmm] :: PipeEnv -> HscEnv -> FilePath -> TPhase ([FilePath], FilePath) [T_Cc] :: Phase -> PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_As] :: Bool -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> TPhase [Char] [T_LlvmOpt] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_LlvmLlc] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_LlvmMangle] :: PipeEnv -> HscEnv -> FilePath -> TPhase [Char] [T_MergeForeign] :: PipeEnv -> HscEnv -> FilePath -> [FilePath] -> TPhase [Char] -- | Default interpretation of each phase, in terms of IO. runPhase :: TPhase out -> IO out -- | What phase to run after one of the backend code generators has run hscPostBackendPhase :: HscSource -> Backend -> Phase type TPipelineClass (f :: Type -> Type) (m :: Type -> Type) = (Functor m, MonadIO m, Applicative m, Monad m, MonadUse f m) -- | Lift a f action into an m action. class MonadUse (f :: Type -> Type) (m :: Type -> Type) use :: MonadUse f m => f a -> m a -- | The preprocessor pipeline preprocessPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m (DynFlags, FilePath) -- | The complete compilation pipeline, from start to finish fullPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> HscSource -> m (ModIface, Maybe Linkable) -- | Everything after preprocess hscPipeline :: P m => PipeEnv -> (HscEnv, ModSummary, HscRecompStatus) -> m (ModIface, Maybe Linkable) hscBackendPipeline :: P m => PipeEnv -> HscEnv -> ModSummary -> HscBackendAction -> m (ModIface, Maybe Linkable) hscPostBackendPipeline :: P m => PipeEnv -> HscEnv -> HscSource -> Backend -> Maybe ModLocation -> FilePath -> m (Maybe FilePath) hscGenBackendPipeline :: P m => PipeEnv -> HscEnv -> ModSummary -> HscBackendAction -> m (ModIface, Maybe Linkable) asPipeline :: P m => Bool -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m FilePath viaCPipeline :: P m => Phase -> PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m (Maybe FilePath) cmmCppPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m FilePath cmmPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m FilePath llvmPipeline :: P m => PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m FilePath llvmLlcPipeline :: P m => PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m FilePath llvmManglePipeline :: P m => PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m FilePath pipelineStart :: P m => PipeEnv -> HscEnv -> FilePath -> m (Maybe FilePath) -- | The default mechanism to run a pipeline, see Note [The Pipeline Monad] runPipeline :: Hooks -> HookedUse a -> IO a module GHC.Driver.Make -- | Perform a dependency analysis starting from the current targets and -- update the session with the new module graph. -- -- Dependency analysis entails parsing the import directives and -- may therefore require running certain preprocessors. -- -- Note that each ModSummary in the module graph caches its -- DynFlags. These DynFlags are determined by the -- current session DynFlags and the OPTIONS and -- LANGUAGE pragmas of the parsed module. Thus if you want -- changes to the DynFlags to take effect you need to call this -- function again. In case of errors, just throw them. depanal :: GhcMonad m => [ModuleName] -> Bool -> m ModuleGraph -- | Perform dependency analysis like in depanal. In case of errors, -- the errors and an empty module graph are returned. depanalE :: GhcMonad m => [ModuleName] -> Bool -> m (DriverMessages, ModuleGraph) -- | Perform dependency analysis like depanal but return a partial -- module graph even in the face of problems with some modules. -- -- Modules which have parse errors in the module header, failing -- preprocessors or other issues preventing them from being summarised -- will simply be absent from the returned module graph. -- -- Unlike depanal this function will not update -- hsc_mod_graph with the new module graph. depanalPartial :: GhcMonad m => [ModuleName] -> Bool -> m (DriverMessages, ModuleGraph) checkHomeUnitsClosed :: UnitEnv -> Set UnitId -> [(UnitId, UnitId)] -> [DriverMessages] -- | Try to load the program. See LoadHowMuch for the different -- modes. -- -- This function implements the core of GHC's --make mode. It -- preprocesses, compiles and loads the specified modules, avoiding -- re-compilation wherever possible. Depending on the backend (see -- backend field) compiling and loading may result in files being -- created on disk. -- -- Calls the defaultWarnErrLogger after each compiling each -- module, whether successful or not. -- -- If errors are encountered during dependency analysis, the module -- depanalE returns together with the errors an empty ModuleGraph. -- After processing this empty ModuleGraph, the errors of depanalE are -- thrown. All other errors are reported using the -- defaultWarnErrLogger. load :: GhcMonad f => LoadHowMuch -> f SuccessFlag loadWithCache :: GhcMonad m => [HomeModInfo] -> LoadHowMuch -> m (SuccessFlag, [HomeModInfo]) -- | Generalized version of load which also supports a custom -- Messager (for reporting progress) and ModuleGraph -- (generally produced by calling depanal. load' :: GhcMonad m => [HomeModInfo] -> LoadHowMuch -> Maybe Messager -> ModuleGraph -> m (SuccessFlag, [HomeModInfo]) -- | Describes which modules of the module graph need to be loaded. data LoadHowMuch -- | Load all targets and its dependencies. LoadAllTargets :: LoadHowMuch -- | Load only the given module and its dependencies. LoadUpTo :: HomeUnitModule -> LoadHowMuch -- | Load only the dependencies of the given module, but not the module -- itself. LoadDependenciesOf :: HomeUnitModule -> LoadHowMuch -- | Collect the instantiations of dependencies to create -- InstantiationNode work graph nodes. These are used to represent -- the type checking that is done after all the free holes (sigs in -- current package) relevant to that instantiation are compiled. This is -- necessary to catch some instantiation errors. -- -- In the future, perhaps more of the work of instantiation could be -- moved here, instead of shoved in with the module compilation nodes. -- That could simplify backpack, and maybe hs-boot too. instantiationNodes :: UnitId -> UnitState -> [ModuleGraphNode] -- | Downsweep (dependency analysis) -- -- Chase downwards from the specified root set, returning summaries for -- all home modules encountered. Only follow source-import links. -- -- We pass in the previous collection of summaries, which is used as a -- cache to avoid recalculating a module summary if the source is -- unchanged. -- -- The returned list of [ModSummary] nodes has one node for each -- home-package module, plus one for any hs-boot files. The imports of -- these nodes are all there, including the imports of non-home-package -- modules. downsweep :: HscEnv -> [ModSummary] -> [ModuleName] -> Bool -> IO ([DriverMessages], [ModuleGraphNode]) -- | Topological sort of the module graph -- -- Calculate SCCs of the module graph, possibly dropping the hi-boot -- nodes The resulting list of strongly-connected-components is in -- topologically sorted order, starting with the module(s) at the bottom -- of the dependency graph (ie compile them first) and ending with the -- ones at the top. -- -- Drop hi-boot nodes (first boolean arg)? -- -- topSortModuleGraph :: Bool -> ModuleGraph -> Maybe HomeUnitModule -> [SCC ModuleGraphNode] -- | Like ms_home_imps, but for SOURCE imports. ms_home_srcimps :: ModSummary -> [Located ModuleName] -- | All of the (possibly) home module imports from a ModSummary; -- that is to say, each of these module names could be a home import if -- an appropriately named file existed. (This is in contrast to package -- qualified imports, which are guaranteed not to be home imports.) ms_home_imps :: ModSummary -> [(PkgQual, Located ModuleName)] summariseModule :: HscEnv -> HomeUnit -> Map FilePath ModSummary -> IsBootInterface -> Located ModuleName -> PkgQual -> Maybe (StringBuffer, UTCTime) -> [ModuleName] -> IO SummariseResult data SummariseResult FoundInstantiation :: InstantiatedUnit -> SummariseResult FoundHomeWithError :: (UnitId, DriverMessages) -> SummariseResult FoundHome :: ModSummary -> SummariseResult External :: UnitId -> SummariseResult NotThere :: SummariseResult summariseFile :: HscEnv -> HomeUnit -> Map FilePath ModSummary -> FilePath -> Maybe Phase -> Maybe (StringBuffer, UTCTime) -> IO (Either DriverMessages ModSummary) -- | Tests if an HscSource is a boot file, primarily for -- constructing elements of BuildModule. We conflate signatures -- and modules because they are bound in the same namespace; only boot -- interfaces can be disambiguated with `import {--}`. hscSourceToIsBoot :: HscSource -> IsBootInterface -- | For a module modname of type HscSource, determine the -- list of extra "imports" of other requirements which should be -- considered part of the import of the requirement, because it -- transitively depends on those requirements by imports of modules from -- other packages. The situation is something like this: -- -- unit p where signature X signature Y import X -- -- unit q where dependency p[X=<A>,Y=<B>] signature A -- signature B -- -- Although q's B does not directly import A, we still have to make sure -- we process A first, because the merging process will cause B to -- indirectly import A. This function finds the TRANSITIVE closure of all -- such imports we need to make. findExtraSigImports :: HscEnv -> HscSource -> ModuleName -> IO [ModuleName] -- | Like implicitRequirements', but returns either the module -- name, if it is a free hole, or the instantiated unit the imported -- module is from, so that that instantiated unit can be processed and -- via the batch mod graph (rather than a transitive closure done here) -- all the free holes are still reachable. implicitRequirementsShallow :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO ([ModuleName], [InstantiatedUnit]) noModError :: HscEnv -> SrcSpan -> ModuleName -> FindResult -> MsgEnvelope GhcMessage cyclicModuleErr :: [ModuleGraphNode] -> SDoc type SummaryNode = Node Int ModuleGraphNode -- | Indicates whether a module name is referring to a boot interface -- (hs-boot file) or regular module (hs file). We need to treat boot -- modules specially when building compilation graphs, since they break -- cycles. Regular source files and signature files are treated -- equivalently. data IsBootInterface NotBoot :: IsBootInterface IsBoot :: IsBootInterface mkNodeKey :: ModuleGraphNode -> NodeKey type ModNodeKey = ModuleNameWithIsBoot data ModNodeKeyWithUid ModNodeKeyWithUid :: ModuleNameWithIsBoot -> UnitId -> ModNodeKeyWithUid [mnkModuleName] :: ModNodeKeyWithUid -> ModuleNameWithIsBoot [mnkUnitId] :: ModNodeKeyWithUid -> UnitId newtype ModNodeMap a ModNodeMap :: Map ModNodeKey a -> ModNodeMap a [unModNodeMap] :: ModNodeMap a -> Map ModNodeKey a emptyModNodeMap :: ModNodeMap a modNodeMapElems :: ModNodeMap a -> [a] modNodeMapLookup :: ModNodeKey -> ModNodeMap a -> Maybe a modNodeMapInsert :: ModNodeKey -> a -> ModNodeMap a -> ModNodeMap a modNodeMapSingleton :: ModNodeKey -> a -> ModNodeMap a modNodeMapUnionWith :: (a -> a -> a) -> ModNodeMap a -> ModNodeMap a -> ModNodeMap a instance Data.Foldable.Foldable GHC.Driver.Make.ModNodeMap instance Data.Traversable.Traversable GHC.Driver.Make.ModNodeMap instance GHC.Base.Functor GHC.Driver.Make.ModNodeMap instance GHC.Base.Functor GHC.Driver.Make.ResultVar instance GHC.Utils.Outputable.Outputable GHC.Driver.Make.BuildPlan instance GHC.Utils.Outputable.Outputable GHC.Driver.Make.ModuleGraphNodeWithBootFile module GHC -- | Install some default exception handlers and run the inner computation. -- Unless you want to handle exceptions yourself, you should wrap this -- around the top level of your program. The default handlers output the -- error message(s) to stderr and exit cleanly. defaultErrorHandler :: ExceptionMonad m => FatalMessager -> FlushOut -> m a -> m a -- | This function is no longer necessary, cleanup is now done by -- runGhc/runGhcT. -- | Deprecated: Cleanup is now done by runGhc/runGhcT defaultCleanupHandler :: ExceptionMonad m => DynFlags -> m a -> m a prettyPrintGhcErrors :: ExceptionMonad m => Logger -> m a -> m a -- | Temporarily install standard signal handlers for catching ^C, which -- just throw an exception in the current thread. withSignalHandlers :: ExceptionMonad m => m a -> m a withCleanupSession :: GhcMonad m => m a -> m a -- | A minimal implementation of a GhcMonad. If you need a custom -- monad, e.g., to maintain additional state consider wrapping this monad -- or using GhcT. data Ghc a -- | A monad transformer to add GHC specific features to another monad. -- -- Note that the wrapped monad must support IO and handling of -- exceptions. data GhcT (m :: Type -> Type) a -- | A monad that has all the features needed by GHC API calls. -- -- In short, a GHC monad -- -- -- -- If you do not use Ghc or GhcT, make sure to call -- initGhcMonad before any call to the GHC API functions can -- occur. class (Functor m, ExceptionMonad m, HasDynFlags m, HasLogger m) => GhcMonad (m :: Type -> Type) getSession :: GhcMonad m => m HscEnv setSession :: GhcMonad m => HscEnv -> m () -- | HscEnv is like Session, except that some of the fields are -- immutable. An HscEnv is used to compile a single module from plain -- Haskell source code (after preprocessing) to either C, assembly or -- C--. It's also used to store the dynamic linker state to allow for -- multiple linkers in the same address space. Things like the module -- graph don't change during a single compilation. -- -- Historical note: "hsc" used to be the name of the compiler binary, -- when there was a separate driver and compiler. To compile a single -- module, the driver would invoke hsc on the source code... so nowadays -- we think of hsc as the layer of the compiler that deals with compiling -- a single module. data HscEnv -- | Run function for the Ghc monad. -- -- It initialises the GHC session and warnings via initGhcMonad. -- Each call to this function will create a new session which should not -- be shared among several threads. -- -- Any errors not handled inside the Ghc action are propagated as -- IO exceptions. runGhc :: Maybe FilePath -> Ghc a -> IO a -- | Run function for GhcT monad transformer. -- -- It initialises the GHC session and warnings via initGhcMonad. -- Each call to this function will create a new session which should not -- be shared among several threads. runGhcT :: ExceptionMonad m => Maybe FilePath -> GhcT m a -> m a -- | Initialise a GHC session. -- -- If you implement a custom GhcMonad you must call this function -- in the monad run function. It will initialise the session variable and -- clear all warnings. -- -- The first argument should point to the directory where GHC's library -- files reside. More precisely, this should be the output of ghc -- --print-libdir of the version of GHC the module using this API is -- compiled with. For portability, you should use the ghc-paths -- package, available at -- http://hackage.haskell.org/package/ghc-paths. initGhcMonad :: GhcMonad m => Maybe FilePath -> m () -- | Print the all diagnostics in a SourceError. Useful inside -- exception handlers. printException :: (HasLogger m, MonadIO m, HasDynFlags m) => SourceError -> m () -- | Perform the given action and call the exception handler if the action -- throws a SourceError. See SourceError for more -- information. handleSourceError :: MonadCatch m => (SourceError -> m a) -> m a -> m a -- | Contains not only a collection of GeneralFlags but also a -- plethora of information relating to the compilation of a single file -- or GHC session data DynFlags DynFlags :: GhcMode -> GhcLink -> !Backend -> {-# UNPACK #-} !GhcNameVersion -> {-# UNPACK #-} !FileSettings -> Platform -> {-# UNPACK #-} !ToolSettings -> {-# UNPACK #-} !PlatformMisc -> [(String, String)] -> TempDir -> LlvmConfig -> Int -> Int -> Int -> Int -> Int -> Maybe String -> [Int] -> Maybe Int -> Bool -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Int -> Int -> Int -> !Int -> Maybe Int -> Maybe Int -> Int -> Maybe Word -> Maybe Int -> Maybe Int -> Maybe Int -> Maybe Int -> Bool -> Maybe Int -> Int -> [FilePath] -> ModuleName -> Maybe String -> IntWithInf -> IntWithInf -> UnitId -> Maybe UnitId -> [(ModuleName, Module)] -> Maybe FilePath -> Maybe String -> Set ModuleName -> Set ModuleName -> Ways -> Maybe (String, Int) -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> String -> String -> String -> String -> String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> DynLibLoader -> !Bool -> FilePath -> Maybe FilePath -> [Option] -> IncludeSpecs -> [String] -> [String] -> [String] -> Maybe String -> RtsOptsEnabled -> Bool -> String -> [ModuleName] -> [(ModuleName, String)] -> [String] -> FilePath -> Bool -> Bool -> [ModuleName] -> [String] -> [PackageDBFlag] -> [IgnorePackageFlag] -> [PackageFlag] -> [PackageFlag] -> [TrustFlag] -> Maybe FilePath -> EnumSet DumpFlag -> EnumSet GeneralFlag -> EnumSet WarningFlag -> EnumSet WarningFlag -> Maybe Language -> SafeHaskellMode -> Bool -> Bool -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> SrcSpan -> [OnOff Extension] -> EnumSet Extension -> !UnfoldingOpts -> Int -> Int -> FlushOut -> Maybe FilePath -> Maybe String -> [String] -> Int -> Int -> Bool -> OverridingBool -> Bool -> Scheme -> ProfAuto -> [CallerCcFilter] -> Maybe String -> Maybe SseVersion -> Maybe BmiVersion -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> IORef (Maybe LinkerInfo) -> IORef (Maybe CompilerInfo) -> IORef (Maybe CompilerInfo) -> Int -> Int -> Int -> Bool -> Maybe Int -> Word -> Int -> Weights -> DynFlags [ghcMode] :: DynFlags -> GhcMode [ghcLink] :: DynFlags -> GhcLink -- | The backend to use (if any). -- -- Whenever you change the backend, also make sure to set ghcLink -- to something sensible. -- -- NoBackend can be used to avoid generating any output, however, -- note that: -- -- [backend] :: DynFlags -> !Backend [ghcNameVersion] :: DynFlags -> {-# UNPACK #-} !GhcNameVersion [fileSettings] :: DynFlags -> {-# UNPACK #-} !FileSettings [targetPlatform] :: DynFlags -> Platform [toolSettings] :: DynFlags -> {-# UNPACK #-} !ToolSettings [platformMisc] :: DynFlags -> {-# UNPACK #-} !PlatformMisc [rawSettings] :: DynFlags -> [(String, String)] [tmpDir] :: DynFlags -> TempDir -- | N.B. It's important that this field is lazy since we load the LLVM -- configuration lazily. See Note [LLVM configuration] in -- GHC.SysTools. [llvmConfig] :: DynFlags -> LlvmConfig -- | LLVM optimisation level [llvmOptLevel] :: DynFlags -> Int -- | Verbosity level: see Note [Verbosity levels] [verbosity] :: DynFlags -> Int -- | How much debug information to produce [debugLevel] :: DynFlags -> Int -- | Number of simplifier phases [simplPhases] :: DynFlags -> Int -- | Max simplifier iterations [maxSimplIterations] :: DynFlags -> Int [ruleCheck] :: DynFlags -> Maybe String -- | Additional demand analysis [strictnessBefore] :: DynFlags -> [Int] -- | The number of modules to compile in parallel in --make mode, where -- Nothing ==> compile as many in parallel as there are CPUs. [parMakeCount] :: DynFlags -> Maybe Int -- | Enable RTS timing statistics? [enableTimeStats] :: DynFlags -> Bool -- | The heap size to set. [ghcHeapSize] :: DynFlags -> Maybe Int -- | Maximum number of bindings from the type envt to show in type error -- messages [maxRelevantBinds] :: DynFlags -> Maybe Int -- | Maximum number of hole fits to show in typed hole error messages [maxValidHoleFits] :: DynFlags -> Maybe Int -- | Maximum number of refinement hole fits to show in typed hole error -- messages [maxRefHoleFits] :: DynFlags -> Maybe Int -- | Maximum level of refinement for refinement hole fits in typed hole -- error messages [refLevelHoleFits] :: DynFlags -> Maybe Int -- | Maximum number of unmatched patterns to show in non-exhaustiveness -- warnings [maxUncoveredPatterns] :: DynFlags -> Int -- | Soft limit on the number of models the pattern match checker checks a -- pattern against. A safe guard against exponential blow-up. [maxPmCheckModels] :: DynFlags -> Int -- | Multiplier for simplifier ticks [simplTickFactor] :: DynFlags -> Int -- | Whether DmdAnal should optimistically put an Unboxed demand on -- returned products with at most this number of fields [dmdUnboxWidth] :: DynFlags -> !Int -- | Threshold for SpecConstr [specConstrThreshold] :: DynFlags -> Maybe Int -- | Max number of specialisations for any one function [specConstrCount] :: DynFlags -> Maybe Int -- | Max number of specialisations for recursive types Not optional; -- otherwise ForceSpecConstr can diverge. [specConstrRecursive] :: DynFlags -> Int -- | Binary literals (e.g. strings) whose size is above this threshold will -- be dumped in a binary file by the assembler code generator. 0 and -- Nothing disables this feature. See Config. [binBlobThreshold] :: DynFlags -> Maybe Word -- | Threshold for LiberateCase [liberateCaseThreshold] :: DynFlags -> Maybe Int -- | Arg count for lambda floating See FloatOutSwitches [floatLamArgs] :: DynFlags -> Maybe Int -- | Maximum number of arguments after lambda lifting a recursive function. [liftLamsRecArgs] :: DynFlags -> Maybe Int -- | Maximum number of arguments after lambda lifting a non-recursive -- function. [liftLamsNonRecArgs] :: DynFlags -> Maybe Int -- | Lambda lift even when this turns a known call into an unknown call. [liftLamsKnown] :: DynFlags -> Bool -- | Align Cmm functions at this boundary or use default. [cmmProcAlignment] :: DynFlags -> Maybe Int -- | Simplification history size [historySize] :: DynFlags -> Int [importPaths] :: DynFlags -> [FilePath] [mainModuleNameIs] :: DynFlags -> ModuleName [mainFunIs] :: DynFlags -> Maybe String -- | Typechecker maximum stack depth [reductionDepth] :: DynFlags -> IntWithInf -- | Number of iterations in the constraints solver Typically only 1 is -- needed [solverIterations] :: DynFlags -> IntWithInf -- | Target home unit-id [homeUnitId_] :: DynFlags -> UnitId -- | Id of the unit to instantiate [homeUnitInstanceOf_] :: DynFlags -> Maybe UnitId -- | Module instantiations [homeUnitInstantiations_] :: DynFlags -> [(ModuleName, Module)] [workingDirectory] :: DynFlags -> Maybe FilePath -- | What the package is called, use with multiple home units [thisPackageName] :: DynFlags -> Maybe String [hiddenModules] :: DynFlags -> Set ModuleName [reexportedModules] :: DynFlags -> Set ModuleName -- | Target way flags from the command line [targetWays_] :: DynFlags -> Ways [splitInfo] :: DynFlags -> Maybe (String, Int) [objectDir] :: DynFlags -> Maybe String [dylibInstallName] :: DynFlags -> Maybe String [hiDir] :: DynFlags -> Maybe String [hieDir] :: DynFlags -> Maybe String [stubDir] :: DynFlags -> Maybe String [dumpDir] :: DynFlags -> Maybe String [objectSuf_] :: DynFlags -> String [hcSuf] :: DynFlags -> String [hiSuf_] :: DynFlags -> String [hieSuf] :: DynFlags -> String [dynObjectSuf_] :: DynFlags -> String [dynHiSuf_] :: DynFlags -> String [outputFile_] :: DynFlags -> Maybe String [dynOutputFile_] :: DynFlags -> Maybe String [outputHi] :: DynFlags -> Maybe String [dynOutputHi] :: DynFlags -> Maybe String [dynLibLoader] :: DynFlags -> DynLibLoader -- | Indicate if we are now generating dynamic output because of -- -dynamic-too. This predicate is used to query the appropriate fields -- (outputFile/dynOutputFile, ways, etc.) [dynamicNow] :: DynFlags -> !Bool -- | This defaults to 'non-module'. It can be set by setDumpPrefix -- or 'ghc.GHCi.UI.runStmt' based on where its output is going. [dumpPrefix] :: DynFlags -> FilePath -- | Override the dumpPrefix set by setDumpPrefix or -- 'ghc.GHCi.UI.runStmt'. Set by -ddump-file-prefix [dumpPrefixForce] :: DynFlags -> Maybe FilePath [ldInputs] :: DynFlags -> [Option] [includePaths] :: DynFlags -> IncludeSpecs [libraryPaths] :: DynFlags -> [String] [frameworkPaths] :: DynFlags -> [String] [cmdlineFrameworks] :: DynFlags -> [String] [rtsOpts] :: DynFlags -> Maybe String [rtsOptsEnabled] :: DynFlags -> RtsOptsEnabled [rtsOptsSuggestions] :: DynFlags -> Bool -- | Path to store the .mix files [hpcDir] :: DynFlags -> String -- | the -fplugin flags given on the command line, in *reverse* -- order that they're specified on the command line. [pluginModNames] :: DynFlags -> [ModuleName] [pluginModNameOpts] :: DynFlags -> [(ModuleName, String)] -- | the -ffrontend-opt flags given on the command line, in -- *reverse* order that they're specified on the command line. [frontendPluginOpts] :: DynFlags -> [String] [depMakefile] :: DynFlags -> FilePath [depIncludePkgDeps] :: DynFlags -> Bool [depIncludeCppDeps] :: DynFlags -> Bool [depExcludeMods] :: DynFlags -> [ModuleName] [depSuffixes] :: DynFlags -> [String] -- | The -package-db flags given on the command line, In *reverse* -- order that they're specified on the command line. This is intended to -- be applied with the list of "initial" package databases derived from -- GHC_PACKAGE_PATH; see getUnitDbRefs. [packageDBFlags] :: DynFlags -> [PackageDBFlag] -- | The -ignore-package flags from the command line. In *reverse* -- order that they're specified on the command line. [ignorePackageFlags] :: DynFlags -> [IgnorePackageFlag] -- | The -package and -hide-package flags from the -- command-line. In *reverse* order that they're specified on the command -- line. [packageFlags] :: DynFlags -> [PackageFlag] -- | The -plugin-package-id flags from command line. In *reverse* -- order that they're specified on the command line. [pluginPackageFlags] :: DynFlags -> [PackageFlag] -- | The -trust and -distrust flags. In *reverse* order -- that they're specified on the command line. [trustFlags] :: DynFlags -> [TrustFlag] -- | Filepath to the package environment file (if overriding default) [packageEnv] :: DynFlags -> Maybe FilePath [dumpFlags] :: DynFlags -> EnumSet DumpFlag [generalFlags] :: DynFlags -> EnumSet GeneralFlag [warningFlags] :: DynFlags -> EnumSet WarningFlag [fatalWarningFlags] :: DynFlags -> EnumSet WarningFlag [language] :: DynFlags -> Maybe Language -- | Safe Haskell mode [safeHaskell] :: DynFlags -> SafeHaskellMode [safeInfer] :: DynFlags -> Bool [safeInferred] :: DynFlags -> Bool [thOnLoc] :: DynFlags -> SrcSpan [newDerivOnLoc] :: DynFlags -> SrcSpan [deriveViaOnLoc] :: DynFlags -> SrcSpan [overlapInstLoc] :: DynFlags -> SrcSpan [incoherentOnLoc] :: DynFlags -> SrcSpan [pkgTrustOnLoc] :: DynFlags -> SrcSpan [warnSafeOnLoc] :: DynFlags -> SrcSpan [warnUnsafeOnLoc] :: DynFlags -> SrcSpan [trustworthyOnLoc] :: DynFlags -> SrcSpan [extensions] :: DynFlags -> [OnOff Extension] [extensionFlags] :: DynFlags -> EnumSet Extension -- | Unfolding control See Note [Discounts and thresholds] in -- GHC.Core.Unfold [unfoldingOpts] :: DynFlags -> !UnfoldingOpts [maxWorkerArgs] :: DynFlags -> Int [ghciHistSize] :: DynFlags -> Int [flushOut] :: DynFlags -> FlushOut [ghcVersionFile] :: DynFlags -> Maybe FilePath [haddockOptions] :: DynFlags -> Maybe String -- | GHCi scripts specified by -ghci-script, in reverse order [ghciScripts] :: DynFlags -> [String] [pprUserLength] :: DynFlags -> Int [pprCols] :: DynFlags -> Int [useUnicode] :: DynFlags -> Bool [useColor] :: DynFlags -> OverridingBool [canUseColor] :: DynFlags -> Bool [colScheme] :: DynFlags -> Scheme -- | what kind of {--} to add automatically [profAuto] :: DynFlags -> ProfAuto [callerCcFilters] :: DynFlags -> [CallerCcFilter] [interactivePrint] :: DynFlags -> Maybe String -- | Machine dependent flags (-m<blah> stuff) [sseVersion] :: DynFlags -> Maybe SseVersion [bmiVersion] :: DynFlags -> Maybe BmiVersion [avx] :: DynFlags -> Bool [avx2] :: DynFlags -> Bool [avx512cd] :: DynFlags -> Bool [avx512er] :: DynFlags -> Bool [avx512f] :: DynFlags -> Bool [avx512pf] :: DynFlags -> Bool -- | Run-time linker information (what options we need, etc.) [rtldInfo] :: DynFlags -> IORef (Maybe LinkerInfo) -- | Run-time C compiler information [rtccInfo] :: DynFlags -> IORef (Maybe CompilerInfo) -- | Run-time assembler information [rtasmInfo] :: DynFlags -> IORef (Maybe CompilerInfo) -- | Max size, in bytes, of inline array allocations. [maxInlineAllocSize] :: DynFlags -> Int -- | Only inline memcpy if it generates no more than this many pseudo -- (roughly: Cmm) instructions. [maxInlineMemcpyInsns] :: DynFlags -> Int -- | Only inline memset if it generates no more than this many pseudo -- (roughly: Cmm) instructions. [maxInlineMemsetInsns] :: DynFlags -> Int -- | Reverse the order of error messages in GHC/GHCi [reverseErrors] :: DynFlags -> Bool -- | Limit the maximum number of errors to show [maxErrors] :: DynFlags -> Maybe Int -- | Unique supply configuration for testing build determinism [initialUnique] :: DynFlags -> Word [uniqueIncrement] :: DynFlags -> Int -- | Temporary: CFG Edge weights for fast iterations [cfgWeights] :: DynFlags -> Weights -- | Enumerates the simple on-or-off dynamic flags data GeneralFlag -- | Append dump output to files instead of stdout. Opt_DumpToFile :: GeneralFlag Opt_D_dump_minimal_imports :: GeneralFlag Opt_DoCoreLinting :: GeneralFlag Opt_DoLinearCoreLinting :: GeneralFlag Opt_DoStgLinting :: GeneralFlag Opt_DoCmmLinting :: GeneralFlag Opt_DoAsmLinting :: GeneralFlag Opt_DoAnnotationLinting :: GeneralFlag Opt_DoBoundsChecking :: GeneralFlag Opt_NoLlvmMangler :: GeneralFlag Opt_FastLlvm :: GeneralFlag Opt_NoTypeableBinds :: GeneralFlag Opt_DistinctConstructorTables :: GeneralFlag Opt_InfoTableMap :: GeneralFlag Opt_WarnIsError :: GeneralFlag Opt_ShowWarnGroups :: GeneralFlag Opt_HideSourcePaths :: GeneralFlag Opt_PrintExplicitForalls :: GeneralFlag Opt_PrintExplicitKinds :: GeneralFlag Opt_PrintExplicitCoercions :: GeneralFlag Opt_PrintExplicitRuntimeReps :: GeneralFlag Opt_PrintEqualityRelations :: GeneralFlag Opt_PrintAxiomIncomps :: GeneralFlag Opt_PrintUnicodeSyntax :: GeneralFlag Opt_PrintExpandedSynonyms :: GeneralFlag Opt_PrintPotentialInstances :: GeneralFlag Opt_PrintTypecheckerElaboration :: GeneralFlag Opt_CallArity :: GeneralFlag Opt_Exitification :: GeneralFlag Opt_Strictness :: GeneralFlag Opt_LateDmdAnal :: GeneralFlag Opt_KillAbsence :: GeneralFlag Opt_KillOneShot :: GeneralFlag Opt_FullLaziness :: GeneralFlag Opt_FloatIn :: GeneralFlag Opt_LateSpecialise :: GeneralFlag Opt_Specialise :: GeneralFlag Opt_SpecialiseAggressively :: GeneralFlag Opt_CrossModuleSpecialise :: GeneralFlag Opt_InlineGenerics :: GeneralFlag Opt_InlineGenericsAggressively :: GeneralFlag Opt_StaticArgumentTransformation :: GeneralFlag Opt_CSE :: GeneralFlag Opt_StgCSE :: GeneralFlag Opt_StgLiftLams :: GeneralFlag Opt_LiberateCase :: GeneralFlag Opt_SpecConstr :: GeneralFlag Opt_SpecConstrKeen :: GeneralFlag Opt_DoLambdaEtaExpansion :: GeneralFlag Opt_IgnoreAsserts :: GeneralFlag Opt_DoEtaReduction :: GeneralFlag Opt_CaseMerge :: GeneralFlag Opt_CaseFolding :: GeneralFlag Opt_UnboxStrictFields :: GeneralFlag Opt_UnboxSmallStrictFields :: GeneralFlag Opt_DictsCheap :: GeneralFlag Opt_EnableRewriteRules :: GeneralFlag Opt_EnableThSpliceWarnings :: GeneralFlag Opt_RegsGraph :: GeneralFlag Opt_RegsIterative :: GeneralFlag Opt_PedanticBottoms :: GeneralFlag Opt_LlvmTBAA :: GeneralFlag Opt_LlvmFillUndefWithGarbage :: GeneralFlag Opt_IrrefutableTuples :: GeneralFlag Opt_CmmSink :: GeneralFlag Opt_CmmStaticPred :: GeneralFlag Opt_CmmElimCommonBlocks :: GeneralFlag Opt_CmmControlFlow :: GeneralFlag Opt_AsmShortcutting :: GeneralFlag Opt_OmitYields :: GeneralFlag Opt_FunToThunk :: GeneralFlag Opt_DictsStrict :: GeneralFlag -- | deprecated, no effect and behaviour is now default. Allowed switching -- of a special demand transformer for dictionary selectors Opt_DmdTxDictSel :: GeneralFlag Opt_Loopification :: GeneralFlag -- | Use the cfg based block layout algorithm. Opt_CfgBlocklayout :: GeneralFlag -- | Layout based on last instruction per block. Opt_WeightlessBlocklayout :: GeneralFlag Opt_CprAnal :: GeneralFlag Opt_WorkerWrapper :: GeneralFlag -- | Do W/W split for unlifting even if we won't unbox anything. Opt_WorkerWrapperUnlift :: GeneralFlag Opt_SolveConstantDicts :: GeneralFlag Opt_AlignmentSanitisation :: GeneralFlag Opt_CatchNonexhaustiveCases :: GeneralFlag Opt_NumConstantFolding :: GeneralFlag Opt_CoreConstantFolding :: GeneralFlag Opt_FastPAPCalls :: GeneralFlag Opt_DoTagInferenceChecks :: GeneralFlag Opt_SimplPreInlining :: GeneralFlag Opt_IgnoreInterfacePragmas :: GeneralFlag Opt_OmitInterfacePragmas :: GeneralFlag Opt_ExposeAllUnfoldings :: GeneralFlag Opt_WriteInterface :: GeneralFlag Opt_WriteHie :: GeneralFlag Opt_AutoSccsOnIndividualCafs :: GeneralFlag Opt_ProfCountEntries :: GeneralFlag Opt_ProfLateCcs :: GeneralFlag Opt_Pp :: GeneralFlag Opt_ForceRecomp :: GeneralFlag Opt_IgnoreOptimChanges :: GeneralFlag Opt_IgnoreHpcChanges :: GeneralFlag Opt_ExcessPrecision :: GeneralFlag Opt_EagerBlackHoling :: GeneralFlag Opt_NoHsMain :: GeneralFlag Opt_SplitSections :: GeneralFlag Opt_StgStats :: GeneralFlag Opt_HideAllPackages :: GeneralFlag Opt_HideAllPluginPackages :: GeneralFlag Opt_PrintBindResult :: GeneralFlag Opt_Haddock :: GeneralFlag Opt_HaddockOptions :: GeneralFlag Opt_BreakOnException :: GeneralFlag Opt_BreakOnError :: GeneralFlag Opt_PrintEvldWithShow :: GeneralFlag Opt_PrintBindContents :: GeneralFlag Opt_GenManifest :: GeneralFlag Opt_EmbedManifest :: GeneralFlag Opt_SharedImplib :: GeneralFlag Opt_BuildingCabalPackage :: GeneralFlag Opt_IgnoreDotGhci :: GeneralFlag Opt_GhciSandbox :: GeneralFlag Opt_GhciHistory :: GeneralFlag Opt_GhciLeakCheck :: GeneralFlag Opt_ValidateHie :: GeneralFlag Opt_LocalGhciHistory :: GeneralFlag Opt_NoIt :: GeneralFlag Opt_HelpfulErrors :: GeneralFlag Opt_DeferTypeErrors :: GeneralFlag Opt_DeferTypedHoles :: GeneralFlag Opt_DeferOutOfScopeVariables :: GeneralFlag -- |
--   -fPIC
--   
Opt_PIC :: GeneralFlag -- |
--   -fPIE
--   
Opt_PIE :: GeneralFlag -- |
--   -pie
--   
Opt_PICExecutable :: GeneralFlag Opt_ExternalDynamicRefs :: GeneralFlag Opt_Ticky :: GeneralFlag Opt_Ticky_Allocd :: GeneralFlag Opt_Ticky_LNE :: GeneralFlag Opt_Ticky_Dyn_Thunk :: GeneralFlag Opt_Ticky_Tag :: GeneralFlag -- | Use regular thunks even when we could use std ap thunks in order to -- get entry counts Opt_Ticky_AP :: GeneralFlag Opt_RPath :: GeneralFlag Opt_RelativeDynlibPaths :: GeneralFlag -- |
--   -fcompact-unwind
--   
Opt_CompactUnwind :: GeneralFlag Opt_Hpc :: GeneralFlag Opt_FamAppCache :: GeneralFlag Opt_ExternalInterpreter :: GeneralFlag Opt_OptimalApplicativeDo :: GeneralFlag Opt_VersionMacros :: GeneralFlag Opt_WholeArchiveHsLibs :: GeneralFlag Opt_SingleLibFolder :: GeneralFlag Opt_ExposeInternalSymbols :: GeneralFlag Opt_KeepCAFs :: GeneralFlag Opt_KeepGoing :: GeneralFlag Opt_ByteCode :: GeneralFlag Opt_LinkRts :: GeneralFlag Opt_ErrorSpans :: GeneralFlag Opt_DeferDiagnostics :: GeneralFlag Opt_DiagnosticsShowCaret :: GeneralFlag Opt_PprCaseAsLet :: GeneralFlag Opt_PprShowTicks :: GeneralFlag Opt_ShowHoleConstraints :: GeneralFlag Opt_ShowValidHoleFits :: GeneralFlag Opt_SortValidHoleFits :: GeneralFlag Opt_SortBySizeHoleFits :: GeneralFlag Opt_SortBySubsumHoleFits :: GeneralFlag Opt_AbstractRefHoleFits :: GeneralFlag Opt_UnclutterValidHoleFits :: GeneralFlag Opt_ShowTypeAppOfHoleFits :: GeneralFlag Opt_ShowTypeAppVarsOfHoleFits :: GeneralFlag Opt_ShowDocsOfHoleFits :: GeneralFlag Opt_ShowTypeOfHoleFits :: GeneralFlag Opt_ShowProvOfHoleFits :: GeneralFlag Opt_ShowMatchesOfHoleFits :: GeneralFlag Opt_ShowLoadedModules :: GeneralFlag Opt_HexWordLiterals :: GeneralFlag Opt_SuppressCoercions :: GeneralFlag Opt_SuppressVarKinds :: GeneralFlag Opt_SuppressModulePrefixes :: GeneralFlag Opt_SuppressTypeApplications :: GeneralFlag Opt_SuppressIdInfo :: GeneralFlag Opt_SuppressUnfoldings :: GeneralFlag Opt_SuppressTypeSignatures :: GeneralFlag Opt_SuppressUniques :: GeneralFlag Opt_SuppressStgExts :: GeneralFlag Opt_SuppressTicks :: GeneralFlag -- | Suppress timestamps in dumps Opt_SuppressTimestamps :: GeneralFlag -- | Suppress per binding Core size stats in dumps Opt_SuppressCoreSizes :: GeneralFlag Opt_AutoLinkPackages :: GeneralFlag Opt_ImplicitImportQualified :: GeneralFlag Opt_KeepHscppFiles :: GeneralFlag Opt_KeepHiDiffs :: GeneralFlag Opt_KeepHcFiles :: GeneralFlag Opt_KeepSFiles :: GeneralFlag Opt_KeepTmpFiles :: GeneralFlag Opt_KeepRawTokenStream :: GeneralFlag Opt_KeepLlvmFiles :: GeneralFlag Opt_KeepHiFiles :: GeneralFlag Opt_KeepOFiles :: GeneralFlag Opt_BuildDynamicToo :: GeneralFlag Opt_DistrustAllPackages :: GeneralFlag Opt_PackageTrust :: GeneralFlag Opt_PluginTrustworthy :: GeneralFlag Opt_G_NoStateHack :: GeneralFlag Opt_G_NoOptCoercion :: GeneralFlag -- | Used to describe warnings and errors o The message has a -- file/line/column heading, plus "warning:" or "error:", added by -- mkLocMessage o With SevIgnore the message is suppressed o -- Output is intended for end users data Severity -- | Ignore this message, for example in case of suppression of warnings -- users don't want to see. See Note [Suppressing Messages] SevIgnore :: Severity SevWarning :: Severity SevError :: Severity -- | Code generation backends. -- -- GHC supports several code generation backends serving different -- purposes (producing machine code, producing ByteCode for the -- interpreter) and supporting different platforms. data Backend -- | Native code generator backend. -- -- Compiles Cmm code into textual assembler, then relies on an external -- assembler toolchain to produce machine code. -- -- Only supports a few platforms (X86, PowerPC, SPARC). -- -- See GHC.CmmToAsm. NCG :: Backend -- | LLVM backend. -- -- Compiles Cmm code into LLVM textual IR, then relies on LLVM toolchain -- to produce machine code. -- -- It relies on LLVM support for the calling convention used by the NCG -- backend to produce code objects ABI compatible with it (see "cc 10" or -- "ghccc" calling convention in -- https://llvm.org/docs/LangRef.html#calling-conventions). -- -- Support a few platforms (X86, AArch64, s390x, ARM). -- -- See GHC.CmmToLlvm LLVM :: Backend -- | Via-C backend. -- -- Compiles Cmm code into C code, then relies on a C compiler to produce -- machine code. -- -- It produces code objects that are *not* ABI compatible with those -- produced by NCG and LLVM backends. -- -- Produced code is expected to be less efficient than the one produced -- by NCG and LLVM backends because STG registers are not pinned into -- real registers. On the other hand, it supports more target platforms -- (those having a valid C toolchain). -- -- See GHC.CmmToC ViaC :: Backend -- | ByteCode interpreter. -- -- Produce ByteCode objects (BCO, see GHC.ByteCode) that can be -- interpreted. It is used by GHCi. -- -- Currently some extensions are not supported (foreign primops). -- -- See GHC.StgToByteCode Interpreter :: Backend -- | No code generated. -- -- Use this to disable code generation. It is particularly useful when -- GHC is used as a library for other purpose than generating code (e.g. -- to generate documentation with Haddock) or when the user requested it -- (via -fno-code) for some reason. NoBackend :: Backend -- | Test whether a GeneralFlag is set -- -- Note that dynamicNow (i.e., dynamic objects built with -- `-dynamic-too`) always implicitly enables Opt_PIC, -- Opt_ExternalDynamicRefs, and disables Opt_SplitSections. gopt :: GeneralFlag -> DynFlags -> Bool -- | The GhcMode tells us whether we're doing multi-module -- compilation (controlled via the GHC API) or one-shot -- (single-module) compilation. This makes a difference primarily to the -- GHC.Unit.Finder: in one-shot mode we look for interface files -- for imported modules, but in multi-module mode we look for source -- files in order to check whether they need to be recompiled. data GhcMode -- | --make, GHCi, etc. CompManager :: GhcMode -- |
--   ghc -c Foo.hs
--   
OneShot :: GhcMode -- | ghc -M, see GHC.Unit.Finder for why we need this MkDepend :: GhcMode -- | What to do in the link step, if there is one. data GhcLink -- | Don't link at all NoLink :: GhcLink -- | Link object code into a binary LinkBinary :: GhcLink -- | Use the in-memory dynamic linker (works for both bytecode and object -- code). LinkInMemory :: GhcLink -- | Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms) LinkDynLib :: GhcLink -- | Link objects into a static lib LinkStaticLib :: GhcLink -- | Link objects into a merged "GHCi object" LinkMergedObj :: GhcLink parseDynamicFlags :: MonadIO m => Logger -> DynFlags -> [Located String] -> m (DynFlags, [Located String], [Warn]) -- | Parse command line arguments that look like files. First normalises -- its arguments and then splits them into source files and object files. -- A source file can be turned into a Target via -- guessTarget parseTargetFiles :: DynFlags -> [String] -> (DynFlags, [(String, Maybe Phase)], [String]) -- | Grabs the DynFlags from the Session getSessionDynFlags :: GhcMonad m => m DynFlags setTopSessionDynFlags :: GhcMonad m => DynFlags -> m () setSessionDynFlags :: (HasCallStack, GhcMonad m) => DynFlags -> m () setUnitDynFlags :: GhcMonad m => UnitId -> DynFlags -> m () -- | Returns the program DynFlags. getProgramDynFlags :: GhcMonad m => m DynFlags -- | Sets the program DynFlags. Note: this invalidates the internal -- cached module graph, causing more work to be done the next time -- load is called. -- -- Returns a boolean indicating if preload units have changed and need to -- be reloaded. setProgramDynFlags :: GhcMonad m => DynFlags -> m Bool -- | Get the DynFlags used to evaluate interactive expressions. getInteractiveDynFlags :: GhcMonad m => m DynFlags -- | Set the DynFlags used to evaluate interactive expressions. Also -- initialise (load) plugins. -- -- Note: this cannot be used for changes to packages. Use -- setSessionDynFlags, or setProgramDynFlags and then copy -- the unitState into the interactive DynFlags. setInteractiveDynFlags :: GhcMonad m => DynFlags -> m () -- | Find the package environment (if one exists) -- -- We interpret the package environment as a set of package flags; to be -- specific, if we find a package environment file like -- --
--   clear-package-db
--   global-package-db
--   package-db blah/package.conf.d
--   package-id id1
--   package-id id2
--   
-- -- we interpret this as -- --
--   [ -hide-all-packages
--   , -clear-package-db
--   , -global-package-db
--   , -package-db blah/package.conf.d
--   , -package-id id1
--   , -package-id id2
--   ]
--   
-- -- There's also an older syntax alias for package-id, which is just an -- unadorned package id -- --
--   id1
--   id2
--   
interpretPackageEnv :: Logger -> DynFlags -> IO DynFlags data Logger getLogger :: HasLogger m => m Logger -- | Push a log hook pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger -- | Pop a log hook popLogHook :: Logger -> Logger -- | Push a log hook on the stack pushLogHookM :: GhcMonad m => (LogAction -> LogAction) -> m () -- | Pop a log hook from the stack popLogHookM :: GhcMonad m => m () -- | Modify the logger modifyLogger :: GhcMonad m => (Logger -> Logger) -> m () -- | Put a log message putMsgM :: GhcMonad m => SDoc -> m () -- | Put a log message putLogMsgM :: GhcMonad m => MessageClass -> SrcSpan -> SDoc -> m () -- | A compilation target. -- -- A target may be supplied with the actual text of the module. If so, -- use this instead of the file contents (this is for use in an IDE where -- the file hasn't been saved by the user yet). -- -- These fields are strict because Targets are long lived. data Target Target :: !TargetId -> !Bool -> !UnitId -> !Maybe (InputFileBuffer, UTCTime) -> Target -- | module or filename [targetId] :: Target -> !TargetId -- | object code allowed? [targetAllowObjCode] :: Target -> !Bool -- | id of the unit this target is part of [targetUnitId] :: Target -> !UnitId -- | Optional in-memory buffer containing the source code GHC should use -- for this target instead of reading it from disk. -- -- Since GHC version 8.10 modules which require preprocessors such as -- Literate Haskell or CPP to run are also supported. -- -- If a corresponding source file does not exist on disk this will result -- in a SourceError exception if targetId = TargetModule -- _ is used. However together with targetId = TargetFile _ -- GHC will not complain about the file missing. [targetContents] :: Target -> !Maybe (InputFileBuffer, UTCTime) data TargetId -- | A module name: search for the file TargetModule :: !ModuleName -> TargetId -- | A filename: preprocess & parse it to find the module name. If -- specified, the Phase indicates how to compile this file (which phase -- to start from). Nothing indicates the starting phase should be -- determined from the suffix of the filename. TargetFile :: !FilePath -> !Maybe Phase -> TargetId -- | Untyped Phase description data Phase -- | Sets the targets for this session. Each target may be a module name or -- a filename. The targets correspond to the set of root modules for the -- program/library. Unloading the current program is achieved by setting -- the current set of targets to be empty, followed by load. setTargets :: GhcMonad m => [Target] -> m () -- | Returns the current set of targets getTargets :: GhcMonad m => m [Target] -- | Add another target. addTarget :: GhcMonad m => Target -> m () -- | Remove a target removeTarget :: GhcMonad m => TargetId -> m () -- | Attempts to guess what Target a string refers to. This function -- implements the --make/GHCi command-line syntax for filenames: -- -- guessTarget :: GhcMonad m => String -> Maybe UnitId -> Maybe Phase -> m Target -- | Perform a dependency analysis starting from the current targets and -- update the session with the new module graph. -- -- Dependency analysis entails parsing the import directives and -- may therefore require running certain preprocessors. -- -- Note that each ModSummary in the module graph caches its -- DynFlags. These DynFlags are determined by the -- current session DynFlags and the OPTIONS and -- LANGUAGE pragmas of the parsed module. Thus if you want -- changes to the DynFlags to take effect you need to call this -- function again. In case of errors, just throw them. depanal :: GhcMonad m => [ModuleName] -> Bool -> m ModuleGraph -- | Perform dependency analysis like in depanal. In case of errors, -- the errors and an empty module graph are returned. depanalE :: GhcMonad m => [ModuleName] -> Bool -> m (DriverMessages, ModuleGraph) -- | Try to load the program. See LoadHowMuch for the different -- modes. -- -- This function implements the core of GHC's --make mode. It -- preprocesses, compiles and loads the specified modules, avoiding -- re-compilation wherever possible. Depending on the backend (see -- backend field) compiling and loading may result in files being -- created on disk. -- -- Calls the defaultWarnErrLogger after each compiling each -- module, whether successful or not. -- -- If errors are encountered during dependency analysis, the module -- depanalE returns together with the errors an empty ModuleGraph. -- After processing this empty ModuleGraph, the errors of depanalE are -- thrown. All other errors are reported using the -- defaultWarnErrLogger. load :: GhcMonad f => LoadHowMuch -> f SuccessFlag loadWithCache :: GhcMonad m => [HomeModInfo] -> LoadHowMuch -> m (SuccessFlag, [HomeModInfo]) -- | Describes which modules of the module graph need to be loaded. data LoadHowMuch -- | Load all targets and its dependencies. LoadAllTargets :: LoadHowMuch -- | Load only the given module and its dependencies. LoadUpTo :: HomeUnitModule -> LoadHowMuch -- | Load only the dependencies of the given module, but not the module -- itself. LoadDependenciesOf :: HomeUnitModule -> LoadHowMuch data InteractiveImport -- | Bring the exports of a particular module (filtered by an import decl) -- into scope IIDecl :: ImportDecl GhcPs -> InteractiveImport -- | Bring into scope the entire top-level envt of of this module, -- including the things imported into it. IIModule :: ModuleName -> InteractiveImport data SuccessFlag Succeeded :: SuccessFlag Failed :: SuccessFlag succeeded :: SuccessFlag -> Bool failed :: SuccessFlag -> Bool defaultWarnErrLogger :: WarnErrLogger -- | A function called to log warnings and errors. type WarnErrLogger = forall (m :: Type -> Type). (HasDynFlags m, MonadIO m, HasLogger m) => Maybe SourceError -> m () -- | Inform GHC that the working directory has changed. GHC will flush its -- cache of module locations, since it may no longer be valid. -- -- Note: Before changing the working directory make sure all threads -- running in the same session have stopped. If you change the working -- directory, you should also unload the current program (set targets to -- empty, followed by load). workingDirectoryChanged :: GhcMonad m => m () -- | Parse a module. -- -- Throws a SourceError on parse error. parseModule :: GhcMonad m => ModSummary -> m ParsedModule -- | Typecheck and rename a parsed module. -- -- Throws a SourceError if either fails. typecheckModule :: GhcMonad m => ParsedModule -> m TypecheckedModule -- | Desugar a typechecked module. desugarModule :: GhcMonad m => TypecheckedModule -> m DesugaredModule -- | The result of successful parsing. data ParsedModule ParsedModule :: ModSummary -> ParsedSource -> [FilePath] -> ParsedModule [pm_mod_summary] :: ParsedModule -> ModSummary [pm_parsed_source] :: ParsedModule -> ParsedSource [pm_extra_src_files] :: ParsedModule -> [FilePath] -- | The result of successful typechecking. It also contains the parser -- result. data TypecheckedModule TypecheckedModule :: ParsedModule -> Maybe RenamedSource -> TypecheckedSource -> ModuleInfo -> (TcGblEnv, ModDetails) -> TypecheckedModule [tm_parsed_module] :: TypecheckedModule -> ParsedModule [tm_renamed_source] :: TypecheckedModule -> Maybe RenamedSource [tm_typechecked_source] :: TypecheckedModule -> TypecheckedSource [tm_checked_module_info] :: TypecheckedModule -> ModuleInfo [tm_internals_] :: TypecheckedModule -> (TcGblEnv, ModDetails) -- | The result of successful desugaring (i.e., translation to core). Also -- contains all the information of a typechecked module. data DesugaredModule DesugaredModule :: TypecheckedModule -> ModGuts -> DesugaredModule [dm_typechecked_module] :: DesugaredModule -> TypecheckedModule [dm_core_module] :: DesugaredModule -> ModGuts type TypecheckedSource = LHsBinds GhcTc type ParsedSource = Located HsModule type RenamedSource = (HsGroup GhcRn, [LImportDecl GhcRn], Maybe [(LIE GhcRn, Avails)], Maybe (LHsDoc GhcRn)) class ParsedMod m => TypecheckedMod m class ParsedMod m moduleInfo :: TypecheckedMod m => m -> ModuleInfo renamedSource :: TypecheckedMod m => m -> Maybe RenamedSource typecheckedSource :: TypecheckedMod m => m -> TypecheckedSource parsedSource :: ParsedMod m => m -> ParsedSource coreModule :: DesugaredMod m => m -> ModGuts -- | Package-qualifier after renaming -- -- Renaming detects if "this" or the unit-id of the home-unit was used as -- a package qualifier. data PkgQual -- | No package qualifier NoPkgQual :: PkgQual -- | Import from home-unit ThisPkg :: UnitId -> PkgQual -- | Import from another unit OtherPkg :: UnitId -> PkgQual -- | A CoreModule consists of just the fields of a ModGuts that are -- needed for the compileToCoreModule interface. data CoreModule CoreModule :: !Module -> !TypeEnv -> CoreProgram -> SafeHaskellMode -> CoreModule -- | Module name [cm_module] :: CoreModule -> !Module -- | Type environment for types declared in this module [cm_types] :: CoreModule -> !TypeEnv -- | Declarations [cm_binds] :: CoreModule -> CoreProgram -- | Safe Haskell mode [cm_safe] :: CoreModule -> SafeHaskellMode -- | This is the way to get access to the Core bindings corresponding to a -- module. compileToCore parses, typechecks, and desugars the -- module, then returns the resulting Core module (consisting of the -- module name, type declarations, and function declarations) if -- successful. compileToCoreModule :: GhcMonad m => FilePath -> m CoreModule -- | Like compileToCoreModule, but invokes the simplifier, so as to return -- simplified and tidied Core. compileToCoreSimplified :: GhcMonad m => FilePath -> m CoreModule -- | A 'ModuleGraph' contains all the nodes from the home package -- (only). See 'ModuleGraphNode' for information about the -- nodes. -- -- Modules need to be compiled. hs-boots need to be typechecked before -- the associated "real" module so modules with {--} imports can be -- built. Instantiations also need to be typechecked to ensure that the -- module fits the signature. Substantiation typechecking is roughly -- comparable to the check that the module and its hs-boot agree. -- -- The graph is not necessarily stored in topologically-sorted order. Use -- topSortModuleGraph and flattenSCC to achieve this. data ModuleGraph emptyMG :: ModuleGraph -- | Map a function f over all the ModSummaries. To -- preserve invariants f can't change the isBoot status. mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph mkModuleGraph :: [ModuleGraphNode] -> ModuleGraph mgModSummaries :: ModuleGraph -> [ModSummary] -- | Look up a ModSummary in the ModuleGraph mgLookupModule :: ModuleGraph -> Module -> Maybe ModSummary -- | Data for a module node in a ModuleGraph. Module nodes of the -- module graph are one of: -- -- data ModSummary ModSummary :: Module -> HscSource -> ModLocation -> Fingerprint -> Maybe UTCTime -> !Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> [(PkgQual, Located ModuleName)] -> [(PkgQual, Located ModuleName)] -> !Bool -> Maybe HsParsedModule -> FilePath -> DynFlags -> Maybe StringBuffer -> ModSummary -- | Identity of the module [ms_mod] :: ModSummary -> Module -- | The module source either plain Haskell, hs-boot, or hsig [ms_hsc_src] :: ModSummary -> HscSource -- | Location of the various files belonging to the module [ms_location] :: ModSummary -> ModLocation -- | Content hash of source file [ms_hs_hash] :: ModSummary -> Fingerprint -- | Timestamp of object, if we have one [ms_obj_date] :: ModSummary -> Maybe UTCTime -- | Timestamp of dynamic object, if we have one [ms_dyn_obj_date] :: ModSummary -> !Maybe UTCTime -- | Timestamp of hi file, if we have one See Note [When source is -- considered modified] and #9243 [ms_iface_date] :: ModSummary -> Maybe UTCTime -- | Timestamp of hie file, if we have one [ms_hie_date] :: ModSummary -> Maybe UTCTime -- | Source imports of the module [ms_srcimps] :: ModSummary -> [(PkgQual, Located ModuleName)] -- | Non-source imports of the module from the module *text* [ms_textual_imps] :: ModSummary -> [(PkgQual, Located ModuleName)] -- | Whether the special module GHC.Prim was imported explicitliy [ms_ghc_prim_import] :: ModSummary -> !Bool -- | The parsed, nonrenamed source, if we have it. This is also used to -- support "inline module syntax" in Backpack files. [ms_parsed_mod] :: ModSummary -> Maybe HsParsedModule -- | Filename of preprocessed source file [ms_hspp_file] :: ModSummary -> FilePath -- | Cached flags from OPTIONS, INCLUDE and -- LANGUAGE pragmas in the modules source code [ms_hspp_opts] :: ModSummary -> DynFlags -- | The actual preprocessed source, if we have it [ms_hspp_buf] :: ModSummary -> Maybe StringBuffer ms_mod_name :: ModSummary -> ModuleName -- | Module Location -- -- Where a module lives on the file system: the actual locations of the -- .hs, .hi, .dyn_hi, .o, .dyn_o and .hie files, if we have them. -- -- For a module in another unit, the ml_hs_file and ml_obj_file -- components of ModLocation are undefined. -- -- The locations specified by a ModLocation may or may not correspond to -- actual files yet: for example, even if the object file doesn't exist, -- the ModLocation still contains the path to where the object file will -- reside if/when it is created. -- -- The paths of anything which can affect recompilation should be placed -- inside ModLocation. -- -- When a ModLocation is created none of the filepaths will have -boot -- suffixes. This is because in --make mode the ModLocation is put in the -- finder cache which is indexed by ModuleName, when a ModLocation is -- retrieved from the FinderCache the boot suffixes are appended. The -- other case is in -c mode, there the ModLocation immediately gets given -- the boot suffixes in mkOneShotModLocation. data ModLocation ModLocation :: Maybe FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> ModLocation -- | The source file, if we have one. Package modules probably don't have -- source files. [ml_hs_file] :: ModLocation -> Maybe FilePath -- | Where the .hi file is, whether or not it exists yet. Always of form -- foo.hi, even if there is an hi-boot file (we add the -boot suffix -- later) [ml_hi_file] :: ModLocation -> FilePath -- | Where the .dyn_hi file is, whether or not it exists yet. [ml_dyn_hi_file] :: ModLocation -> FilePath -- | Where the .o file is, whether or not it exists yet. (might not exist -- either because the module hasn't been compiled yet, or because it is -- part of a unit with a .a file) [ml_obj_file] :: ModLocation -> FilePath -- | Where the .dy file is, whether or not it exists yet. [ml_dyn_obj_file] :: ModLocation -> FilePath -- | Where the .hie file is, whether or not it exists yet. [ml_hie_file] :: ModLocation -> FilePath -- | Return the ModSummary of a module with the given name. -- -- The module must be part of the module graph (see hsc_mod_graph -- and ModuleGraph). If this is not the case, this function will -- throw a GhcApiError. -- -- This function ignores boot modules and requires that there is only one -- non-boot module with the given name. getModSummary :: GhcMonad m => ModuleName -> m ModSummary -- | Get the module dependency graph. getModuleGraph :: GhcMonad m => m ModuleGraph -- | Return True <==> module is loaded. isLoaded :: GhcMonad m => ModuleName -> m Bool -- | Topological sort of the module graph -- -- Calculate SCCs of the module graph, possibly dropping the hi-boot -- nodes The resulting list of strongly-connected-components is in -- topologically sorted order, starting with the module(s) at the bottom -- of the dependency graph (ie compile them first) and ending with the -- ones at the top. -- -- Drop hi-boot nodes (first boolean arg)? -- -- topSortModuleGraph :: Bool -> ModuleGraph -> Maybe HomeUnitModule -> [SCC ModuleGraphNode] -- | Container for information about a Module. data ModuleInfo -- | Request information about a loaded Module getModuleInfo :: GhcMonad m => Module -> m (Maybe ModuleInfo) -- | The list of top-level entities defined in a module modInfoTyThings :: ModuleInfo -> [TyThing] modInfoTopLevelScope :: ModuleInfo -> Maybe [Name] modInfoExports :: ModuleInfo -> [Name] modInfoExportsWithSelectors :: ModuleInfo -> [Name] -- | Returns the instances defined by the specified module. Warning: -- currently unimplemented for package modules. modInfoInstances :: ModuleInfo -> [ClsInst] modInfoIsExportedName :: ModuleInfo -> Name -> Bool modInfoLookupName :: GhcMonad m => ModuleInfo -> Name -> m (Maybe TyThing) modInfoIface :: ModuleInfo -> Maybe ModIface modInfoRdrEnv :: ModuleInfo -> Maybe GlobalRdrEnv -- | Retrieve module safe haskell mode modInfoSafe :: ModuleInfo -> SafeHaskellMode -- | Looks up a global name: that is, any top-level name in any visible -- module. Unlike lookupName, lookupGlobalName does not use the -- interactive context, and therefore does not require a preceding -- setContext. lookupGlobalName :: GhcMonad m => Name -> m (Maybe TyThing) findGlobalAnns :: (GhcMonad m, Typeable a) => ([Word8] -> a) -> AnnTarget Name -> m [a] mkPrintUnqualifiedForModule :: GhcMonad m => ModuleInfo -> m (Maybe PrintUnqualified) type ModIface = ModIface_ 'ModIfaceFinal -- | A ModIface plus a ModDetails summarises everything we -- know about a compiled module. The ModIface is the stuff -- *before* linking, and can be written out to an interface file. The -- 'ModDetails is after linking and can be completely recovered from just -- the ModIface. -- -- When we read an interface file, we also construct a ModIface -- from it, except that we explicitly make the mi_decls and a few -- other fields empty; as when reading we consolidate the declarations -- etc. into a number of indexed maps and environments in the -- ExternalPackageState. -- -- See Note [Strictness in ModIface] to learn about why some fields are -- strict and others are not. data ModIface_ (phase :: ModIfacePhase) ModIface :: !Module -> !Maybe Module -> !HscSource -> Dependencies -> [Usage] -> ![IfaceExport] -> !Bool -> [(OccName, Fixity)] -> Warnings GhcRn -> [IfaceAnnotation] -> [IfaceDeclExts phase] -> !Maybe GlobalRdrEnv -> [IfaceClsInst] -> [IfaceFamInst] -> [IfaceRule] -> !AnyHpcUsage -> !IfaceTrustInfo -> !Bool -> ![IfaceCompleteMatch] -> Maybe Docs -> !IfaceBackendExts phase -> !ExtensibleFields -> !Fingerprint -> ModIface_ (phase :: ModIfacePhase) -- | Name of the module we are for [mi_module] :: ModIface_ (phase :: ModIfacePhase) -> !Module -- | Are we a sig of another mod? [mi_sig_of] :: ModIface_ (phase :: ModIfacePhase) -> !Maybe Module -- | Boot? Signature? [mi_hsc_src] :: ModIface_ (phase :: ModIfacePhase) -> !HscSource -- | The dependencies of the module. This is consulted for -- directly-imported modules, but not for anything else (hence lazy) [mi_deps] :: ModIface_ (phase :: ModIfacePhase) -> Dependencies -- | Usages; kept sorted so that it's easy to decide whether to write a new -- iface file (changing usages doesn't affect the hash of this module) -- NOT STRICT! we read this field lazily from the interface file It is -- *only* consulted by the recompilation checker [mi_usages] :: ModIface_ (phase :: ModIfacePhase) -> [Usage] -- | Exports Kept sorted by (mod,occ), to make version comparisons easier -- Records the modules that are the declaration points for things -- exported by this module, and the OccNames of those things [mi_exports] :: ModIface_ (phase :: ModIfacePhase) -> ![IfaceExport] -- | Module required TH splices when it was compiled. This disables -- recompilation avoidance (see #481). [mi_used_th] :: ModIface_ (phase :: ModIfacePhase) -> !Bool -- | Fixities NOT STRICT! we read this field lazily from the interface file [mi_fixities] :: ModIface_ (phase :: ModIfacePhase) -> [(OccName, Fixity)] -- | Warnings NOT STRICT! we read this field lazily from the interface file [mi_warns] :: ModIface_ (phase :: ModIfacePhase) -> Warnings GhcRn -- | Annotations NOT STRICT! we read this field lazily from the interface -- file [mi_anns] :: ModIface_ (phase :: ModIfacePhase) -> [IfaceAnnotation] -- | Type, class and variable declarations The hash of an Id changes if its -- fixity or deprecations change (as well as its type of course) Ditto -- data constructors, class operations, except that the hash of the -- parent class/tycon changes [mi_decls] :: ModIface_ (phase :: ModIfacePhase) -> [IfaceDeclExts phase] -- | Binds all the things defined at the top level in the original -- source code for this module. which is NOT the same as mi_exports, -- nor mi_decls (which may contains declarations for things not actually -- defined by the user). Used for GHCi and for inspecting the contents of -- modules via the GHC API only. -- -- (We need the source file to figure out the top-level environment, if -- we didn't compile this module from source then this field contains -- Nothing). -- -- Strictly speaking this field should live in the HomeModInfo, -- but that leads to more plumbing. [mi_globals] :: ModIface_ (phase :: ModIfacePhase) -> !Maybe GlobalRdrEnv -- | Sorted class instance [mi_insts] :: ModIface_ (phase :: ModIfacePhase) -> [IfaceClsInst] -- | Sorted family instances [mi_fam_insts] :: ModIface_ (phase :: ModIfacePhase) -> [IfaceFamInst] -- | Sorted rules [mi_rules] :: ModIface_ (phase :: ModIfacePhase) -> [IfaceRule] -- | True if this program uses Hpc at any point in the program. [mi_hpc] :: ModIface_ (phase :: ModIfacePhase) -> !AnyHpcUsage -- | Safe Haskell Trust information for this module. [mi_trust] :: ModIface_ (phase :: ModIfacePhase) -> !IfaceTrustInfo -- | Do we require the package this module resides in be trusted to trust -- this module? This is used for the situation where a module is Safe (so -- doesn't require the package be trusted itself) but imports some -- trustworthy modules from its own package (which does require its own -- package be trusted). See Note [Trust Own Package] in GHC.Rename.Names [mi_trust_pkg] :: ModIface_ (phase :: ModIfacePhase) -> !Bool [mi_complete_matches] :: ModIface_ (phase :: ModIfacePhase) -> ![IfaceCompleteMatch] -- | Docstrings and related data for use by haddock, the ghci :doc -- command, and other tools. -- -- Just _ = the module was built with -- -haddock. [mi_docs] :: ModIface_ (phase :: ModIfacePhase) -> Maybe Docs -- | Either () or ModIfaceBackend for a fully instantiated -- interface. [mi_final_exts] :: ModIface_ (phase :: ModIfacePhase) -> !IfaceBackendExts phase -- | Additional optional fields, where the Map key represents the field -- name, resulting in a (size, serialized data) pair. Because the data is -- intended to be serialized through the internal Binary class -- (increasing compatibility with types using Name and -- FastString, such as HIE), this format is chosen over -- ByteStrings. [mi_ext_fields] :: ModIface_ (phase :: ModIfacePhase) -> !ExtensibleFields -- | Hash of the .hs source, used for recompilation checking. [mi_src_hash] :: ModIface_ (phase :: ModIfacePhase) -> !Fingerprint -- | The various Safe Haskell modes data SafeHaskellMode -- | inferred unsafe Sf_None :: SafeHaskellMode -- | declared and checked Sf_Unsafe :: SafeHaskellMode -- | declared and checked Sf_Trustworthy :: SafeHaskellMode -- | declared and checked Sf_Safe :: SafeHaskellMode -- | inferred as safe Sf_SafeInferred :: SafeHaskellMode -- | -fno-safe-haskell state Sf_Ignore :: SafeHaskellMode -- | When printing code that contains original names, we need to map the -- original names back to something the user understands. This is the -- purpose of the triple of functions that gets passed around when -- rendering SDoc. data PrintUnqualified alwaysQualify :: PrintUnqualified -- | Run a statement in the current interactive context. execStmt :: GhcMonad m => String -> ExecOptions -> m ExecResult -- | Like execStmt, but takes a parsed statement as argument. Useful -- when doing preprocessing on the AST before execution, e.g. in GHCi -- (see GHCi.UI.runStmt). execStmt' :: GhcMonad m => GhciLStmt GhcPs -> String -> ExecOptions -> m ExecResult data ExecOptions ExecOptions :: SingleStep -> String -> Int -> (ForeignHValue -> EvalExpr ForeignHValue) -> ExecOptions -- | stepping mode [execSingleStep] :: ExecOptions -> SingleStep -- | filename (for errors) [execSourceFile] :: ExecOptions -> String -- | line number (for errors) [execLineNumber] :: ExecOptions -> Int [execWrap] :: ExecOptions -> ForeignHValue -> EvalExpr ForeignHValue -- | default ExecOptions execOptions :: ExecOptions data ExecResult ExecComplete :: Either SomeException [Name] -> Word64 -> ExecResult [execResult] :: ExecResult -> Either SomeException [Name] [execAllocation] :: ExecResult -> Word64 ExecBreak :: [Name] -> Maybe BreakInfo -> ExecResult [breakNames] :: ExecResult -> [Name] [breakInfo] :: ExecResult -> Maybe BreakInfo resumeExec :: GhcMonad m => (SrcSpan -> Bool) -> SingleStep -> Maybe Int -> m ExecResult runDecls :: GhcMonad m => String -> m [Name] -- | Run some declarations and return any user-visible names that were -- brought into scope. runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name] -- | Like runDeclsWithLocation, but takes parsed declarations as -- argument. Useful when doing preprocessing on the AST before execution, -- e.g. in GHCi (see GHCi.UI.runStmt). runParsedDecls :: GhcMonad m => [LHsDecl GhcPs] -> m [Name] parseImportDecl :: GhcMonad m => String -> m (ImportDecl GhcPs) -- | Set the interactive evaluation context. -- -- (setContext imports) sets the ic_imports field (which in turn -- determines what is in scope at the prompt) to imports, and -- updates the icReaderEnv environment to reflect it. -- -- We retain in scope all the things defined at the prompt, and kept in -- ic_tythings. (Indeed, they shadow stuff from ic_imports.) setContext :: GhcMonad m => [InteractiveImport] -> m () -- | Get the interactive evaluation context, consisting of a pair of the -- set of modules from which we take the full top-level scope, and the -- set of modules from which we take just the exports respectively. getContext :: GhcMonad m => m [InteractiveImport] -- | Set the monad GHCi lifts user statements into. -- -- Checks that a type (in string form) is an instance of the -- GHC.GHCi.GHCiSandboxIO type class. Sets it to be the GHCi -- monad if it is, throws an error otherwise. setGHCiMonad :: GhcMonad m => String -> m () -- | Get the monad GHCi lifts user statements into. getGHCiMonad :: GhcMonad m => m Name -- | Return the bindings for the current interactive session. getBindings :: GhcMonad m => m [TyThing] -- | Return the instances for the current interactive session. getInsts :: GhcMonad m => m ([ClsInst], [FamInst]) getPrintUnqual :: GhcMonad m => m PrintUnqualified -- | Takes a ModuleName and possibly a UnitId, and consults -- the filesystem and package database to find the corresponding -- Module, using the algorithm that is used for an import -- declaration. findModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module -- | Like findModule, but differs slightly when the module refers to -- a source file, and the file has not been loaded via load. In -- this case, findModule will throw an error (module not loaded), -- but lookupModule will check to see whether the module can also -- be found in a package, and if so, that package Module will be -- returned. If not, the usual module-not-found error will be thrown. lookupModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module findQualifiedModule :: GhcMonad m => PkgQual -> ModuleName -> m Module lookupQualifiedModule :: GhcMonad m => PkgQual -> ModuleName -> m Module renamePkgQualM :: GhcMonad m => ModuleName -> Maybe FastString -> m PkgQual renameRawPkgQualM :: GhcMonad m => ModuleName -> RawPkgQual -> m PkgQual -- | Check that a module is safe to import (according to Safe Haskell). -- -- We return True to indicate the import is safe and False otherwise -- although in the False case an error may be thrown first. isModuleTrusted :: GhcMonad m => Module -> m Bool -- | Return if a module is trusted and the pkgs it depends on to be -- trusted. moduleTrustReqs :: GhcMonad m => Module -> m (Bool, Set UnitId) -- | Returns all names in scope in the current interactive context getNamesInScope :: GhcMonad m => m [Name] -- | Returns all RdrNames in scope in the current interactive -- context, excluding any that are internally-generated. getRdrNamesInScope :: GhcMonad m => m [RdrName] -- | get the GlobalRdrEnv for a session getGRE :: GhcMonad m => m GlobalRdrEnv -- | Returns True if the specified module is interpreted, and -- hence has its full top-level scope available. moduleIsInterpreted :: GhcMonad m => Module -> m Bool -- | Looks up an identifier in the current interactive context (for :info) -- Filter the instances by the ones whose tycons (or clases resp) are in -- scope (qualified or otherwise). Otherwise we list a whole lot too -- many! The exact choice of which ones to show, and which to hide, is a -- judgement call. (see #1581) getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst], SDoc)) showModule :: GhcMonad m => ModSummary -> m String moduleIsBootOrNotObjectLinkable :: GhcMonad m => ModSummary -> m Bool -- | Retrieve all type and family instances in the environment, indexed by -- Name. Each name's lists will contain every instance in which -- that name is mentioned in the instance head. getNameToInstancesIndex :: GhcMonad m => [Module] -> Maybe [Module] -> m (Messages TcRnMessage, Maybe (NameEnv ([ClsInst], [FamInst]))) -- | Get the type of an expression Returns the type as described by -- TcRnExprMode exprType :: GhcMonad m => TcRnExprMode -> String -> m Type -- | How should we infer a type? See Note [TcRnExprMode] data TcRnExprMode -- | Instantiate inferred quantifiers only (:type) TM_Inst :: TcRnExprMode -- | Instantiate all quantifiers, and do eager defaulting (:type +d) TM_Default :: TcRnExprMode -- | Get the kind of a type typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind) -- | Parses a string as an identifier, and returns the list of Names -- that the identifier can refer to in the current interactive context. parseName :: GhcMonad m => String -> m [Name] -- | Returns the TyThing for a Name. The Name may -- refer to any entity known to GHC, including Names defined using -- runStmt. lookupName :: GhcMonad m => Name -> m (Maybe TyThing) data HValue -- | Parse an expression, the parsed expression can be further processed -- and passed to compileParsedExpr. parseExpr :: GhcMonad m => String -> m (LHsExpr GhcPs) compileParsedExpr :: GhcMonad m => LHsExpr GhcPs -> m HValue -- | Compile an expression, run it, and deliver the resulting HValue. compileExpr :: GhcMonad m => String -> m HValue -- | Compile an expression, run it and return the result as a Dynamic. dynCompileExpr :: GhcMonad m => String -> m Dynamic type ForeignHValue = ForeignRef HValue -- | Compile an expression, run it, and deliver the resulting HValue. compileExprRemote :: GhcMonad m => String -> m ForeignHValue -- | Compile a parsed expression (before renaming), run it, and deliver the -- resulting HValue. compileParsedExprRemote :: GhcMonad m => LHsExpr GhcPs -> m ForeignHValue getDocs :: GhcMonad m => Name -> m (Either GetDocsFailure (Maybe [HsDoc GhcRn], IntMap (HsDoc GhcRn))) -- | Failure modes for getDocs. data GetDocsFailure -- | nameModule_maybe returned Nothing. NameHasNoModule :: Name -> GetDocsFailure -- | True: The module was compiled. False: The module was -- :loaded. NoDocsInIface :: Module -> Bool -> GetDocsFailure -- | The Name was defined interactively. InteractiveName :: GetDocsFailure runTcInteractive :: HscEnv -> TcRn a -> IO (Messages TcRnMessage, Maybe a) -- | Returns True if passed string is a statement. isStmt :: ParserOpts -> String -> Bool -- | Returns True if passed string has an import declaration. hasImport :: ParserOpts -> String -> Bool -- | Returns True if passed string is an import declaration. isImport :: ParserOpts -> String -> Bool -- | Returns True if passed string is a declaration but not -- a splice. isDecl :: ParserOpts -> String -> Bool data SingleStep RunToCompletion :: SingleStep SingleStep :: SingleStep RunAndLogSteps :: SingleStep data Resume Resume :: String -> ForeignRef (ResumeContext [HValueRef]) -> ResumeBindings -> [Id] -> ForeignHValue -> Maybe BreakInfo -> SrcSpan -> String -> RemotePtr CostCentreStack -> [History] -> Int -> Resume [resumeStmt] :: Resume -> String [resumeContext] :: Resume -> ForeignRef (ResumeContext [HValueRef]) [resumeBindings] :: Resume -> ResumeBindings [resumeFinalIds] :: Resume -> [Id] [resumeApStack] :: Resume -> ForeignHValue [resumeBreakInfo] :: Resume -> Maybe BreakInfo [resumeSpan] :: Resume -> SrcSpan [resumeDecl] :: Resume -> String [resumeCCS] :: Resume -> RemotePtr CostCentreStack [resumeHistory] :: Resume -> [History] [resumeHistoryIx] :: Resume -> Int data History getHistorySpan :: GhcMonad m => History -> m SrcSpan getHistoryModule :: History -> Module abandon :: GhcMonad m => m Bool abandonAll :: GhcMonad m => m Bool getResumeContext :: GhcMonad m => m [Resume] obtainTermFromId :: GhcMonad m => Int -> Bool -> Id -> m Term obtainTermFromVal :: GhcMonad m => Int -> Bool -> Type -> a -> m Term reconstructType :: HscEnv -> Int -> Id -> IO (Maybe Type) modInfoModBreaks :: ModuleInfo -> ModBreaks -- | All the information about the breakpoints for a module data ModBreaks ModBreaks :: ForeignRef BreakArray -> !Array BreakIndex SrcSpan -> !Array BreakIndex [OccName] -> !Array BreakIndex [String] -> !Array BreakIndex (RemotePtr CostCentre) -> IntMap CgBreakInfo -> ModBreaks -- | The array of flags, one per breakpoint, indicating which breakpoints -- are enabled. [modBreaks_flags] :: ModBreaks -> ForeignRef BreakArray -- | An array giving the source span of each breakpoint. [modBreaks_locs] :: ModBreaks -> !Array BreakIndex SrcSpan -- | An array giving the names of the free variables at each breakpoint. [modBreaks_vars] :: ModBreaks -> !Array BreakIndex [OccName] -- | An array giving the names of the declarations enclosing each -- breakpoint. See Note [Field modBreaks_decls] [modBreaks_decls] :: ModBreaks -> !Array BreakIndex [String] -- | Array pointing to cost centre for each breakpoint [modBreaks_ccs] :: ModBreaks -> !Array BreakIndex (RemotePtr CostCentre) -- | info about each breakpoint from the bytecode generator [modBreaks_breakInfo] :: ModBreaks -> IntMap CgBreakInfo -- | Breakpoint index type BreakIndex = Int data BreakInfo BreakInfo :: Module -> Int -> BreakInfo [breakInfo_module] :: BreakInfo -> Module [breakInfo_number] :: BreakInfo -> Int back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String) setupBreakpoint :: GhcMonad m => HscEnv -> BreakInfo -> Int -> m () type Unit = GenUnit UnitId -- | A Module is a pair of a Unit and a ModuleName. type Module = GenModule Unit mkModule :: u -> ModuleName -> GenModule u pprModule :: Module -> SDoc -- | Module name (e.g. A.B.C) moduleName :: GenModule unit -> ModuleName -- | Unit the module belongs to moduleUnit :: GenModule unit -> unit -- | A ModuleName is essentially a simple string, e.g. Data.List. data ModuleName mkModuleName :: String -> ModuleName moduleNameString :: ModuleName -> String -- | A unique, unambiguous name for something, containing information about -- where that thing originated. data Name isExternalName :: Name -> Bool nameModule :: HasDebugCallStack => Name -> Module -- | print a NamedThing, adding parentheses if the name is an -- operator. pprParenSymName :: NamedThing a => a -> SDoc nameSrcSpan :: Name -> SrcSpan -- | A class allowing convenient access to the Name of various -- datatypes class NamedThing a getOccName :: NamedThing a => a -> OccName getName :: NamedThing a => a -> Name -- | Reader Name -- -- Do not use the data constructors of RdrName directly: prefer the -- family of functions that creates them, such as mkRdrUnqual -- -- -- --
--   `bar`
--   ( ~ )
--   
-- -- data RdrName -- | Unqualified name -- -- Used for ordinary, unqualified occurrences, e.g. x, -- y or Foo. Create such a RdrName with -- mkRdrUnqual Unqual :: OccName -> RdrName -- | Qualified name -- -- A qualified name written by the user in source code. The module -- isn't necessarily the module where the thing is defined; just the one -- from which it is imported. Examples are Bar.x, Bar.y -- or Bar.Foo. Create such a RdrName with -- mkRdrQual Qual :: ModuleName -> OccName -> RdrName -- | Identifier type Id = Var idType :: Id -> Kind -- | isImplicitId tells whether an Ids info is implied by -- other declarations, so we don't need to put its signature in an -- interface file, even if it's mentioned in some other interface -- unfolding. isImplicitId :: Id -> Bool isDeadBinder :: Id -> Bool -- | isExportedIdVar means "don't throw this away" isExportedId :: Var -> Bool isLocalId :: Var -> Bool isGlobalId :: Var -> Bool isRecordSelector :: Id -> Bool isPrimOpId :: Id -> Bool isFCallId :: Id -> Bool isClassOpId_maybe :: Id -> Maybe Class isDataConWorkId :: Id -> Bool -- | Get from either the worker or the wrapper Id to the -- DataCon. Currently used only in the desugarer. -- -- INVARIANT: idDataCon (dataConWrapId d) = d: remember, -- dataConWrapId can return either the wrapper or the worker idDataCon :: Id -> DataCon -- | Returns true if an application to n args diverges or throws an -- exception See Note [Dead ends] in GHC.Types.Demand. isDeadEndId :: Var -> Bool isDictonaryId :: Id -> Bool -- | If the Id is that for a record selector, extract the -- sel_tycon. Panic otherwise. recordSelectorTyCon :: Id -> RecSelParent -- | TyCons represent type constructors. Type constructors are introduced -- by things such as: -- -- 1) Data declarations: data Foo = ... creates the Foo -- type constructor of kind * -- -- 2) Type synonyms: type Foo = ... creates the Foo -- type constructor -- -- 3) Newtypes: newtype Foo a = MkFoo ... creates the -- Foo type constructor of kind * -> * -- -- 4) Class declarations: class Foo where creates the -- Foo type constructor of kind * -- -- This data type also encodes a number of primitive, built in type -- constructors such as those for function and tuple types. data TyCon -- | TyVar binders tyConTyVars :: TyCon -> [TyVar] -- | As tyConDataCons_maybe, but returns the empty list of -- constructors if no constructors could be found tyConDataCons :: TyCon -> [DataCon] -- | Arity tyConArity :: TyCon -> Arity -- | Is this TyCon that for a class instance? isClassTyCon :: TyCon -> Bool -- | Is this a TyCon representing a regular H98 type synonym -- (type)? isTypeSynonymTyCon :: TyCon -> Bool -- | Is this a synonym TyCon that can have may have further -- instances appear? isTypeFamilyTyCon :: TyCon -> Bool -- | Is this TyCon that for a newtype isNewTyCon :: TyCon -> Bool -- | Does this TyCon represent something that cannot be defined in -- Haskell? isPrimTyCon :: TyCon -> Bool isFunTyCon :: TyCon -> Bool -- | Is this a TyCon, synonym or otherwise, that defines a family? isFamilyTyCon :: TyCon -> Bool -- | Is this a TyCon, synonym or otherwise, that defines a family -- with instances? isOpenFamilyTyCon :: TyCon -> Bool -- | Is this an open type family TyCon? isOpenTypeFamilyTyCon :: TyCon -> Bool -- | If this TyCon is that for a class instance, return the class it -- is for. Otherwise returns Nothing tyConClass_maybe :: TyCon -> Maybe Class -- | Extract the information pertaining to the right hand side of a type -- synonym (type) declaration. synTyConRhs_maybe :: TyCon -> Maybe Type -- | Extract the TyVars bound by a vanilla type synonym and the -- corresponding (unsubstituted) right hand side. synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) -- | Kind of this TyCon tyConKind :: TyCon -> Kind -- | Type or kind Variable type TyVar = Var alphaTyVars :: [TyVar] -- | A data constructor -- -- data DataCon dataConType :: DataCon -> Type -- | The type constructor that we are building via this data constructor dataConTyCon :: DataCon -> TyCon -- | The labels for the fields of this particular DataCon dataConFieldLabels :: DataCon -> [FieldLabel] -- | Should the DataCon be presented infix? dataConIsInfix :: DataCon -> Bool -- | Vanilla DataCons are those that are nice boring Haskell 98 -- constructors isVanillaDataCon :: DataCon -> Bool -- | The user-declared type of the data constructor in the nice-to-read -- form: -- --
--   T :: forall a b. a -> b -> T [a]
--   
-- -- rather than: -- --
--   T :: forall a c. forall b. (c~[a]) => a -> b -> T c
--   
-- -- The type variables are quantified in the order that the user wrote -- them. See Note [DataCon user type variable binders]. -- -- NB: If the constructor is part of a data instance, the result type -- mentions the family tycon, not the internal one. dataConWrapperType :: DataCon -> Type -- | Strictness/unpack annotations, from user; or, for imported DataCons, -- from the interface file The list is in one-to-one correspondence with -- the arity of the DataCon dataConSrcBangs :: DataCon -> [HsSrcBang] data StrictnessMark MarkedStrict :: StrictnessMark NotMarkedStrict :: StrictnessMark isMarkedStrict :: StrictnessMark -> Bool data Class classMethods :: Class -> [Id] classSCTheta :: Class -> [PredType] classTvsFds :: Class -> ([TyVar], [FunDep TyVar]) classATs :: Class -> [TyCon] pprFundeps :: Outputable a => [FunDep a] -> SDoc -- | A type-class instance. Note that there is some tricky laziness at work -- here. See Note [ClsInst laziness and the rough-match fields] for more -- details. data ClsInst instanceDFunId :: ClsInst -> DFunId pprInstance :: ClsInst -> SDoc pprInstanceHdr :: ClsInst -> SDoc -- | Pretty-prints a FamInst (type/data family instance) with its -- defining location. pprFamInst :: FamInst -> SDoc data FamInst data Type -- | Take a ForAllTy apart, returning the list of tycovars and the result -- type. This always succeeds, even if it returns only an empty list. -- Note that the result type returned may have free variables that were -- bound by a forall. splitForAllTyCoVars :: Type -> ([TyCoVar], Type) -- | Extract the function result type and panic if that is not possible funResultTy :: Type -> Type pprParendType :: Type -> SDoc pprTypeApp :: TyCon -> [Type] -> SDoc -- | The key type representing kinds in the compiler. type Kind = Type -- | A type of the form p of constraint kind represents a value -- whose type is the Haskell predicate p, where a predicate is -- what occurs before the => in a Haskell type. -- -- We use PredType as documentation to mark those types that we -- guarantee to have this kind. -- -- It can be expanded into its representation, but: -- -- -- -- Consider these examples: -- --
--   f :: (Eq a) => a -> Int
--   g :: (?x :: Int -> Int) => a -> Int
--   h :: (r\l) => {r} => {l::Int | r}
--   
-- -- Here the Eq a and ?x :: Int -> Int and -- rl are all called "predicates" type PredType = Type -- | A collection of PredTypes type ThetaType = [PredType] pprForAll :: [TyCoVarBinder] -> SDoc pprThetaArrowTy :: ThetaType -> SDoc parseInstanceHead :: GhcMonad m => String -> m Type getInstancesForType :: GhcMonad m => Type -> m [ClsInst] -- | A global typecheckable-thing, essentially anything that has a name. -- Not to be confused with a TcTyThing, which is also a -- typecheckable thing but in the *local* context. See -- GHC.Tc.Utils.Env for how to retrieve a TyThing given a -- Name. data TyThing AnId :: Id -> TyThing AConLike :: ConLike -> TyThing ATyCon :: TyCon -> TyThing ACoAxiom :: CoAxiom Branched -> TyThing data FixityDirection InfixL :: FixityDirection InfixR :: FixityDirection InfixN :: FixityDirection defaultFixity :: Fixity maxPrecedence :: Int negateFixity :: Fixity compareFixity :: Fixity -> Fixity -> (Bool, Bool) -- | Captures the fixity of declarations as they are parsed. This is not -- necessarily the same as the fixity declaration, as the normal fixity -- may be overridden using parens or backticks. data LexicalFixity Prefix :: LexicalFixity Infix :: LexicalFixity -- | Source Location data SrcLoc RealSrcLoc :: !RealSrcLoc -> !Maybe BufPos -> SrcLoc UnhelpfulLoc :: !FastString -> SrcLoc -- | Real Source Location -- -- Represents a single point within a file data RealSrcLoc mkSrcLoc :: FastString -> Int -> Int -> SrcLoc -- | Built-in "bad" SrcLoc values for particular locations noSrcLoc :: SrcLoc -- | Gives the filename of the RealSrcLoc srcLocFile :: RealSrcLoc -> FastString -- | Raises an error when used on a "bad" SrcLoc srcLocLine :: RealSrcLoc -> Int -- | Raises an error when used on a "bad" SrcLoc srcLocCol :: RealSrcLoc -> Int -- | Source Span -- -- A SrcSpan identifies either a specific portion of a text file -- or a human-readable description of a location. data SrcSpan RealSrcSpan :: !RealSrcSpan -> !Maybe BufSpan -> SrcSpan UnhelpfulSpan :: !UnhelpfulSpanReason -> SrcSpan -- | A RealSrcSpan delimits a portion of a text file. It could be -- represented by a pair of (line,column) coordinates, but in fact we -- optimise slightly by using more compact representations for -- single-line and zero-length spans, both of which are quite common. -- -- The end position is defined to be the column after the end of -- the span. That is, a span of (1,1)-(1,2) is one character long, and a -- span of (1,1)-(1,1) is zero characters long. -- -- Real Source Span data RealSrcSpan -- | Create a SrcSpan between two points in a file mkSrcSpan :: SrcLoc -> SrcLoc -> SrcSpan -- | Create a SrcSpan corresponding to a single point srcLocSpan :: SrcLoc -> SrcSpan -- | Test if a SrcSpan is "good", i.e. has precise location -- information isGoodSrcSpan :: SrcSpan -> Bool -- | Built-in "bad" SrcSpans for common sources of location -- uncertainty noSrcSpan :: SrcSpan -- | Returns the location at the start of the SrcSpan or a "bad" -- SrcSpan if that is unavailable srcSpanStart :: SrcSpan -> SrcLoc -- | Returns the location at the end of the SrcSpan or a "bad" -- SrcSpan if that is unavailable srcSpanEnd :: SrcSpan -> SrcLoc srcSpanFile :: RealSrcSpan -> FastString srcSpanStartLine :: RealSrcSpan -> Int srcSpanEndLine :: RealSrcSpan -> Int srcSpanStartCol :: RealSrcSpan -> Int srcSpanEndCol :: RealSrcSpan -> Int -- | We attach SrcSpans to lots of things, so let's have a datatype for it. data GenLocated l e L :: l -> e -> GenLocated l e type Located = GenLocated SrcSpan type RealLocated = GenLocated RealSrcSpan noLoc :: e -> Located e mkGeneralLocated :: String -> e -> Located e getLoc :: GenLocated l e -> l unLoc :: GenLocated l e -> e getRealSrcSpan :: RealLocated a -> RealSrcSpan unRealSrcSpan :: RealLocated a -> a -- | Tests whether the two located things are equal eqLocated :: Eq a => GenLocated l a -> GenLocated l a -> Bool -- | Tests the ordering of the two located things cmpLocated :: Ord a => GenLocated l a -> GenLocated l a -> Ordering combineLocs :: Located a -> Located b -> SrcSpan -- | Combine locations from two Located things and add them to a -- third thing addCLoc :: Located a -> Located b -> c -> Located c -- | Strategies for ordering SrcSpans leftmost_smallest :: SrcSpan -> SrcSpan -> Ordering -- | Strategies for ordering SrcSpans leftmost_largest :: SrcSpan -> SrcSpan -> Ordering -- | Strategies for ordering SrcSpans rightmost_smallest :: SrcSpan -> SrcSpan -> Ordering -- | Determines whether a span encloses a given line and column index spans :: SrcSpan -> (Int, Int) -> Bool -- | Determines whether a span is enclosed by another one isSubspanOf :: SrcSpan -> SrcSpan -> Bool -- | GHC's own exception type error messages all take the form: -- --
--   <location>: <error>
--   
--   
-- -- If the location is on the command line, or in GHC itself, then -- <location>="ghc". All of the error types below correspond to a -- <location> of "ghc", except for ProgramError (where the string -- is assumed to contain a location already, so we don't print one). data GhcException -- | Some other fatal signal (SIGHUP,SIGTERM) Signal :: Int -> GhcException -- | Prints the short usage msg after the error UsageError :: String -> GhcException -- | A problem with the command line arguments, but don't print usage. CmdLineError :: String -> GhcException -- | The impossible happened. Panic :: String -> GhcException PprPanic :: String -> SDoc -> GhcException -- | The user tickled something that's known not to work yet, but we're not -- counting it as a bug. Sorry :: String -> GhcException PprSorry :: String -> SDoc -> GhcException -- | An installation problem. InstallationError :: String -> GhcException -- | An error in the user's code, probably. ProgramError :: String -> GhcException PprProgramError :: String -> SDoc -> GhcException -- | Append a description of the given exception to this string. showGhcException :: SDocContext -> GhcException -> ShowS -- | An error thrown if the GHC API is used in an incorrect fashion. newtype GhcApiError GhcApiError :: String -> GhcApiError data Token -- | Return module source as token stream, including comments. -- -- A Module can be turned into a ModSummary using -- getModSummary if your session is fully initialised. Throws a -- SourceError on parse error. getTokenStream :: ModSummary -> IO [Located Token] -- | Give even more information on the source than getTokenStream -- This function allows reconstructing the source completely with -- showRichTokenStream. getRichTokenStream :: ModSummary -> IO [(Located Token, String)] -- | Take a rich token stream such as produced from -- getRichTokenStream and return source code almost identical to -- the original code (except for insignificant whitespace.) showRichTokenStream :: [(Located Token, String)] -> String -- | Given a source location and a StringBuffer corresponding to this -- location, return a rich token stream with the source associated to the -- tokens. addSourceToTokens :: RealSrcLoc -> StringBuffer -> [Located Token] -> [(Located Token, String)] -- | A pure interface to the module parser. parser :: String -> DynFlags -> FilePath -> (WarningMessages, Either ErrorMessages (Located HsModule)) -- | Exact print annotations exist so that tools can perform source to -- source conversions of Haskell code. They are used to keep track of the -- various syntactic keywords that are not otherwise captured in the AST. -- -- The wiki page describing this feature is -- https://gitlab.haskell.org/ghc/ghc/wikis/api-annotations -- https://gitlab.haskell.org/ghc/ghc/-/wikis/implementing-trees-that-grow/in-tree-api-annotations -- -- Note: in general the names of these are taken from the corresponding -- token, unless otherwise noted See Note [exact print annotations] above -- for details of the usage data AnnKeywordId AnnAnyclass :: AnnKeywordId AnnAs :: AnnKeywordId AnnAt :: AnnKeywordId -- | ! AnnBang :: AnnKeywordId -- | '`' AnnBackquote :: AnnKeywordId AnnBy :: AnnKeywordId -- | case or lambda case AnnCase :: AnnKeywordId AnnClass :: AnnKeywordId -- | '#)' or '#-}' etc AnnClose :: AnnKeywordId -- | '|)' AnnCloseB :: AnnKeywordId -- | '|)', unicode variant AnnCloseBU :: AnnKeywordId -- | '}' AnnCloseC :: AnnKeywordId -- | '|]' AnnCloseQ :: AnnKeywordId -- | '|]', unicode variant AnnCloseQU :: AnnKeywordId -- | ')' AnnCloseP :: AnnKeywordId -- | '#)' AnnClosePH :: AnnKeywordId -- | ']' AnnCloseS :: AnnKeywordId AnnColon :: AnnKeywordId -- | as a list separator AnnComma :: AnnKeywordId -- | in a RdrName for a tuple AnnCommaTuple :: AnnKeywordId -- | '=>' AnnDarrow :: AnnKeywordId -- | '=>', unicode variant AnnDarrowU :: AnnKeywordId AnnData :: AnnKeywordId -- | '::' AnnDcolon :: AnnKeywordId -- | '::', unicode variant AnnDcolonU :: AnnKeywordId AnnDefault :: AnnKeywordId AnnDeriving :: AnnKeywordId AnnDo :: AnnKeywordId -- | . AnnDot :: AnnKeywordId -- | '..' AnnDotdot :: AnnKeywordId AnnElse :: AnnKeywordId AnnEqual :: AnnKeywordId AnnExport :: AnnKeywordId AnnFamily :: AnnKeywordId AnnForall :: AnnKeywordId -- | Unicode variant AnnForallU :: AnnKeywordId AnnForeign :: AnnKeywordId -- | for function name in matches where there are multiple equations for -- the function. AnnFunId :: AnnKeywordId AnnGroup :: AnnKeywordId -- | for CType AnnHeader :: AnnKeywordId AnnHiding :: AnnKeywordId AnnIf :: AnnKeywordId AnnImport :: AnnKeywordId AnnIn :: AnnKeywordId -- | 'infix' or 'infixl' or 'infixr' AnnInfix :: AnnKeywordId AnnInstance :: AnnKeywordId AnnLam :: AnnKeywordId -- | '<-' AnnLarrow :: AnnKeywordId -- | '<-', unicode variant AnnLarrowU :: AnnKeywordId AnnLet :: AnnKeywordId -- | The unicode arrow AnnLollyU :: AnnKeywordId AnnMdo :: AnnKeywordId -- | - AnnMinus :: AnnKeywordId AnnModule :: AnnKeywordId AnnNewtype :: AnnKeywordId -- | where a name loses its location in the AST, this carries it AnnName :: AnnKeywordId AnnOf :: AnnKeywordId -- | '{-# DEPRECATED' etc. Opening of pragmas where the capitalisation of -- the string can be changed by the user. The actual text used is stored -- in a SourceText on the relevant pragma item. AnnOpen :: AnnKeywordId -- | '(|' AnnOpenB :: AnnKeywordId -- | '(|', unicode variant AnnOpenBU :: AnnKeywordId -- | '{' AnnOpenC :: AnnKeywordId -- | '[e|' or '[e||' AnnOpenE :: AnnKeywordId -- | '[|' AnnOpenEQ :: AnnKeywordId -- | '[|', unicode variant AnnOpenEQU :: AnnKeywordId -- | '(' AnnOpenP :: AnnKeywordId -- | '[' AnnOpenS :: AnnKeywordId -- | '(#' AnnOpenPH :: AnnKeywordId -- | prefix $ -- TemplateHaskell AnnDollar :: AnnKeywordId -- | prefix $$ -- TemplateHaskell AnnDollarDollar :: AnnKeywordId AnnPackageName :: AnnKeywordId AnnPattern :: AnnKeywordId -- | % -- for HsExplicitMult AnnPercent :: AnnKeywordId -- | '%1' -- for HsLinearArrow AnnPercentOne :: AnnKeywordId AnnProc :: AnnKeywordId AnnQualified :: AnnKeywordId -- | -> AnnRarrow :: AnnKeywordId -- | ->, unicode variant AnnRarrowU :: AnnKeywordId AnnRec :: AnnKeywordId AnnRole :: AnnKeywordId AnnSafe :: AnnKeywordId -- | ';' AnnSemi :: AnnKeywordId -- | ''' AnnSimpleQuote :: AnnKeywordId AnnSignature :: AnnKeywordId -- | static AnnStatic :: AnnKeywordId AnnStock :: AnnKeywordId AnnThen :: AnnKeywordId -- | double ''' AnnThTyQuote :: AnnKeywordId -- | '~' AnnTilde :: AnnKeywordId AnnType :: AnnKeywordId -- | () for types AnnUnit :: AnnKeywordId AnnUsing :: AnnKeywordId -- | e.g. INTEGER AnnVal :: AnnKeywordId -- | String value, will need quotes when output AnnValStr :: AnnKeywordId -- | '|' AnnVbar :: AnnKeywordId -- | via AnnVia :: AnnKeywordId AnnWhere :: AnnKeywordId -- | -< Annlarrowtail :: AnnKeywordId -- | -<, unicode variant AnnlarrowtailU :: AnnKeywordId -- | -> Annrarrowtail :: AnnKeywordId -- | ->, unicode variant AnnrarrowtailU :: AnnKeywordId -- | -<< AnnLarrowtail :: AnnKeywordId -- | -<<, unicode variant AnnLarrowtailU :: AnnKeywordId -- | >>- AnnRarrowtail :: AnnKeywordId -- | >>-, unicode variant AnnRarrowtailU :: AnnKeywordId data EpaComment EpaComment :: EpaCommentTok -> RealSrcSpan -> EpaComment [ac_tok] :: EpaComment -> EpaCommentTok -- | The location of the prior token, used in exact printing. The -- EpaComment appears as an LEpaComment containing its -- location. The difference between the end of the prior token and the -- start of this location is used for the spacing when exact printing the -- comment. [ac_prior_tok] :: EpaComment -> RealSrcSpan cyclicModuleErr :: [ModuleGraphNode] -> SDoc instance GHC.Show.Show GHC.GhcApiError instance GHC.Exception.Type.Exception GHC.GhcApiError instance GHC.DesugaredMod GHC.DesugaredModule instance GHC.TypecheckedMod GHC.TypecheckedModule instance GHC.TypecheckedMod GHC.DesugaredModule instance GHC.ParsedMod GHC.DesugaredModule instance GHC.ParsedMod GHC.TypecheckedModule instance GHC.Utils.Outputable.Outputable GHC.CoreModule instance GHC.ParsedMod GHC.ParsedModule module GHC.Runtime.Debugger -- | The :print & friends commands pprintClosureCommand :: GhcMonad m => Bool -> Bool -> String -> m () showTerm :: GhcMonad m => Term -> m SDoc pprTypeAndContents :: GhcMonad m => Id -> m SDoc module GHC.Driver.MakeFile doMkDependHS :: GhcMonad m => [FilePath] -> m () -- | This is the driver for the 'ghc --backpack' mode, which is a -- reimplementation of the "package manager" bits of Backpack directly in -- GHC. The basic method of operation is to compile packages and then -- directly insert them into GHC's in memory database. -- -- The compilation products of this mode aren't really suitable for -- Cabal, because GHC makes up component IDs for the things it builds and -- doesn't serialize out the database contents. But it's still handy for -- constructing tests. module GHC.Driver.Backpack -- | Entry point to compile a Backpack file. doBackpack :: [FilePath] -> Ghc () instance GHC.Classes.Eq GHC.Driver.Backpack.SessionType instance GHC.Driver.Session.HasDynFlags GHC.Driver.Backpack.BkpM instance GHC.Utils.Logger.HasLogger GHC.Driver.Backpack.BkpM instance GHC.Driver.Monad.GhcMonad GHC.Driver.Backpack.BkpM -- | A lazy state monad. module GHC.Utils.Monad.State.Lazy -- | A state monad which is lazy in the state. data State s a pattern State :: (s -> (# a, s #)) -> State s a state :: (s -> (a, s)) -> State s a evalState :: State s a -> s -> a execState :: State s a -> s -> s runState :: State s a -> s -> (a, s) get :: State s s gets :: (s -> a) -> State s a put :: s -> State s () modify :: (s -> s) -> State s () instance GHC.Base.Functor (GHC.Utils.Monad.State.Lazy.State s) instance GHC.Base.Applicative (GHC.Utils.Monad.State.Lazy.State s) instance GHC.Base.Monad (GHC.Utils.Monad.State.Lazy.State s) -- | Create real byte-code objects from ResolvedBCOs. module GHCi.CreateBCO createBCOs :: [ResolvedBCO] -> IO [HValueRef] -- | Run-time info table support. This module provides support for creating -- and reading info tables in the running program. We use the RTS -- data structures directly via hsc2hs. module GHCi.InfoTable mkConInfoTable :: Bool -> Int -> Int -> Int -> Int -> ByteString -> IO (Ptr StgInfoTable) -- | Primarily, this module consists of an interface to the C-land dynamic -- linker. module GHCi.ObjLink initObjLinker :: ShouldRetainCAFs -> IO () data ShouldRetainCAFs -- | Retain CAFs unconditionally in linked Haskell code. Note that this -- prevents any code from being unloaded. It should not be necessary -- unless you are GHCi or hs-plugins, which needs to be able call any -- function in the compiled code. RetainCAFs :: ShouldRetainCAFs -- | Do not retain CAFs. Everything reachable from foreign exports will be -- retained, due to the StablePtrs created by the module initialisation -- code. unloadObj frees these StablePtrs, which will allow the CAFs to -- be GC'd and the code to be removed. DontRetainCAFs :: ShouldRetainCAFs -- | loadDLL loads a dynamic library using the OS's native linker (i.e. -- dlopen() on Unix, LoadLibrary() on Windows). It takes either an -- absolute pathname to the file, or a relative filename (e.g. -- "libfoo.so" or "foo.dll"). In the latter case, loadDLL searches the -- standard locations for the appropriate library. loadDLL :: String -> IO (Maybe String) loadArchive :: String -> IO () loadObj :: String -> IO () -- | unloadObj drops the given dynamic library from the symbol -- table as well as enables the library to be removed from memory during -- a future major GC. unloadObj :: String -> IO () -- | purgeObj drops the symbols for the dynamic library from the -- symbol table. Unlike unloadObj, the library will not be dropped -- memory during a future major GC. purgeObj :: String -> IO () lookupSymbol :: String -> IO (Maybe (Ptr a)) lookupClosure :: String -> IO (Maybe HValueRef) resolveObjs :: IO Bool addLibrarySearchPath :: String -> IO (Ptr ()) removeLibrarySearchPath :: Ptr () -> IO Bool findSystemLibrary :: String -> IO (Maybe String) module GHCi.Signals -- | Install standard signal handlers for catching ^C, which just throw an -- exception in the target thread. The current target thread is the -- thread at the head of the list in the MVar passed to -- installSignalHandlers. installSignalHandlers :: IO () module GHCi.StaticPtrTable -- | Used by GHCi to add an SPT entry for a set of interactive bindings. sptAddEntry :: Fingerprint -> HValue -> IO () -- | Running TH splices module GHCi.TH -- | The implementation of the StartTH message: create a new IORef -- QState, and return a RemoteRef to it. startTH :: IO (RemoteRef (IORef QState)) -- | Runs the mod finalizers. -- -- The references must be created on the caller process. runModFinalizerRefs :: Pipe -> RemoteRef (IORef QState) -> [RemoteRef (Q ())] -> IO () -- | The implementation of the RunTH message runTH :: Pipe -> RemoteRef (IORef QState) -> HValueRef -> THResultType -> Maybe Loc -> IO ByteString -- | The exception thrown by "fail" in the GHCiQ monad data GHCiQException GHCiQException :: QState -> String -> GHCiQException instance GHC.Show.Show GHCi.TH.GHCiQException instance GHC.Exception.Type.Exception GHCi.TH.GHCiQException instance Control.Monad.Fail.MonadFail GHCi.TH.GHCiQ instance Language.Haskell.TH.Syntax.Quasi GHCi.TH.GHCiQ instance GHC.Base.Functor GHCi.TH.GHCiQ instance GHC.Base.Applicative GHCi.TH.GHCiQ instance GHC.Base.Monad GHCi.TH.GHCiQ instance Control.Monad.IO.Class.MonadIO GHCi.TH.GHCiQ -- | Execute GHCi messages. -- -- For details on Remote GHCi, see Note [Remote GHCi] in -- compilerGHCRuntime/Interpreter.hs. module GHCi.Run run :: Message a -> IO a redirectInterrupts :: ThreadId -> IO a -> IO a -- | This module exists to work nicely with the QualifiedDo extension. -- --
--   import qualified Language.Haskell.TH.CodeDo as Code
--   
--   myExample :: Monad m => Code m a -> Code m a -> Code m a
--   myExample opt1 opt2 =
--     Code.do
--      x <- someSideEffect               -- This one is of type `M Bool`
--      if x then opt1 else opt2
--   
module Language.Haskell.TH.CodeDo -- | Module over monad operator for Code (>>=) :: Monad m => m a -> (a -> Code m b) -> Code m b (>>) :: Monad m => m a -> Code m b -> Code m b -- | Template Haskell supports quasiquoting, which permits users to -- construct program fragments by directly writing concrete syntax. A -- quasiquoter is essentially a function with takes a string to a -- Template Haskell AST. This module defines the QuasiQuoter -- datatype, which specifies a quasiquoter q which can be -- invoked using the syntax [q| ... string to parse ... |] when -- the QuasiQuotes language extension is enabled, and some -- utility functions for manipulating quasiquoters. Nota bene: this -- package does not define any parsers, that is up to you. module Language.Haskell.TH.Quote -- | The QuasiQuoter type, a value q of this type can be -- used in the syntax [q| ... string to parse ...|]. In fact, -- for convenience, a QuasiQuoter actually defines multiple -- quasiquoters to be used in different splice contexts; if you are only -- interested in defining a quasiquoter to be used for expressions, you -- would define a QuasiQuoter with only quoteExp, and leave -- the other fields stubbed out with errors. data QuasiQuoter QuasiQuoter :: (String -> Q Exp) -> (String -> Q Pat) -> (String -> Q Type) -> (String -> Q [Dec]) -> QuasiQuoter -- | Quasi-quoter for expressions, invoked by quotes like lhs = -- $[q|...] [quoteExp] :: QuasiQuoter -> String -> Q Exp -- | Quasi-quoter for patterns, invoked by quotes like f $[q|...] = -- rhs [quotePat] :: QuasiQuoter -> String -> Q Pat -- | Quasi-quoter for types, invoked by quotes like f :: $[q|...] [quoteType] :: QuasiQuoter -> String -> Q Type -- | Quasi-quoter for declarations, invoked by top-level quotes [quoteDec] :: QuasiQuoter -> String -> Q [Dec] -- | quoteFile takes a QuasiQuoter and lifts it into one that -- read the data out of a file. For example, suppose asmq is an -- assembly-language quoter, so that you can write [asmq| ld r1, r2 |] as -- an expression. Then if you define asmq_f = quoteFile asmq, -- then the quote [asmq_f|foo.s|] will take input from file -- "foo.s" instead of the inline text quoteFile :: QuasiQuoter -> QuasiQuoter -- | dataToQa is an internal utility function for constructing -- generic conversion functions from types with Data instances to -- various quasi-quoting representations. See the source of -- dataToExpQ and dataToPatQ for two example usages: -- mkCon, mkLit and appQ are overloadable to -- account for different syntax for expressions and patterns; -- antiQ allows you to override type-specific cases, a common -- usage is just const Nothing, which results in no overloading. dataToQa :: (Quote m, Data a) => (Name -> k) -> (Lit -> m q) -> (k -> [m q] -> m q) -> (forall b. Data b => b -> Maybe (m q)) -> a -> m q -- | dataToExpQ converts a value to a Exp representation of -- the same value, in the SYB style. It is generalized to take a function -- override type-specific cases; see liftData for a more commonly -- used variant. dataToExpQ :: (Quote m, Data a) => (forall b. Data b => b -> Maybe (m Exp)) -> a -> m Exp -- | dataToPatQ converts a value to a Pat representation of -- the same value, in the SYB style. It takes a function to handle -- type-specific cases, alternatively, pass const Nothing to get -- default behavior. dataToPatQ :: (Quote m, Data a) => (forall b. Data b => b -> Maybe (m Pat)) -> a -> m Pat module Paths_ghc_lib version :: Version getBinDir :: IO FilePath getLibDir :: IO FilePath getDynLibDir :: IO FilePath getDataDir :: IO FilePath getLibexecDir :: IO FilePath getDataFileName :: FilePath -> IO FilePath getSysconfDir :: IO FilePath