Safe Haskell | None |
---|
CoreMonad
Contents
- data CoreToDo
- = CoreDoSimplify Int SimplifierMode
- | CoreDoPluginPass String PluginPass
- | CoreDoFloatInwards
- | CoreDoFloatOutwards FloatOutSwitches
- | CoreLiberateCase
- | CoreDoPrintCore
- | CoreDoStaticArgs
- | CoreDoStrictness
- | CoreDoWorkerWrapper
- | CoreDoSpecialising
- | CoreDoSpecConstr
- | CoreCSE
- | CoreDoRuleCheck CompilerPhase String
- | CoreDoVectorisation
- | CoreDoNothing
- | CoreDoPasses [CoreToDo]
- | CoreDesugar
- | CoreDesugarOpt
- | CoreTidy
- | CorePrep
- runWhen :: Bool -> CoreToDo -> CoreToDo
- runMaybe :: Maybe a -> (a -> CoreToDo) -> CoreToDo
- data SimplifierMode = SimplMode {
- sm_names :: [String]
- sm_phase :: CompilerPhase
- sm_rules :: Bool
- sm_inline :: Bool
- sm_case_case :: Bool
- sm_eta_expand :: Bool
- data FloatOutSwitches = FloatOutSwitches {}
- dumpSimplPhase :: DynFlags -> SimplifierMode -> Bool
- pprPassDetails :: CoreToDo -> SDoc
- type PluginPass = ModGuts -> CoreM ModGuts
- data Plugin = Plugin {
- installCoreToDos :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo]
- type CommandLineOption = String
- defaultPlugin :: Plugin
- bindsOnlyPass :: (CoreProgram -> CoreM CoreProgram) -> ModGuts -> CoreM ModGuts
- data SimplCount
- doSimplTick :: Tick -> SimplCount -> SimplCount
- doFreeSimplTick :: Tick -> SimplCount -> SimplCount
- simplCountN :: SimplCount -> Int
- pprSimplCount :: SimplCount -> SDoc
- plusSimplCount :: SimplCount -> SimplCount -> SimplCount
- zeroSimplCount :: DynFlags -> SimplCount
- isZeroSimplCount :: SimplCount -> Bool
- hasDetailedCounts :: SimplCount -> Bool
- data Tick
- = PreInlineUnconditionally Id
- | PostInlineUnconditionally Id
- | UnfoldingDone Id
- | RuleFired FastString
- | LetFloatFromLet
- | EtaExpansion Id
- | EtaReduction Id
- | BetaReduction Id
- | CaseOfCase Id
- | KnownBranch Id
- | CaseMerge Id
- | AltMerge Id
- | CaseElim Id
- | CaseIdentity Id
- | FillInCaseDefault Id
- | BottomFound
- | SimplifierDone
- data CoreM a
- runCoreM :: HscEnv -> RuleBase -> UniqSupply -> Module -> CoreM a -> IO (a, SimplCount)
- getHscEnv :: CoreM HscEnv
- getRuleBase :: CoreM RuleBase
- getModule :: CoreM Module
- getDynFlags :: HasDynFlags m => m DynFlags
- getOrigNameCache :: CoreM OrigNameCache
- addSimplCount :: SimplCount -> CoreM ()
- liftIO :: MonadIO m => IO a -> m a
- liftIOWithCount :: IO (SimplCount, a) -> CoreM a
- liftIO1 :: MonadIO m => (a -> IO b) -> a -> m b
- liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c
- liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m d
- liftIO4 :: MonadIO m => (a -> b -> c -> d -> IO e) -> a -> b -> c -> d -> m e
- reinitializeGlobals :: CoreM ()
- getAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM [a])
- getFirstAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM a)
- showPass :: DynFlags -> CoreToDo -> IO ()
- endPass :: DynFlags -> CoreToDo -> CoreProgram -> [CoreRule] -> IO ()
- dumpPassResult :: DynFlags -> Maybe DynFlag -> SDoc -> SDoc -> CoreProgram -> [CoreRule] -> IO ()
- lintPassResult :: DynFlags -> CoreToDo -> CoreProgram -> IO ()
- dumpIfSet :: DynFlags -> Bool -> CoreToDo -> SDoc -> SDoc -> IO ()
- putMsg :: SDoc -> CoreM ()
- putMsgS :: String -> CoreM ()
- errorMsg :: SDoc -> CoreM ()
- errorMsgS :: String -> CoreM ()
- fatalErrorMsg :: SDoc -> CoreM ()
- fatalErrorMsgS :: String -> CoreM ()
- debugTraceMsg :: SDoc -> CoreM ()
- debugTraceMsgS :: String -> CoreM ()
- dumpIfSet_dyn :: DynFlag -> String -> SDoc -> CoreM ()
Configuration of the core-to-core passes
Constructors
Instances
data SimplifierMode Source
Constructors
SimplMode | |
Fields
|
Instances
data FloatOutSwitches Source
Constructors
FloatOutSwitches | |
Fields
|
Instances
dumpSimplPhase :: DynFlags -> SimplifierMode -> BoolSource
pprPassDetails :: CoreToDo -> SDocSource
Plugins
type PluginPass = ModGuts -> CoreM ModGutsSource
A description of the plugin pass itself
Plugin
is the core compiler plugin data type. Try to avoid
constructing one of these directly, and just modify some fields of
defaultPlugin
instead: this is to try and preserve source-code
compatability when we add fields to this.
Nonetheless, this API is preliminary and highly likely to change in the future.
Constructors
Plugin | |
Fields
|
type CommandLineOption = StringSource
Command line options gathered from the -PModule.Name:stuff syntax are given to you as this type
Default plugin: does nothing at all! For compatability reasons you should base all your plugin definitions on this default value.
bindsOnlyPass :: (CoreProgram -> CoreM CoreProgram) -> ModGuts -> CoreM ModGutsSource
Counting
data SimplCount Source
doSimplTick :: Tick -> SimplCount -> SimplCountSource
doFreeSimplTick :: Tick -> SimplCount -> SimplCountSource
simplCountN :: SimplCount -> IntSource
Constructors
The monad
The monad used by Core-to-Core passes to access common state, register simplification statistics and so on
runCoreM :: HscEnv -> RuleBase -> UniqSupply -> Module -> CoreM a -> IO (a, SimplCount)Source
Reading from the monad
getDynFlags :: HasDynFlags m => m DynFlagsSource
getOrigNameCache :: CoreM OrigNameCacheSource
The original name cache is the current mapping from Module
and
OccName
to a compiler-wide unique Name
Writing to the monad
addSimplCount :: SimplCount -> CoreM ()Source
Lifting into the monad
liftIOWithCount :: IO (SimplCount, a) -> CoreM aSource
Lift an IO
operation into CoreM
while consuming its SimplCount
liftIO1 :: MonadIO m => (a -> IO b) -> a -> m bSource
Lift an IO
operation with 1 argument into another monad
liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m cSource
Lift an IO
operation with 2 arguments into another monad
liftIO3 :: MonadIO m => (a -> b -> c -> IO d) -> a -> b -> c -> m dSource
Lift an IO
operation with 3 arguments into another monad
liftIO4 :: MonadIO m => (a -> b -> c -> d -> IO e) -> a -> b -> c -> d -> m eSource
Lift an IO
operation with 4 arguments into another monad
Global initialization
Dealing with annotations
getAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM [a])Source
Get all annotations of a given type. This happens lazily, that is no deserialization will take place until the [a] is actually demanded and the [a] can also be empty (the UniqFM is not filtered).
This should be done once at the start of a Core-to-Core pass that uses annotations.
See Note [Annotations]
getFirstAnnotations :: Typeable a => ([Word8] -> a) -> ModGuts -> CoreM (UniqFM a)Source
Get at most one annotation of a given type per Unique.
Debug output
dumpPassResult :: DynFlags -> Maybe DynFlag -> SDoc -> SDoc -> CoreProgram -> [CoreRule] -> IO ()Source
lintPassResult :: DynFlags -> CoreToDo -> CoreProgram -> IO ()Source
Screen output
fatalErrorMsg :: SDoc -> CoreM ()Source
Output a fatal error to the screen. Note this does not by itself cause the compiler to die
fatalErrorMsgS :: String -> CoreM ()Source
Output a fatal string error to the screen. Note this does not by itself cause the compiler to die
debugTraceMsg :: SDoc -> CoreM ()Source
Outputs a debugging message at verbosity level of -v
or higher
debugTraceMsgS :: String -> CoreM ()Source
Output a string debugging message at verbosity level of -v
or higher