Example #1
0
    public boolean contains(RefGroup r) {
      int l = r.refs.size();

      for (int k = 0; k < l; k++) if (refs.contains(r.refs.elementAt(k))) return true;

      return false;
    }
Example #2
0
 public void add(RefGroup r) {
   int l = r.refs.size();
   for (int i = 0; i < l; i++) {
     Object ref = r.refs.elementAt(i);
     if (!refs.contains(ref)) refs.addElement(ref);
   }
 }
Example #3
0
  /** Reverse if-convert the given predicate block from the hyperblock. */
  private void reverseIfConvert(Hyperblock hb, PredicateBlock start) {
    Stack<Node> wl = WorkArea.<Node>getStack("reverseIfConvert");
    Stack<PredicateBlock> reverse = WorkArea.<PredicateBlock>getStack("reverseIfConvert");
    Vector<PredicateBlock> blocks = new Vector<PredicateBlock>();
    Vector<Hyperblock> hbs = new Vector<Hyperblock>();

    // Find the blocks which need to be reverse if-converted.

    start.nextVisit();
    start.setVisited();
    wl.add(start);

    while (!wl.isEmpty()) {
      PredicateBlock block = (PredicateBlock) wl.pop();
      block.pushOutEdges(wl);

      for (int i = 0; i < block.numInEdges(); i++) {
        PredicateBlock pred = (PredicateBlock) block.getInEdge(i);
        if (!pred.visited()) {
          blocks.add(block);
          break;
        } else if (blocks.contains(pred) && block.numInEdges() > 1) {
          blocks.add(block);
          break;
        }
      }
    }

    // Order the blocks to reverse if-convert based on their depth from the root.

    PredicateBlock head = hb.getFirstBlock();
    Vector<PredicateBlock> wl2 = new Vector<PredicateBlock>();

    head.nextVisit();
    head.setVisited();
    wl2.add(head);

    while (!wl2.isEmpty()) {
      int l = wl2.size();

      for (int i = 0; i < l; i++) {
        PredicateBlock block = wl2.get(i);
        if (blocks.contains(block)) {
          blocks.remove(block);
          reverse.push(block);
        }
      }

      wl2 = hb.getNextPFGLevel(wl2);
    }

    // Remove the special "dummy" last block from the PFG.

    PredicateBlock last = hb.getLastBlock();
    assert (last.numOutEdges() == 0 && !last.isPredicated());

    if (last.getFirstInstruction() == null) {
      for (int i = last.numInEdges() - 1; i > -1; i--) {
        PredicateBlock pred = (PredicateBlock) last.getInEdge(i);
        pred.deleteOutEdge(last);
        last.deleteInEdge(pred);
      }
      reverse.remove(last);
    }

    // Reverse if-convert.

    while (!reverse.isEmpty()) {
      PredicateBlock block = reverse.pop();
      Hyperblock hbn = reverseIfConvertBlock(block);

      hbs.add(hbn);
      workingSet.add(hbn);
    }

    // Update the PFG.

    hb.updateLastBlock();
    hb.invalidateDomination(); // The dominators are now invalid.

    // Insert the new hyperblocks in the HFG.

    HashMap<Instruction, Hyperblock> entries = computeEntries(hb, hbs);
    hbs.add(hb);
    Hyperblock.computeHyperblockFlowGraph(hbs, entries);

    // Update the return block.  Since 'hbs' is an ordered list, the
    // first element in the list is the hyperblock with the return
    // because this was the original tail of the PFG which was reverse
    // if-converted.

    if (hb == gen.getReturnBlock()) {
      gen.setReturnBlock(hbs.firstElement());
    }

    WorkArea.<Node>returnStack(wl);
    WorkArea.<PredicateBlock>returnStack(reverse);
  }
Example #4
0
 public boolean contains(Expr d) {
   return refs.contains(d);
 }
Example #5
0
    public void add(DDEdge edge) {
      if (refs.contains(edge)) return;

      refs.addElement(edge);
    }