aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/AArch64/aarch64-mixed-ptr-sizes.ll
blob: b7c8df7310adca0d6840159c704a045be221a5af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s | FileCheck %s
; RUN: llc --fast-isel < %s | FileCheck %s
; RUN: llc --global-isel --global-isel-abort=2 < %s | FileCheck %s

; Source to regenerate:
; struct Foo {
;   int * __ptr32 p32;
;   int * __ptr64 p64;
;   __attribute__((address_space(9))) int *p_other;
; };
; extern "C" void use_foo(Foo *f);
; extern "C" int use_int(int i);
; extern "C" void test_sign_ext(Foo *f, int * __ptr32 __sptr i) {
;   f->p64 = i;
;   use_foo(f);
; }
; extern "C" void test_sign_ext_store_load(int * __ptr32 __sptr i) {
;   *i = use_int(*i);
; }
; extern "C" void test_zero_ext(Foo *f, int * __ptr32 __uptr i) {
;   f->p64 = i;
;   use_foo(f);
; }
; extern "C" void test_zero_ext_store_load(int * __ptr32 __uptr i) {
;   *i = use_int(*i);
; }
; extern "C" void test_trunc(Foo *f, int * __ptr64 i) {
;   f->p32 = i;
;   use_foo(f);
; }
; extern "C" void test_noop1(Foo *f, int * __ptr32 i) {
;   f->p32 = i;
;   use_foo(f);
; }
; extern "C" void test_noop2(Foo *f, int * __ptr64 i) {
;   f->p64 = i;
;   use_foo(f);
; }
; extern "C" void test_null_arg(Foo *f, int * __ptr32 i) {
;   test_noop1(f, 0);
; }
; extern "C" void test_unrecognized(Foo *f, __attribute__((address_space(14))) int *i) {
;   f->p32 = (int * __ptr32)i;
;   use_foo(f);
; }
;
; $ clang --target=aarch64-windows-msvc -fms-extensions -O2 -S -emit-llvm t.cpp

target datalayout = "e-m:w-p:64:64-i32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-windows-msvc"

; Function Attrs: mustprogress uwtable
define dso_local void @test_sign_ext(ptr noundef %f, ptr addrspace(270) noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_sign_ext:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    // kill: def $w1 killed $w1 def $x1
; CHECK-NEXT:    sxtw x8, w1
; CHECK-NEXT:    str  x8, [x0, #8]
; CHECK-NEXT:    b    use_foo
entry:
  %0 = addrspacecast ptr addrspace(270) %i to ptr
  %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
  store ptr %0, ptr %p64, align 8
  tail call void @use_foo(ptr noundef %f)
  ret void
}

declare dso_local void @use_foo(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @test_sign_ext_store_load(ptr addrspace(270) nocapture noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_sign_ext_store_load:
; CHECK:       // %bb.0: // %entry
; CHECK:       sxtw    x19, w0
; CHECK-NEXT:  ldr     w0, [x19]
; CHECK-NEXT:  bl      use_int
; CHECK-NEXT:  str     w0, [x19]
entry:
  %0 = load i32, ptr addrspace(270) %i, align 4
  %call = tail call i32 @use_int(i32 noundef %0)
  store i32 %call, ptr addrspace(270) %i, align 4
  ret void
}

declare dso_local i32 @use_int(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @test_zero_ext(ptr noundef %f, ptr addrspace(271) noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_zero_ext:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:  mov     w8, w1
; CHECK-NEXT:  str     x8, [x0, #8]
; CHECK-NEXT:  b       use_foo
entry:
  %0 = addrspacecast ptr addrspace(271) %i to ptr
  %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
  store ptr %0, ptr %p64, align 8
  tail call void @use_foo(ptr noundef %f)
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_zero_ext_store_load(ptr addrspace(271) nocapture noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_zero_ext_store_load:
; CHECK:       // %bb.0: // %entry
; CHECK:       mov     w19, w0
; CHECK-NEXT:  ldr     w0, [x19]
; CHECK-NEXT:  bl      use_int
; CHECK-NEXT:  str     w0, [x19]
entry:
  %0 = load i32, ptr addrspace(271) %i, align 4
  %call = tail call i32 @use_int(i32 noundef %0)
  store i32 %call, ptr addrspace(271) %i, align 4
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_trunc(ptr noundef %f, ptr noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_trunc:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str     w1, [x0]
; CHECK-NEXT:    b      use_foo
entry:
  %0 = addrspacecast ptr %i to ptr addrspace(270)
  store ptr addrspace(270) %0, ptr %f, align 8
  tail call void @use_foo(ptr noundef nonnull %f)
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_noop1(ptr noundef %f, ptr addrspace(270) noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_noop1:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str  w1, [x0]
; CHECK-NEXT:    b    use_foo
entry:
  store ptr addrspace(270) %i, ptr %f, align 8
  tail call void @use_foo(ptr noundef nonnull %f)
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_noop2(ptr noundef %f, ptr noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_noop2:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str  x1, [x0, #8]
; CHECK-NEXT:    b    use_foo
entry:
  %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
  store ptr %i, ptr %p64, align 8
  tail call void @use_foo(ptr noundef %f)
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_null_arg(ptr noundef %f, ptr addrspace(270) nocapture noundef readnone %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_null_arg:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str  wzr, [x0]
; CHECK-NEXT:    b    use_foo
entry:
  store ptr addrspace(270) null, ptr %f, align 8
  tail call void @use_foo(ptr noundef nonnull %f)
  ret void
}

; Function Attrs: mustprogress uwtable
define dso_local void @test_unrecognized(ptr noundef %f, ptr addrspace(14) noundef %i) local_unnamed_addr #0 {
; CHECK-LABEL: test_unrecognized:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str   w1, [x0]
; CHECK-NEXT:    b    use_foo
entry:
  %0 = addrspacecast ptr addrspace(14) %i to ptr addrspace(270)
  store ptr addrspace(270) %0, ptr %f, align 8
  tail call void @use_foo(ptr noundef nonnull %f)
  ret void
}

attributes #0 = { mustprogress uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }