Class LoopConditionUnroller


  • public class LoopConditionUnroller
    extends BodyTransformer
    "unrolls" the condition of while/for loops.
    before the first test of a while-loop, we can't be sure, if the body will be taken or not, and several optimizations (especially LCM) can't be done. In this class we try to solve this problem by unrolling the condition of the while-block: we make a copy of the condition-block, and redirect the back-edge of the while-loop to the new block.
    After this transformation the edge between the original condition-block and the loop-body is only executed once (and hence suitable for LCM) and we can be sure, that the loop-body will get executed.
    Exceptions are ignored (the transformation is done on a BriefBlockGraph.
    • Constructor Detail

      • LoopConditionUnroller

        public LoopConditionUnroller()
    • Method Detail

      • internalTransform

        protected void internalTransform​(Body body,
                                         String phaseName,
                                         Map<String,​String> options)
        unrolls conditions.
        Specified by:
        internalTransform in class BodyTransformer
        Parameters:
        body - the body on which to apply the transformation
        phaseName - the phasename for this transform; not typically used by implementations.
        options - the actual computed options; a combination of default options and Scene specified options.