1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -run-pass=legalizer %s -o - | FileCheck %s
3 # RUN: llc -O0 -run-pass=legalizer --code-model=large %s -o - | FileCheck %s --check-prefix=CMLARGE
6 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
7 target triple = "aarch64--"
8 @var = external dso_local global i8
9 define ptr @test_global() { ret ptr undef }
10 define ptr @test_global_with_offset() { ret ptr undef }
19 ; We don't want to lower to G_ADD_LOW when we need a GOT access, or when the code
20 ; model isn't 'Small'.
21 ; CHECK-LABEL: name: test_global
22 ; CHECK: [[ADRP:%[0-9]+]]:gpr64(p0) = ADRP target-flags(aarch64-page) @var
23 ; CHECK: [[ADD_LOW:%[0-9]+]]:_(p0) = G_ADD_LOW [[ADRP]](p0), target-flags(aarch64-pageoff, aarch64-nc) @var
24 ; CHECK: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[ADD_LOW]](p0)
25 ; CHECK: $x0 = COPY [[PTRTOINT]](s64)
26 ; CMLARGE-LABEL: name: test_global
27 ; CMLARGE: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var
28 ; CMLARGE: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[GV]](p0)
29 ; CMLARGE: $x0 = COPY [[PTRTOINT]](s64)
30 %0(p0) = G_GLOBAL_VALUE @var
31 %1:_(s64) = G_PTRTOINT %0
35 name: test_global_with_offset
38 ; When we legalize into ADRP + G_ADD_LOW, both should inherit the offset
39 ; from the original G_GLOBAL_VALUE.
41 ; CHECK-LABEL: name: test_global_with_offset
42 ; CHECK: [[ADRP:%[0-9]+]]:gpr64(p0) = ADRP target-flags(aarch64-page) @var + 1
43 ; CHECK: [[ADD_LOW:%[0-9]+]]:_(p0) = G_ADD_LOW [[ADRP]](p0), target-flags(aarch64-pageoff, aarch64-nc) @var + 1
44 ; CHECK: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[ADD_LOW]](p0)
45 ; CHECK: $x0 = COPY [[PTRTOINT]](s64)
46 ; CMLARGE-LABEL: name: test_global_with_offset
47 ; CMLARGE: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var + 1
48 ; CMLARGE: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[GV]](p0)
49 ; CMLARGE: $x0 = COPY [[PTRTOINT]](s64)
50 %0:_(p0) = G_GLOBAL_VALUE @var + 1
51 %1:_(s64) = G_PTRTOINT %0