Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,DAG-ISEL
      2 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -fast-isel -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,FAST-ISEL
      3 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -O0 -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,GLOBAL-ISEL,GLOBAL-ISEL-FALLBACK
      4 
      5 @var = external dllimport global i32
      6 @ext = external global i32
      7 declare dllimport i32 @external()
      8 declare i32 @internal()
      9 
     10 define i32 @get_var() {
     11   %1 = load i32, i32* @var, align 4
     12   ret i32 %1
     13 }
     14 
     15 ; CHECK-LABEL: get_var
     16 ; CHECK: adrp x8, __imp_var
     17 ; CHECK: ldr x8, [x8, __imp_var]
     18 ; CHECK: ldr w0, [x8]
     19 ; CHECK: ret
     20 
     21 define i32 @get_ext() {
     22   %1 = load i32, i32* @ext, align 4
     23   ret i32 %1
     24 }
     25 
     26 ; CHECK-LABEL: get_ext
     27 ; CHECK: adrp x8, ext
     28 ; DAG-ISEL: ldr w0, [x8, ext]
     29 ; FAST-ISEL: add x8, x8, ext
     30 ; FAST-ISEL: ldr w0, [x8]
     31 ; GLOBAL-ISEL-FALLBACK: add x8, x8, ext
     32 ; GLOBAL-ISEL-FALLBACK: ldr w0, [x8]
     33 ; CHECK: ret
     34 
     35 define i32* @get_var_pointer() {
     36   ret i32* @var
     37 }
     38 
     39 ; CHECK-LABEL: get_var_pointer
     40 ; CHECK: adrp [[REG1:x[0-9]+]], __imp_var
     41 ; CHECK: ldr {{x[0-9]+}}, {{\[}}[[REG1]], __imp_var]
     42 ; CHECK: ret
     43 
     44 define i32 @call_external() {
     45   %call = tail call i32 @external()
     46   ret i32 %call
     47 }
     48 
     49 ; CHECK-LABEL: call_external
     50 ; CHECK: adrp x0, __imp_external
     51 ; CHECK: ldr x0, [x0, __imp_external]
     52 ; CHECK: br x0
     53 
     54 define i32 @call_internal() {
     55   %call = tail call i32 @internal()
     56   ret i32 %call
     57 }
     58 
     59 ; CHECK-LABEL: call_internal
     60 ; DAG-ISEL: b internal
     61 ; FAST-ISEL: b internal
     62 ; GLOBAL-ISEL: bl internal
     63