public abstract class InsnFormat
extends java.lang.Object
DalvInsn instances into
streams of code units, as well as human-oriented listing strings
representing such translations.| Modifier and Type | Field and Description |
|---|---|
static boolean |
ALLOW_EXTENDED_OPCODES
flag to enable/disable the new extended opcode formats; meant as a
temporary measure until VM support for the salient opcodes is
added.
|
| Constructor and Description |
|---|
InsnFormat() |
| Modifier and Type | Method and Description |
|---|---|
protected static int |
argIndex(DalvInsn insn)
Helper method to extract the callout-argument index from an
appropriate instruction.
|
protected static java.lang.String |
branchComment(DalvInsn insn)
Helper method to return the comment for a branch.
|
boolean |
branchFits(TargetInsn insn)
Returns whether or not the given instruction's branch offset will
fit in this instance's format.
|
protected static java.lang.String |
branchString(DalvInsn insn)
Helper method to return a branch address string.
|
abstract int |
codeSize()
Gets the code size of instructions that use this format.
|
protected static short |
codeUnit(int low,
int high)
Helper method to combine two bytes into a code unit.
|
protected static short |
codeUnit(int n0,
int n1,
int n2,
int n3)
Helper method to combine four nibbles into a code unit.
|
java.util.BitSet |
compatibleRegs(DalvInsn insn)
Returns which of a given instruction's registers will fit in
this instance's format.
|
abstract java.lang.String |
insnArgString(DalvInsn insn)
Returns the string form of the arguments to the given instruction.
|
abstract java.lang.String |
insnCommentString(DalvInsn insn,
boolean noteIndices)
Returns the associated comment for the given instruction, if any.
|
abstract boolean |
isCompatible(DalvInsn insn)
Returns whether or not the given instruction's arguments will
fit in this instance's format.
|
protected static boolean |
isRegListSequential(RegisterSpecList list)
Helper method to determine if a list of registers are sequential,
including degenerate cases for empty or single-element lists.
|
java.lang.String |
listingString(DalvInsn insn,
boolean noteIndices)
Returns the string form, suitable for inclusion in a listing
dump, of the given instruction.
|
protected static java.lang.String |
literalBitsComment(CstLiteralBits value,
int width)
Helper method to return a literal bits comment string.
|
protected static java.lang.String |
literalBitsString(CstLiteralBits value)
Helper method to return a literal bits argument string.
|
protected static int |
makeByte(int low,
int high)
Helper method to combine two nibbles into a byte.
|
protected static short |
opcodeUnit(DalvInsn insn)
Helper method to get an extended (16-bit) opcode out of an
instruction, returning it as a code unit.
|
protected static short |
opcodeUnit(DalvInsn insn,
int arg)
Helper method to combine an opcode and a second byte of data into
the appropriate form for emitting into a code buffer.
|
protected static java.lang.String |
regListString(RegisterSpecList list)
Helper method to return a register list string.
|
protected static java.lang.String |
regRangeString(RegisterSpecList list)
Helper method to return a register range string.
|
protected static boolean |
signedFitsInByte(int value)
Helper method to determine if a signed int value fits in a byte.
|
protected static boolean |
signedFitsInNibble(int value)
Helper method to determine if a signed int value fits in a nibble.
|
protected static boolean |
signedFitsInShort(int value)
Helper method to determine if a signed int value fits in a short.
|
protected static boolean |
unsignedFitsInByte(int value)
Helper method to determine if an unsigned int value fits in a byte.
|
protected static boolean |
unsignedFitsInNibble(int value)
Helper method to determine if an unsigned int value fits in a nibble.
|
protected static boolean |
unsignedFitsInShort(int value)
Helper method to determine if an unsigned int value fits in a short.
|
protected static void |
write(AnnotatedOutput out,
short c0)
Writes one code unit to the given output destination.
|
protected static void |
write(AnnotatedOutput out,
short c0,
int c1c2)
Writes three code units to the given output destination, where the
second and third are represented as single
int and emitted
in little-endian order. |
protected static void |
write(AnnotatedOutput out,
short c0,
int c1c2,
short c3)
Writes four code units to the given output destination, where the
second and third are represented as single
int and emitted
in little-endian order. |
protected static void |
write(AnnotatedOutput out,
short c0,
int c1c2,
short c3,
short c4)
Writes five code units to the given output destination, where the
second and third are represented as single
int and emitted
in little-endian order. |
protected static void |
write(AnnotatedOutput out,
short c0,
long c1c2c3c4)
Writes five code units to the given output destination, where the
second through fifth are represented as single
long
and emitted in little-endian order. |
protected static void |
write(AnnotatedOutput out,
short c0,
short c1)
Writes two code units to the given output destination.
|
protected static void |
write(AnnotatedOutput out,
short c0,
short c1,
short c2)
Writes three code units to the given output destination.
|
protected static void |
write(AnnotatedOutput out,
short c0,
short c1,
short c2,
short c3)
Writes four code units to the given output destination.
|
protected static void |
write(AnnotatedOutput out,
short c0,
short c1,
short c2,
short c3,
short c4)
Writes five code units to the given output destination.
|
abstract void |
writeTo(AnnotatedOutput out,
DalvInsn insn)
Writes the code units for the given instruction to the given
output destination.
|
public static final boolean ALLOW_EXTENDED_OPCODES
public final java.lang.String listingString(DalvInsn insn, boolean noteIndices)
insn - non-null; the instructionnoteIndices - whether to include an explicit notation of
constant pool indicesnon-null; the string formpublic abstract java.lang.String insnArgString(DalvInsn insn)
"", not
null.
Subclasses must override this method.
insn - non-null; the instructionnon-null; the string formpublic abstract java.lang.String insnCommentString(DalvInsn insn, boolean noteIndices)
"", not
null.
Subclasses must override this method.
insn - non-null; the instructionnoteIndices - whether to include an explicit notation of
constant pool indicesnon-null; the string formpublic abstract int codeSize()
>= 0; the instruction length in 16-bit code unitspublic abstract boolean isCompatible(DalvInsn insn)
Subclasses must override this method.
insn - non-null; the instruction to checktrue iff the instruction's arguments are
appropriate for this instance, or false if notpublic java.util.BitSet compatibleRegs(DalvInsn insn)
The default implementation of this method always returns an empty BitSet. Subclasses must override this method if they have registers.
insn - non-null; the instruction to checknon-null; a BitSet flagging registers in the
register list that are compatible to this formatpublic boolean branchFits(TargetInsn insn)
false
for formats that don't include a branch offset.
The default implementation of this method always returns
false. Subclasses must override this method if they
include branch offsets.
insn - non-null; the instruction to checktrue iff the instruction's branch offset is
appropriate for this instance, or false if notpublic abstract void writeTo(AnnotatedOutput out, DalvInsn insn)
Subclasses must override this method.
out - non-null; the output destination to write toinsn - non-null; the instruction to writeprotected static java.lang.String regListString(RegisterSpecList list)
list - non-null; the list of registersnon-null; the string formprotected static java.lang.String regRangeString(RegisterSpecList list)
list - non-null; the list of registers (which must be
sequential)non-null; the string formprotected static java.lang.String literalBitsString(CstLiteralBits value)
value - the valuenon-null; the string formprotected static java.lang.String literalBitsComment(CstLiteralBits value, int width)
value - the valuewidth - the width of the constant, in bits (used for displaying
the uninterpreted bits; one of: 4 8 16 32 64non-null; the commentprotected static java.lang.String branchString(DalvInsn insn)
insn - non-null; the instruction in questionnon-null; the string form of the instruction's
branch targetprotected static java.lang.String branchComment(DalvInsn insn)
insn - non-null; the instruction in questionnon-null; the commentprotected static boolean signedFitsInNibble(int value)
value - the value in questiontrue iff it's in the range -8..+7protected static boolean unsignedFitsInNibble(int value)
value - the value in questiontrue iff it's in the range 0..0xfprotected static boolean signedFitsInByte(int value)
value - the value in questiontrue iff it's in the range -0x80..+0x7fprotected static boolean unsignedFitsInByte(int value)
value - the value in questiontrue iff it's in the range 0..0xffprotected static boolean signedFitsInShort(int value)
value - the value in questiontrue iff it's in the range -0x8000..+0x7fffprotected static boolean unsignedFitsInShort(int value)
value - the value in questiontrue iff it's in the range 0..0xffffprotected static boolean isRegListSequential(RegisterSpecList list)
list - non-null; the list of registerstrue iff the list is sequentially orderedprotected static int argIndex(DalvInsn insn)
insn - non-null; the instruction>= 0; the callout argument indexprotected static short opcodeUnit(DalvInsn insn, int arg)
insn - non-null; the instruction containing the opcodearg - 0..255; arbitrary other byte valueprotected static short opcodeUnit(DalvInsn insn)
insn - non-null; the instruction containing the
extended opcodeprotected static short codeUnit(int low,
int high)
low - 0..255; low bytehigh - 0..255; high byteprotected static short codeUnit(int n0,
int n1,
int n2,
int n3)
n0 - 0..15; low nibblen1 - 0..15; medium-low nibblen2 - 0..15; medium-high nibblen3 - 0..15; high nibbleprotected static int makeByte(int low,
int high)
low - 0..15; low nibblehigh - 0..15; high nibble0..255; combined valueprotected static void write(AnnotatedOutput out, short c0)
out - non-null; where to write toc0 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, short c1)
out - non-null; where to write toc0 - code unit to writec1 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, short c1, short c2)
out - non-null; where to write toc0 - code unit to writec1 - code unit to writec2 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, short c1, short c2, short c3)
out - non-null; where to write toc0 - code unit to writec1 - code unit to writec2 - code unit to writec3 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, short c1, short c2, short c3, short c4)
out - non-null; where to write toc0 - code unit to writec1 - code unit to writec2 - code unit to writec3 - code unit to writec4 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, int c1c2)
int and emitted
in little-endian order.out - non-null; where to write toc0 - code unit to writec1c2 - code unit pair to writeprotected static void write(AnnotatedOutput out, short c0, int c1c2, short c3)
int and emitted
in little-endian order.out - non-null; where to write toc0 - code unit to writec1c2 - code unit pair to writec3 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, int c1c2, short c3, short c4)
int and emitted
in little-endian order.out - non-null; where to write toc0 - code unit to writec1c2 - code unit pair to writec3 - code unit to writec4 - code unit to writeprotected static void write(AnnotatedOutput out, short c0, long c1c2c3c4)
long
and emitted in little-endian order.out - non-null; where to write toc0 - code unit to writec1c2c3c4 - code unit quad to writeCopyright © 2020. All Rights Reserved.