mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
682e019983
This completes the handling for DLL import storage symbols when lowering instructions. A DLL import storage symbol must have an additional load performed prior to use. This is applicable to variables and functions. This is particularly important for non-function symbols as it is possible to handle function references by emitting a thunk which performs the translation from the unprefixed __imp_ symbol to the proper symbol (although, this is a non-optimal lowering). For a variable symbol, no such thunk can be accommodated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212431 91177308-0d34-0410-b5e6-96231b3b80d8
62 lines
1.3 KiB
LLVM
62 lines
1.3 KiB
LLVM
; RUN: llc -mtriple thumbv7-windows -filetype asm -o - %s | FileCheck %s
|
|
|
|
; ModuleID = 'dllimport.c'
|
|
|
|
@var = external dllimport global i32
|
|
@ext = external global i32
|
|
declare dllimport arm_aapcs_vfpcc i32 @external()
|
|
declare arm_aapcs_vfpcc i32 @internal()
|
|
|
|
define arm_aapcs_vfpcc i32 @get_var() {
|
|
%1 = load i32* @var, align 4
|
|
ret i32 %1
|
|
}
|
|
|
|
; CHECK-LABEL: get_var
|
|
; CHECK: movw r0, :lower16:__imp_var
|
|
; CHECK: movt r0, :upper16:__imp_var
|
|
; CHECK: ldr r0, [r0]
|
|
; CHECK: ldr r0, [r0]
|
|
; CHECK: bx lr
|
|
|
|
define arm_aapcs_vfpcc i32 @get_ext() {
|
|
%1 = load i32* @ext, align 4
|
|
ret i32 %1
|
|
}
|
|
|
|
; CHECK-LABEL: get_ext
|
|
; CHECK: movw r0, :lower16:ext
|
|
; CHECK: movt r0, :upper16:ext
|
|
; CHECK: ldr r0, [r0]
|
|
; CHECK: bx lr
|
|
|
|
define arm_aapcs_vfpcc i32* @get_var_pointer() {
|
|
ret i32* @var
|
|
}
|
|
|
|
; CHECK-LABEL: get_var_pointer
|
|
; CHECK: movw r0, :lower16:__imp_var
|
|
; CHECK: movt r0, :upper16:__imp_var
|
|
; CHECK: ldr r0, [r0]
|
|
; CHECK: bx lr
|
|
|
|
define arm_aapcs_vfpcc i32 @call_external() {
|
|
%call = tail call arm_aapcs_vfpcc i32 @external()
|
|
ret i32 %call
|
|
}
|
|
|
|
; CHECK-LABEL: call_external
|
|
; CHECK: movw r0, :lower16:__imp_external
|
|
; CHECK: movt r0, :upper16:__imp_external
|
|
; CHECK: ldr r0, [r0]
|
|
; CHECK: bx r0
|
|
|
|
define arm_aapcs_vfpcc i32 @call_internal() {
|
|
%call = tail call arm_aapcs_vfpcc i32 @internal()
|
|
ret i32 %call
|
|
}
|
|
|
|
; CHECK-LABEL: call_internal
|
|
; CHECK: b internal
|
|
|