blob: 9f3ed9ac78a1459f02b292711b59af17a3880a31 [file] [log] [blame]
Jim Grosbachf7947052012-07-09 18:34:21 +00001// REQUIRES: arm-registered-target
Rafael Espindolaa71d3c62010-06-08 03:59:28 +00002// RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o - %s | FileCheck %s
Chris Lattner2752c012010-03-03 19:03:45 +00003
Chris Lattner2752c012010-03-03 19:03:45 +00004void *f0()
5{
6 return __builtin_thread_pointer();
7}
Rafael Espindolaa71d3c62010-06-08 03:59:28 +00008
9void f1(char *a, char *b) {
10 __clear_cache(a,b);
11}
12
Daniel Dunbar10582532010-07-16 00:31:23 +000013// CHECK: call {{.*}} @__clear_cache
Logan Chiena8f7a972013-02-23 04:24:36 +000014
15void test_eh_return_data_regno()
16{
17 volatile int res;
18 res = __builtin_eh_return_data_regno(0); // CHECK: store volatile i32 0
19 res = __builtin_eh_return_data_regno(1); // CHECK: store volatile i32 1
20}
Joey Gouly594e1932013-10-02 10:00:18 +000021
Stephen Hines176edba2014-12-01 14:53:08 -080022void nop() {
23 __builtin_arm_nop();
24}
25
26// CHECK: call {{.*}} @llvm.arm.hint(i32 0)
27
Stephen Hines6bcf27b2014-05-29 04:14:42 -070028void yield() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070029 __builtin_arm_yield();
Joey Gouly594e1932013-10-02 10:00:18 +000030}
Stephen Hines6bcf27b2014-05-29 04:14:42 -070031
32// CHECK: call {{.*}} @llvm.arm.hint(i32 1)
33
34void wfe() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070035 __builtin_arm_wfe();
Stephen Hines6bcf27b2014-05-29 04:14:42 -070036}
37
38// CHECK: call {{.*}} @llvm.arm.hint(i32 2)
39
40void wfi() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070041 __builtin_arm_wfi();
Stephen Hines6bcf27b2014-05-29 04:14:42 -070042}
43
44// CHECK: call {{.*}} @llvm.arm.hint(i32 3)
45
46void sev() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070047 __builtin_arm_sev();
Stephen Hines6bcf27b2014-05-29 04:14:42 -070048}
49
50// CHECK: call {{.*}} @llvm.arm.hint(i32 4)
51
52void sevl() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070053 __builtin_arm_sevl();
Stephen Hines6bcf27b2014-05-29 04:14:42 -070054}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070055
Stephen Hines6bcf27b2014-05-29 04:14:42 -070056// CHECK: call {{.*}} @llvm.arm.hint(i32 5)
Weiming Zhao186b26d2013-11-12 21:42:50 +000057
Stephen Hines176edba2014-12-01 14:53:08 -080058void dbg() {
59 __builtin_arm_dbg(0);
60}
61
62// CHECK: call {{.*}} @llvm.arm.dbg(i32 0)
63
Weiming Zhao186b26d2013-11-12 21:42:50 +000064void test_barrier() {
65 __builtin_arm_dmb(1); //CHECK: call {{.*}} @llvm.arm.dmb(i32 1)
66 __builtin_arm_dsb(2); //CHECK: call {{.*}} @llvm.arm.dsb(i32 2)
Stephen Hinesc568f1e2014-07-21 00:47:37 -070067 __builtin_arm_isb(3); //CHECK: call {{.*}} @llvm.arm.isb(i32 3)
68}
69
70// CHECK: call {{.*}} @llvm.arm.rbit(i32 %a)
71
72unsigned rbit(unsigned a) {
73 return __builtin_arm_rbit(a);
Weiming Zhao186b26d2013-11-12 21:42:50 +000074}
Stephen Hines176edba2014-12-01 14:53:08 -080075
76void prefetch(int i) {
77 __builtin_arm_prefetch(&i, 0, 1);
78// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 0, i32 3, i32 1)
79
80 __builtin_arm_prefetch(&i, 1, 1);
81// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 1)
82
83
84 __builtin_arm_prefetch(&i, 1, 0);
85// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
86}