Class SSA


  • public class SSA
    extends Object
    Main entry point for SSA-form IR operations.
    • Constructor Detail

      • SSA

        public SSA​(ConstPool constPool)
        Creates a new SSA processor.
        Parameters:
        constPool - the constant pool for the class being processed
    • Method Detail

      • getConstPool

        public ConstPool getConstPool()
        Gets the constant pool associated with this SSA processor.
        Returns:
        the constant pool
      • withExceptionLocalResolution

        public SSA withExceptionLocalResolution()
        Enables exception-local resolution during lifting.
        Returns:
        this for fluent chaining
      • withoutLocalVariableTable

        public SSA withoutLocalVariableTable()
        Disables LocalVariableTable emission when lowering back to bytecode.
        Returns:
        this for fluent chaining
      • lift

        public IRMethod lift​(MethodEntry method)
        Lifts a method from bytecode to SSA-form IR.
        Parameters:
        method - the method to lift
        Returns:
        the SSA-form IR representation
      • lower

        public void lower​(IRMethod irMethod,
                          MethodEntry targetMethod)
        Lowers an SSA-form IR method back to bytecode.
        Parameters:
        irMethod - the IR method to lower
        targetMethod - the target method to write bytecode into
      • toLlvm

        public String toLlvm​(IRMethod irMethod)
        Lowers an SSA-form IR method to textual LLVM IR (computational subset).
        Parameters:
        irMethod - the IR method to lower
        Returns:
        the LLVM IR module text
      • addTransform

        public SSA addTransform​(IRTransform transform)
        Adds an optimization transform to be applied.
        Parameters:
        transform - the transform to add
        Returns:
        this SSA instance for chaining
      • withDeadCodeElimination

        public SSA withDeadCodeElimination()
        Enables dead code elimination optimization.
        Returns:
        this SSA instance for chaining
      • withCopyPropagation

        public SSA withCopyPropagation()
        Enables copy propagation optimization.
        Returns:
        this SSA instance for chaining
      • withConstantFolding

        public SSA withConstantFolding()
        Enables constant folding optimization.
        Returns:
        this SSA instance for chaining
      • withStrengthReduction

        public SSA withStrengthReduction()
        Enables strength reduction optimization.
        Returns:
        this SSA instance for chaining
      • withAlgebraicSimplification

        public SSA withAlgebraicSimplification()
        Enables algebraic simplification optimization.
        Returns:
        this SSA instance for chaining
      • withReassociate

        public SSA withReassociate()
        Enables reassociation optimization.
        Returns:
        this SSA instance for chaining
      • withPhiConstantPropagation

        public SSA withPhiConstantPropagation()
        Enables phi constant propagation optimization.
        Returns:
        this SSA instance for chaining
      • withPeepholeOptimizations

        public SSA withPeepholeOptimizations()
        Enables peephole optimizations.
        Returns:
        this SSA instance for chaining
      • withCommonSubexpressionElimination

        public SSA withCommonSubexpressionElimination()
        Enables common subexpression elimination.
        Returns:
        this SSA instance for chaining
      • withNullCheckElimination

        public SSA withNullCheckElimination()
        Enables null check elimination optimization.
        Returns:
        this SSA instance for chaining
      • withConditionalConstantPropagation

        public SSA withConditionalConstantPropagation()
        Enables conditional constant propagation optimization.
        Returns:
        this SSA instance for chaining
      • withLoopInvariantCodeMotion

        public SSA withLoopInvariantCodeMotion()
        Enables loop-invariant code motion optimization.
        Returns:
        this SSA instance for chaining
      • withLoopPredication

        public SSA withLoopPredication()
        Enables loop predication optimization.
        Returns:
        this SSA instance for chaining
      • withJumpThreading

        public SSA withJumpThreading()
        Enables jump threading optimization.
        Returns:
        this SSA instance for chaining
      • withBlockMerging

        public SSA withBlockMerging()
        Enables block merging optimization.
        Returns:
        this SSA instance for chaining
      • withControlFlowReducibility

        public SSA withControlFlowReducibility()
        Enables control flow reducibility transformation.
        Returns:
        this SSA instance for chaining
      • withDuplicateBlockMerging

        public SSA withDuplicateBlockMerging()
        Enables duplicate block merging optimization.
        Returns:
        this SSA instance for chaining
      • withDuplicateBlockMerging

        public SSA withDuplicateBlockMerging​(boolean aggressive)
        Enables duplicate block merging optimization with configurable aggression.
        Parameters:
        aggressive - true for aggressive merging, false for conservative
        Returns:
        this SSA instance for chaining
      • withRedundantCopyElimination

        public SSA withRedundantCopyElimination()
        Enables redundant copy elimination optimization.
        Returns:
        this SSA instance for chaining
      • withBitTrackingDCE

        public SSA withBitTrackingDCE()
        Enables bit-tracking dead code elimination.
        Returns:
        this SSA instance for chaining
      • withCorrelatedValuePropagation

        public SSA withCorrelatedValuePropagation()
        Enables correlated value propagation optimization.
        Returns:
        this SSA instance for chaining
      • addClassTransform

        public SSA addClassTransform​(ClassTransform transform)
        Adds a class-level transform to be applied.
        Parameters:
        transform - the class transform to add
        Returns:
        this SSA instance for chaining
      • withMethodInlining

        public SSA withMethodInlining()
        Enables method inlining optimization.
        Returns:
        this SSA instance for chaining
      • withDeadMethodElimination

        public SSA withDeadMethodElimination()
        Enables dead method elimination.
        Returns:
        this SSA instance for chaining
      • withStandardOptimizations

        public SSA withStandardOptimizations()
        Enables the standard set of optimizations.
        Returns:
        this SSA instance for chaining
      • withAllOptimizations

        public SSA withAllOptimizations()
        Enables all available optimizations.
        Returns:
        this SSA instance for chaining
      • runTransforms

        public void runTransforms​(IRMethod method)
        Runs all registered transforms on a method until a fixed point is reached.
        Parameters:
        method - the method to optimize
      • computeDominators

        public DominatorTree computeDominators​(IRMethod method)
        Computes the dominator tree for a method.
        Parameters:
        method - the method to analyze
        Returns:
        the computed dominator tree
      • computeLiveness

        public LivenessAnalysis computeLiveness​(IRMethod method)
        Computes liveness information for a method.
        Parameters:
        method - the method to analyze
        Returns:
        the computed liveness analysis
      • computeDefUse

        public DefUseChains computeDefUse​(IRMethod method)
        Computes def-use chains for a method.
        Parameters:
        method - the method to analyze
        Returns:
        the computed def-use chains
      • computeLoops

        public LoopAnalysis computeLoops​(IRMethod method)
        Computes loop information for a method.
        Parameters:
        method - the method to analyze
        Returns:
        the computed loop analysis
      • liftAndOptimize

        public IRMethod liftAndOptimize​(MethodEntry method)
        Lifts a method to SSA form and applies all registered optimizations.
        Parameters:
        method - the method to lift and optimize
        Returns:
        the optimized IR method
      • optimizeAndLower

        public void optimizeAndLower​(IRMethod irMethod,
                                     MethodEntry targetMethod)
        Optimizes an IR method and lowers it back to bytecode.
        Parameters:
        irMethod - the IR method to optimize
        targetMethod - the target method to write bytecode into
      • transform

        public void transform​(MethodEntry method)
        Performs a complete transformation: lift, optimize, and lower.
        Parameters:
        method - the method to transform
      • runClassTransforms

        public boolean runClassTransforms​(ClassFile classFile)
        Runs all registered class-level transforms on a class file.
        Parameters:
        classFile - the class file to transform
        Returns:
        true if any transform modified the class
      • transformClass

        public void transformClass​(ClassFile classFile)
        Transforms an entire class file with all registered transforms.
        Parameters:
        classFile - the class file to transform
      • getClassTransforms

        public List<ClassTransform> getClassTransforms()
        Gets the list of registered class-level transforms.
        Returns:
        unmodifiable list of class transforms