private void expandRegister(int regIdx, RegisterSpec registerToExpand) {
      boolean replace = (compatRegs == null) || !compatRegs.get(regIdx);
      RegisterSpec expandedReg;

      if (replace) {
        expandedReg = registerToExpand.withReg(base);
        if (!duplicateFirst) {
          base += expandedReg.getCategory();
        }
      } else {
        expandedReg = registerToExpand;
      }

      // Reset duplicateFirst when the first register has been dealt with.
      duplicateFirst = false;

      result.set0(regIdx, expandedReg);
    }
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.

@param base the base register number
@param duplicateFirst whether to duplicate the first number
@param compatRegs {@code null-ok;} either a {@code non-null} set of compatible registers, or
    {@code null} to indicate all registers are incompatible
@return {@code non-null;} an appropriately-constructed instance
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/code/RegisterSpecList.java