public abstract class Assembler extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Assembler.InstructionCounter
Instruction counter class which gives the user of the assembler to count different kinds of
instructions in the generated assembler code.
|
static class |
Assembler.LabelHint |
Modifier and Type | Field and Description |
---|---|
private Buffer |
codeBuffer
Backing code buffer.
|
private List<Assembler.LabelHint> |
jumpDisplacementHints |
private Map<Label,String> |
nameMap |
private static String |
NEWLINE |
TargetDescription |
target |
Constructor and Description |
---|
Assembler(TargetDescription target) |
Modifier and Type | Method and Description |
---|---|
abstract void |
align(int modulus) |
void |
bind(Label l) |
private void |
captureLabelPositions() |
byte[] |
close(boolean trimmedCopy)
Closes this assembler.
|
protected String |
createLabelName(Label l,
int id)
Creates a name for a label.
|
void |
emitByte(int x) |
void |
emitByte(int b,
int pos) |
void |
emitInt(int x) |
void |
emitInt(int b,
int pos) |
void |
emitLong(long x) |
void |
emitLong(long b,
int pos) |
void |
emitShort(int x) |
void |
emitShort(int b,
int pos) |
void |
emitString(String x)
Some GPU architectures have a text based encoding.
|
void |
emitString(String s,
int pos) |
void |
emitString0(String x) |
abstract void |
ensureUniquePC()
Emits a NOP instruction to advance the current PC.
|
int |
getByte(int pos) |
Assembler.InstructionCounter |
getInstructionCounter() |
int |
getInt(int pos) |
abstract AbstractAddress |
getPlaceholder()
Returns a target specific placeholder address that can be used for code patching.
|
int |
getShort(int pos) |
abstract void |
jmp(Label l) |
abstract AbstractAddress |
makeAddress(Register base,
int displacement)
This is used by the CompilationResultBuilder to convert a
StackSlot to an
AbstractAddress . |
String |
nameOf(Label l)
Gets a name for a label, creating it if it does not yet exist.
|
protected abstract void |
patchJumpTarget(int branch,
int jumpTarget) |
int |
position()
Returns the current position of the underlying code buffer.
|
Assembler.LabelHint |
requestLabelHint(Label label) |
void |
reset() |
public final TargetDescription target
private List<Assembler.LabelHint> jumpDisplacementHints
private final Buffer codeBuffer
public Assembler(TargetDescription target)
public int position()
public final void emitByte(int x)
public final void emitShort(int x)
public final void emitInt(int x)
public final void emitLong(long x)
public final void emitByte(int b, int pos)
public final void emitShort(int b, int pos)
public final void emitInt(int b, int pos)
public final void emitLong(long b, int pos)
public final int getByte(int pos)
public final int getShort(int pos)
public final int getInt(int pos)
public final void emitString(String x)
public final void emitString0(String x)
public void emitString(String s, int pos)
public byte[] close(boolean trimmedCopy)
trimmedCopy
- if true
, then a copy of the underlying byte array up to (but not
including) position()
is returnedtrimmedCopy
is true
public abstract void align(int modulus)
protected abstract void patchJumpTarget(int branch, int jumpTarget)
protected String createLabelName(Label l, int id)
l
- the label for which a name is being createdid
- a label identifier that is unique with the scope of this assemblerpublic String nameOf(Label l)
public abstract AbstractAddress makeAddress(Register base, int displacement)
StackSlot
to an
AbstractAddress
.public abstract AbstractAddress getPlaceholder()
public abstract void ensureUniquePC()
public void reset()
private void captureLabelPositions()
public Assembler.LabelHint requestLabelHint(Label label)
public Assembler.InstructionCounter getInstructionCounter()