Package jminusminus

Class NHIRInstruction

java.lang.Object
jminusminus.NHIRInstruction
Direct Known Subclasses:
NHIRALoad, NHIRArithmetic, NHIRAStore, NHIRConditionalJump, NHIRGetField, NHIRGoto, NHIRIntConstant, NHIRInvoke, NHIRLoadLocal, NHIRLocal, NHIRNewArray, NHIRPhiFunction, NHIRPutField, NHIRReturn, NHIRStringConstant

abstract class NHIRInstruction extends Object
This abstract base class provides a high-level intermediate representation (HIR) of a JVM instruction.
  • Field Details

    • hirMnemonic

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

      public NBasicBlock block
      The block containing this instruction.
    • id

      public int id
      Unique identifier of this instruction.
    • sType

      public String sType
      Short type name for this instruction.
    • lType

      public String lType
      Long type name for this instruction.
    • lir

      public NLIRInstruction lir
      The LIR instruction corresponding to this HIR instruction.
  • Constructor Details

    • NHIRInstruction

      protected NHIRInstruction(NBasicBlock block, int id)
      Constructs a NHIRInstruction object.
      Parameters:
      block - enclosing block.
      id - identifier of the instruction.
    • NHIRInstruction

      protected NHIRInstruction(NBasicBlock block, int id, String sType, String lType)
      Constructs a NHIRInstruction object.
      Parameters:
      block - enclosing block.
      id - identifier of the instruction.
      sType - short type name of the instruction.
      lType - long type name of the instruction.
  • Method Details

    • equals

      public boolean equals(NHIRInstruction other)
      Returns true if this instruction is the same as the other, and false otherwise.
      Parameters:
      other - the instruction to compare to.
      Returns:
      true if this instruction is the same as the other, and false otherwise.
    • toLir

      public NLIRInstruction toLir()
      Converts and returns a low-level representation (LIR) of this HIR instruction. Also adds the returned LIR instruction to the list of LIR instructions for the block containing this instruction, along with any other intermediate LIR instructions needed.
      Returns:
      the LIR instruction corresponding to this HIR instruction.
    • id

      public String id()
      Returns the identifier of this instruction with the short type name prefix.
      Returns:
      the identifier of this instruction with the short type name prefix.
    • toString

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