1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3 
4 void test_eh_return_data_regno()
5 {
6   volatile int res;
7   res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 3
8   res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 4
9 }
10 
11 // CHECK-LABEL: define{{.*}} i64 @test_builtin_ppc_get_timebase
12 long long test_builtin_ppc_get_timebase() {
13   // CHECK: call i64 @llvm.readcyclecounter()
14   return __builtin_ppc_get_timebase();
15 }
16 
17 void test_builtin_ppc_setrnd() {
18   volatile double res;
19   volatile int x = 100;
20 
21   // CHECK: call double @llvm.ppc.setrnd(i32 2)
22   res = __builtin_setrnd(2);
23 
24   // CHECK: call double @llvm.ppc.setrnd(i32 100)
25   res = __builtin_setrnd(100);
26 
27   // CHECK: call double @llvm.ppc.setrnd(i32 %2)
28   res = __builtin_setrnd(x);
29 }
30 
31 void test_builtin_ppc_flm() {
32   volatile double res;
33   // CHECK: call double @llvm.ppc.readflm()
34   res = __builtin_readflm();
35 
36   // CHECK: call double @llvm.ppc.setflm(double %1)
37   res = __builtin_setflm(res);
38 }
39 
40 double test_builtin_unpack_ldbl(long double x) {
41   // CHECK: call double @llvm.ppc.unpack.longdouble(ppc_fp128 %0, i32 1)
42   return __builtin_unpack_longdouble(x, 1);
43 }
44 
45 long double test_builtin_pack_ldbl(double x, double y) {
46   // CHECK: call ppc_fp128 @llvm.ppc.pack.longdouble(double %0, double %1)
47   return __builtin_pack_longdouble(x, y);
48 }
49