@Override
    public void encode(DecodedInstruction insn, CodeOutput out) {
      FillArrayDataPayloadDecodedInstruction payload =
          (FillArrayDataPayloadDecodedInstruction) insn;
      short elementWidth = payload.getElementWidthUnit();
      Object data = payload.getData();

      out.write(payload.getOpcodeUnit());
      out.write(elementWidth);
      out.writeInt(payload.getSize());

      switch (elementWidth) {
        case 1:
          out.write((byte[]) data);
          break;
        case 2:
          out.write((short[]) data);
          break;
        case 4:
          out.write((int[]) data);
          break;
        case 8:
          out.write((long[]) data);
          break;
        default:
          {
            throw new DexException("bogus element_width: " + Hex.u2(elementWidth));
          }
      }
    }
Representation of an instruction format, which knows how to decode into and encode from instances
of {@link DecodedInstruction}.
android/android_framework/dex-maker/src/main/java/com/android/dx/io/instructions/InstructionCodec.java