Class SSAValue

  • All Implemented Interfaces:
    Value

    public class SSAValue
    extends Object
    implements Value
    Represents a value defined by an SSA instruction.
    • Constructor Detail

      • SSAValue

        public SSAValue​(IRType type)
        Creates an SSA value with the given type.
        Parameters:
        type - the IR type of this value
      • SSAValue

        public SSAValue​(IRType type,
                        String name)
        Creates an SSA value with the given type and name.
        Parameters:
        type - the IR type of this value
        name - the name for this value
    • Method Detail

      • getId

        public int getId()
        Returns:
        the id
      • getType

        public IRType getType()
        Description copied from interface: Value
        Gets the IR type of this value.
        Specified by:
        getType in interface Value
        Returns:
        the type
      • getName

        public String getName()
        Returns:
        the name
      • setName

        public void setName​(String name)
        Renames this value.
        Parameters:
        name - the new name
      • getDefinition

        public IRInstruction getDefinition()
        Returns:
        the definition
      • setDefinition

        public void setDefinition​(IRInstruction definition)
        Records the instruction that produces this value.
        Parameters:
        definition - the defining instruction
      • isConstant

        public boolean isConstant()
        Description copied from interface: Value
        Checks if this value is a constant.
        Specified by:
        isConstant in interface Value
        Returns:
        true if constant, false otherwise
      • addUse

        public void addUse​(IRInstruction instruction)
        Adds a use of this value by an instruction.
        Parameters:
        instruction - the instruction using this value
      • removeUse

        public void removeUse​(IRInstruction instruction)
        Removes a use of this value by an instruction.
        Parameters:
        instruction - the instruction to remove
      • hasUses

        public boolean hasUses()
        Checks if this value has any uses.
        Returns:
        true if there are uses, false otherwise
      • getUseCount

        public int getUseCount()
        Gets the number of uses of this value.
        Returns:
        the use count
      • replaceAllUsesWith

        public void replaceAllUsesWith​(Value newValue)
        Replaces all uses of this value with a new value.
        Parameters:
        newValue - the value to replace with
      • resetIdCounter

        public static void resetIdCounter()
        Resets the ID counter for SSA values.
      • equals

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

        public int hashCode()
        Overrides:
        hashCode in class Object