Class AbstractEExpressionOptimizer

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

public abstract class AbstractEExpressionOptimizer extends AbstractEOptimizer
Skeleton for a top-down, recursive, IEGeneric optimizer. Expressions are provided in depth-first, pre-order way: parent expressions are provided before their constituting children.

By default, IEStatements are not candidates for optimization (although they can be). Generally, IEStatements should be optimized via the use an AbstractEStatementOptimizer.

  • Field Details

    • skipStatementProcessing

      protected boolean skipStatementProcessing
      Optimize only the constituents of the IRE statements, not the statements themselves.
      Default value: true.
    • skipLeftSideOfAssignment

      protected boolean skipLeftSideOfAssignment
      Do not process left-side of statement. Exception: If the left-side is an IEMem, the memory reference is processed.
      Default value: false.
    • currentStatement

      protected IEStatement currentStatement
      This field holds a reference to the top-level parent statement of the expression currently being optimized.
  • Constructor Details

  • Method Details

    • 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
    • optimizeExpression

      protected abstract AbstractEExpressionOptimizer.EOR optimizeExpression(IEGeneric e)
      Attempt to optimize expressions. Sub-expressions may be examined. The implementor should not attempt to modify parent or cousins expressions.
      Parameters:
      e - IRE
      Returns:
      the new (optimized) expression as well as DFA update hints, or null if the expression could not be optimized
    • doSubstitution

      protected IEGeneric doSubstitution(IEGeneric e, SubstitutionDefinition... substitutions)
      Attempt to apply the first matching SubstitutionDefinition on an IEGeneric expression.
      Parameters:
      e - the target expression to be matched and modified
      substitutions - a list of candidate substitutions
      Returns:
      null if no substitution was performed, else the new expression