mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-11 08:07:22 +00:00
72062f5744
This patch adds support for AArch64 (ARM's 64-bit architecture) to LLVM in the "experimental" category. Currently, it won't be built unless requested explicitly. This initial commit should have support for: + Assembly of all scalar (i.e. non-NEON, non-Crypto) instructions (except the late addition CRC instructions). + CodeGen features required for C++03 and C99. + Compilation for the "small" memory model: code+static data < 4GB. + Absolute and position-independent code. + GNU-style (i.e. "__thread") TLS. + Debugging information. The principal omission, currently, is performance tuning. This patch excludes the NEON support also reviewed due to an outbreak of batshit insanity in our legal department. That will be committed soon bringing the changes to precisely what has been approved. Further reviews would be gratefully received. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174054 91177308-0d34-0410-b5e6-96231b3b80d8
70 lines
2.0 KiB
LLVM
70 lines
2.0 KiB
LLVM
; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -relocation-model=pic %s -o - | FileCheck %s
|
|
; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -relocation-model=pic -filetype=obj %s -o -| llvm-objdump -r - | FileCheck --check-prefix=CHECK-ELF %s
|
|
|
|
@var = global i32 0
|
|
|
|
; CHECK-ELF: RELOCATION RECORDS FOR [.text]
|
|
|
|
define i32 @get_globalvar() {
|
|
; CHECK: get_globalvar:
|
|
|
|
%val = load i32* @var
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
|
|
; CHECK: ldr x[[GOTLOC:[0-9]+]], [x[[GOTHI]], #:got_lo12:var]
|
|
; CHECK: ldr w0, [x[[GOTLOC]]]
|
|
|
|
; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE var
|
|
; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC var
|
|
ret i32 %val
|
|
}
|
|
|
|
define i32* @get_globalvaraddr() {
|
|
; CHECK: get_globalvaraddr:
|
|
|
|
%val = load i32* @var
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
|
|
; CHECK: ldr x0, [x[[GOTHI]], #:got_lo12:var]
|
|
|
|
; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE var
|
|
; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC var
|
|
ret i32* @var
|
|
}
|
|
|
|
@hiddenvar = hidden global i32 0
|
|
|
|
define i32 @get_hiddenvar() {
|
|
; CHECK: get_hiddenvar:
|
|
|
|
%val = load i32* @hiddenvar
|
|
; CHECK: adrp x[[HI:[0-9]+]], hiddenvar
|
|
; CHECK: ldr w0, [x[[HI]], #:lo12:hiddenvar]
|
|
|
|
; CHECK-ELF: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
|
|
; CHECK-ELF: R_AARCH64_LDST32_ABS_LO12_NC hiddenvar
|
|
ret i32 %val
|
|
}
|
|
|
|
define i32* @get_hiddenvaraddr() {
|
|
; CHECK: get_hiddenvaraddr:
|
|
|
|
%val = load i32* @hiddenvar
|
|
; CHECK: adrp [[HI:x[0-9]+]], hiddenvar
|
|
; CHECK: add x0, [[HI]], #:lo12:hiddenvar
|
|
|
|
; CHECK-ELF: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
|
|
; CHECK-ELF: R_AARCH64_ADD_ABS_LO12_NC hiddenvar
|
|
ret i32* @hiddenvar
|
|
}
|
|
|
|
define void()* @get_func() {
|
|
; CHECK: get_func:
|
|
|
|
ret void()* bitcast(void()*()* @get_func to void()*)
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:get_func
|
|
; CHECK: ldr x0, [x[[GOTHI]], #:got_lo12:get_func]
|
|
|
|
; Particularly important that the ADRP gets a relocation, LLVM tends to think
|
|
; it can relax it because it knows where get_func is. It can't!
|
|
; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE get_func
|
|
; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC get_func
|
|
} |