xref: /llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-pwr8.c (revision fa1f88cdeca245497843c507167b84f5522e88cc)
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm %s \
3 // RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm %s \
5 // RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
6 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
7 // RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
8 // RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
9 // RUN:   -target-cpu pwr8 -o - | FileCheck %s -check-prefix=CHECK-PWR8
10 // RUN: not %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm %s \
11 // RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
12 // RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
13 // RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
14 // RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
15 // RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
16 
17 extern void *a;
18 extern volatile char *c_addr;
19 extern char *ptr;
20 extern char c;
21 extern int i;
22 extern vector unsigned char vuc;
23 
test_xlcompat()24 void test_xlcompat() {
25   // CHECK-PWR8-LABEL: @test_xlcompat(
26   // CHECK-PWR8: call void @llvm.ppc.icbt(ptr %{{[0-9]+}})
27   // CHECK-NOPWR8: error: '__builtin_ppc_icbt' needs target feature isa-v207-instructions
28   __icbt(a);
29 
30   // CHECK-PWR8: call void @llvm.ppc.icbt(ptr %{{[0-9]+}})
31   // CHECK-NOPWR8: error: '__builtin_ppc_icbt' needs target feature isa-v207-instructions
32   __builtin_ppc_icbt(a);
33 
34   // CHECK-PWR8:         [[TMP0:%.*]] = load ptr, ptr @c_addr, align {{[0-9]+}}
35   // CHECK-PWR8-NEXT:    [[TMP1:%.*]] = load i8, ptr @c, align 1
36   // CHECK-PWR8-NEXT:    [[TMP2:%.*]] = sext i8 [[TMP1]] to i32
37   // CHECK-PWR8-NEXT:    [[TMP3:%.*]] = call i32 @llvm.ppc.stbcx(ptr [[TMP0]], i32 [[TMP2]])
38   // CHECK-NOPWR8: error: '__builtin_ppc_stbcx' needs target feature isa-v207-instructions
39   i = __builtin_ppc_stbcx(c_addr, c);
40 
41   // CHECK-NOPWR8: error: '__builtin_vsx_ldrmb' needs target feature isa-v207-instructions
42   vuc = __builtin_vsx_ldrmb(ptr, 14);
43 
44   // CHECK-NOPWR8: error: '__builtin_vsx_strmb' needs target feature isa-v207-instructions
45   __builtin_vsx_strmb(ptr, 14, vuc);
46 }
47