Java Code Examples for com.android.dx.rop.code.Rop#getOpcode()
The following examples show how to use
com.android.dx.rop.code.Rop#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 buck with Apache License 2.0 | 6 votes |
/** * 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: NormalSsaInsn.java From buck with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * TODO: Increase the scope of this. */ @Override public boolean hasSideEffect() { Rop opcode = getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_NONE) { return true; } boolean hasLocalSideEffect = Optimizer.getPreserveLocals() && getLocalAssignment() != null; switch (opcode.getOpcode()) { case RegOps.MOVE_RESULT: case RegOps.MOVE: case RegOps.CONST: return hasLocalSideEffect; default: return true; } }
Example 3
Source File: NormalSsaInsn.java From Box with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * TODO: Increase the scope of this. */ @Override public boolean hasSideEffect() { Rop opcode = getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_NONE) { return true; } boolean hasLocalSideEffect = Optimizer.getPreserveLocals() && getLocalAssignment() != null; switch (opcode.getOpcode()) { case RegOps.MOVE_RESULT: case RegOps.MOVE: case RegOps.CONST: return hasLocalSideEffect; default: return true; } }
Example 4
Source File: FirstFitLocalCombiningAllocator.java From Box with Apache License 2.0 | 6 votes |
/** * 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: FirstFitLocalCombiningAllocator.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * 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 6
Source File: NormalSsaInsn.java From Box with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * TODO: Increase the scope of this. */ @Override public boolean hasSideEffect() { Rop opcode = getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_NONE) { return true; } boolean hasLocalSideEffect = Optimizer.getPreserveLocals() && getLocalAssignment() != null; switch (opcode.getOpcode()) { case RegOps.MOVE_RESULT: case RegOps.MOVE: case RegOps.CONST: return hasLocalSideEffect; default: return true; } }
Example 7
Source File: FirstFitLocalCombiningAllocator.java From Box with Apache License 2.0 | 6 votes |
/** * 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 8
Source File: NormalSsaInsn.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * TODO: Increase the scope of this. */ @Override public boolean hasSideEffect() { Rop opcode = getOpcode(); if (opcode.getBranchingness() != Rop.BRANCH_NONE) { return true; } boolean hasLocalSideEffect = Optimizer.getPreserveLocals() && getLocalAssignment() != null; switch (opcode.getOpcode()) { case RegOps.MOVE_RESULT: case RegOps.MOVE: case RegOps.CONST: return hasLocalSideEffect; default: return true; } }
Example 9
Source File: RopTranslator.java From Box with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void visitPlainCstInsn(PlainCstInsn insn) { SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); Rop rop = insn.getOpcode(); int ropOpcode = rop.getOpcode(); DalvInsn di; if (rop.getBranchingness() != Rop.BRANCH_NONE) { throw new RuntimeException("shouldn't happen"); } if (ropOpcode == RegOps.MOVE_PARAM) { if (!paramsAreInOrder) { /* * Parameters are not in order at the top of the reg space. * We need to add moves. */ RegisterSpec dest = insn.getResult(); int param = ((CstInteger) insn.getConstant()).getValue(); RegisterSpec source = RegisterSpec.make(regCount - paramSize + param, dest.getType()); di = new SimpleInsn(opcode, pos, RegisterSpecList.make(dest, source)); addOutput(di); } } else { // No moves required for the parameters RegisterSpecList regs = getRegs(insn); di = new CstInsn(opcode, pos, regs, insn.getConstant()); addOutput(di); } }
Example 10
Source File: LiteralOpUpgrader.java From buck with Apache License 2.0 | 5 votes |
/** * Tries to replace an instruction with a const instruction. The given * instruction must have a constant result for it to be replaced. * * @param insn {@code non-null;} instruction to try to replace * @return true if the instruction was replaced */ private boolean tryReplacingWithConstant(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpec result = insn.getResult(); if (result != null && !ssaMeth.isRegALocal(result) && opcode.getOpcode() != RegOps.CONST) { TypeBearer type = insn.getResult().getTypeBearer(); if (type.isConstant() && type.getBasicType() == Type.BT_INT) { // Replace the instruction with a constant replacePlainInsn(insn, RegisterSpecList.EMPTY, RegOps.CONST, (Constant) type); // Remove the source as well if this is a move-result-pseudo if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns = ssaMeth.getBlocks().get(pred).getInsns(); NormalSsaInsn sourceInsn = (NormalSsaInsn) predInsns.get(predInsns.size()-1); replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY, RegOps.GOTO, null); } return true; } } return false; }
Example 11
Source File: RopTranslator.java From buck with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ public void visitPlainCstInsn(PlainCstInsn insn) { SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); Rop rop = insn.getOpcode(); int ropOpcode = rop.getOpcode(); DalvInsn di; if (rop.getBranchingness() != Rop.BRANCH_NONE) { throw new RuntimeException("shouldn't happen"); } if (ropOpcode == RegOps.MOVE_PARAM) { if (!paramsAreInOrder) { /* * Parameters are not in order at the top of the reg space. * We need to add moves. */ RegisterSpec dest = insn.getResult(); int param = ((CstInteger) insn.getConstant()).getValue(); RegisterSpec source = RegisterSpec.make(regCount - paramSize + param, dest.getType()); di = new SimpleInsn(opcode, pos, RegisterSpecList.make(dest, source)); addOutput(di); } } else { // No moves required for the parameters RegisterSpecList regs = getRegs(insn); di = new CstInsn(opcode, pos, regs, insn.getConstant()); addOutput(di); } }
Example 12
Source File: LiteralOpUpgrader.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Tries to replace an instruction with a const instruction. The given * instruction must have a constant result for it to be replaced. * * @param insn {@code non-null;} instruction to try to replace * @return true if the instruction was replaced */ private boolean tryReplacingWithConstant(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpec result = insn.getResult(); if (result != null && !ssaMeth.isRegALocal(result) && opcode.getOpcode() != RegOps.CONST) { TypeBearer type = insn.getResult().getTypeBearer(); if (type.isConstant() && type.getBasicType() == Type.BT_INT) { // Replace the instruction with a constant replacePlainInsn(insn, RegisterSpecList.EMPTY, RegOps.CONST, (Constant) type); // Remove the source as well if this is a move-result-pseudo if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns = ssaMeth.getBlocks().get(pred).getInsns(); NormalSsaInsn sourceInsn = (NormalSsaInsn) predInsns.get(predInsns.size()-1); replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY, RegOps.GOTO, null); } return true; } } return false; }
Example 13
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void visitPlainCstInsn(PlainCstInsn insn) { SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); Rop rop = insn.getOpcode(); int ropOpcode = rop.getOpcode(); DalvInsn di; if (rop.getBranchingness() != Rop.BRANCH_NONE) { throw new RuntimeException("shouldn't happen"); } if (ropOpcode == RegOps.MOVE_PARAM) { if (!paramsAreInOrder) { /* * Parameters are not in order at the top of the reg space. * We need to add moves. */ RegisterSpec dest = insn.getResult(); int param = ((CstInteger) insn.getConstant()).getValue(); RegisterSpec source = RegisterSpec.make(regCount - paramSize + param, dest.getType()); di = new SimpleInsn(opcode, pos, RegisterSpecList.make(dest, source)); addOutput(di); } } else { // No moves required for the parameters RegisterSpecList regs = getRegs(insn); di = new CstInsn(opcode, pos, regs, insn.getConstant()); addOutput(di); } }
Example 14
Source File: LiteralOpUpgrader.java From Box with Apache License 2.0 | 5 votes |
/** * Tries to replace an instruction with a const instruction. The given * instruction must have a constant result for it to be replaced. * * @param insn {@code non-null;} instruction to try to replace * @return true if the instruction was replaced */ private boolean tryReplacingWithConstant(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpec result = insn.getResult(); if (result != null && !ssaMeth.isRegALocal(result) && opcode.getOpcode() != RegOps.CONST) { TypeBearer type = insn.getResult().getTypeBearer(); if (type.isConstant() && type.getBasicType() == Type.BT_INT) { // Replace the instruction with a constant replacePlainInsn(insn, RegisterSpecList.EMPTY, RegOps.CONST, (Constant) type); // Remove the source as well if this is a move-result-pseudo if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns = ssaMeth.getBlocks().get(pred).getInsns(); NormalSsaInsn sourceInsn = (NormalSsaInsn) predInsns.get(predInsns.size()-1); replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY, RegOps.GOTO, null); } return true; } } return false; }
Example 15
Source File: RopTranslator.java From Box with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void visitPlainCstInsn(PlainCstInsn insn) { SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); Rop rop = insn.getOpcode(); int ropOpcode = rop.getOpcode(); DalvInsn di; if (rop.getBranchingness() != Rop.BRANCH_NONE) { throw new RuntimeException("shouldn't happen"); } if (ropOpcode == RegOps.MOVE_PARAM) { if (!paramsAreInOrder) { /* * Parameters are not in order at the top of the reg space. * We need to add moves. */ RegisterSpec dest = insn.getResult(); int param = ((CstInteger) insn.getConstant()).getValue(); RegisterSpec source = RegisterSpec.make(regCount - paramSize + param, dest.getType()); di = new SimpleInsn(opcode, pos, RegisterSpecList.make(dest, source)); addOutput(di); } } else { // No moves required for the parameters RegisterSpecList regs = getRegs(insn); di = new CstInsn(opcode, pos, regs, insn.getConstant()); addOutput(di); } }
Example 16
Source File: LiteralOpUpgrader.java From Box with Apache License 2.0 | 5 votes |
/** * Tries to replace an instruction with a const instruction. The given * instruction must have a constant result for it to be replaced. * * @param insn {@code non-null;} instruction to try to replace * @return true if the instruction was replaced */ private boolean tryReplacingWithConstant(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpec result = insn.getResult(); if (result != null && !ssaMeth.isRegALocal(result) && opcode.getOpcode() != RegOps.CONST) { TypeBearer type = insn.getResult().getTypeBearer(); if (type.isConstant() && type.getBasicType() == Type.BT_INT) { // Replace the instruction with a constant replacePlainInsn(insn, RegisterSpecList.EMPTY, RegOps.CONST, (Constant) type); // Remove the source as well if this is a move-result-pseudo if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { int pred = insn.getBlock().getPredecessors().nextSetBit(0); ArrayList<SsaInsn> predInsns = ssaMeth.getBlocks().get(pred).getInsns(); NormalSsaInsn sourceInsn = (NormalSsaInsn) predInsns.get(predInsns.size()-1); replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY, RegOps.GOTO, null); } return true; } } return false; }
Example 17
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 18
Source File: RopTranslator.java From buck with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 19
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 20
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }