Class RegisterSpecList

All Implemented Interfaces:
TypeList, ToHuman

public final class RegisterSpecList extends FixedSizeList implements TypeList
List of RegisterSpec instances.
  • Field Details

    • EMPTY

      public static final RegisterSpecList EMPTY
      non-null; no-element instance
  • Constructor Details

    • RegisterSpecList

      public RegisterSpecList(int size)
      Constructs an instance. All indices initially contain null.
      Parameters:
      size - the size of the list
  • Method Details

    • make

      public static RegisterSpecList make(RegisterSpec spec)
      Makes a single-element instance.
      Parameters:
      spec - non-null; the element
      Returns:
      non-null; an appropriately-constructed instance
    • make

      public static RegisterSpecList make(RegisterSpec spec0, RegisterSpec spec1)
      Makes a two-element instance.
      Parameters:
      spec0 - non-null; the first element
      spec1 - non-null; the second element
      Returns:
      non-null; an appropriately-constructed instance
    • make

      public static RegisterSpecList make(RegisterSpec spec0, RegisterSpec spec1, RegisterSpec spec2)
      Makes a three-element instance.
      Parameters:
      spec0 - non-null; the first element
      spec1 - non-null; the second element
      spec2 - non-null; the third element
      Returns:
      non-null; an appropriately-constructed instance
    • make

      public static RegisterSpecList make(RegisterSpec spec0, RegisterSpec spec1, RegisterSpec spec2, RegisterSpec spec3)
      Makes a four-element instance.
      Parameters:
      spec0 - non-null; the first element
      spec1 - non-null; the second element
      spec2 - non-null; the third element
      spec3 - non-null; the fourth element
      Returns:
      non-null; an appropriately-constructed instance
    • getType

      public Type getType(int n)
      Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.
      Specified by:
      getType in interface TypeList
      Parameters:
      n - >= 0, < size(); which element
      Returns:
      non-null; the indicated element
    • getWordCount

      public int getWordCount()
      Gets the number of 32-bit words required to hold instances of all the elements of this list. This is a sum of the widths (categories) of all the elements.
      Specified by:
      getWordCount in interface TypeList
      Returns:
      >= 0; the required number of words
    • withAddedType

      public TypeList withAddedType(Type type)
      Returns a new instance which is identical to this one, except that the given item is appended to the end and it is guaranteed to be immutable.
      Specified by:
      withAddedType in interface TypeList
      Parameters:
      type - non-null; item to append
      Returns:
      non-null; an appropriately-constructed instance
    • get

      public RegisterSpec get(int n)
      Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.
      Parameters:
      n - >= 0, < size(); which element
      Returns:
      non-null; the indicated element
    • specForRegister

      public RegisterSpec specForRegister(int reg)
      Returns a RegisterSpec in this list that uses the specified register, or null if there is none in this list.
      Parameters:
      reg - Register to find
      Returns:
      RegisterSpec that uses argument or null.
    • indexOfRegister

      public int indexOfRegister(int reg)
      Returns the index of a RegisterSpec in this list that uses the specified register, or -1 if none in this list uses the register.
      Parameters:
      reg - Register to find
      Returns:
      index of RegisterSpec or -1
    • set

      public void set(int n, RegisterSpec spec)
      Sets the element at the given index.
      Parameters:
      n - >= 0, < size(); which element
      spec - non-null; the value to store
    • getRegistersSize

      public int getRegistersSize()
      Gets the minimum required register count implied by this instance. This is equal to the highest register number referred to plus the widest width (largest category) of the type used in that register.
      Returns:
      >= 0; the required registers size
    • withFirst

      public RegisterSpecList withFirst(RegisterSpec spec)
      Returns a new instance, which is the same as this instance, except that it has an additional element prepended to the original. Mutability of the result is inherited from the original.
      Parameters:
      spec - non-null; the new first spec (to prepend)
      Returns:
      non-null; an appropriately-constructed instance
    • withoutFirst

      public RegisterSpecList withoutFirst()
      Returns a new instance, which is the same as this instance, except that its first element is removed. Mutability of the result is inherited from the original.
      Returns:
      non-null; an appropriately-constructed instance
    • withoutLast

      public RegisterSpecList withoutLast()
      Returns a new instance, which is the same as this instance, except that its last element is removed. Mutability of the result is inherited from the original.
      Returns:
      non-null; an appropriately-constructed instance
    • subset

      public RegisterSpecList subset(BitSet exclusionSet)
      Returns a new instance, which contains a subset of the elements specified by the given BitSet. Indexes in the BitSet with a zero are included, while indexes with a one are excluded. Mutability of the result is inherited from the original.
      Parameters:
      exclusionSet - non-null; set of registers to exclude
      Returns:
      non-null; an appropriately-constructed instance
    • withOffset

      public RegisterSpecList withOffset(int delta)
      Returns an instance that is identical to this one, except that all register numbers are offset by the given amount. Mutability of the result is inherited from the original.
      Parameters:
      delta - the amount to offset the register numbers by
      Returns:
      non-null; an appropriately-constructed instance
    • withExpandedRegisters

      public RegisterSpecList withExpandedRegisters(int base, boolean duplicateFirst, BitSet compatRegs)
      Returns an instance that is identical to this one, except that all incompatible register numbers are renumbered sequentially from the given base, with the first number duplicated if indicated. If a null BitSet is given, it indicates all registers are incompatible.
      Parameters:
      base - the base register number
      duplicateFirst - whether to duplicate the first number
      compatRegs - null-ok; either a non-null set of compatible registers, or null to indicate all registers are incompatible
      Returns:
      non-null; an appropriately-constructed instance