InterferenceRegisterMapperpublic class InterferenceRegisterMapper extends BasicRegisterMapper A register mapper that keeps track of the accumulated interference
information for the registers in the new namespace.
Please note that this mapper requires that the old namespace does not
have variable register widths/categories, and the new namespace does. |
Fields Summary |
---|
private final ArrayList | newRegInterferenceArray of interference sets. ArrayList is indexed by new namespace
and BitIntSet's are indexed by old namespace. The list expands
as needed and missing items are assumed to interfere with nothing.
Bit sets are always used here, unlike elsewhere, because the max
size of this matrix will be (countSsaRegs * countRopRegs), which may
grow to hundreds of K but not megabytes. | private final com.android.dx.ssa.back.InterferenceGraph | oldRegInterferenceThe interference graph for the old namespace |
Constructors Summary |
---|
public InterferenceRegisterMapper(com.android.dx.ssa.back.InterferenceGraph oldRegInterference, int countOldRegisters)
super(countOldRegisters);
newRegInterference = new ArrayList<BitIntSet>();
this.oldRegInterference = oldRegInterference;
|
Methods Summary |
---|
private void | addInterfence(int newReg, int oldReg)Adds a register's interference set to the interference list,
growing it if necessary.
newRegInterference.ensureCapacity(newReg + 1);
while (newReg >= newRegInterference.size()) {
newRegInterference.add(new BitIntSet(newReg +1));
}
oldRegInterference.mergeInterferenceSet(
oldReg, newRegInterference.get(newReg));
| public void | addMapping(int oldReg, int newReg, int category){@inheritDoc}
super.addMapping(oldReg, newReg, category);
addInterfence(newReg, oldReg);
if (category == 2) {
addInterfence(newReg + 1, oldReg);
}
| public boolean | areAnyPinned(com.android.dx.rop.code.RegisterSpecList oldSpecs, int newReg, int targetCategory)Checks to see if any of a set of old-namespace registers are
pinned to the specified new-namespace reg + category. Takes into
account the category of the old-namespace registers.
int sz = oldSpecs.size();
for (int i = 0; i < sz; i++) {
RegisterSpec oldSpec = oldSpecs.get(i);
int r = oldToNew(oldSpec.getReg());
/*
* If oldSpec is a category-2 register, then check both newReg
* and newReg - 1.
*/
if (r == newReg
|| (oldSpec.getCategory() == 2 && (r + 1) == newReg)
|| (targetCategory == 2 && (r == newReg + 1))) {
return true;
}
}
return false;
| public boolean | interferes(int oldReg, int newReg, int category)Checks to see if old namespace reg oldReg interferes
with what currently maps to newReg .
if (newReg >= newRegInterference.size()) {
return false;
} else {
IntSet existing = newRegInterference.get(newReg);
if (existing == null) {
return false;
} else if (category == 1) {
return existing.has(oldReg);
} else {
return existing.has(oldReg)
|| (interferes(oldReg, newReg+1, category-1));
}
}
| public boolean | interferes(com.android.dx.rop.code.RegisterSpec oldSpec, int newReg)Checks to see if old namespace reg oldReg interferes
with what currently maps to newReg .
return interferes(oldSpec.getReg(), newReg, oldSpec.getCategory());
|
|