/** * Makes a new SSA insn form a rop insn. * * @param insn {@code non-null;} rop insn * @param block {@code non-null;} owning block * @return {@code non-null;} an appropriately constructed instance */ public static SsaInsn makeFromRop(Insn insn, SsaBasicBlock block) { return new NormalSsaInsn(insn, block); }
/** {@inheritDoc} */ @Override public boolean isPhiOrMove() { return isNormalMoveInsn(); }
@Override public void visitNonMoveInsn(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpecList sources = insn.getSources(); insn.upgradeToLiteral(); } else if (opcode.isCommutative() && advice.hasConstantOperation( insn.setNewSources( RegisterSpecList.make( sources.get(1), sources.get(0))); insn.upgradeToLiteral();
RegisterSpec moveRegSpec = insn.getResult(); int moveReg = moveRegSpec.getReg(); BitSet predBlocks = insn.getBlock().getPredecessors(); int checkRopReg = mapper.oldToNew(checkReg); if (moveRopReg != checkRopReg && !hasExceptionHandlers) { ((NormalSsaInsn) checkCastInsn).changeOneSource(0, insertMoveBefore(checkCastInsn, checkRegSpec)); addMapping(checkCastInsn.getSources().get(0), moveRopReg);
/** * {@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; } } }
/** {@inheritDoc} */ @Override public final void mapSourceRegisters(RegisterMapper mapper) { RegisterSpecList oldSources = insn.getSources(); RegisterSpecList newSources = mapper.map(oldSources); if (newSources != oldSources) { insn = insn.withNewRegisters(getResult(), newSources); getBlock().getParent().onSourcesChanged(this, oldSources); } }
RegisterSpec ropResult = insn.getResult(); int ropResultReg = ropResult.getReg(); int ropSourceReg = insn.getSources().get(0).getReg(); insn.mapSourceRegisters(mapper); int ssaSourceReg = insn.getSources().get(0).getReg();
/** * Returns the parameter index associated with a move-param insn. Does * not verify that the insn is a move-param insn. * * @param insn {@code non-null;} a move-param insn * @return {@code >=0;} parameter index */ private int getParamIndex(NormalSsaInsn insn) { CstInsn cstInsn = (CstInsn)(insn.getOriginalRopInsn()); int param = ((CstInteger)cstInsn.getConstant()).getValue(); return param; }
/** * {@inheritDoc} * * All insns that are not move or phi insns have their source registers * mapped ot the current mapping. Their result registers are then * renamed to a new SSA register which is then added to the current * register mapping. */ public void visitNonMoveInsn(NormalSsaInsn insn) { /* for each use of some variable X in S */ insn.mapSourceRegisters(mapper); processResultReg(insn); }
/** * Returns true if the definition site of this register is a * move-param (ie, this is a method parameter). * * @param reg register in question * @return {@code true} if this is a method parameter */ protected boolean isDefinitionMoveParam(int reg) { SsaInsn defInsn = ssaMeth.getDefinitionForRegister(reg); if (defInsn instanceof NormalSsaInsn) { NormalSsaInsn ndefInsn = (NormalSsaInsn) defInsn; return ndefInsn.getOpcode().getOpcode() == RegOps.MOVE_PARAM; } return false; }
= spec.withType((TypedConstant)latticeConstants[reg]); nInsn.changeOneSource(index, newSpec);
/** * Upgrades this insn to a version that represents the constant source * literally. If the upgrade is not possible, this does nothing. * * @see Insn#withSourceLiteral */ public void upgradeToLiteral() { RegisterSpecList oldSources = insn.getSources(); insn = insn.withSourceLiteral(); getBlock().getParent().onSourcesChanged(this, oldSources); }
int newRegStart = findRangeAndAdjust(insn); RegisterSpecList sources = insn.getSources(); int szSources = sources.size(); int nextRopReg = newRegStart;
public void visitNonMoveInsn(NormalSsaInsn insn) { Insn originalRopInsn = insn.getOriginalRopInsn(); Rop opcode = originalRopInsn.getOpcode(); RegisterSpecList sources = insn.getSources(); insn.upgradeToLiteral(); } else if (opcode.isCommutative() && advice.hasConstantOperation( insn.setNewSources( RegisterSpecList.make( sources.get(1), sources.get(0))); insn.upgradeToLiteral();
RegisterSpec moveRegSpec = insn.getResult(); int moveReg = moveRegSpec.getReg(); BitSet predBlocks = insn.getBlock().getPredecessors(); int checkRopReg = mapper.oldToNew(checkReg); if (moveRopReg != checkRopReg && !hasExceptionHandlers) { ((NormalSsaInsn) checkCastInsn).changeOneSource(0, insertMoveBefore(checkCastInsn, checkRegSpec)); addMapping(checkCastInsn.getSources().get(0), moveRopReg);
/** * {@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; } } }
/** {@inheritDoc} */ @Override public final void mapSourceRegisters(RegisterMapper mapper) { RegisterSpecList oldSources = insn.getSources(); RegisterSpecList newSources = mapper.map(oldSources); if (newSources != oldSources) { insn = insn.withNewRegisters(getResult(), newSources); getBlock().getParent().onSourcesChanged(this, oldSources); } }
RegisterSpec ropResult = insn.getResult(); int ropResultReg = ropResult.getReg(); int ropSourceReg = insn.getSources().get(0).getReg(); insn.mapSourceRegisters(mapper); int ssaSourceReg = insn.getSources().get(0).getReg();
/** * Returns the parameter index associated with a move-param insn. Does * not verify that the insn is a move-param insn. * * @param insn {@code non-null;} a move-param insn * @return {@code >=0;} parameter index */ private int getParamIndex(NormalSsaInsn insn) { CstInsn cstInsn = (CstInsn)(insn.getOriginalRopInsn()); int param = ((CstInteger)cstInsn.getConstant()).getValue(); return param; }