package jdk.tools.jaotc.aarch64;
import static jdk.vm.ci.aarch64.AArch64.r12;
import static jdk.vm.ci.aarch64.AArch64.r16;
import static jdk.vm.ci.aarch64.AArch64.r17;
import static jdk.vm.ci.aarch64.AArch64.r9;
import org.graalvm.compiler.asm.aarch64.AArch64Address;
import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
import jdk.tools.jaotc.ELFMacroAssembler;
import jdk.tools.jaotc.StubInformation;
import jdk.vm.ci.code.TargetDescription;
public final class AArch64ELFMacroAssembler extends AArch64MacroAssembler implements ELFMacroAssembler {
private int currentEndOfInstruction;
public AArch64ELFMacroAssembler(TargetDescription target) {
super(target);
}
@Override
public int currentEndOfInstruction() {
return currentEndOfInstruction;
}
@Override
public byte[] getPLTJumpCode() {
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
currentEndOfInstruction = position();
align(8);
return close(true);
}
@Override
public byte[] getPLTStaticEntryCode(StubInformation stub) {
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
stub.setDispatchJumpOffset(position());
adrpAdd(r12);
ldr(64, r12, AArch64Address.createBaseRegisterOnlyAddress(r12));
nop();
stub.setMovOffset(position());
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
stub.setC2IJumpOffset(position());
stub.setResolveJumpStart(position());
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
stub.setResolveJumpOffset(position());
currentEndOfInstruction = position();
align(8);
stub.setSize(position());
return close(true);
}
@Override
public byte[] getPLTVirtualEntryCode(StubInformation stub) {
adrpAdd(r17);
ldr(64, r9, AArch64Address.createBaseRegisterOnlyAddress(r17));
nop();
stub.setMovOffset(position());
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
stub.setDispatchJumpOffset(position());
stub.setResolveJumpStart(position());
adrpAdd(r16);
ldr(64, r16, AArch64Address.createBaseRegisterOnlyAddress(r16));
jmp(r16);
stub.setResolveJumpOffset(position());
currentEndOfInstruction = position();
align(8);
stub.setSize(position());
return close(true);
}
}