morley-1.20.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Michelson.Optimizer.Internal.Ruleset

Description

Optimizer rule and ruleset definitions.

Synopsis

Documentation

newtype Rule Source #

Type of a single rewrite rule, wrapped in `newtype`. It takes an instruction and tries to optimize its head (first few instructions). If optimization succeeds, it returns Just the optimized instruction, otherwise it returns Nothing.

Constructors

Rule 

Fields

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.

Constructors

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 DROP n, PAIR n, etc into their primitive counterparts to simplify some optimisations. This stages coalesces them back.

newtype Ruleset Source #

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.