Java Code Examples for com.android.dx.ssa.SsaInsn#getOpcode()

The following examples show how to use com.android.dx.ssa.SsaInsn#getOpcode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the parameter index for SSA registers that are method parameters.
 * {@code -1} is returned for non-parameter registers.
 *
 * @param ssaReg {@code >=0;} SSA register to look up
 * @return parameter index or {@code -1} if not a parameter
 */
private int getParameterIndexForReg(int ssaReg) {
    SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg);
    if (defInsn == null) {
        return -1;
    }

    Rop opcode = defInsn.getOpcode();

    // opcode == null for phi insns.
    if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) {
        CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn();
        return  ((CstInteger) origInsn.getConstant()).getValue();
    }

    return -1;
}
 
Example 2
Source File: FirstFitLocalCombiningAllocator.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the parameter index for SSA registers that are method parameters.
 * {@code -1} is returned for non-parameter registers.
 *
 * @param ssaReg {@code >=0;} SSA register to look up
 * @return parameter index or {@code -1} if not a parameter
 */
private int getParameterIndexForReg(int ssaReg) {
    SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg);
    if (defInsn == null) {
        return -1;
    }

    Rop opcode = defInsn.getOpcode();

    // opcode == null for phi insns.
    if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) {
        CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn();
        return  ((CstInteger) origInsn.getConstant()).getValue();
    }

    return -1;
}
 
Example 3
Source File: FirstFitLocalCombiningAllocator.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the parameter index for SSA registers that are method parameters.
 * {@code -1} is returned for non-parameter registers.
 *
 * @param ssaReg {@code >=0;} SSA register to look up
 * @return parameter index or {@code -1} if not a parameter
 */
private int getParameterIndexForReg(int ssaReg) {
    SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg);
    if (defInsn == null) {
        return -1;
    }

    Rop opcode = defInsn.getOpcode();

    // opcode == null for phi insns.
    if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) {
        CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn();
        return  ((CstInteger) origInsn.getConstant()).getValue();
    }

    return -1;
}
 
Example 4
Source File: FirstFitLocalCombiningAllocator.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the parameter index for SSA registers that are method parameters.
 * {@code -1} is returned for non-parameter registers.
 *
 * @param ssaReg {@code >=0;} SSA register to look up
 * @return parameter index or {@code -1} if not a parameter
 */
private int getParameterIndexForReg(int ssaReg) {
    SsaInsn defInsn = ssaMeth.getDefinitionForRegister(ssaReg);
    if (defInsn == null) {
        return -1;
    }

    Rop opcode = defInsn.getOpcode();

    // opcode == null for phi insns.
    if (opcode != null && opcode.getOpcode() == RegOps.MOVE_PARAM) {
        CstInsn origInsn = (CstInsn) defInsn.getOriginalRopInsn();
        return  ((CstInteger) origInsn.getConstant()).getValue();
    }

    return -1;
}
 
Example 5
Source File: SsaToRop.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * 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.");
    }
}
 
Example 6
Source File: SsaToRop.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * 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.");
    }
}
 
Example 7
Source File: SsaToRop.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * 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.");
    }
}
 
Example 8
Source File: SsaToRop.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * 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.");
    }
}