blob: 064048e6d5e15a734d50b48479179d18dc5ecff5 [file] [log] [blame]
// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.ir.regalloc;
/**
* Simple mapping from a register to an int value.
*
* <p>The backing for the mapping grows as needed up to a given limit. If no mapping exists for a
* register number the value is assumed to be Integer.MAX_VALUE.
*/
public abstract class RegisterPositions {
enum RegisterType {
MONITOR,
CONST_NUMBER,
OTHER,
ANY
}
public abstract boolean hasType(int index, RegisterType type);
public abstract void set(int index, int value, LiveIntervals intervals);
public abstract int get(int index);
public final int get(int index, boolean isWide) {
int result = get(index);
if (isWide) {
return Math.min(result, get(index + 1));
}
return result;
}
public abstract int getLimit();
public abstract void setBlocked(int index);
public abstract boolean isBlocked(int index);
public final boolean isBlocked(int index, boolean isWide) {
if (isBlocked(index)) {
return true;
}
return isWide && isBlocked(index + 1);
}
}