[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-xlcompat-macros.c
blob2ef4c28a5e999a4e12332a86280fdf8a8126efa7
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu \
3 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s --check-prefixes=64BIT --check-prefix=BOTH
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu \
5 // RUN: -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s --check-prefixes=64BIT --check-prefix=BOTH
6 // RUN: %clang_cc1 -triple powerpc-unknown-aix \
7 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s --check-prefixes=32BIT --check-prefix=BOTH
8 // RUN: %clang_cc1 -triple powerpc64-unknown-aix \
9 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s --check-prefixes=64BIT --check-prefix=BOTH
11 // Will not be adding include files to avoid any dependencies on the system.
12 // Required for size_t. Usually found in stddef.h.
13 typedef __SIZE_TYPE__ size_t;
15 // BOTH-LABEL: @testabs(
16 // BOTH-NEXT: entry:
17 // BOTH-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
18 // BOTH-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
19 // BOTH-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
20 // BOTH-NEXT: [[ABS:%.*]] = call i32 @llvm.abs.i32(i32 %0, i1 true)
21 // BOTH-NEXT: ret i32 [[ABS]]
22 signed int testabs(signed int a) {
23 return __abs(a);
26 // 64BIT-LABEL: @testlabs(
27 // 64BIT-NEXT: entry:
28 // 64BIT-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
29 // 64BIT-NEXT: store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
30 // 64BIT-NEXT: [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
31 // 64BIT-NEXT: [[ABS:%.*]] = call i64 @llvm.abs.i64(i64 [[TMP0]], i1 true)
32 // 64BIT-NEXT: ret i64 [[ABS]]
34 // 32BIT-LABEL: @testlabs(
35 // 32BIT-NEXT: entry:
36 // 32BIT-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
37 // 32BIT-NEXT: store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
38 // 32BIT-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
39 // 32BIT-NEXT: [[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[TMP0]], i1 true)
40 // 32BIT-NEXT: ret i32 [[ABS]]
42 signed long testlabs(signed long a) {
43 return __labs(a);
46 // 64BIT-LABEL: @testllabs(
47 // 64BIT-NEXT: entry:
48 // 64BIT-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
49 // 64BIT-NEXT: store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
50 // 64BIT-NEXT: [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
51 // 64BIT-NEXT: [[ABS:%.*]] = call i64 @llvm.abs.i64(i64 [[TMP0]], i1 true)
52 // 64BIT-NEXT: ret i64 [[ABS]]
54 // 32BIT-LABEL: @testllabs(
55 // 32BIT-NEXT: entry:
56 // 32BIT-NEXT: [[A_ADDR:%.*]] = alloca i64, align 8
57 // 32BIT-NEXT: store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
58 // 32BIT-NEXT: [[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
59 // 32BIT-NEXT: [[ABS:%.*]] = call i64 @llvm.abs.i64(i64 [[TMP0]], i1 true)
60 // 32BIT-NEXT: ret i64 [[ABS]]
62 signed long long testllabs(signed long long a) {
63 return __llabs(a);
66 // 64BIT-LABEL: @testalloca(
67 // 64BIT: [[TMP1:%.*]] = alloca i8, i64
68 // 64BIT-NEXT: ret ptr [[TMP1]]
70 // 32BIT-LABEL: @testalloca(
71 // 32BIT: [[TMP1:%.*]] = alloca i8, i32
72 // 32BIT-NEXT: ret ptr [[TMP1]]
74 void *testalloca(size_t size) {
75 return __alloca(size);
78 // Note that bpermd is 64 bit only.
79 #ifdef __PPC64__
80 // 64BIT-LABEL: @testbpermd(
81 // 64BIT: [[TMP:%.*]] = call i64 @llvm.ppc.bpermd(i64 {{%.*}}, i64 {{%.*}})
82 // 64BIT-NEXT: ret i64 [[TMP]]
84 long long testbpermd(long long bit_selector, long long source) {
85 return __bpermd(bit_selector, source);
87 #endif
89 #ifdef __PPC64__
90 // 64BIT-LABEL: @testdivde(
91 // 64BIT: [[TMP2:%.*]] = call i64 @llvm.ppc.divde
92 // 64BIT-NEXT: ret i64 [[TMP2]]
93 long long testdivde(long long dividend, long long divisor) {
94 return __divde(dividend, divisor);
97 // 64BIT-LABEL: @testdivdeu(
98 // 64BIT: [[TMP2:%.*]] = call i64 @llvm.ppc.divdeu
99 // 64BIT-NEXT: ret i64 [[TMP2]]
100 unsigned long long testdivdeu(unsigned long long dividend, unsigned long long divisor) {
101 return __divdeu(dividend, divisor);
103 #endif
105 // 64BIT-LABEL: @testdivwe(
106 // 64BIT: [[TMP2:%.*]] = call i32 @llvm.ppc.divwe
107 // 64BIT-NEXT: ret i32 [[TMP2]]
109 // 32BIT-LABEL: @testdivwe(
110 // 32BIT: [[TMP2:%.*]] = call i32 @llvm.ppc.divwe
111 // 32BIT-NEXT: ret i32 [[TMP2]]
112 int testdivwe(int dividend, int divisor) {
113 return __divwe(dividend, divisor);
116 // 64BIT-LABEL: @testdivweu(
117 // 64BIT: [[TMP2:%.*]] = call i32 @llvm.ppc.divweu
118 // 64BIT-NEXT: ret i32 [[TMP2]]
120 // 32BIT-LABEL: @testdivweu(
121 // 32BIT: [[TMP2:%.*]] = call i32 @llvm.ppc.divweu
122 // 32BIT-NEXT: ret i32 [[TMP2]]
123 unsigned int testdivweu(unsigned int dividend, unsigned int divisor) {
124 return __divweu(dividend, divisor);
127 // BOTH-LABEL: @testfmadd(
128 // BOTH: [[TMP3:%.*]] = call double @llvm.fma.f64
129 // BOTH-NEXT: ret double [[TMP3]]
131 double testfmadd(double a, double b, double c) {
132 return __fmadd(a, b, c);
135 // BOTH-LABEL: @testfmadds(
136 // BOTH: [[TMP3:%.*]] = call float @llvm.fma.f32(
137 // BOTH-NEXT: ret float [[TMP3]]
139 float testfmadds(float a, float b, float c) {
140 return __fmadds(a, b, c);
143 // Required for bzero and bcopy. Usually in strings.h.
144 extern void bcopy(const void *__src, void *__dest, size_t __n);
145 extern void bzero(void *__s, size_t __n);
147 // 64BIT-LABEL: @testalignx(
148 // 64BIT: call void @llvm.assume(i1 true) [ "align"(ptr {{%.*}}, i64 16) ]
149 // 64BIT-NEXT: ret void
151 // 32BIT-LABEL: @testalignx(
152 // 32BIT: call void @llvm.assume(i1 true) [ "align"(ptr {{%.*}}, i32 16) ]
153 // 32BIT-NEXT: ret void
155 void testalignx(const void *pointer) {
156 __alignx(16, pointer);
159 // 64BIT-LABEL: @testbcopy(
160 // 64BIT: call void @llvm.memmove.p0.p0.i64(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i64 {{%.*}}, i1 false)
161 // 64BIT-NEXT: ret void
163 // 32BIT-LABEL: @testbcopy(
164 // 32BIT: call void @llvm.memmove.p0.p0.i32(ptr align 1 {{%.*}}, ptr align 1 {{%.*}}, i32 {{%.*}}, i1 false)
165 // 32BIT-NEXT: ret void
167 void testbcopy(const void *src, void *dest, size_t n) {
168 bcopy(src, dest, n);
171 // 64BIT-LABEL: @testbzero(
172 // 64BIT: call void @llvm.memset.p0.i64(ptr align 1 {{%.*}}, i8 0, i64 {{%.*}}, i1 false)
173 // 64BIT-NEXT: ret void
175 // 32BIT-LABEL: @testbzero(
176 // 32BIT: call void @llvm.memset.p0.i32(ptr align 1 {{%.*}}, i8 0, i32 {{%.*}}, i1 false)
177 // 32BIT-NEXT: ret void
179 void testbzero(void *s, size_t n) {
180 bzero(s, n);
183 // 64BIT-LABEL: @testdcbf(
184 // 64BIT: call void @llvm.ppc.dcbf(ptr {{%.*}})
185 // 64BIT-NEXT: ret void
187 // 32BIT-LABEL: @testdcbf(
188 // 32BIT: call void @llvm.ppc.dcbf(ptr {{%.*}})
189 // 32BIT-NEXT: ret void
191 void testdcbf(const void *addr) {
192 __dcbf(addr);
195 // BOTH-LABEL: @testreadflm(
196 // BOTH: [[TMP0:%.*]] = call double @llvm.ppc.readflm()
197 // BOTH-NEXT: ret double [[TMP0]]
199 double testreadflm(void) {
200 return __readflm();
203 // BOTH-LABEL: @testsetflm(
204 // BOTH: [[TMP1:%.*]] = call double @llvm.ppc.setflm(double {{%.*}})
205 // BOTH-NEXT: ret double [[TMP1]]
207 double testsetflm(double a) {
208 return __setflm(a);
211 // BOTH-LABEL: @testsetrnd(
212 // BOTH: [[TMP1:%.*]] = call double @llvm.ppc.setrnd(i32 {{%.*}})
213 // BOTH-NEXT: ret double [[TMP1]]
215 double testsetrnd(int mode) {
216 return __setrnd(mode);