Esempio n. 1
0
  /** {@inheritDoc} */
  @Override
  public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int cpi = ((CstInsn) insn).getIndex();

    write(out, opcodeUnit(insn, regs.get(0).getReg()), (short) cpi);
  }
Esempio n. 2
0
  /** {@inheritDoc} */
  @Override
  public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int offset = ((TargetInsn) insn).getTargetOffset();

    write(out, opcodeUnit(insn, regs.get(0).getReg()), (short) offset, (short) (offset >> 16));
  }
Esempio n. 3
0
  /** {@inheritDoc} */
  @Override
  public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    return (insn instanceof TargetInsn)
        && (regs.size() == 1)
        && unsignedFitsInByte(regs.get(0).getReg());
  }
Esempio n. 4
0
  /** {@inheritDoc} */
  @Override
  public boolean isCompatible(DalvInsn insn) {
    if (!((insn instanceof TargetInsn) && (insn.getRegisters().size() == 0))) {
      return false;
    }

    TargetInsn ti = (TargetInsn) insn;
    return ti.hasTargetOffset() ? branchFits(ti) : true;
  }
Esempio n. 5
0
  /** {@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();

    if (!unsignedFitsInShort(cpi)) {
      return false;
    }

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
  }
Esempio n. 6
0
  /** {@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;
  }
Esempio n. 7
0
 /** {@inheritDoc} */
 @Override
 public String insnArgString(DalvInsn insn) {
   RegisterSpecList regs = insn.getRegisters();
   return regs.get(0).regString() + ", " + cstString(insn);
 }