2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.dx.dex.code.form;
19 import com.android.dx.dex.code.CstInsn;
20 import com.android.dx.dex.code.DalvInsn;
21 import com.android.dx.dex.code.InsnFormat;
22 import com.android.dx.rop.code.RegisterSpecList;
23 import com.android.dx.rop.cst.Constant;
24 import com.android.dx.rop.cst.CstLiteral64;
25 import com.android.dx.rop.cst.CstLiteralBits;
26 import com.android.dx.util.AnnotatedOutput;
29 * Instruction format {@code 51l}. See the instruction format spec
32 public final class Form51l extends InsnFormat {
33 /** {@code non-null;} unique instance of this class */
34 public static final InsnFormat THE_ONE = new Form51l();
37 * Constructs an instance. This class is not publicly
38 * instantiable. Use {@link #THE_ONE}.
41 // This space intentionally left blank.
46 public String insnArgString(DalvInsn insn) {
47 RegisterSpecList regs = insn.getRegisters();
48 CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();
50 return regs.get(0).regString() + ", " + literalBitsString(value);
55 public String insnCommentString(DalvInsn insn, boolean noteIndices) {
56 CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();
57 return literalBitsComment(value, 64);
62 public int codeSize() {
68 public boolean isCompatible(DalvInsn insn) {
69 RegisterSpecList regs = insn.getRegisters();
70 if (!((insn instanceof CstInsn) &&
72 unsignedFitsInByte(regs.get(0).getReg()))) {
76 CstInsn ci = (CstInsn) insn;
77 Constant cst = ci.getConstant();
79 return (cst instanceof CstLiteral64);
84 public void writeTo(AnnotatedOutput out, DalvInsn insn) {
85 RegisterSpecList regs = insn.getRegisters();
87 ((CstLiteral64) ((CstInsn) insn).getConstant()).getLongBits();
89 write(out, opcodeUnit(insn, regs.get(0).getReg()), value);