Search in sources :

Example 16 with SsaInsn

use of com.android.dx.ssa.SsaInsn in project J2ME-Loader by nikita36078.

the class LivenessAnalyzer method coInterferePhis.

/**
 * Ensures that all the phi result registers for all the phis in the
 * same basic block interfere with each other. This is needed since
 * the dead code remover has allowed through "dead-end phis" whose
 * results are not used except as local assignments. Without this step,
 * a the result of a dead-end phi might be assigned the same register
 * as the result of another phi, and the phi removal move scheduler may
 * generate moves that over-write the live result.
 *
 * @param ssaMeth {@code non-null;} method to pricess
 * @param interference {@code non-null;} interference graph
 */
private static void coInterferePhis(SsaMethod ssaMeth, InterferenceGraph interference) {
    for (SsaBasicBlock b : ssaMeth.getBlocks()) {
        List<SsaInsn> phis = b.getPhiInsns();
        int szPhis = phis.size();
        for (int i = 0; i < szPhis; i++) {
            for (int j = 0; j < szPhis; j++) {
                if (i == j) {
                    continue;
                }
                interference.add(phis.get(i).getResult().getReg(), phis.get(j).getResult().getReg());
            }
        }
    }
}
Also used : SsaBasicBlock(com.android.dx.ssa.SsaBasicBlock) SsaInsn(com.android.dx.ssa.SsaInsn)

Example 17 with SsaInsn

use of com.android.dx.ssa.SsaInsn in project J2ME-Loader by nikita36078.

the class SsaToRop method verifyValidExitPredecessor.

/**
 * Validates that a basic block is a valid end predecessor. It must
 * end in a RETURN or a THROW. Throws a runtime exception on error.
 *
 * @param b {@code non-null;} block to validate
 * @throws RuntimeException on error
 */
private void verifyValidExitPredecessor(SsaBasicBlock b) {
    ArrayList<SsaInsn> insns = b.getInsns();
    SsaInsn lastInsn = insns.get(insns.size() - 1);
    Rop opcode = lastInsn.getOpcode();
    if (opcode.getBranchingness() != Rop.BRANCH_RETURN && opcode != Rops.THROW) {
        throw new RuntimeException("Exit predecessor must end" + " in valid exit statement.");
    }
}
Also used : Rop(com.android.dx.rop.code.Rop) SsaInsn(com.android.dx.ssa.SsaInsn)

Aggregations

SsaInsn (com.android.dx.ssa.SsaInsn)17 SsaBasicBlock (com.android.dx.ssa.SsaBasicBlock)9 RegisterSpec (com.android.dx.rop.code.RegisterSpec)8 NormalSsaInsn (com.android.dx.ssa.NormalSsaInsn)8 ArrayList (java.util.ArrayList)5 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)4 Rop (com.android.dx.rop.code.Rop)4 BitSet (java.util.BitSet)3 CstInsn (com.android.dx.rop.code.CstInsn)2 PlainInsn (com.android.dx.rop.code.PlainInsn)2 CstInteger (com.android.dx.rop.cst.CstInteger)2 PhiInsn (com.android.dx.ssa.PhiInsn)2 IntIterator (com.android.dx.util.IntIterator)2 IntSet (com.android.dx.util.IntSet)2 ConcreteMethod (com.android.dx.cf.code.ConcreteMethod)1 Method (com.android.dx.cf.iface.Method)1 DexTranslationAdvice (com.android.dx.rop.code.DexTranslationAdvice)1 RopMethod (com.android.dx.rop.code.RopMethod)1 TranslationAdvice (com.android.dx.rop.code.TranslationAdvice)1 Optimizer (com.android.dx.ssa.Optimizer)1