xref: /llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-move-tofrom-regs.c (revision f563bd74cb9a4f0d2d3eb49d35536b648361ec53)
1 // RUN: %clang_cc1 -O2 -triple powerpc64-unknown-linux-gnu \
2 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
3 // RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-linux-gnu \
4 // RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
5 // RUN: %clang_cc1 -O2 -triple powerpc-unknown-aix \
6 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | \
7 // RUN:   FileCheck %s --check-prefix=CHECK-32BIT
8 // RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \
9 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
10 
11 extern unsigned long ula;
12 
test_mftbu(void)13 unsigned int test_mftbu(void) {
14   // CHECK-LABEL: @test_mftbu
15   // CHECK: %0 = tail call i32 @llvm.ppc.mftbu()
16   return __mftbu();
17 }
18 
test_mfmsr(void)19 unsigned long test_mfmsr(void) {
20   // CHECK-LABEL: @test_mfmsr
21   // CHECK: %0 = tail call i32 @llvm.ppc.mfmsr()
22   return __mfmsr();
23 }
24 
test_mtmsr(void)25 void test_mtmsr(void) {
26   // CHECK-LABEL: @test_mtmsr
27   // CHECK: tail call void @llvm.ppc.mtmsr(i32 %conv)
28   // CHECK-32BIT-LABEL: @test_mtmsr
29   // CHECK-32BIT: tail call void @llvm.ppc.mtmsr(i32 %0)
30   __mtmsr(ula);
31 }
32 
test_mfspr(void)33 unsigned long test_mfspr(void) {
34   // CHECK-LABEL: @test_mfspr
35   // CHECK: %0 = tail call i64 @llvm.ppc.mfspr.i64(i32 898)
36   return __mfspr(898);
37 }
38 
test_mtspr(void)39 void test_mtspr(void) {
40   // CHECK-LABEL: @test_mtspr
41   // CHECK: tail call void @llvm.ppc.mtspr.i64(i32 1, i64 %0)
42   __mtspr(1, ula);
43 }
44