/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dx.ssa; /** *

An introduction to SSA Form

* * This package contains classes associated with dx's {@code SSA} * intermediate form. This form is a static-single-assignment representation of * Rop-form a method with Rop-form-like instructions (with the addition of a * {@link PhiInsn phi instriction}. This form is intended to make it easy to * implement basic optimization steps and register allocation so that a * reasonably efficient register machine representation can be produced from a * stack machine source bytecode.

* *

Key Classes

* *

Classes related to conversion and lifetime

* * *

Classes related to method representation

* * *

Classes related to optimization steps

* * *

SSA Lifetime

* The representation of a method in SSA form obeys slightly different * constraints depending upon whether it is in the process of being converted * into or out of SSA form. * *

Conversion into SSA Form

* * {@link SsaConverter#convertToSsaMethod} takes a {@code RopMethod} and * returns a fully-converted {@code SsaMethod}. The conversion process * is roughly as follows: * *
    *
  1. The Rop-form method, its blocks and their instructions are directly * wrapped in {@code SsaMethod}, {@code SsaBasicBlock} and * {@code SsaInsn} instances. Nothing else changes. *
  2. Critical control-flow graph edges are {@link SsaConverter#edgeSplit * split} and new basic blocks inserted as required to meet the constraints * necessary for the ultimate SSA representation. *
  3. A {@link LocalVariableExtractor} is run to produce a table of * Rop registers to local variables necessary during phi placement. This * step could also be done in Rop form and then updated through the preceding * steps. *
  4. {@code Phi} instructions are {link SsaConverter#placePhiFunctions} * placed in a semi-pruned fashion, which requires computation of {@link * Dominators dominance graph} and each node's {@link DomFront * dominance-frontier set}. *
  5. Finally, source and result registers for all instructions are {@link * SsaRenamer renamed} such that each assignment is given a unique register * number (register categories or widths, significant in Rop form, do not * exist in SSA). Move instructions are eliminated except where necessary * to preserve local variable assignments. *
* */