Package jminusminus

Class NBasicBlock

java.lang.Object
jminusminus.NBasicBlock

class NBasicBlock extends Object
Representation of a block within a control flow graph.
  • Field Details

    • cfg

      public NControlFlowGraph cfg
      The control flow graph (cfg) that this block belongs to.
    • id

      public int id
      Unique identifier of ths block.
    • tuples

      public ArrayList<NTuple> tuples
      List of tuples in this block.
    • predecessors

      public ArrayList<NBasicBlock> predecessors
      List of predecessor blocks.
    • successors

      public ArrayList<NBasicBlock> successors
      List of successor blocks.
    • hir

      public ArrayList<Integer> hir
      List of high-level (HIR) instructions in this block.
    • lir

      List of low-level (LIR) instructions in this block.
    • locals

      public int[] locals
      The state array for this block that maps local variable index to the HIR instruction that last affected it.
    • visited

      public boolean visited
      Has this block been visited?
    • active

      public boolean active
      Is this block active?
    • isLoopHead

      public boolean isLoopHead
      Is this block a loop head?
    • isLoopTail

      public boolean isLoopTail
      Is this block a loop tail?
    • loopIndex

      public int loopIndex
      Index of a loop.
    • loopDepth

      public int loopDepth
      Depth of a loop.
    • fwdBranches

      public int fwdBranches
      Number of forward branches to this block.
    • bwdBranches

      public int bwdBranches
      Number of backward branches to this block.
    • ref

      public int ref
      Ref count of this block.
    • dom

      public NBasicBlock dom
      The dominator of this block.
    • liveDef

      public BitSet liveDef
      All virtual registers locally defined within this block.
    • liveUse

      public BitSet liveUse
      All virtual registers used before definition within this block.
    • liveIn

      public BitSet liveIn
      All virtual registers live in the block.
    • liveOut

      public BitSet liveOut
      All virtual registers live outside the block.
  • Constructor Details

    • NBasicBlock

      public NBasicBlock(NControlFlowGraph cfg, int id)
      Constructs a basic block.
      Parameters:
      cfg - the cfg containing this block.
      id - id of the block.
  • Method Details

    • id

      public String id()
      Returns a string identifier of this block.
      Returns:
      a string identifier of this block.
    • equals

      public boolean equals(NBasicBlock other)
      Returns true if this block and other have the same id, and false otherwise.
      Parameters:
      other - the other block.
      Returns:
      true if this block and other have the same id, and false otherwise.
    • toString

      public String toString()
      Returns a string representation of this block.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this block.
    • writeTuplesToStdOut

      public void writeTuplesToStdOut(PrettyPrinter p)
      Writes the tuples in this block to standard output.
      Parameters:
      p - for pretty printing with indentation.
    • writeHirToStdOut

      public void writeHirToStdOut(PrettyPrinter p)
      Writes the HIR instructions in this block to standard output.
      Parameters:
      p - for pretty printing with indentation.
    • writeLirToStdOut

      public void writeLirToStdOut(PrettyPrinter p)
      Writes the LIR instructions in this block to standard output.
      Parameters:
      p - for pretty printing with indentation.
    • getFirstLIRInstId

      public int getFirstLIRInstId()
      Returns the instruction identifier for the first LIR instruction, or -1.
      Returns:
      the instruction identifier for the first LIR instruction, or -1.
    • getLastLIRInstId

      public int getLastLIRInstId()
      Returns the instruction identifier for the last LIR instruction, or -1.
      Returns:
      the instruction identifier for the last LIR instruction, or -1.
    • getInstruction

      public NLIRInstruction getInstruction(int id)
      Returns the LIR instruction with the given id, or null.
      Parameters:
      id - the id to look for.
      Returns:
      the LIR instruction with the given id, or null.
    • idIsFree

      public boolean idIsFree(int id)
      Returns true if there is no LIR instruction with the given id, and false otherwise.
      Parameters:
      id - the id to check for.
      Returns:
      true if there is no LIR instruction with the given id, and false otherwise.
    • insertLIRInst

      public void insertLIRInst(NLIRInstruction inst)
      Inserts the given LIR instruction at the appropriate place in this block's lir array based on its id -- preserving order by id.
      Parameters:
      inst - the LIR instruction to be inserted.