Class AbstractEPatternOptimizer

All Implemented Interfaces:
IPlugin, IEOptimizer, IOptimizer<IERoutineContext>

public abstract class AbstractEPatternOptimizer extends AbstractEOptimizer
Pattern-Matcher-Replacer optimizers run with the policy DataChainsUpdatePolicy.UPDATE_IF_OPTIMIZED or DataChainsUpdatePolicy.UPDATE_IF_REQUIRED.
  • Constructor Details

    • AbstractEPatternOptimizer

      public AbstractEPatternOptimizer()
      Create a default matcher with a IF_OPTIMIZED policy.
    • AbstractEPatternOptimizer

      public AbstractEPatternOptimizer(boolean updateChainsIfOptimized)
      Create a matcher.
      Parameters:
      updateChainsIfOptimized - if true, the DFA update policy is set to IF_OPTIMIZED; else, it is set to IF_REQUIRED and the requirement comes from a successful match-and-replace on a pattern having the EPatternCompiler.FLAG_INVALIDATE_DFA flag.
  • Method Details

    • getPatterns

      protected abstract Collection<EPatternCompiler.EPattern> getPatterns()
    • perform

      protected int perform()
      Description copied from class: AbstractEOptimizer
      Perform the optimization pass. The caller may request that data chains not be updated, whenever possible. (They may be updated internally by the optimizer, which has the final say as to how and when DFA calculations should be run.)

      The above means that data chains after running this method may or may not have been modified, and may or may not be in a consistent state with the optimized CFG.

      Specified by:
      perform in class AbstractEOptimizer
      Returns:
      the result of a call to one of postPerform(...) or a negative number indicating an error has occurred and the optimizing process should be aborted
    • performOnExpression

      public IEGeneric performOnExpression(IEGeneric exp, IERoutineContext ectx)
      Description copied from class: AbstractEOptimizer
      The default implementation does nothing and returns null.
      Specified by:
      performOnExpression in interface IEOptimizer
      Overrides:
      performOnExpression in class AbstractEOptimizer
      Parameters:
      exp - IR expression to optimize
      ectx - helper routine context
      Returns:
      non-null if the expression was optimized; null otherwise