use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.
the class Form35c method explicitize.
/**
* Returns a register list which is equivalent to the given one,
* except that it splits category-2 registers into two explicit
* entries. This returns the original list if no modification is
* required
*
* @param orig {@code non-null;} the original list
* @return {@code non-null;} the list with the described transformation
*/
private static RegisterSpecList explicitize(RegisterSpecList orig) {
int wordCount = wordCount(orig);
int sz = orig.size();
if (wordCount == sz) {
return orig;
}
RegisterSpecList result = new RegisterSpecList(wordCount);
int wordAt = 0;
for (int i = 0; i < sz; i++) {
RegisterSpec one = orig.get(i);
result.set(wordAt, one);
if (one.getCategory() == 2) {
result.set(wordAt + 1, RegisterSpec.make(one.getReg() + 1, Type.VOID));
wordAt += 2;
} else {
wordAt++;
}
}
result.setImmutable();
return result;
}
use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.
the class Form35c method wordCount.
/**
* Gets the number of words required for the given register list, where
* category-2 values count as two words. Return {@code -1} if the
* list requires more than five words or contains registers that need
* more than a nibble to identify them.
*
* @param regs {@code non-null;} the register list in question
* @return {@code >= -1;} the number of words required, or {@code -1}
* if the list couldn't possibly fit in this format
*/
private static int wordCount(RegisterSpecList regs) {
int sz = regs.size();
if (sz > MAX_NUM_OPS) {
// It can't possibly fit.
return -1;
}
int result = 0;
for (int i = 0; i < sz; i++) {
RegisterSpec one = regs.get(i);
result += one.getCategory();
/*
* The check below adds (category - 1) to the register, to
* account for the fact that the second half of a
* category-2 register has to be represented explicitly in
* the result.
*/
if (!unsignedFitsInNibble(one.getReg() + one.getCategory() - 1)) {
return -1;
}
}
return (result <= MAX_NUM_OPS) ? result : -1;
}
use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.
the class Form35c method compatibleRegs.
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
int sz = regs.size();
BitSet bits = new BitSet(sz);
for (int i = 0; i < sz; i++) {
RegisterSpec reg = regs.get(i);
/*
* The check below adds (category - 1) to the register, to
* account for the fact that the second half of a
* category-2 register has to be represented explicitly in
* the result.
*/
bits.set(i, unsignedFitsInNibble(reg.getReg() + reg.getCategory() - 1));
}
return bits;
}
use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.
the class SsaMethod method updateOneDefinition.
/**
* Updates a single definition.
*
* @param insn {@code non-null;} insn who's result should be recorded as
* a definition
* @param oldResult {@code null-ok;} a previous result that should
* be no longer considered a definition by this insn
*/
/*package*/
void updateOneDefinition(SsaInsn insn, RegisterSpec oldResult) {
if (definitionList == null)
return;
if (oldResult != null) {
int reg = oldResult.getReg();
definitionList[reg] = null;
}
RegisterSpec resultReg = insn.getResult();
if (resultReg != null) {
int reg = resultReg.getReg();
if (definitionList[reg] != null) {
throw new RuntimeException("Duplicate add of insn");
} else {
definitionList[resultReg.getReg()] = insn;
}
}
}
use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.
the class FirstFitLocalCombiningAllocator method handleUnassociatedParameters.
/**
* Maps any parameter that isn't local-associated, which can happen
* in the case where there is no java debug info.
*/
private void handleUnassociatedParameters() {
int szSsaRegs = ssaMeth.getRegCount();
for (int ssaReg = 0; ssaReg < szSsaRegs; ssaReg++) {
if (ssaRegsMapped.get(ssaReg)) {
// We already did this one above
continue;
}
int paramIndex = getParameterIndexForReg(ssaReg);
RegisterSpec ssaSpec = getDefinitionSpecForSsaReg(ssaReg);
if (paramIndex >= 0) {
addMapping(ssaSpec, paramIndex);
}
}
}
Aggregations