Class IRInstruction

    • Method Detail

      • getId

        public int getId()
        Returns:
        the id
      • getBlock

        public IRBlock getBlock()
        Returns:
        the block
      • setBlock

        public void setBlock​(IRBlock block)
        Parameters:
        block - the block containing this instruction
      • getResult

        public SSAValue getResult()
        Returns:
        the result
      • setResult

        public void setResult​(SSAValue result)
        Parameters:
        result - the SSA value produced by this instruction, or null for none
      • getBytecodeOffset

        public int getBytecodeOffset()
        Stamped by the lifter so SSA instructions can be correlated back to their source bytecode (e.g. data-flow provenance).
        Returns:
        the originating bytecode offset, or -1 when unknown
      • setBytecodeOffset

        public void setBytecodeOffset​(int bytecodeOffset)
        Parameters:
        bytecodeOffset - the originating bytecode offset, or -1 when unknown
      • getOperands

        public abstract List<Value> getOperands()
        Gets the operands used by this instruction.
        Returns:
        list of operand values
      • replaceOperand

        public abstract void replaceOperand​(Value oldValue,
                                            Value newValue)
        Replaces an operand value with a new value.
        Parameters:
        oldValue - the value to replace
        newValue - the replacement value
      • accept

        public abstract <T> T accept​(IRVisitor<T> visitor)
        Accepts a visitor for this instruction.
        Type Parameters:
        T - the return type
        Parameters:
        visitor - the visitor to accept
        Returns:
        the visitor result
      • hasResult

        public boolean hasResult()
        Checks if this instruction produces a result value.
        Returns:
        true if instruction has a result
      • getResultType

        public IRType getResultType()
        Gets the type of the result value.
        Returns:
        the result type, or null if no result
      • isTerminator

        public boolean isTerminator()
        Checks if this instruction terminates a basic block.
        Returns:
        true if this is a terminator instruction
      • isPhi

        public boolean isPhi()
        Checks if this is a phi instruction.
        Returns:
        true if this is a phi instruction
      • resetIdCounter

        public static void resetIdCounter()
        Resets the instruction ID counter.
      • equals

        public boolean equals​(Object o)
        Identity by id.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copyWithNewOperands

        public IRInstruction copyWithNewOperands​(SSAValue newResult,
                                                 List<Value> newOperands)
        Creates a copy of this instruction with new result and operands.
        Parameters:
        newResult - the new result value (may be null)
        newOperands - the new operand values
        Returns:
        a copy of this instruction, or null if copying not supported
      • replaceTarget

        public void replaceTarget​(IRBlock oldTarget,
                                  IRBlock newTarget)
        Replaces a target block in terminator instructions.
        Parameters:
        oldTarget - the block to replace
        newTarget - the replacement block