public class AMD64Assembler extends Assembler
Modifier and Type | Class and Description |
---|---|
static class |
AMD64Assembler.AMD64BinaryArithmetic
Arithmetic operation with operand order of RM, MR or MI.
|
static class |
AMD64Assembler.AMD64ImmOp
Base class for AMD64 opcodes with immediate operands.
|
static class |
AMD64Assembler.AMD64MIOp
Opcodes with operand order of MI.
|
static class |
AMD64Assembler.AMD64MOp
Opcodes with operand order of M.
|
static class |
AMD64Assembler.AMD64MROp
Opcode with operand order of MR.
|
static class |
AMD64Assembler.AMD64Op
Base class for AMD64 opcodes.
|
static class |
AMD64Assembler.AMD64RMIOp
Opcodes with operand order of RMI.
|
static class |
AMD64Assembler.AMD64RMOp
Opcode with operand order of RM.
|
static class |
AMD64Assembler.AMD64RROp
Opcode with operand order of either RM or MR.
|
static class |
AMD64Assembler.AMD64Shift
Shift operation with operand order of M1, MC or MI.
|
static class |
AMD64Assembler.ConditionFlag
The x86 condition codes used for conditional jumps/moves.
|
private static class |
AMD64Assembler.OpAssertion
Operand size and register type constraints.
|
static class |
AMD64Assembler.OperandSize
The x86 operand sizes.
|
private static class |
AMD64Assembler.Prefix
Constants for X86 prefix bytes.
|
static class |
AMD64Assembler.SSEOp |
Assembler.InstructionCounter, Assembler.LabelHint
Modifier and Type | Field and Description |
---|---|
Register |
frameRegister
The register to which
Register.Frame and Register.CallerFrame are bound. |
private static int |
MinEncodingNeedsRex |
private static AMD64Address |
Placeholder
A sentinel value used as a place holder in an instruction stream for an address that will be
patched.
|
Constructor and Description |
---|
AMD64Assembler(TargetDescription target,
RegisterConfig registerConfig)
Constructs an assembler for the AMD64 architecture.
|
Modifier and Type | Method and Description |
---|---|
void |
addl(AMD64Address dst,
int imm32) |
void |
addl(Register dst,
int imm32) |
void |
addq(AMD64Address dst,
int imm32) |
void |
addq(AMD64Address dst,
Register src) |
void |
addq(Register dst,
int imm32) |
void |
addq(Register dst,
Register src) |
private void |
addrNop4() |
private void |
addrNop5() |
private void |
addrNop7() |
private void |
addrNop8() |
void |
align(int modulus) |
void |
andl(Register dst,
int imm32) |
void |
andq(Register dst,
int imm32) |
void |
bswapl(Register reg) |
void |
bswapq(Register reg) |
void |
call()
Emits a direct call instruction.
|
void |
call(Register src) |
void |
cdql() |
void |
cdqq() |
void |
cmovl(AMD64Assembler.ConditionFlag cc,
Register dst,
AMD64Address src) |
void |
cmovl(AMD64Assembler.ConditionFlag cc,
Register dst,
Register src) |
void |
cmovq(AMD64Assembler.ConditionFlag cc,
Register dst,
AMD64Address src) |
void |
cmovq(AMD64Assembler.ConditionFlag cc,
Register dst,
Register src) |
void |
cmpl(AMD64Address dst,
int imm32) |
void |
cmpl(Register dst,
AMD64Address src) |
void |
cmpl(Register dst,
int imm32) |
void |
cmpl(Register dst,
Register src) |
void |
cmpq(Register dst,
AMD64Address src) |
void |
cmpq(Register dst,
int imm32) |
void |
cmpq(Register dst,
Register src) |
void |
cmpxchgl(Register reg,
AMD64Address adr) |
void |
cmpxchgq(Register reg,
AMD64Address adr) |
protected void |
decl(AMD64Address dst) |
protected void |
decl(Register dst) |
void |
decq(AMD64Address dst) |
protected void |
decq(Register dst) |
private void |
emitFPUArith(int b1,
int b2,
int i) |
protected void |
emitModRM(int reg,
Register rm)
Emit the ModR/M byte for one register operand and an opcode extension in the R field.
|
protected void |
emitModRM(Register reg,
Register rm)
Emit the ModR/M byte for two register operands.
|
protected void |
emitOperandHelper(int reg,
AMD64Address addr)
Emits the ModR/M byte and optionally the SIB byte for one memory operand and an opcode
extension in the R field.
|
protected void |
emitOperandHelper(Register reg,
AMD64Address addr)
Emits the ModR/M byte and optionally the SIB byte for one register and one memory operand.
|
private void |
emitx87(int b1,
int b2,
int i) |
private static int |
encode(Register r) |
void |
ensureUniquePC()
Emits a NOP instruction to advance the current PC.
|
void |
fcos() |
void |
ffree(int i) |
void |
fincstp() |
void |
fldd(AMD64Address src) |
void |
fldlg2() |
void |
fldln2() |
void |
flds(AMD64Address src) |
void |
fnstswAX() |
void |
fprem() |
void |
fptan() |
void |
fsin() |
void |
fstp(int i) |
void |
fstpd(AMD64Address src) |
void |
fstps(AMD64Address src) |
void |
fwait() |
void |
fxch(int i) |
void |
fyl2x() |
AMD64Address |
getPlaceholder()
Returns a target specific placeholder address that can be used for code patching.
|
protected static int |
getRXB(Register reg,
AMD64Address rm)
Get RXB bits for register-memory instruction.
|
protected static int |
getRXB(Register reg,
Register rm)
Get RXB bits for register-register instruction.
|
void |
hlt() |
void |
illegal()
Emits an instruction which is considered to be illegal.
|
void |
imull(Register dst,
Register src,
int value) |
protected void |
incl(AMD64Address dst) |
protected void |
incl(Register dst) |
void |
incq(AMD64Address dst) |
void |
incq(Register dst) |
void |
int3() |
void |
jcc(AMD64Assembler.ConditionFlag cc,
int jumpTarget,
boolean forceDisp32) |
void |
jcc(AMD64Assembler.ConditionFlag cc,
Label l) |
void |
jccb(AMD64Assembler.ConditionFlag cc,
Label l) |
void |
jmp(int jumpTarget,
boolean forceDisp32) |
void |
jmp(Label l) |
void |
jmp(Register entry) |
void |
jmpb(Label l) |
void |
leaq(Register dst,
AMD64Address src) |
void |
leave() |
void |
lock() |
AMD64Address |
makeAddress(Register base,
int displacement)
This is used by the CompilationResultBuilder to convert a
StackSlot to an
AbstractAddress . |
void |
membar(int barriers) |
void |
movapd(Register dst,
Register src) |
void |
movaps(Register dst,
Register src) |
void |
movb(AMD64Address dst,
int imm8) |
void |
movb(AMD64Address dst,
Register src) |
void |
movdq(Register dst,
Register src) |
void |
movdqu(Register dst,
AMD64Address src) |
void |
movl(AMD64Address dst,
int imm32) |
void |
movl(AMD64Address dst,
Register src) |
void |
movl(Register dst,
AMD64Address src) |
void |
movl(Register dst,
int imm32) |
void |
movl(Register dst,
Register src) |
void |
movlpd(Register dst,
AMD64Address src)
New CPUs require use of movsd and movss to avoid partial register stall when loading from
memory.
|
void |
movq(AMD64Address dst,
Register src) |
void |
movq(Register dst,
AMD64Address src) |
void |
movq(Register dst,
long imm64) |
void |
movq(Register dst,
Register src) |
void |
movsbl(Register dst,
AMD64Address src) |
void |
movsbl(Register dst,
Register src) |
void |
movsbq(Register dst,
AMD64Address src) |
void |
movsbq(Register dst,
Register src) |
void |
movsd(AMD64Address dst,
Register src) |
void |
movsd(Register dst,
AMD64Address src) |
void |
movsd(Register dst,
Register src) |
void |
movslq(AMD64Address dst,
int imm32) |
void |
movslq(Register dst,
AMD64Address src) |
void |
movslq(Register dst,
int imm32) |
void |
movslq(Register dst,
Register src) |
void |
movss(AMD64Address dst,
Register src) |
void |
movss(Register dst,
AMD64Address src) |
void |
movss(Register dst,
Register src) |
void |
movswl(Register dst,
AMD64Address src) |
void |
movw(AMD64Address dst,
int imm16) |
void |
movw(AMD64Address dst,
Register src) |
void |
movzbl(Register dst,
AMD64Address src) |
void |
movzwl(Register dst,
AMD64Address src) |
private static boolean |
needsRex(Register reg) |
void |
negq(Register dst) |
void |
nop() |
void |
nop(int count) |
void |
nullCheck(AMD64Address address) |
protected void |
patchJumpTarget(int branch,
int branchTarget) |
void |
pop(Register dst) |
void |
popfq() |
void |
prefetchnta(AMD64Address src) |
private void |
prefetchPrefix(AMD64Address src) |
(package private) void |
prefetchr(AMD64Address src) |
void |
prefetcht0(AMD64Address src) |
void |
prefetcht1(AMD64Address src) |
void |
prefetcht2(AMD64Address src) |
void |
prefetchw(AMD64Address src) |
private void |
prefix(AMD64Address adr) |
private void |
prefix(AMD64Address adr,
Register reg) |
private void |
prefix(AMD64Address adr,
Register reg,
boolean byteinst) |
private int |
prefixAndEncode(int regEnc) |
private int |
prefixAndEncode(int regEnc,
boolean byteinst) |
private int |
prefixAndEncode(int dstEncoding,
boolean dstIsByte,
int srcEncoding,
boolean srcIsByte) |
private int |
prefixAndEncode(int dstEnc,
int srcEnc) |
private void |
prefixq(AMD64Address adr) |
private void |
prefixq(AMD64Address adr,
Register src) |
private int |
prefixqAndEncode(int regEnc) |
private int |
prefixqAndEncode(int regEncoding,
int rmEncoding)
Creates prefix and the encoding of the lower 6 bits of the ModRM-Byte.
|
void |
ptest(Register dst,
Register src) |
void |
push(Register src) |
void |
pushfq() |
void |
pxor(Register dst,
Register src) |
void |
ret(int imm16) |
void |
shlq(Register dst,
int imm8) |
void |
shrq(Register dst,
int imm8) |
void |
subl(AMD64Address dst,
int imm32) |
void |
subl(Register dst,
int imm32) |
void |
subq(AMD64Address dst,
int imm32) |
void |
subq(Register dst,
int imm32) |
void |
subq(Register dst,
Register src) |
void |
subqWide(Register dst,
int imm32) |
private boolean |
supports(AMD64.CPUFeature feature) |
void |
testl(Register dst,
AMD64Address src) |
void |
testl(Register dst,
int imm32) |
void |
testl(Register dst,
Register src) |
void |
testq(Register dst,
Register src) |
void |
xaddl(AMD64Address dst,
Register src) |
void |
xaddq(AMD64Address dst,
Register src) |
void |
xchgl(Register dst,
AMD64Address src) |
void |
xchgq(Register dst,
AMD64Address src) |
void |
xorl(Register dst,
Register src) |
void |
xorpd(Register dst,
Register src) |
void |
xorps(Register dst,
Register src) |
bind, close, createLabelName, emitByte, emitByte, emitInt, emitInt, emitLong, emitLong, emitShort, emitShort, emitString, emitString, emitString0, getByte, getInstructionCounter, getInt, getShort, nameOf, position, requestLabelHint, reset
private static final int MinEncodingNeedsRex
private static final AMD64Address Placeholder
public final Register frameRegister
Register.Frame
and Register.CallerFrame
are bound.public AMD64Assembler(TargetDescription target, RegisterConfig registerConfig)
registerConfig
- the register configuration used to bind Register.Frame
and
Register.CallerFrame
to physical registers. This value can be null if this
assembler instance will not be used to assemble instructions using these logical
registers.private boolean supports(AMD64.CPUFeature feature)
protected static int getRXB(Register reg, Register rm)
protected static int getRXB(Register reg, AMD64Address rm)
protected void emitModRM(int reg, Register rm)
Format: [ 11 reg r/m ]
protected void emitModRM(Register reg, Register rm)
Format: [ 11 reg r/m ]
protected void emitOperandHelper(Register reg, AMD64Address addr)
protected void emitOperandHelper(int reg, AMD64Address addr)
public final void addl(AMD64Address dst, int imm32)
private void addrNop4()
private void addrNop5()
private void addrNop7()
private void addrNop8()
public final void cdql()
public final void cmovl(AMD64Assembler.ConditionFlag cc, Register dst, Register src)
public final void cmovl(AMD64Assembler.ConditionFlag cc, Register dst, AMD64Address src)
public final void cmpl(Register dst, AMD64Address src)
public final void cmpl(AMD64Address dst, int imm32)
public final void cmpxchgl(Register reg, AMD64Address adr)
protected final void decl(AMD64Address dst)
public final void hlt()
protected final void incl(AMD64Address dst)
public void jcc(AMD64Assembler.ConditionFlag cc, int jumpTarget, boolean forceDisp32)
public final void jcc(AMD64Assembler.ConditionFlag cc, Label l)
public final void jccb(AMD64Assembler.ConditionFlag cc, Label l)
public final void jmp(int jumpTarget, boolean forceDisp32)
public final void leaq(Register dst, AMD64Address src)
public final void leave()
public final void lock()
public final void movb(AMD64Address dst, int imm8)
public final void movb(AMD64Address dst, Register src)
public final void movl(Register dst, AMD64Address src)
public final void movl(AMD64Address dst, int imm32)
public final void movl(AMD64Address dst, Register src)
public final void movlpd(Register dst, AMD64Address src)
AMD64MacroAssembler.movdbl(Register, AMD64Address)
and
AMD64MacroAssembler.movflt(Register, Register)
.public final void movq(Register dst, AMD64Address src)
public final void movq(AMD64Address dst, Register src)
public final void movsbl(Register dst, AMD64Address src)
public final void movsbq(Register dst, AMD64Address src)
public final void movsd(Register dst, AMD64Address src)
public final void movsd(AMD64Address dst, Register src)
public final void movss(Register dst, AMD64Address src)
public final void movss(AMD64Address dst, Register src)
public final void movswl(Register dst, AMD64Address src)
public final void movw(AMD64Address dst, int imm16)
public final void movw(AMD64Address dst, Register src)
public final void movzbl(Register dst, AMD64Address src)
public final void movzwl(Register dst, AMD64Address src)
public final void ensureUniquePC()
Assembler
ensureUniquePC
in class Assembler
public final void nop()
public void nop(int count)
public void popfq()
public void pushfq()
public final void ret(int imm16)
public final void subl(AMD64Address dst, int imm32)
public final void testl(Register dst, AMD64Address src)
private int prefixAndEncode(int regEnc)
private int prefixAndEncode(int regEnc, boolean byteinst)
private int prefixqAndEncode(int regEnc)
private int prefixAndEncode(int dstEnc, int srcEnc)
private int prefixAndEncode(int dstEncoding, boolean dstIsByte, int srcEncoding, boolean srcIsByte)
private int prefixqAndEncode(int regEncoding, int rmEncoding)
regEncoding
- the encoding of the register part of the ModRM-BytermEncoding
- the encoding of the r/m part of the ModRM-Byteprivate void prefix(AMD64Address adr)
private void prefixq(AMD64Address adr)
private void prefix(AMD64Address adr, Register reg)
private void prefix(AMD64Address adr, Register reg, boolean byteinst)
private void prefixq(AMD64Address adr, Register src)
public final void addq(AMD64Address dst, int imm32)
public final void addq(AMD64Address dst, Register src)
public final void cdqq()
public final void cmovq(AMD64Assembler.ConditionFlag cc, Register dst, Register src)
public final void cmovq(AMD64Assembler.ConditionFlag cc, Register dst, AMD64Address src)
public final void cmpq(Register dst, AMD64Address src)
public final void cmpxchgq(Register reg, AMD64Address adr)
public final void decq(AMD64Address dst)
public final void incq(AMD64Address dst)
public final void movdqu(Register dst, AMD64Address src)
public final void movslq(AMD64Address dst, int imm32)
public final void movslq(Register dst, AMD64Address src)
public final void subq(AMD64Address dst, int imm32)
public final void xaddl(AMD64Address dst, Register src)
public final void xaddq(AMD64Address dst, Register src)
public final void xchgl(Register dst, AMD64Address src)
public final void xchgq(Register dst, AMD64Address src)
public final void membar(int barriers)
protected final void patchJumpTarget(int branch, int branchTarget)
patchJumpTarget
in class Assembler
public void nullCheck(AMD64Address address)
public final void call()
public final void int3()
private void emitx87(int b1, int b2, int i)
public final void fldd(AMD64Address src)
public final void flds(AMD64Address src)
public final void fldln2()
public final void fldlg2()
public final void fyl2x()
public final void fstps(AMD64Address src)
public final void fstpd(AMD64Address src)
private void emitFPUArith(int b1, int b2, int i)
public void ffree(int i)
public void fincstp()
public void fxch(int i)
public void fnstswAX()
public void fwait()
public void fprem()
public final void fsin()
public final void fcos()
public final void fptan()
public final void fstp(int i)
public AMD64Address makeAddress(Register base, int displacement)
Assembler
StackSlot
to an
AbstractAddress
.makeAddress
in class Assembler
public AMD64Address getPlaceholder()
Assembler
getPlaceholder
in class Assembler
private void prefetchPrefix(AMD64Address src)
public void prefetchnta(AMD64Address src)
void prefetchr(AMD64Address src)
public void prefetcht0(AMD64Address src)
public void prefetcht1(AMD64Address src)
public void prefetcht2(AMD64Address src)
public void prefetchw(AMD64Address src)
public void illegal()