| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // RUN: %clang_cc1 -triple s390x-ibm-zos -emit-llvm < %s | FileCheck %s --check-prefix=PTR32-ZOS | ||
| // RUN: %clang_cc1 -triple s390x-ibm-linux -fzos-extensions -emit-llvm < %s | FileCheck %s --check-prefix=PTR32-LINUX | ||
| // RUN: %clang_cc1 -triple s390x-linux-gnu -fzos-extensions -emit-llvm < %s | FileCheck %s --check-prefix=PTR32-LINUX | ||
|
|
||
| void ptr32_declarations() { | ||
| // PTR32-ZOS-LABEL: @ptr32_declarations() | ||
| // PTR32-LINUX-LABEL: @ptr32_declarations() | ||
|
|
||
| // PTR32-ZOS: %p1 = alloca ptr addrspace(1), align 4 | ||
| // PTR32-LINUX-NOT: %p1 = alloca i8 addrspace(1)*, align 4 | ||
| // PTR32-LINUX: %p1 = alloca ptr, align 8 | ||
| char * __ptr32 p1; | ||
|
|
||
| // PTR32-ZOS: %p2 = alloca ptr, align 8 | ||
| // PTR32-LINUX-NOT: %p2 = alloca ptr addrspace(1), align 8 | ||
| // PTR32-LINUX: %p2 = alloca ptr, align 8 | ||
| char * __ptr32 *p2; | ||
|
|
||
| // PTR32-ZOS: %p3 = alloca ptr addrspace(1), align 4 | ||
| // PTR32-LINUX-NOT: %p3 = alloca i8* addrspace(1)*, align 4 | ||
| // PTR32-LINUX: %p3 = alloca ptr, align 8 | ||
| char ** __ptr32 p3; | ||
|
|
||
| // PTR32-ZOS: %p4 = alloca ptr, align 8 | ||
| // PTR32-LINUX-NOT: %p4 = alloca ptr addrspace(1), align 8 | ||
| // PTR32-LINUX: %p4 = alloca ptr, align 8 | ||
| char ** __ptr32 *p4; | ||
|
|
||
| // PTR32-ZOS: %p5 = alloca ptr, align 8 | ||
| // PTR32-LINUX-NOT: %p5 = alloca ptr addrspace(1), align 8 | ||
| // PTR32-LINUX: %p5 = alloca ptr, align 8 | ||
| char *** __ptr32 *p5; | ||
|
|
||
| // PTR32-ZOS: %p6 = alloca ptr, align 8 | ||
| // PTR32-LINUX: %p6 = alloca ptr, align 8 | ||
| char **p6; | ||
|
|
||
| // PTR32-ZOS: %p7 = alloca ptr addrspace(1), align 4 | ||
| // PTR32-LINUX-NOT: %p7 = alloca i8 addrspace(1)* addrspace(1)*, align 4 | ||
| // PTR32-LINUX: %p7 = alloca ptr, align 8 | ||
| char * __ptr32 * __ptr32 p7; | ||
|
|
||
| // PTR32-ZOS: %p8 = alloca ptr addrspace(1), align 4 | ||
| // PTR32-LINUX-NOT: %p8 = alloca i8* addrspace(1)* addrspace(1)*, align 4 | ||
| // PTR32-LINUX: %p8 = alloca ptr, align 8 | ||
| char ** __ptr32 * __ptr32 p8; | ||
|
|
||
| // PTR32-ZOS: %p9 = alloca ptr, align 8 | ||
| // PTR32-LINUX-NOT: %p9 = alloca i8* addrspace(1)* addrspace(1)**, align 8 | ||
| // PTR32-LINUX: %p9 = alloca ptr, align 8 | ||
| char ** __ptr32 * __ptr32 *p9; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // RUN: %clang -target s390x-ibm-zos -emit-llvm -S -O2 %s -o - | FileCheck %s --check-prefix=X64 | ||
| #include <stddef.h> | ||
| void *__malloc31(size_t); | ||
|
|
||
| int test_1() { | ||
| // X64-LABEL: define {{.*}} i32 @test_1() | ||
| // X64: ret i32 135 | ||
| int *__ptr32 a; | ||
| int *b; | ||
| int i; | ||
| int sum1, sum2, sum3; | ||
|
|
||
| a = (int *__ptr32)__malloc31(sizeof(int) * 10); | ||
|
|
||
| b = a; | ||
| sum1 = 0; | ||
| for (i = 0; i < 10; ++i) { | ||
| a[i] = i; | ||
| sum1 += i; | ||
| } | ||
|
|
||
| sum2 = 0; | ||
| for (i = 0; i < 10; ++i) { | ||
| sum2 += a[i]; | ||
| } | ||
| sum3 = 0; | ||
| for (i = 0; i < 10; ++i) { | ||
| sum3 += b[i]; | ||
| } | ||
|
|
||
| return (sum1 + sum2 + sum3); | ||
| } | ||
|
|
||
| int test_2() { | ||
| // X64-LABEL: define {{.*}} i32 @test_2() | ||
| // X64: ret i32 4 | ||
| int *a = (int *)__malloc31(sizeof(int)); | ||
| int *__ptr32 b; | ||
|
|
||
| *a = 99; | ||
| b = a; | ||
| *b = 44; | ||
|
|
||
| // Test should return 4 | ||
| return (*b - 40); | ||
| } | ||
|
|
||
| int test_3() { | ||
| // X64-LABEL: define {{.*}} i32 @test_3() | ||
| // X64: ret i32 4 | ||
| int *a = (int *)__malloc31(sizeof(int)); | ||
| int *__ptr32 b; | ||
|
|
||
| *a = 99; | ||
| b = a; | ||
|
|
||
| // Test should return 4 | ||
| return (*b - 95); | ||
| } | ||
|
|
||
| int test_4() { | ||
| // X64-LABEL: define {{.*}} i32 @test_4() | ||
| // X64: ret i32 1 | ||
| int *a = (int *)__malloc31(sizeof(int)); | ||
| float *d = (float *)__malloc31(sizeof(float)); | ||
|
|
||
| int *__ptr32 b; | ||
| int *c; | ||
|
|
||
| float *__ptr32 e; | ||
| float *f; | ||
|
|
||
| *a = 0; | ||
| *d = 0.0; | ||
|
|
||
| b = a; | ||
| c = a; | ||
| e = d; | ||
| f = d; | ||
|
|
||
| // Test should return 1 | ||
| return (b == c && e == f); | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // RUN: %clang_cc1 -emit-llvm -triple s390x-ibm-zos -fzos-extensions -fdump-record-layouts < %s | FileCheck %s --check-prefix=PTR32-ZOS | ||
| // RUN: %clang_cc1 -emit-llvm -triple s390x-ibm-linux -fzos-extensions -fdump-record-layouts < %s | FileCheck %s --check-prefix=PTR32-LINUX | ||
| // RUN: %clang_cc1 -emit-llvm -triple s390x-linux-gnu -fzos-extensions -fdump-record-layouts < %s | FileCheck %s --check-prefix=PTR32-LINUX | ||
|
|
||
| // PTR32-ZOS: 0 | struct s1 | ||
| // PTR32-ZOS-NEXT: 0 | long a | ||
| // PTR32-ZOS-NEXT: 8 | int b | ||
| // PTR32-ZOS-NEXT: 12 | int * __ptr32 c | ||
| // PTR32-ZOS-NEXT: 16 | int d | ||
| // PTR32-ZOS-NEXT: | [sizeof=24, align=8] | ||
|
|
||
| // PTR32-LINUX: 0 | struct s1 | ||
| // PTR32-LINUX-NEXT: 0 | long a | ||
| // PTR32-LINUX-NEXT: 8 | int b | ||
| // PTR32-LINUX-NEXT: 16 | int * __ptr32 c | ||
| // PTR32-LINUX-NEXT: 24 | int d | ||
| // PTR32-LINUX-NEXT: | [sizeof=32, align=8] | ||
| struct s1 { | ||
| long a; | ||
| int b; | ||
| int * __ptr32 c; | ||
| int d; | ||
| } S1; | ||
|
|
||
| // PTR32-ZOS: 0 | struct s2 | ||
| // PTR32-ZOS-NEXT: 0 | long a | ||
| // PTR32-ZOS-NEXT: 8 | int b | ||
| // PTR32-ZOS-NEXT: 16 | int * c | ||
| // PTR32-ZOS-NEXT: 24 | int d | ||
| // PTR32-ZOS-NEXT: | [sizeof=32, align=8] | ||
|
|
||
| // PTR32-LINUX: 0 | struct s2 | ||
| // PTR32-LINUX-NEXT: 0 | long a | ||
| // PTR32-LINUX-NEXT: 8 | int b | ||
| // PTR32-LINUX-NEXT: 16 | int * c | ||
| // PTR32-LINUX-NEXT: 24 | int d | ||
| // PTR32-LINUX-NEXT: | [sizeof=32, align=8] | ||
| struct s2 { | ||
| long a; | ||
| int b; | ||
| int *c; | ||
| int d; | ||
| } S2; | ||
|
|
||
| // PTR32-ZOS: 0 | struct s3 | ||
| // PTR32-ZOS-NEXT: 0 | int a | ||
| // PTR32-ZOS-NEXT: 4 | int * __ptr32 b | ||
| // PTR32-ZOS-NEXT: 8 | int * __ptr32 c | ||
| // PTR32-ZOS-NEXT: 12 | int * d | ||
| // PTR32-ZOS-NEXT: | [sizeof=20, align=1] | ||
|
|
||
| struct __attribute__((packed)) s3 { | ||
| int a; | ||
| int *__ptr32 b; | ||
| int *__ptr32 c; | ||
| int *d; | ||
| }; | ||
| struct s3 S3; | ||
|
|
||
| // PTR32-ZOS: 0 | union u1 | ||
| // PTR32-ZOS-NEXT: 0 | int * __ptr32 a | ||
| // PTR32-ZOS-NEXT: 0 | int * b | ||
| // PTR32-ZOS-NEXT: | [sizeof=8, align=8] | ||
|
|
||
| // PTR32-LINUX: 0 | union u1 | ||
| // PTR32-LINUX-NEXT: 0 | int * __ptr32 a | ||
| // PTR32-LINUX-NEXT: 0 | int * b | ||
| // PTR32-LINUX-NEXT: | [sizeof=8, align=8] | ||
| union u1 { | ||
| int *__ptr32 a; | ||
| int *b; | ||
| } U1; | ||
|
|
||
| // PTR32-ZOS: 0 | union u2 | ||
| // PTR32-ZOS-NEXT: 0 | int * __ptr32 a | ||
| // PTR32-ZOS-NEXT: 0 | int * b | ||
| // PTR32-ZOS-NEXT: | [sizeof=8, align=1] | ||
|
|
||
| union __attribute__((packed)) u2 { | ||
| int *__ptr32 a; | ||
| int *b; | ||
| }; | ||
| union u2 U2; | ||
|
|
||
| // PTR32-ZOS: 0 | union u3 | ||
| // PTR32-ZOS-NEXT: 0 | int * __ptr32 a | ||
| // PTR32-ZOS-NEXT: 0 | short b | ||
| // PTR32-ZOS-NEXT: | [sizeof=4, align=1] | ||
|
|
||
| union __attribute__((packed)) u3 { | ||
| int *__ptr32 a; | ||
| short b; | ||
| }; | ||
| union u3 U3; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,298 @@ | ||
| // RUN: %clang_cc1 -triple s390x-ibm-zos -emit-llvm -O2 < %s | FileCheck %s --check-prefix=X64 | ||
|
|
||
| #define PSA_PTR 0x00 | ||
| #define PSAAOLD 0x224 | ||
|
|
||
| struct Foo { | ||
| int * __ptr32 p32; | ||
| int *p64; | ||
| char *cp64; | ||
| }; | ||
|
|
||
| void use_foo(struct Foo *f); | ||
|
|
||
| void ptr32_to_ptr(struct Foo *f, int * __ptr32 i) { | ||
| // X64-LABEL: define void @ptr32_to_ptr(ptr noundef %f, ptr addrspace(1) noundef %i) | ||
| // X64: %{{.+}} = addrspacecast ptr addrspace(1) %i to ptr | ||
| f->p64= i; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| void ptr_to_ptr32(struct Foo *f, int *i) { | ||
| // X64-LABEL: define void @ptr_to_ptr32(ptr noundef %f, ptr noundef %i) | ||
| // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(1) | ||
| f->p32 = i; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| void ptr32_to_ptr32(struct Foo *f, int * __ptr32 i) { | ||
| // X64-LABEL: define void @ptr32_to_ptr32(ptr noundef %f, ptr addrspace(1) noundef %i) | ||
| // X64-NOT: addrspacecast | ||
| f->p32 = i; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| void ptr_to_ptr32_explicit_cast(struct Foo *f, int *i) { | ||
| // X64-LABEL: define void @ptr_to_ptr32_explicit_cast(ptr noundef %f, ptr noundef %i) | ||
| // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(1) | ||
| f->p32 = (int * __ptr32)i; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| void test_indexing(struct Foo *f) { | ||
| // X64-LABEL: define void @test_indexing(ptr noundef %f) | ||
| // X64: addrspacecast ptr addrspace(1) {{%[0-9]}} to ptr | ||
| f->cp64 = ((char * __ptr32 *)1028)[1]; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| void test_indexing_2(struct Foo *f) { | ||
| // X64-LABEL: define void @test_indexing_2(ptr noundef %f) | ||
| // X64: getelementptr inbounds i8, ptr addrspace(1) {{%[0-9]}}, i32 16 | ||
| // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 24 | ||
| f->cp64 = ((char *** __ptr32 *)1028)[1][2][3]; | ||
| use_foo(f); | ||
| } | ||
|
|
||
| unsigned long* test_misc() { | ||
| // X64-LABEL: define ptr @test_misc() | ||
| // X64: %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %0, i32 88 | ||
| // X64-NEXT: %1 = load ptr, ptr addrspace(1) %arrayidx | ||
| // X64-NEXT: %arrayidx1 = getelementptr inbounds i8, ptr %1, i64 8 | ||
| // X64-NEXT: %2 = load ptr, ptr %arrayidx1 | ||
| // X64-NEXT: %arrayidx2 = getelementptr inbounds i8, ptr %2, i64 904 | ||
| // X64-NEXT: %3 = load ptr, ptr %arrayidx2 | ||
| // X64-NEXT: %arrayidx3 = getelementptr inbounds i8, ptr %3, i64 1192 | ||
| unsigned long* x = (unsigned long*)((char***** __ptr32*)1208)[0][11][1][113][149]; | ||
| return x; | ||
| } | ||
|
|
||
| char* __ptr32* __ptr32 test_misc_2() { | ||
| // X64-LABEL: define ptr addrspace(1) @test_misc_2() | ||
| // X64: br i1 %cmp, label %if.then, label %if.end | ||
| // X64: %1 = load ptr addrspace(1), ptr inttoptr (i64 16 to ptr) | ||
| // X64-NEXT: %arrayidx = getelementptr inbounds i8, ptr addrspace(1) %1, i32 544 | ||
| // X64-NEXT: %2 = load ptr addrspace(1), ptr addrspace(1) %arrayidx | ||
| // X64-NEXT: %arrayidx1 = getelementptr inbounds i8, ptr addrspace(1) %2, i32 24 | ||
| // X64-NEXT: %3 = load ptr addrspace(1), ptr addrspace(1) %arrayidx1 | ||
| // X64-NEXT: store ptr addrspace(1) %3, ptr @test_misc_2.res | ||
| // X64: ret ptr addrspace(1) | ||
| static char* __ptr32* __ptr32 res = 0; | ||
| if (res == 0) { | ||
| res = ((char* __ptr32* __ptr32* __ptr32* __ptr32*)0)[4][136][6]; | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| unsigned short test_misc_3() { | ||
| // X64-LABEL: define zeroext i16 @test_misc_3() | ||
| // X64: %0 = load ptr addrspace(1), ptr inttoptr (i64 548 to ptr) | ||
| // X64-NEXT: %1 = addrspacecast ptr addrspace(1) %0 to ptr | ||
| // X64-NEXT: %arrayidx = getelementptr inbounds i8, ptr %1, i64 36 | ||
| // X64-NEXT: %2 = load i16, ptr %arrayidx, align 2 | ||
| // X64-NEXT: ret i16 %2 | ||
| unsigned short this_asid = ((unsigned short*)(*(char* __ptr32*)(0x224)))[18]; | ||
| return this_asid; | ||
| } | ||
|
|
||
| int test_misc_4() { | ||
| // X64-LABEL: define signext range(i32 0, 2) i32 @test_misc_4() | ||
| // X64: getelementptr inbounds i8, ptr addrspace(1) {{%[0-9]}}, i32 88 | ||
| // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 8 | ||
| // X64: getelementptr inbounds i8, ptr {{%[0-9]}}, i64 984 | ||
| // X64: getelementptr inbounds i8, ptr %3, i64 80 | ||
| // X64: icmp sgt i32 {{.*[0-9]}}, 67240703 | ||
| // X64: ret i32 | ||
| int a = (*(int*)(80 + ((char**** __ptr32*)1208)[0][11][1][123]) > 0x040202FF); | ||
| return a; | ||
| } | ||
|
|
||
| void test_misc_5(struct Foo *f) { | ||
| // X64-LABEL: define void @test_misc_5(ptr noundef %f) | ||
| // X64: addrspacecast ptr addrspace(1) %0 to ptr | ||
| f->cp64 = *(char* __ptr32 *)(PSA_PTR + PSAAOLD); | ||
| use_foo(f); | ||
| } | ||
|
|
||
| int test_misc_6() { | ||
| // X64-LABEL: define {{.*}} i32 @test_misc_6() | ||
| // X64: ret i32 8 | ||
| int * __ptr32 ip32; | ||
| int *ip64; | ||
| ip64 = ip32; | ||
| return sizeof(ip64); | ||
| } | ||
|
|
||
| int test_misc_7() { | ||
| // X64-LABEL: define {{.*}} i32 @test_misc_7() | ||
| // X64: ret i32 12 | ||
| int foo = 12; | ||
|
|
||
| int *ip64; | ||
| int * __ptr32 ip32; | ||
|
|
||
| ip64 = &foo; | ||
| ip32 = (int * __ptr32) ip64; | ||
|
|
||
| return *ip32; | ||
| } | ||
|
|
||
| int test_misc_8() { | ||
| // X64-LABEL: define {{.*}} i32 @test_misc_8() | ||
| // X64: ret i32 97 | ||
| char foo = 'a'; | ||
|
|
||
| char *cp64; | ||
| char * __ptr32 cp32; | ||
|
|
||
| cp64 = &foo; | ||
| cp32 = (char * __ptr32) cp64; | ||
|
|
||
| return *cp32; | ||
| } | ||
|
|
||
| int test_misc_9() { | ||
| // X64-LABEL: define {{.*}} i32 @test_misc_9() | ||
| // X64: ret i32 15 | ||
| int foo = 15; | ||
|
|
||
| int *ip64; | ||
| int * __ptr32 ip32; | ||
|
|
||
| ip32 = &foo; | ||
| ip64 = (int *)ip32; | ||
|
|
||
| return *ip64; | ||
| } | ||
|
|
||
| int test_misc_10() { | ||
| // X64-LABEL: define {{.*}} i32 @test_misc_10() | ||
| // X64: ret i32 97 | ||
| char foo = 'a'; | ||
|
|
||
| char *cp64; | ||
| char * __ptr32 cp32; | ||
|
|
||
| cp32 = &foo; | ||
| cp64= (char *)cp32; | ||
|
|
||
| return *cp64; | ||
| } | ||
|
|
||
| int test_function_ptr32_is_32bit() { | ||
| // X64-LABEL: define {{.*}} i32 @test_function_ptr32_is_32bit() | ||
| // X64: ret i32 4 | ||
| int (* __ptr32 a)(int a); | ||
| return sizeof(a); | ||
| } | ||
|
|
||
| int get_processor_count() { | ||
| // X64-LABEL: define signext range(i32 -128, 128) i32 @get_processor_count() | ||
| // X64: load ptr addrspace(1), ptr inttoptr (i64 16 to ptr) | ||
| // X64-NEXT: [[ARR_IDX1:%[a-z].*]] = getelementptr inbounds i8, ptr addrspace(1) %0, i32 660 | ||
| // X64: load ptr addrspace(1), ptr addrspace(1) [[ARR_IDX1]] | ||
| // X64: load i8, ptr addrspace(1) {{%[a-z].*}} | ||
| // X64: sext i8 {{%[0-9]}} to i32 | ||
| // X64-NEXT: ret i32 | ||
| return ((char * __ptr32 * __ptr32 *)0)[4][165][53]; | ||
| } | ||
|
|
||
| int get_sizes_ptr32() { | ||
| // X64-LABEL: define {{.*}} i32 @get_sizes_ptr32() | ||
| // X64: ret i32 72 | ||
| char * __ptr32 a; | ||
| signed char * __ptr32 b; | ||
| unsigned char *__ptr32 c; | ||
| int * __ptr32 d; | ||
| signed int * __ptr32 e; | ||
| unsigned int *__ptr32 f; | ||
| short * __ptr32 g; | ||
| signed short * __ptr32 h; | ||
| unsigned short * __ptr32 i; | ||
| long * __ptr32 j; | ||
| signed * __ptr32 k; | ||
| unsigned * __ptr32 l; | ||
| long long * __ptr32 m; | ||
| signed long long * __ptr32 n; | ||
| unsigned long long * __ptr32 o; | ||
| float * __ptr32 p; | ||
| double * __ptr32 q; | ||
| long double * __ptr32 r; | ||
|
|
||
| int sum = 0; | ||
| sum += sizeof(a); | ||
| sum += sizeof(b); | ||
| sum += sizeof(c); | ||
| sum += sizeof(d); | ||
| sum += sizeof(e); | ||
| sum += sizeof(f); | ||
| sum += sizeof(g); | ||
| sum += sizeof(h); | ||
| sum += sizeof(i); | ||
| sum += sizeof(j); | ||
| sum += sizeof(k); | ||
| sum += sizeof(l); | ||
| sum += sizeof(m); | ||
| sum += sizeof(n); | ||
| sum += sizeof(o); | ||
| sum += sizeof(p); | ||
| sum += sizeof(q); | ||
| sum += sizeof(r); | ||
|
|
||
| return sum; | ||
| } | ||
|
|
||
| int get_sizes_p64() { | ||
| // X64-LABEL: define {{.*}} i32 @get_sizes_p64() | ||
| // X64: ret i32 144 | ||
| char *a; | ||
| signed char *b; | ||
| unsigned char *c; | ||
| int *d; | ||
| signed int *e; | ||
| unsigned int *f; | ||
| short *g; | ||
| signed short *h; | ||
| unsigned short *i; | ||
| long *j; | ||
| signed *k; | ||
| unsigned *l; | ||
| long long *m; | ||
| signed long long *n; | ||
| unsigned long long *o; | ||
| float *p; | ||
| double *q; | ||
| long double *r; | ||
|
|
||
| int sum = 0; | ||
| sum += sizeof(a); | ||
| sum += sizeof(b); | ||
| sum += sizeof(c); | ||
| sum += sizeof(d); | ||
| sum += sizeof(e); | ||
| sum += sizeof(f); | ||
| sum += sizeof(g); | ||
| sum += sizeof(h); | ||
| sum += sizeof(i); | ||
| sum += sizeof(j); | ||
| sum += sizeof(k); | ||
| sum += sizeof(l); | ||
| sum += sizeof(m); | ||
| sum += sizeof(n); | ||
| sum += sizeof(o); | ||
| sum += sizeof(p); | ||
| sum += sizeof(q); | ||
| sum += sizeof(r); | ||
|
|
||
| return sum; | ||
|
|
||
| } | ||
|
|
||
| int host_cpu() { | ||
| char *__ptr32 CVT = *(char * __ptr32 *__ptr32) 16; | ||
| unsigned short Id = *(unsigned short *)&CVT[-6]; | ||
| Id = ((((Id >> 12) & 0x0f) * 10 + ((Id >> 8) & 0x0f)) * 10 + ((Id >> 4) & 0x0f)) * 10 + (Id & 0x0f); | ||
| int HaveVectorSupport = CVT[244] & 0x80; | ||
| int z13 = (Id >= 2964 && HaveVectorSupport); | ||
| return z13; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // RUN: %clang_cc1 -fzos-extensions -emit-llvm -triple s390x-ibm-zos -x c++ -o - %s | FileCheck %s --check-prefixes=CHECK | ||
|
|
||
| // CHECK-LABEL: define void @_Z2f1v() | ||
| void f1() {} | ||
|
|
||
| // CHECK-LABEL: define void @_Z2f2Pi(ptr addrspace(1) noundef %p32) | ||
| void f2(int * __ptr32 p32) {} | ||
|
|
||
| // CHECK-LABEL: define noundef ptr addrspace(1) @_Z2f3Pi(ptr addrspace(1) noundef %p32) | ||
| int * __ptr32 f3(int * __ptr32 p32) { | ||
| return p32; | ||
| } | ||
|
|
||
| // CHECK-LABEL: define noundef ptr @_Z2f4PPi(ptr noundef %p32) | ||
| int * __ptr32 *f4(int * __ptr32 *p32) { | ||
| return p32; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| // RUN: %clang_cc1 -triple s390x-ibm-zos %s -fsyntax-only -fzos-extensions -verify | ||
| // RUN: %clang_cc1 -triple s390x-ibm-zos %s -fsyntax-only -verify | ||
|
|
||
| struct A { | ||
| int a; | ||
| short b; | ||
| float q; | ||
| double z; | ||
| }; | ||
|
|
||
| union B { | ||
| int a; | ||
| short b; | ||
| float q; | ||
| double z; | ||
| }; | ||
|
|
||
| class C { | ||
| int a; | ||
| short b; | ||
| float q; | ||
| double z; | ||
| }; | ||
|
|
||
| // ************************ | ||
| // INCORRECT DECLARATION | ||
| // ************************ | ||
| int * __ptr64 p64; // expected-error {{expected ';' after top level declarator}} | ||
| int *wrong_var3 __ptr32; // expected-error {{expected ';' after top level declarator}} expected-warning {{declaration does not declare anything}} | ||
|
|
||
| // ************************** | ||
| // INCORRECT USAGES OF PTR32 | ||
| // ************************** | ||
| struct D { | ||
| int __ptr32 *a; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| }; | ||
|
|
||
| union E { | ||
| int __ptr32 *b; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| }; | ||
|
|
||
| char __ptr32 *a; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| signed char __ptr32 *b; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| unsigned char __ptr32 *c; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 *d; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| signed int __ptr32 *e; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| unsigned int __ptr32 *f; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| short int __ptr32 *g; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| signed short int __ptr32 *h; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| unsigned short int __ptr32 *i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| long int __ptr32 *j; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| signed long int __ptr32 *k; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| unsigned long int __ptr32 *l; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| long long int __ptr32 *m; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| signed long long int __ptr32 *n; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| unsigned long long int __ptr32 *o; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| float __ptr32 *p; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| double __ptr32 *q; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 **r; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 *__ptr32 *s; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 *__ptr32 *__ptr32 t; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 *__ptr32 *__ptr32 *__ptr32 u; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 __ptr32 **v_i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int __ptr32 __ptr32 __ptr32 w_i; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
|
|
||
| __ptr32 int wrong_var; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
|
|
||
| struct A __ptr32 *c1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| struct A __ptr32 **e1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| struct A __ptr32 *__ptr32 *f1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| struct A __ptr32 *__ptr32 *__ptr32 g1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| union B __ptr32 *d1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| union B __ptr32 **h1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| union B __ptr32 * __ptr32 *i1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| union B __ptr32 * __ptr32 * __ptr32 j1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
|
|
||
| C __ptr32 **k1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| C __ptr32 * __ptr32 *l1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| C __ptr32 * __ptr32 * __ptr32 m1; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
|
|
||
| struct D n1; | ||
| union E o1; | ||
|
|
||
| int incorrect_func() { | ||
| int __ptr32 = 1; // expected-error {{expected unqualified-id}} | ||
| return __ptr32; // expected-error {{expected expression}} | ||
| } | ||
|
|
||
| typedef int __ptr32; // expected-warning {{typedef requires a name}} | ||
| int incorrect_func2() { | ||
| return 1; | ||
| } | ||
|
|
||
| typedef int __ptr32 *v; // expected-error {{'__ptr32' attribute only applies to pointer arguments}} | ||
| int incorrect_func3() { | ||
| v v1; | ||
| return 0; | ||
| } | ||
|
|
||
| int *__ptr32 a_ptr; //expected-note {{previous definition is here}} | ||
| int *a_ptr; // expected-error {{redefinition of 'a_ptr' with a different type: 'int *' vs 'int * __ptr32'}} | ||
|
|
||
| // ******************************************************* | ||
| // FUNCTION OVERLOADING BETWEEN PTR32 AND REGULAR POINTERS | ||
| // ******************************************************* | ||
| void func(int * __ptr32 p32) {} // expected-note {{previous definition is here}} | ||
| void func(int *p64) {} // expected-error {{redefinition of 'func'}} | ||
|
|
||
| // Overloads between ptr32 and other non-pointer types are permissible | ||
| void func1(int *__ptr32 p32) {} | ||
| void func1(int p64) {} | ||
|
|
||
| // ****** | ||
| // MISC | ||
| // ****** | ||
| void func2() { | ||
| char * __ptr32 v = ((char * __ptr32 *)1028)[0]; | ||
| char *v1 = ((char ** __ptr32 *)1028)[0][1]; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // RUN: %clang_cc1 %s -triple s390x-ibm-zos -ast-print -fzos-extensions | FileCheck %s | ||
|
|
||
| // CHECK: int * __ptr32 p32; | ||
| int * __ptr32 p32; | ||
|
|
||
| // CHECK: char * __ptr32 c32; | ||
| char * __ptr32 c32; | ||
|
|
||
| // CHECK: void * __ptr32 v32; | ||
| void * __ptr32 v32; | ||
|
|
||
| // CHECK: int * __ptr32 *q; | ||
| int * __ptr32 *q; | ||
|
|
||
| // CHECK: void *func(int * __ptr32 p); | ||
| void *func(int * __ptr32 p); | ||
|
|
||
| // CHECK: int * __ptr32 func1(int * __ptr32 p); | ||
| int * __ptr32 func1(int * __ptr32 p); | ||
|
|
||
| // CHECK: int *func2(void * __ptr32 p); | ||
| int *func2(void * __ptr32 p); | ||
|
|
||
| // CHECK: int *const __ptr32 r; | ||
| int * __ptr32 const r; | ||
|
|
||
| // CHECK: int ** __ptr32 *v; | ||
| int * *__ptr32* v; | ||
|
|
||
| // CHECK: int *** __ptr32 *z; | ||
| int ** * __ptr32 * z; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s | ||
|
|
||
| // This is heavily affected by the speculative resolution applied to CWG2311 | ||
| // So behaviour shown here is subject to change. | ||
|
|
||
| // expected-no-diagnostics | ||
|
|
||
| namespace std { | ||
| typedef decltype(sizeof(int)) size_t; | ||
|
|
||
| // libc++'s implementation | ||
| template <class _E> | ||
| class initializer_list | ||
| { | ||
| const _E* __begin_; | ||
| size_t __size_; | ||
|
|
||
| initializer_list(const _E* __b, size_t __s) | ||
| : __begin_(__b), | ||
| __size_(__s) | ||
| {} | ||
|
|
||
| public: | ||
| typedef _E value_type; | ||
| typedef const _E& reference; | ||
| typedef const _E& const_reference; | ||
| typedef size_t size_type; | ||
|
|
||
| typedef const _E* iterator; | ||
| typedef const _E* const_iterator; | ||
|
|
||
| constexpr initializer_list() : __begin_(nullptr), __size_(0) {} | ||
|
|
||
| constexpr size_t size() const {return __size_;} | ||
| const _E* begin() const {return __begin_;} | ||
| const _E* end() const {return __begin_ + __size_;} | ||
| }; | ||
|
|
||
| template<typename T> | ||
| struct vector { | ||
| size_t sz; | ||
| constexpr vector() : sz(0) {} | ||
| constexpr vector(initializer_list<T> ilist) : sz(ilist.size()) {} | ||
| constexpr vector(const vector& other) : sz(other.sz) {} | ||
| constexpr std::size_t size() const { return sz; } | ||
| }; | ||
| } | ||
|
|
||
| // https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908062472 | ||
| namespace Issue1 { | ||
| struct A { | ||
| constexpr A() {} | ||
| }; | ||
|
|
||
| struct B { | ||
| int called_ctor; | ||
| constexpr explicit B(A) : called_ctor(0) {} | ||
| constexpr explicit B(std::vector<A>) : called_ctor(1) {} | ||
| }; | ||
|
|
||
| struct C { | ||
| B b; | ||
| constexpr C() : b({A()}) {} | ||
| }; | ||
|
|
||
| static_assert(C().b.called_ctor == 0); | ||
| } | ||
|
|
||
| // https://github.com/llvm/llvm-project/pull/77768#issuecomment-1957171805 | ||
| namespace Issue2 { | ||
| struct A { | ||
| constexpr A(int x_) {} | ||
| constexpr A(const std::vector<A>& a) {} | ||
| }; | ||
|
|
||
| void f() { | ||
| constexpr std::vector<A> a{1,2}; | ||
| constexpr std::vector<A> b{a}; | ||
| // -> constexpr std::vector<A> b(std::initializer_list<A>{ A(a) }); | ||
| static_assert(b.size() == 1); | ||
| } | ||
| } |