Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Optimizer for typed instructions.
It's quite experimental and incomplete.
Synopsis
- optimize :: Instr inp out -> Instr inp out
- optimizeWithConf :: OptimizerConf -> Instr inp out -> Instr inp out
- optimizeVerboseWithConf :: OptimizerConf -> Instr inp out -> ([OptimizerStageStats], Instr inp out)
- defaultOptimizerConf :: OptimizerConf
- defaultRules :: Ruleset
- defaultRulesAndPushPack :: Ruleset
- newtype Rule = Rule {}
- data OptimizerConf = OptimizerConf {}
- ocGotoValuesL :: Lens' OptimizerConf Bool
- data OptimizationStage
- data Ruleset
- rulesAtPrio :: OptimizationStage -> Ruleset -> [Rule]
- insertRuleAtPrio :: OptimizationStage -> Rule -> Ruleset -> Ruleset
- clearRulesAtPrio :: OptimizationStage -> Ruleset -> Ruleset
- alterRulesAtPrio :: ([Rule] -> [Rule]) -> OptimizationStage -> Ruleset -> Ruleset
- data OptimizerStageStats = OptimizerStageStats {}
Documentation
optimize :: Instr inp out -> Instr inp out Source #
Optimize a typed instruction by replacing some sequences of instructions with smaller equivalent sequences. Applies default set of rewrite rules.
optimizeWithConf :: OptimizerConf -> Instr inp out -> Instr inp out Source #
Optimize a typed instruction using a custom set of rules. The set is divided into several stages, as applying some rules can prevent others to be performed.
If any stage resulted in optimizations, we apply it again until we reach
fixpoint, but no more than ocMaxIterations
times.
optimizeVerboseWithConf :: OptimizerConf -> Instr inp out -> ([OptimizerStageStats], Instr inp out) Source #
Returns some optimizer statistics in addition to optimized instruction. Mostly useful for testing and debugging.
defaultOptimizerConf :: OptimizerConf Source #
Default config - all commonly useful rules will be applied to all the code.
defaultRules :: Ruleset Source #
Default optimization rules.
defaultRulesAndPushPack :: Ruleset Source #
We do not enable pushPack
rule by default because it is potentially
dangerous. There are various code processing functions that may depend on
constants, e. g. string transformations.
data OptimizerConf Source #
Instances
Default OptimizerConf Source # | |
Defined in Morley.Michelson.Optimizer def :: OptimizerConf # |
Ruleset manipulation
data OptimizationStage Source #
Optimization stages. Stages are run in first to last order, each stage has
an Int
argument, which allows splitting each stage into sub-stages, which
will run lowest index to highest. All default rules use sub-stage 0
.
OptimizationStagePrepare Int | |
OptimizationStageMain Int | Main optimisation stage, except rules that would interfere with other rules. |
OptimizationStageMainExtended Int | All main stage rules. |
OptimizationStageFixup Int | Post main stage fixups. |
OptimizationStageRollAdjacent Int | Main stage rules unroll |
Instances
Eq OptimizationStage Source # | |
Defined in Morley.Michelson.Optimizer.Internal.Ruleset (==) :: OptimizationStage -> OptimizationStage -> Bool # (/=) :: OptimizationStage -> OptimizationStage -> Bool # | |
Ord OptimizationStage Source # | |
Defined in Morley.Michelson.Optimizer.Internal.Ruleset compare :: OptimizationStage -> OptimizationStage -> Ordering # (<) :: OptimizationStage -> OptimizationStage -> Bool # (<=) :: OptimizationStage -> OptimizationStage -> Bool # (>) :: OptimizationStage -> OptimizationStage -> Bool # (>=) :: OptimizationStage -> OptimizationStage -> Bool # max :: OptimizationStage -> OptimizationStage -> OptimizationStage # min :: OptimizationStage -> OptimizationStage -> OptimizationStage # | |
Buildable OptimizationStage Source # | |
Defined in Morley.Michelson.Optimizer.Internal.Ruleset build :: OptimizationStage -> Doc buildList :: [OptimizationStage] -> Doc |
A set of optimization stages. Rules at the same sub-stage are applied in
arbitrary order. See OptimizationStage
for explanation of sub-stages.
Default
ruleset is empty.
rulesAtPrio :: OptimizationStage -> Ruleset -> [Rule] Source #
Get rules for a given priority as a list.
insertRuleAtPrio :: OptimizationStage -> Rule -> Ruleset -> Ruleset Source #
Insert a single rule at a given priority without touching other rules.
clearRulesAtPrio :: OptimizationStage -> Ruleset -> Ruleset Source #
Remove the stage with the given priority.
alterRulesAtPrio :: ([Rule] -> [Rule]) -> OptimizationStage -> Ruleset -> Ruleset Source #
Alter all stage rules for a given priority.
data OptimizerStageStats Source #
Instances
Buildable OptimizerStageStats Source # | |
Defined in Morley.Michelson.Optimizer build :: OptimizerStageStats -> Doc buildList :: [OptimizerStageStats] -> Doc |