/** * Converts a method in SSA form to ROP form. * * @param ssaMeth {@code non-null;} method to process * @param minimizeRegisters {@code true} if the converter should * attempt to minimize the rop-form register count * @return {@code non-null;} rop-form output */ public static RopMethod convertToRopMethod(SsaMethod ssaMeth, boolean minimizeRegisters) { return new SsaToRop(ssaMeth, minimizeRegisters).convert(); }
removePhiFunctions(); moveParametersToHighRegisters(); removeEmptyGotos(); RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())); ropMethod = new IdenticalBlockCombiner(ropMethod).process();
primarySuccessorLabel = -1; verifyValidExitPredecessor(block); block.getRopLabel(), convertInsns(block.getInsns()), successorList, primarySuccessorLabel);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true); return resultMeth;
/** * @return rop-form basic block list */ private BasicBlockList convertBasicBlocks() { ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); // Exit block may be null. SsaBasicBlock exitBlock = ssaMeth.getExitBlock(); BitSet reachable = ssaMeth.computeReachability(); int ropBlockCount = reachable.cardinality(); // Don't count the exit block, if it exists and is reachable. if (exitBlock != null && reachable.get(exitBlock.getIndex())) { ropBlockCount -= 1; } BasicBlockList result = new BasicBlockList(ropBlockCount); // Convert all the reachable blocks except the exit block. int ropBlockIndex = 0; for (SsaBasicBlock b : blocks) { if (reachable.get(b.getIndex()) && b != exitBlock) { result.set(ropBlockIndex++, convertBasicBlock(b)); } } // The exit block, which is discarded, must do nothing. if (exitBlock != null && !exitBlock.getInsns().isEmpty()) { throw new RuntimeException( "Exit block must have no insns when leaving SSA form"); } return result; }
removePhiFunctions(); moveParametersToHighRegisters(); removeEmptyGotos(); RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())); ropMethod = new IdenticalBlockCombiner(ropMethod).process();
primarySuccessorLabel = -1; verifyValidExitPredecessor(block); block.getRopLabel(), convertInsns(block.getInsns()), successorList, primarySuccessorLabel);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true); return resultMeth;
/** * @return rop-form basic block list */ private BasicBlockList convertBasicBlocks() { ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); // Exit block may be null. SsaBasicBlock exitBlock = ssaMeth.getExitBlock(); int ropBlockCount = ssaMeth.getCountReachableBlocks(); // Don't count the exit block, if it exists. ropBlockCount -= (exitBlock == null) ? 0 : 1; BasicBlockList result = new BasicBlockList(ropBlockCount); // Convert all the reachable blocks except the exit block. int ropBlockIndex = 0; for (SsaBasicBlock b : blocks) { if (b.isReachable() && b != exitBlock) { result.set(ropBlockIndex++, convertBasicBlock(b)); } } // The exit block, which is discarded, must do nothing. if (exitBlock != null && exitBlock.getInsns().size() != 0) { throw new RuntimeException( "Exit block must have no insns when leaving SSA form"); } return result; }
removePhiFunctions(); moveParametersToHighRegisters(); removeEmptyGotos(); RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())); ropMethod = new IdenticalBlockCombiner(ropMethod).process();
/** * Converts a method in SSA form to ROP form. * * @param ssaMeth {@code non-null;} method to process * @param minimizeRegisters {@code true} if the converter should * attempt to minimize the rop-form register count * @return {@code non-null;} rop-form output */ public static RopMethod convertToRopMethod(SsaMethod ssaMeth, boolean minimizeRegisters) { return new SsaToRop(ssaMeth, minimizeRegisters).convert(); }
primarySuccessorLabel = -1; verifyValidExitPredecessor(block); block.getRopLabel(), convertInsns(block.getInsns()), successorList, primarySuccessorLabel);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true); return resultMeth;
/** * @return rop-form basic block list */ private BasicBlockList convertBasicBlocks() { ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); // Exit block may be null. SsaBasicBlock exitBlock = ssaMeth.getExitBlock(); ssaMeth.computeReachability(); int ropBlockCount = ssaMeth.getCountReachableBlocks(); // Don't count the exit block, if it exists and is reachable. ropBlockCount -= (exitBlock != null && exitBlock.isReachable()) ? 1 : 0; BasicBlockList result = new BasicBlockList(ropBlockCount); // Convert all the reachable blocks except the exit block. int ropBlockIndex = 0; for (SsaBasicBlock b : blocks) { if (b.isReachable() && b != exitBlock) { result.set(ropBlockIndex++, convertBasicBlock(b)); } } // The exit block, which is discarded, must do nothing. if (exitBlock != null && exitBlock.getInsns().size() != 0) { throw new RuntimeException( "Exit block must have no insns when leaving SSA form"); } return result; }
removePhiFunctions(); moveParametersToHighRegisters(); removeEmptyGotos(); RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())); ropMethod = new IdenticalBlockCombiner(ropMethod).process();
/** * Converts a method in SSA form to ROP form. * * @param ssaMeth {@code non-null;} method to process * @param minimizeRegisters {@code true} if the converter should * attempt to minimize the rop-form register count * @return {@code non-null;} rop-form output */ public static RopMethod convertToRopMethod(SsaMethod ssaMeth, boolean minimizeRegisters) { return new SsaToRop(ssaMeth, minimizeRegisters).convert(); }
primarySuccessorLabel = -1; verifyValidExitPredecessor(block); block.getRopLabel(), convertInsns(block.getInsns()), successorList, primarySuccessorLabel);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true); return resultMeth;
/** * @return rop-form basic block list */ private BasicBlockList convertBasicBlocks() { ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks(); // Exit block may be null. SsaBasicBlock exitBlock = ssaMeth.getExitBlock(); ssaMeth.computeReachability(); int ropBlockCount = ssaMeth.getCountReachableBlocks(); // Don't count the exit block, if it exists and is reachable. ropBlockCount -= (exitBlock != null && exitBlock.isReachable()) ? 1 : 0; BasicBlockList result = new BasicBlockList(ropBlockCount); // Convert all the reachable blocks except the exit block. int ropBlockIndex = 0; for (SsaBasicBlock b : blocks) { if (b.isReachable() && b != exitBlock) { result.set(ropBlockIndex++, convertBasicBlock(b)); } } // The exit block, which is discarded, must do nothing. if (exitBlock != null && exitBlock.getInsns().size() != 0) { throw new RuntimeException( "Exit block must have no insns when leaving SSA form"); } return result; }
removePhiFunctions(); moveParametersToHighRegisters(); removeEmptyGotos(); RopMethod ropMethod = new RopMethod(convertBasicBlocks(), ssaMeth.blockIndexToRopLabel(ssaMeth.getEntryBlockIndex())); ropMethod = new IdenticalBlockCombiner(ropMethod).process();