1 ; RUN: llc --relocation-model=static < %s \
2 ; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-SELECTIONDAGISEL
4 ; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 < %s \
5 ; RUN: | FileCheck %s --check-prefixes=CHECK-STATIC,CHECK-GLOBALISEL
7 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8 target triple = "aarch64-unknown-linux-android"
10 @global = external dso_local global i32
11 declare dso_local void @func()
13 define ptr @global_addr() #0 {
14 ; Static relocation model has common codegen between SelectionDAGISel and
15 ; GlobalISel when the address-taken of a global isn't folded into a load or
17 ; CHECK-STATIC: global_addr:
18 ; CHECK-STATIC: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
19 ; CHECK-STATIC: movk [[REG]], #:prel_g3:global+4294967296
20 ; CHECK-STATIC: add x0, [[REG]], :lo12:global
26 define i32 @global_load() #0 {
27 ; CHECK-SELECTIONDAGISEL: global_load:
28 ; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
29 ; CHECK-SELECTIONDAGISEL: ldr w0, [[[REG]], :lo12:global]
30 ; CHECK-SELECTIONDAGISEL: ret
32 ; CHECK-GLOBALISEL: global_load:
33 ; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
34 ; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296
35 ; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global
36 ; CHECK-GLOBALISEL: ldr w0, [[[REG]]]
37 ; CHECK-GLOBALISEL: ret
39 %load = load i32, ptr @global
43 define void @global_store() #0 {
44 ; CHECK-SELECTIONDAGISEL: global_store:
45 ; CHECK-SELECTIONDAGISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
46 ; CHECK-SELECTIONDAGISEL: str wzr, [[[REG]], :lo12:global]
47 ; CHECK-SELECTIONDAGISEL: ret
49 ; CHECK-GLOBALISEL: global_store:
50 ; CHECK-GLOBALISEL: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
51 ; CHECK-GLOBALISEL: movk [[REG]], #:prel_g3:global+4294967296
52 ; CHECK-GLOBALISEL: add [[REG]], [[REG]], :lo12:global
53 ; CHECK-GLOBALISEL: str wzr, [[[REG]]]
54 ; CHECK-GLOBALISEL: ret
56 store i32 0, ptr @global
60 define ptr @func_addr() #0 {
61 ; CHECK-STATIC: func_addr:
62 ; CHECK-STATIC: adrp [[REG:x[0-9]+]], func
63 ; CHECK-STATIC: add x0, [[REG]], :lo12:func
69 attributes #0 = { "target-features"="+tagged-globals" }