/** * Compute the entry points for a list of hyperblocks to be inserted into the HFG. This method * also removes the link between hbStart and all its successors. */ public static HashMap<Instruction, Hyperblock> computeEntries( Hyperblock hbStart, Vector<Hyperblock> hbs) { HashMap<Instruction, Hyperblock> entries = new HashMap<Instruction, Hyperblock>(203); // Find the entry points in the new hyperblocks. int l = hbs.size(); for (int i = 0; i < l; i++) { Hyperblock hb = hbs.elementAt(i); PredicateBlock start = hb.getFirstBlock(); Instruction first = start.getFirstInstruction(); entries.put(first, hb); } // The successors of the original hyperblock are also entry points. int sl = hbStart.numOutEdges(); for (int i = 0; i < sl; i++) { Hyperblock succ = (Hyperblock) hbStart.getOutEdge(0); PredicateBlock start = succ.getFirstBlock(); Instruction first = start.getFirstInstruction(); hbStart.deleteOutEdge(succ); succ.deleteInEdge(hbStart); entries.put(first, succ); } return entries; }
/** Split an unpredicated predicate block. */ private void splitBlock(Hyperblock hb, PredicateBlock block) { int chunkSize = (block.getBlockSize() + block.getFanout()) / 2; int maxChunk = (int) (Trips2Machine.maxBlockSize * MAXFILL); if (chunkSize > maxChunk) { chunkSize = maxChunk; } Instruction splitLocation = findSplitLocation(hb, block, chunkSize); PredicateBlock start = block.cut(splitLocation, gen); Hyperblock nhb = new Hyperblock(start, regs); // Insert the new hyperblock into the HFG. for (int i = hb.numOutEdges() - 1; i > -1; i--) { Hyperblock out = (Hyperblock) hb.getOutEdge(i); out.replaceInEdge(hb, nhb); hb.deleteOutEdge(out); nhb.addOutEdge(out); } hb.addOutEdge(nhb); nhb.addInEdge(hb); workingSet.add(nhb); hb.invalidateDomination(); hb.findLastBlock(); hb.determinePredicatesBranches(); nhb.findLastBlock(); nhb.determinePredicatesBranches(); // Update the return block if it has changed. if (gen.getReturnBlock() == hb) { gen.setReturnBlock(nhb); } }