1 // RUN: %clang_cc1 -triple s390x-ibm-zos -emit-llvm -O2 < %s | FileCheck %s --check-prefix=X64
12 void use_foo(struct Foo
*f
);
14 void ptr32_to_ptr(struct Foo
*f
, int * __ptr32 i
) {
15 // X64-LABEL: define void @ptr32_to_ptr(ptr noundef %f, ptr addrspace(1) noundef %i)
16 // X64: %{{.+}} = addrspacecast ptr addrspace(1) %i to ptr
21 void ptr_to_ptr32(struct Foo
*f
, int *i
) {
22 // X64-LABEL: define void @ptr_to_ptr32(ptr noundef %f, ptr noundef %i)
23 // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(1)
28 void ptr32_to_ptr32(struct Foo
*f
, int * __ptr32 i
) {
29 // X64-LABEL: define void @ptr32_to_ptr32(ptr noundef %f, ptr addrspace(1) noundef %i)
30 // X64-NOT: addrspacecast
35 void ptr_to_ptr32_explicit_cast(struct Foo
*f
, int *i
) {
36 // X64-LABEL: define void @ptr_to_ptr32_explicit_cast(ptr noundef %f, ptr noundef %i)
37 // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(1)
38 f
->p32
= (int * __ptr32
)i
;
42 void test_indexing(struct Foo
*f
) {
43 // X64-LABEL: define void @test_indexing(ptr noundef %f)
44 // X64: addrspacecast ptr addrspace(1) {{%[0-9]}} to ptr
45 f
->cp64
= ((char * __ptr32
*)1028)[1];
49 void test_indexing_2(struct Foo
*f
) {
50 // X64-LABEL: define void @test_indexing_2(ptr noundef %f)
51 // X64: getelementptr inbounds i8, ptr addrspace(1) {{%[0-9]}}, i32 16
52 // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 24
53 f
->cp64
= ((char *** __ptr32
*)1028)[1][2][3];
57 unsigned long* test_misc() {
58 // X64-LABEL: define ptr @test_misc()
59 // X64: %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %0, i32 88
60 // X64-NEXT: %1 = load ptr, ptr addrspace(1) %arrayidx
61 // X64-NEXT: %arrayidx1 = getelementptr inbounds i8, ptr %1, i64 8
62 // X64-NEXT: %2 = load ptr, ptr %arrayidx1
63 // X64-NEXT: %arrayidx2 = getelementptr inbounds i8, ptr %2, i64 904
64 // X64-NEXT: %3 = load ptr, ptr %arrayidx2
65 // X64-NEXT: %arrayidx3 = getelementptr inbounds i8, ptr %3, i64 1192
66 unsigned long* x
= (unsigned long*)((char***** __ptr32
*)1208)[0][11][1][113][149];
70 char* __ptr32
* __ptr32
test_misc_2() {
71 // X64-LABEL: define ptr addrspace(1) @test_misc_2()
72 // X64: br i1 %cmp, label %if.then, label %if.end
73 // X64: %1 = load ptr addrspace(1), ptr inttoptr (i64 16 to ptr)
74 // X64-NEXT: %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %1, i32 544
75 // X64-NEXT: %2 = load ptr addrspace(1), ptr addrspace(1) %arrayidx
76 // X64-NEXT: %arrayidx1 = getelementptr inbounds i8, ptr addrspace(1) %2, i32 24
77 // X64-NEXT: %3 = load ptr addrspace(1), ptr addrspace(1) %arrayidx1
78 // X64-NEXT: store ptr addrspace(1) %3, ptr @test_misc_2.res
79 // X64: ret ptr addrspace(1)
80 static char* __ptr32
* __ptr32 res
= 0;
82 res
= ((char* __ptr32
* __ptr32
* __ptr32
* __ptr32
*)0)[4][136][6];
87 unsigned short test_misc_3() {
88 // X64-LABEL: define zeroext i16 @test_misc_3()
89 // X64: %0 = load ptr addrspace(1), ptr inttoptr (i64 548 to ptr)
90 // X64-NEXT: %1 = addrspacecast ptr addrspace(1) %0 to ptr
91 // X64-NEXT: %arrayidx = getelementptr inbounds i8, ptr %1, i64 36
92 // X64-NEXT: %2 = load i16, ptr %arrayidx, align 2
93 // X64-NEXT: ret i16 %2
94 unsigned short this_asid
= ((unsigned short*)(*(char* __ptr32
*)(0x224)))[18];
99 // X64-LABEL: define signext range(i32 0, 2) i32 @test_misc_4()
100 // X64: getelementptr inbounds i8, ptr addrspace(1) {{%[0-9]}}, i32 88
101 // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 8
102 // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 984
103 // X64: getelementptr inbounds i8, ptr %3, i64 80
104 // X64: icmp sgt i32 {{.*[0-9]}}, 67240703
106 int a
= (*(int*)(80 + ((char**** __ptr32
*)1208)[0][11][1][123]) > 0x040202FF);
110 void test_misc_5(struct Foo
*f
) {
111 // X64-LABEL: define void @test_misc_5(ptr noundef %f)
112 // X64: addrspacecast ptr addrspace(1) %0 to ptr
113 f
->cp64
= *(char* __ptr32
*)(PSA_PTR
+ PSAAOLD
);
118 // X64-LABEL: define {{.*}} i32 @test_misc_6()
127 // X64-LABEL: define {{.*}} i32 @test_misc_7()
135 ip32
= (int * __ptr32
) ip64
;
141 // X64-LABEL: define {{.*}} i32 @test_misc_8()
149 cp32
= (char * __ptr32
) cp64
;
155 // X64-LABEL: define {{.*}} i32 @test_misc_9()
169 // X64-LABEL: define {{.*}} i32 @test_misc_10()
182 int test_function_ptr32_is_32bit() {
183 // X64-LABEL: define {{.*}} i32 @test_function_ptr32_is_32bit()
185 int (* __ptr32 a
)(int a
);
189 int get_processor_count() {
190 // X64-LABEL: define signext range(i32 -128, 128) i32 @get_processor_count()
191 // X64: load ptr addrspace(1), ptr inttoptr (i64 16 to ptr)
192 // X64-NEXT: [[ARR_IDX1:%[a-z].*]] = getelementptr inbounds i8, ptr addrspace(1) %0, i32 660
193 // X64: load ptr addrspace(1), ptr addrspace(1) [[ARR_IDX1]]
194 // X64: load i8, ptr addrspace(1) {{%[a-z].*}}
195 // X64: sext i8 {{%[0-9]}} to i32
197 return ((char * __ptr32
* __ptr32
*)0)[4][165][53];
200 int get_sizes_ptr32() {
201 // X64-LABEL: define {{.*}} i32 @get_sizes_ptr32()
204 signed char * __ptr32 b
;
205 unsigned char *__ptr32 c
;
207 signed int * __ptr32 e
;
208 unsigned int *__ptr32 f
;
210 signed short * __ptr32 h
;
211 unsigned short * __ptr32 i
;
214 unsigned * __ptr32 l
;
215 long long * __ptr32 m
;
216 signed long long * __ptr32 n
;
217 unsigned long long * __ptr32 o
;
220 long double * __ptr32 r
;
245 int get_sizes_p64() {
246 // X64-LABEL: define {{.*}} i32 @get_sizes_p64()
262 unsigned long long *o
;
292 char *__ptr32 CVT
= *(char * __ptr32
*__ptr32
) 16;
293 unsigned short Id
= *(unsigned short *)&CVT
[-6];
294 Id
= ((((Id
>> 12) & 0x0f) * 10 + ((Id
>> 8) & 0x0f)) * 10 + ((Id
>> 4) & 0x0f)) * 10 + (Id
& 0x0f);
295 int HaveVectorSupport
= CVT
[244] & 0x80;
296 int z13
= (Id
>= 2964 && HaveVectorSupport
);