/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
Constant cst) { Insn origRopInsn = insn.getOriginalRopInsn(); Rop newRop = Rops.ropFor(newOpcode, newResult, newSources, cst); Insn newRopInsn;
Constant cst) { Insn origRopInsn = insn.getOriginalRopInsn(); Rop newRop = Rops.ropFor(newOpcode, newResult, newSources, cst); Insn newRopInsn;
/** * Replaces branches that have constant conditions with gotos */ private void replaceBranches() { for (SsaInsn insn : branchWorklist) { // Find if a successor block is never executed int oldSuccessor = -1; SsaBasicBlock block = insn.getBlock(); int successorSize = block.getSuccessorList().size(); for (int i = 0; i < successorSize; i++) { int successorBlock = block.getSuccessorList().get(i); if (!executableBlocks.get(successorBlock)) { oldSuccessor = successorBlock; } } /* * Prune branches that have already been handled and ones that no * longer have constant conditions (no nonexecutable successors) */ if (successorSize != 2 || oldSuccessor == -1) continue; // Replace branch with goto Insn originalRopInsn = insn.getOriginalRopInsn(); block.replaceLastInsn(new PlainInsn(Rops.GOTO, originalRopInsn.getPosition(), null, RegisterSpecList.EMPTY)); block.removeSuccessor(oldSuccessor); } } }
/** * Replaces branches that have constant conditions with gotos */ private void replaceBranches() { for (SsaInsn insn : branchWorklist) { // Find if a successor block is never executed int oldSuccessor = -1; SsaBasicBlock block = insn.getBlock(); int successorSize = block.getSuccessorList().size(); for (int i = 0; i < successorSize; i++) { int successorBlock = block.getSuccessorList().get(i); if (!executableBlocks.get(successorBlock)) { oldSuccessor = successorBlock; } } /* * Prune branches that have already been handled and ones that no * longer have constant conditions (no nonexecutable successors) */ if (successorSize != 2 || oldSuccessor == -1) continue; // Replace branch with goto Insn originalRopInsn = insn.getOriginalRopInsn(); block.replaceLastInsn(new PlainInsn(Rops.GOTO, originalRopInsn.getPosition(), null, RegisterSpecList.EMPTY)); block.removeSuccessor(oldSuccessor); } } }
/** * Replaces branches that have constant conditions with gotos */ private void replaceBranches() { for (SsaInsn insn : branchWorklist) { // Find if a successor block is never executed int oldSuccessor = -1; SsaBasicBlock block = insn.getBlock(); int successorSize = block.getSuccessorList().size(); for (int i = 0; i < successorSize; i++) { int successorBlock = block.getSuccessorList().get(i); if (!executableBlocks.get(successorBlock)) { oldSuccessor = successorBlock; } } /* * Prune branches that have already been handled and ones that no * longer have constant conditions (no nonexecutable successors) */ if (successorSize != 2 || oldSuccessor == -1) continue; // Replace branch with goto Insn originalRopInsn = insn.getOriginalRopInsn(); block.replaceLastInsn(new PlainInsn(Rops.GOTO, originalRopInsn.getPosition(), null, RegisterSpecList.EMPTY)); block.removeSuccessor(oldSuccessor); } } }
/** * Replaces branches that have constant conditions with gotos */ private void replaceBranches() { for (SsaInsn insn : branchWorklist) { // Find if a successor block is never executed int oldSuccessor = -1; SsaBasicBlock block = insn.getBlock(); int successorSize = block.getSuccessorList().size(); for (int i = 0; i < successorSize; i++) { int successorBlock = block.getSuccessorList().get(i); if (!executableBlocks.get(successorBlock)) { oldSuccessor = successorBlock; } } /* * Prune branches that have already been handled and ones that no * longer have constant conditions (no nonexecutable successors) */ if (successorSize != 2 || oldSuccessor == -1) continue; // Replace branch with goto Insn originalRopInsn = insn.getOriginalRopInsn(); block.replaceLastInsn(new PlainInsn(Rops.GOTO, originalRopInsn.getPosition(), null, RegisterSpecList.EMPTY)); block.removeSuccessor(oldSuccessor); } } }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }