{@inheritDoc}
int oldRegCount = ssaMeth.getRegCount();
BasicRegisterMapper mapper
= new BasicRegisterMapper(oldRegCount);
int nextNewRegister = 0;
if (PRESLOT_PARAMS) {
/*
* Reserve space for the params at the bottom of the register
* space. Later, we'll flip the params to the end of the register
* space.
*/
nextNewRegister = ssaMeth.getParamWidth();
}
for (int i = 0; i < oldRegCount; i++) {
if (mapped.get(i)) {
// we already got this one
continue;
}
int maxCategory = getCategoryForSsaReg(i);
IntSet current = new BitIntSet(oldRegCount);
interference.mergeInterferenceSet(i, current);
boolean isPreslotted = false;
int newReg = 0;
if (PRESLOT_PARAMS && isDefinitionMoveParam(i)) {
// Any move-param definition must be a NormalSsaInsn
NormalSsaInsn defInsn = (NormalSsaInsn)
ssaMeth.getDefinitionForRegister(i);
newReg = paramNumberFromMoveParam(defInsn);
mapper.addMapping(i, newReg, maxCategory);
isPreslotted = true;
} else {
mapper.addMapping(i, nextNewRegister, maxCategory);
newReg = nextNewRegister;
}
for (int j = i + 1; j < oldRegCount; j++) {
if (mapped.get(j) || isDefinitionMoveParam(j)) {
continue;
}
/*
* If reg j doesn't interfere with the current mapping.
* Also, if this is a pre-slotted method parameter, we
* can't use more than the original param width.
*/
if (!current.has(j)
&& !(isPreslotted
&& (maxCategory < getCategoryForSsaReg(j)))) {
interference.mergeInterferenceSet(j, current);
maxCategory = Math.max(maxCategory,
getCategoryForSsaReg(j));
mapper.addMapping(j, newReg, maxCategory);
mapped.set(j);
}
}
mapped.set(i);
if (!isPreslotted) {
nextNewRegister += maxCategory;
}
}
return mapper;