use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class Form32x method compatibleRegs.
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
BitSet bits = new BitSet(2);
bits.set(0, unsignedFitsInShort(regs.get(0).getReg()));
bits.set(1, unsignedFitsInShort(regs.get(1).getReg()));
return bits;
}
use of com.taobao.android.dx.rop.code.RegisterSpecList 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.RegisterSpecList in project atlas by alibaba.
the class Form35c method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
if (!(insn instanceof CstInsn)) {
return false;
}
CstInsn ci = (CstInsn) insn;
int cpi = ci.getIndex();
if (!unsignedFitsInShort(cpi)) {
return false;
}
Constant cst = ci.getConstant();
if (!((cst instanceof CstMethodRef) || (cst instanceof CstType))) {
return false;
}
RegisterSpecList regs = ci.getRegisters();
return (wordCount(regs) >= 0);
}
use of com.taobao.android.dx.rop.code.RegisterSpecList 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.RegisterSpecList in project atlas by alibaba.
the class Form35c method writeTo.
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
int cpi = ((CstInsn) insn).getIndex();
RegisterSpecList regs = explicitize(insn.getRegisters());
int sz = regs.size();
int r0 = (sz > 0) ? regs.get(0).getReg() : 0;
int r1 = (sz > 1) ? regs.get(1).getReg() : 0;
int r2 = (sz > 2) ? regs.get(2).getReg() : 0;
int r3 = (sz > 3) ? regs.get(3).getReg() : 0;
int r4 = (sz > 4) ? regs.get(4).getReg() : 0;
write(out, opcodeUnit(insn, // encode the fifth operand here
makeByte(r4, sz)), (short) cpi, codeUnit(r0, r1, r2, r3));
}
Aggregations