use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.
the class Form12x method writeTo.
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
int sz = regs.size();
/*
* The (sz - 2) and (sz - 1) below makes this code work for
* both the two- and three-register ops. (See "case 3" in
* isCompatible(), above.)
*/
write(out, opcodeUnit(insn, makeByte(regs.get(sz - 2).getReg(), regs.get(sz - 1).getReg())));
}
use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.
the class Form12x method compatibleRegs.
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
BitSet bits = new BitSet(2);
int r0 = regs.get(0).getReg();
int r1 = regs.get(1).getReg();
switch(regs.size()) {
case 2:
{
bits.set(0, unsignedFitsInNibble(r0));
bits.set(1, unsignedFitsInNibble(r1));
break;
}
case 3:
{
if (r0 != r1) {
bits.set(0, false);
bits.set(1, false);
} else {
boolean dstRegComp = unsignedFitsInNibble(r1);
bits.set(0, dstRegComp);
bits.set(1, dstRegComp);
}
bits.set(2, unsignedFitsInNibble(regs.get(2).getReg()));
break;
}
default:
{
throw new AssertionError();
}
}
return bits;
}
use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.
the class Form12x method insnArgString.
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
int sz = regs.size();
return regs.get(sz - 2).regString() + ", " + regs.get(sz - 1).regString();
}
use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.
the class Form21c 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;
}
use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.
the class Form21c method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
if (!(insn instanceof CstInsn)) {
return false;
}
RegisterSpecList regs = insn.getRegisters();
RegisterSpec reg;
switch(regs.size()) {
case 1:
{
reg = regs.get(0);
break;
}
case 2:
{
/*
* This format is allowed for ops that are effectively
* 2-arg but where the two args are identical.
*/
reg = regs.get(0);
if (reg.getReg() != regs.get(1).getReg()) {
return false;
}
break;
}
default:
{
return false;
}
}
if (!unsignedFitsInByte(reg.getReg())) {
return false;
}
CstInsn ci = (CstInsn) insn;
int cpi = ci.getIndex();
Constant cst = ci.getConstant();
if (!unsignedFitsInShort(cpi)) {
return false;
}
return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
}
Aggregations