• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \
2 // RUN:   -target-cpu pwr9 -target-feature +float128 -mabi=ieeelongdouble \
3 // RUN:   -o - %s | FileCheck %s -check-prefix=IEEE
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \
5 // RUN:   -target-cpu pwr9 -target-feature +float128 \
6 // RUN:   -o - %s | FileCheck %s -check-prefix=IBM
7 
8 // RUN: %clang_cc1 -triple ppc64le -emit-llvm-bc %s -target-cpu pwr9 \
9 // RUN:   -target-feature +float128 -mabi=ieeelongdouble -fopenmp \
10 // RUN:   -fopenmp-targets=ppc64le -o %t-ppc-host.bc
11 // RUN: %clang_cc1 -triple ppc64le -aux-triple ppc64le %s -target-cpu pwr9 \
12 // RUN:   -target-feature +float128 -fopenmp -fopenmp-is-device -emit-llvm \
13 // RUN:   -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s \
14 // RUN:   -check-prefix=OMP-TARGET
15 // RUN: %clang_cc1 %t-ppc-host.bc -emit-llvm -o - | FileCheck %s \
16 // RUN:   -check-prefix=OMP-HOST
17 
18 #include <stdarg.h>
19 
20 void foo_ld(long double);
21 void foo_fq(__float128);
22 
23 // Verify cases when OpenMP target's and host's long-double semantics differ.
24 
25 // OMP-TARGET-LABEL: define internal void @.omp_outlined.(
26 // OMP-TARGET: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8**
27 // OMP-TARGET: %[[V2:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
28 // OMP-TARGET: %[[V3:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V2]], align 8
29 // OMP-TARGET: call void @foo_ld(ppc_fp128 %[[V3]])
30 
31 // OMP-HOST-LABEL: define void @omp(
32 // OMP-HOST: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
33 // OMP-HOST: call void @llvm.va_start(i8* %[[AP1]])
34 // OMP-HOST: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]], align 8
35 // OMP-HOST: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
36 // OMP-HOST: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
37 // OMP-HOST: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
38 // OMP-HOST: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
39 // OMP-HOST: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
40 // OMP-HOST: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
41 // OMP-HOST: call void @foo_ld(fp128 %[[V4]])
omp(int n,...)42 void omp(int n, ...) {
43   va_list ap;
44   va_start(ap, n);
45   foo_ld(va_arg(ap, long double));
46   #pragma omp target parallel
47   for (int i = 1; i < n; ++i) {
48     foo_ld(va_arg(ap, long double));
49   }
50   va_end(ap);
51 }
52 
53 // IEEE-LABEL: define void @f128
54 // IEEE: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
55 // IEEE: call void @llvm.va_start(i8* %[[AP1]])
56 // IEEE: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]]
57 // IEEE: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
58 // IEEE: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
59 // IEEE: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
60 // IEEE: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
61 // IEEE: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
62 // IEEE: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
63 // IEEE: call void @foo_fq(fp128 %[[V4]])
64 // IEEE: %[[AP2:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP]] to i8*
65 // IEEE: call void @llvm.va_end(i8* %[[AP2]])
f128(int n,...)66 void f128(int n, ...) {
67   va_list ap;
68   va_start(ap, n);
69   foo_fq(va_arg(ap, __float128));
70   va_end(ap);
71 }
72 
73 // IEEE-LABEL: define void @long_double
74 // IEEE: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
75 // IEEE: call void @llvm.va_start(i8* %[[AP1]])
76 // IEEE: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]]
77 // IEEE: %[[V0:[0-9a-zA-Z_.]+]] = ptrtoint i8* %[[CUR]] to i64
78 // IEEE: %[[V1:[0-9a-zA-Z_.]+]] = add i64 %[[V0]], 15
79 // IEEE: %[[V2:[0-9a-zA-Z_.]+]] = and i64 %[[V1]], -16
80 // IEEE: %[[ALIGN:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[V2]] to i8*
81 // IEEE: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[ALIGN]] to fp128*
82 // IEEE: %[[V4:[0-9a-zA-Z_.]+]] = load fp128, fp128* %[[V3]], align 16
83 // IEEE: call void @foo_ld(fp128 %[[V4]])
84 // IEEE: %[[AP2:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP]] to i8*
85 // IEEE: call void @llvm.va_end(i8* %[[AP2]])
86 
87 // IBM-LABEL: define void @long_double
88 // IBM: %[[AP1:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP:[0-9a-zA-Z_.]+]] to i8*
89 // IBM: call void @llvm.va_start(i8* %[[AP1]])
90 // IBM: %[[CUR:[0-9a-zA-Z_.]+]] = load i8*, i8** %[[AP]]
91 // IBM: %[[V3:[0-9a-zA-Z_.]+]] = bitcast i8* %[[CUR]] to ppc_fp128*
92 // IBM: %[[V4:[0-9a-zA-Z_.]+]] = load ppc_fp128, ppc_fp128* %[[V3]], align 8
93 // IBM: call void @foo_ld(ppc_fp128 %[[V4]])
94 // IBM: %[[AP2:[0-9a-zA-Z_.]+]] = bitcast i8** %[[AP]] to i8*
95 // IBM: call void @llvm.va_end(i8* %[[AP2]])
long_double(int n,...)96 void long_double(int n, ...) {
97   va_list ap;
98   va_start(ap, n);
99   foo_ld(va_arg(ap, long double));
100   va_end(ap);
101 }
102