Package jminusminus

Class NLIRInstruction

java.lang.Object
jminusminus.NLIRInstruction
Direct Known Subclasses:
NLIRALoad, NLIRArithmetic, NLIRAStore, NLIRConditionalJump, NLIRGetField, NLIRGoto, NLIRIntConstant, NLIRInvoke, NLIRLoad, NLIRLoadLocal, NLIRMove, NLIRNewArray, NLIRPhiFunction, NLIRPutField, NLIRReturn, NLIRStore, NLIRStringConstant

abstract class NLIRInstruction extends Object
This abstract base class provides a low-level intermediate representation (LIR) of a JVM instruction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The block containing this instruction.
    int
    Unique identifier of this instruction.
    protected static String[]
    Maps JVM opcode to a string mnemonic for LIR instructions.
    Registers that store the inputs (if any) of this instruction.
    Register that stores the result (if any) of this instruction.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    NLIRInstruction(NBasicBlock block, int id)
    Constructs an NLIRInstruction object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Replace references to virtual registers in this LIR instruction with references to physical registers.
    void
    Translates this LIR instruction into SPIM and writes it out to the specified output stream.
    Returns a string representation of this instruction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • lirMnemonic

      protected static String[] lirMnemonic
      Maps JVM opcode to a string mnemonic for LIR instructions. For example, imul is mapped to the "MUL".
    • block

      public NBasicBlock block
      The block containing this instruction.
    • id

      public int id
      Unique identifier of this instruction.
    • reads

      public ArrayList<NRegister> reads
      Registers that store the inputs (if any) of this instruction.
    • write

      public NRegister write
      Register that stores the result (if any) of this instruction.
  • Constructor Details

    • NLIRInstruction

      protected NLIRInstruction(NBasicBlock block, int id)
      Constructs an NLIRInstruction object.
      Parameters:
      block - enclosing block.
      id - identifier of the instruction.
  • Method Details

    • allocatePhysicalRegisters

      public void allocatePhysicalRegisters()
      Replace references to virtual registers in this LIR instruction with references to physical registers.
    • toSpim

      public void toSpim(PrintWriter out)
      Translates this LIR instruction into SPIM and writes it out to the specified output stream.
      Parameters:
      out - output stream for SPIM code.
    • toString

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