org.jikesrvm.compilers.opt.controlflow
Class Diamond

java.lang.Object
  extended by org.jikesrvm.compilers.opt.controlflow.Diamond

final class Diamond
extends Object

This class represents a diamond (if-then-else) structure in the control-flow graph.


Field Summary
private  BasicBlock bottom
          The bottom of the diamond
private  BasicBlock notTaken
          The "not-taken" branch of the diamond (might be null)
private  BasicBlock taken
          The "taken" branch of the diamond (might be null)
private  BasicBlock top
          The top of the diamond
 
Constructor Summary
Diamond(BasicBlock top, BasicBlock taken, BasicBlock notTaken, BasicBlock bottom)
           
 
Method Summary
(package private) static Diamond buildDiamond(BasicBlock bb)
          See if bb is the root of a diamond.
private static Diamond fourElementDiamond(BasicBlock top, BasicBlock left, BasicBlock right, BasicBlock bottom)
          Given that four blocks form a diamond, return the correct structure.
(package private)  BasicBlock getBottom()
          The bottom of the diamond
(package private)  BasicBlock getNotTaken()
          The "not-taken" branch of the diamond (might be null)
(package private)  BasicBlock getTaken()
          The "taken" branch of the diamond (might be null)
(package private)  BasicBlock getTop()
          The top of the diamond
private static Diamond threeElementDiamond(BasicBlock top, BasicBlock side, BasicBlock bottom)
          Given that three blocks form a diamond, return the correct structure.
 String toString()
          Return a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

top

private final BasicBlock top
The top of the diamond


bottom

private final BasicBlock bottom
The bottom of the diamond


taken

private final BasicBlock taken
The "taken" branch of the diamond (might be null)


notTaken

private final BasicBlock notTaken
The "not-taken" branch of the diamond (might be null)

Constructor Detail

Diamond

Diamond(BasicBlock top,
        BasicBlock taken,
        BasicBlock notTaken,
        BasicBlock bottom)
Method Detail

getTop

BasicBlock getTop()
The top of the diamond


getBottom

BasicBlock getBottom()
The bottom of the diamond


getTaken

BasicBlock getTaken()
The "taken" branch of the diamond (might be null)


getNotTaken

BasicBlock getNotTaken()
The "not-taken" branch of the diamond (might be null)


buildDiamond

static Diamond buildDiamond(BasicBlock bb)
See if bb is the root of a diamond. If so, return an Diamond representing the structure.

Returns:
a structure representing the diamond. null if not applicable.

fourElementDiamond

private static Diamond fourElementDiamond(BasicBlock top,
                                          BasicBlock left,
                                          BasicBlock right,
                                          BasicBlock bottom)
Given that four blocks form a diamond, return the correct structure.


threeElementDiamond

private static Diamond threeElementDiamond(BasicBlock top,
                                           BasicBlock side,
                                           BasicBlock bottom)
Given that three blocks form a diamond, return the correct structure.


toString

public String toString()
Return a string representation.

Overrides:
toString in class Object