From 80cceec6f6299181d94e844eb22dffbef3ecc9e4 Mon Sep 17 00:00:00 2001 From: Loic Ottet Date: Tue, 13 Aug 2019 17:16:46 +0200 Subject: [PATCH] Add ARM64 target to the LLVM backend --- .../svm/core/graal/llvm/LLVMFeature.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java index 466d9ae2993b..0b2988bc811e 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java @@ -264,3 +264,72 @@ public List getLLCAdditionalOptions() { }); } } + +@AutomaticFeature +@Platforms(Platform.AArch64.class) +class LLVMAArch64TargetSpecificFeature implements Feature { + private static final int AARCH64_FP_IDX = 29; + private static final int AARCH64_SP_IDX = 31; + + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return CompilerBackend.getValue().equals("llvm"); + } + + @Override + public void afterRegistration(AfterRegistrationAccess access) { + ImageSingletons.add(TargetSpecific.class, new TargetSpecific() { + @Override + public String getRegisterInlineAsm(String register) { + return "MOV $0, " + getLLVMRegisterName(register); + } + + @Override + public String getJumpInlineAsm() { + return "BR $0"; + } + + @Override + public String getLLVMArchName() { + return "aarch64"; + } + + /* + * The return address is not saved on the stack on ARM, so the stack frames have no + * space inbetween them. + */ + @Override + public int getCallFrameSeparation() { + return 0; + } + + /* + * The frame pointer is stored below the saved value for the link register. + */ + @Override + public int getFramePointerOffset() { + return -2 * FrameAccess.wordSize(); + } + + @Override + public int getStackPointerDwarfRegNum() { + return AARCH64_SP_IDX; + } + + @Override + public int getFramePointerDwarfRegNum() { + return AARCH64_FP_IDX; + } + + @Override + public List getLLCAdditionalOptions() { + return Collections.singletonList("--frame-pointer=all"); + } + + @Override + public String getLLVMRegisterName(String register) { + return register.replace("r", "x"); + } + }); + } +}