use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class Form22x method compatibleRegs.
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
BitSet bits = new BitSet(2);
bits.set(0, unsignedFitsInByte(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 DeadCodeRemover method pruneDeadInstructions.
/**
* Removes all instructions from every unreachable block.
*/
private void pruneDeadInstructions() {
HashSet<SsaInsn> deletedInsns = new HashSet<SsaInsn>();
ssaMeth.computeReachability();
for (SsaBasicBlock block : ssaMeth.getBlocks()) {
if (block.isReachable())
continue;
// Prune instructions from unreachable blocks
for (int i = 0; i < block.getInsns().size(); i++) {
SsaInsn insn = block.getInsns().get(i);
RegisterSpecList sources = insn.getSources();
int sourcesSize = sources.size();
// Delete this instruction completely if it has sources
if (sourcesSize != 0) {
deletedInsns.add(insn);
}
// Delete this instruction from all usage lists.
for (int j = 0; j < sourcesSize; j++) {
RegisterSpec source = sources.get(j);
useList[source.getReg()].remove(insn);
}
// Remove this instruction result from the sources of any phis
RegisterSpec result = insn.getResult();
if (result == null)
continue;
for (SsaInsn use : useList[result.getReg()]) {
if (use instanceof PhiInsn) {
PhiInsn phiUse = (PhiInsn) use;
phiUse.removePhiRegister(result);
}
}
}
}
ssaMeth.deleteInsns(deletedInsns);
}
use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class Form3rc method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
if (!(insn instanceof CstInsn)) {
return false;
}
CstInsn ci = (CstInsn) insn;
int cpi = ci.getIndex();
Constant cst = ci.getConstant();
if (!unsignedFitsInShort(cpi)) {
return false;
}
if (!((cst instanceof CstMethodRef) || (cst instanceof CstType))) {
return false;
}
RegisterSpecList regs = ci.getRegisters();
int sz = regs.size();
return (regs.size() == 0) || (isRegListSequential(regs) && unsignedFitsInShort(regs.get(0).getReg()) && unsignedFitsInByte(regs.getWordCount()));
}
use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class Form51l method writeTo.
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
long value = ((CstLiteral64) ((CstInsn) insn).getConstant()).getLongBits();
write(out, opcodeUnit(insn, regs.get(0).getReg()), value);
}
use of com.taobao.android.dx.rop.code.RegisterSpecList in project atlas by alibaba.
the class Form31c method compatibleRegs.
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
int sz = regs.size();
BitSet bits = new BitSet(sz);
boolean compat = unsignedFitsInByte(regs.get(0).getReg());
if (sz == 1) {
bits.set(0, compat);
} else {
if (regs.get(0).getReg() == regs.get(1).getReg()) {
bits.set(0, compat);
bits.set(1, compat);
}
}
return bits;
}
Aggregations