本文整理汇总了Java中com.android.dx.rop.code.Rop.BRANCH_NONE属性的典型用法代码示例。如果您正苦于以下问题:Java Rop.BRANCH_NONE属性的具体用法?Java Rop.BRANCH_NONE怎么用?Java Rop.BRANCH_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.android.dx.rop.code.Rop
的用法示例。
在下文中一共展示了Rop.BRANCH_NONE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitFillArrayDataInsn
/** {@inheritDoc} */
public void visitFillArrayDataInsn(FillArrayDataInsn insn) {
SourcePosition pos = insn.getPosition();
Constant cst = insn.getConstant();
ArrayList<Constant> values = insn.getInitValues();
Rop rop = insn.getOpcode();
if (rop.getBranchingness() != Rop.BRANCH_NONE) {
throw new RuntimeException("shouldn't happen");
}
CodeAddress dataAddress = new CodeAddress(pos);
ArrayData dataInsn =
new ArrayData(pos, lastAddress, values, cst);
TargetInsn fillArrayDataInsn =
new TargetInsn(Dops.FILL_ARRAY_DATA, pos, getRegs(insn),
dataAddress);
addOutput(lastAddress);
addOutput(fillArrayDataInsn);
addOutputSuffix(new OddSpacer(pos));
addOutputSuffix(dataAddress);
addOutputSuffix(dataInsn);
}
示例2: hasSideEffect
/**
* {@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;
}
}
示例3: hasSideEffect
/**
* {@inheritDoc}
*
* TODO: Increase the scope of this.
* @param optimizer
*/
@Override
public boolean hasSideEffect(Optimizer optimizer) {
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;
}
}
示例4: visitPlainCstInsn
/** {@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);
}
}
示例5: replaceLastInsn
/**
* Replaces the last insn in this block. The provided insn must have
* some branchingness.
*
* @param insn {@code non-null;} rop-form insn to add, which must branch.
*/
public void replaceLastInsn(Insn insn) {
if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) {
throw new IllegalArgumentException("last insn must branch");
}
SsaInsn oldInsn = insns.get(insns.size() - 1);
SsaInsn newInsn = SsaInsn.makeFromRop(insn, this);
insns.set(insns.size() - 1, newInsn);
parent.onInsnRemoved(oldInsn);
parent.onInsnAdded(newInsn);
}
示例6: deleteInsns
/**
* Deletes all insns in the set from this method.
*
* @param deletedInsns {@code non-null;} insns to delete
*/
public void deleteInsns(Set<SsaInsn> deletedInsns) {
for (SsaBasicBlock block : getBlocks()) {
ArrayList<SsaInsn> insns = block.getInsns();
for (int i = insns.size() - 1; i >= 0; i--) {
SsaInsn insn = insns.get(i);
if (deletedInsns.contains(insn)) {
onInsnRemoved(insn);
insns.remove(i);
}
}
// Check to see if we need to add a GOTO
int insnsSz = insns.size();
SsaInsn lastInsn = (insnsSz == 0) ? null : insns.get(insnsSz - 1);
if (block != getExitBlock() && (insnsSz == 0
|| lastInsn.getOriginalRopInsn() == null
|| lastInsn.getOriginalRopInsn().getOpcode()
.getBranchingness() == Rop.BRANCH_NONE)) {
// We managed to eat a throwable insn
Insn gotoInsn = new PlainInsn(Rops.GOTO,
SourcePosition.NO_INFO, null, RegisterSpecList.EMPTY);
insns.add(SsaInsn.makeFromRop(gotoInsn, block));
// Remove secondary successors from this block
BitSet succs = block.getSuccessors();
for (int i = succs.nextSetBit(0); i >= 0;
i = succs.nextSetBit(i + 1)) {
if (i != block.getPrimarySuccessorIndex()) {
block.removeSuccessor(i);
}
}
}
}
}
示例7: visitPlainInsn
/** {@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);
}
示例8: simulateStmt
/**
* Simulates a statement and set the result lattice value.
* @param insn instruction to simulate
*/
private void simulateStmt(SsaInsn insn) {
Insn ropInsn = insn.getOriginalRopInsn();
if (ropInsn.getOpcode().getBranchingness() != Rop.BRANCH_NONE
|| ropInsn.getOpcode().isCallLike()) {
simulateBranch(insn);
}
int opcode = insn.getOpcode().getOpcode();
RegisterSpec result = insn.getResult();
if (result == null) {
// Find move-result-pseudo result for int div and int rem
if (opcode == RegOps.DIV || opcode == RegOps.REM) {
SsaBasicBlock succ = insn.getBlock().getPrimarySuccessor();
result = succ.getInsns().get(0).getResult();
} else {
return;
}
}
int resultReg = result.getReg();
int resultValue = VARYING;
Constant resultConstant = null;
switch (opcode) {
case RegOps.CONST: {
CstInsn cstInsn = (CstInsn)ropInsn;
resultValue = CONSTANT;
resultConstant = cstInsn.getConstant();
break;
}
case RegOps.MOVE: {
if (insn.getSources().size() == 1) {
int sourceReg = insn.getSources().get(0).getReg();
resultValue = latticeValues[sourceReg];
resultConstant = latticeConstants[sourceReg];
}
break;
}
case RegOps.ADD:
case RegOps.SUB:
case RegOps.MUL:
case RegOps.DIV:
case RegOps.AND:
case RegOps.OR:
case RegOps.XOR:
case RegOps.SHL:
case RegOps.SHR:
case RegOps.USHR:
case RegOps.REM: {
resultConstant = simulateMath(insn, result.getBasicType());
if (resultConstant != null) {
resultValue = CONSTANT;
}
break;
}
case RegOps.MOVE_RESULT_PSEUDO: {
if (latticeValues[resultReg] == CONSTANT) {
resultValue = latticeValues[resultReg];
resultConstant = latticeConstants[resultReg];
}
break;
}
// TODO: Handle non-int arithmetic.
// TODO: Eliminate check casts that we can prove the type of.
default: {}
}
if (setLatticeValueTo(resultReg, resultValue, resultConstant)) {
addUsersToWorklist(resultReg, resultValue);
}
}
示例9: run
/**
* Applies the optimization.
*/
private void run() {
int regSz = ssaMeth.getRegCount();
ArrayList<TypedConstant> constantList
= getConstsSortedByCountUse();
int toCollect = Math.min(constantList.size(), MAX_COLLECTED_CONSTANTS);
SsaBasicBlock start = ssaMeth.getEntryBlock();
// Constant to new register containing the constant
HashMap<TypedConstant, RegisterSpec> newRegs
= new HashMap<TypedConstant, RegisterSpec> (toCollect);
for (int i = 0; i < toCollect; i++) {
TypedConstant cst = constantList.get(i);
RegisterSpec result
= RegisterSpec.make(ssaMeth.makeNewSsaReg(), cst);
Rop constRop = Rops.opConst(cst);
if (constRop.getBranchingness() == Rop.BRANCH_NONE) {
start.addInsnToHead(
new PlainCstInsn(Rops.opConst(cst),
SourcePosition.NO_INFO, result,
RegisterSpecList.EMPTY, cst));
} else {
// We need two new basic blocks along with the new insn
SsaBasicBlock entryBlock = ssaMeth.getEntryBlock();
SsaBasicBlock successorBlock
= entryBlock.getPrimarySuccessor();
// Insert a block containing the const insn.
SsaBasicBlock constBlock
= entryBlock.insertNewSuccessor(successorBlock);
constBlock.replaceLastInsn(
new ThrowingCstInsn(constRop, SourcePosition.NO_INFO,
RegisterSpecList.EMPTY,
StdTypeList.EMPTY, cst));
// Insert a block containing the move-result-pseudo insn.
SsaBasicBlock resultBlock
= constBlock.insertNewSuccessor(successorBlock);
PlainInsn insn
= new PlainInsn(
Rops.opMoveResultPseudo(result.getTypeBearer()),
SourcePosition.NO_INFO,
result, RegisterSpecList.EMPTY);
resultBlock.addInsnToHead(insn);
}
newRegs.put(cst, result);
}
updateConstUses(newRegs, regSz);
}