2017-05-29 13:38:20 +08:00
|
|
|
// RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
|
2010-03-04 03:03:45 +08:00
|
|
|
|
2016-06-17 08:59:41 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2010-03-04 03:03:45 +08:00
|
|
|
void *f0()
|
|
|
|
{
|
|
|
|
return __builtin_thread_pointer();
|
|
|
|
}
|
2010-06-08 11:59:28 +08:00
|
|
|
|
|
|
|
void f1(char *a, char *b) {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @__clear_cache
|
2010-06-08 11:59:28 +08:00
|
|
|
__clear_cache(a,b);
|
|
|
|
}
|
|
|
|
|
2018-02-17 00:01:08 +08:00
|
|
|
float test_vcvtrf0(float f) {
|
|
|
|
// CHECK: call float @llvm.arm.vcvtr.f32(float %f)
|
|
|
|
return __builtin_arm_vcvtr_f(f, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
float test_vcvtrf1(float f) {
|
|
|
|
// CHECK: call float @llvm.arm.vcvtru.f32(float %f)
|
|
|
|
return __builtin_arm_vcvtr_f(f, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
double test_vcvtrd0(double d) {
|
|
|
|
// CHECK: call float @llvm.arm.vcvtr.f64(double %d)
|
|
|
|
return __builtin_arm_vcvtr_d(d, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
double test_vcvtrd1(double d) {
|
|
|
|
// call float @llvm.arm.vcvtru.f64(double %d)
|
|
|
|
return __builtin_arm_vcvtr_d(d, 1);
|
|
|
|
}
|
2013-02-23 12:24:36 +08:00
|
|
|
|
|
|
|
void test_eh_return_data_regno()
|
|
|
|
{
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: store volatile i32 0
|
|
|
|
// CHECK: store volatile i32 1
|
2013-02-23 12:24:36 +08:00
|
|
|
volatile int res;
|
2018-02-17 00:01:08 +08:00
|
|
|
res = __builtin_eh_return_data_regno(0);
|
|
|
|
res = __builtin_eh_return_data_regno(1);
|
2013-02-23 12:24:36 +08:00
|
|
|
}
|
2013-10-02 18:00:18 +08:00
|
|
|
|
2014-07-14 23:20:09 +08:00
|
|
|
void nop() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 0)
|
2014-07-14 23:20:09 +08:00
|
|
|
__builtin_arm_nop();
|
|
|
|
}
|
|
|
|
|
2014-05-04 10:52:25 +08:00
|
|
|
void yield() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 1)
|
2014-07-03 10:43:20 +08:00
|
|
|
__builtin_arm_yield();
|
2014-05-04 10:52:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void wfe() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 2)
|
2014-07-03 10:43:20 +08:00
|
|
|
__builtin_arm_wfe();
|
2014-05-04 10:52:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void wfi() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 3)
|
2014-07-03 10:43:20 +08:00
|
|
|
__builtin_arm_wfi();
|
2014-05-04 10:52:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void sev() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 4)
|
2014-07-03 10:43:20 +08:00
|
|
|
__builtin_arm_sev();
|
2014-05-04 10:52:25 +08:00
|
|
|
}
|
|
|
|
|
2013-10-02 18:00:18 +08:00
|
|
|
void sevl() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.hint(i32 5)
|
2014-07-03 10:43:20 +08:00
|
|
|
__builtin_arm_sevl();
|
2013-10-02 18:00:18 +08:00
|
|
|
}
|
2014-07-03 01:41:27 +08:00
|
|
|
|
2014-08-26 20:48:06 +08:00
|
|
|
void dbg() {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.arm.dbg(i32 0)
|
2014-08-26 20:48:06 +08:00
|
|
|
__builtin_arm_dbg(0);
|
|
|
|
}
|
|
|
|
|
2013-11-13 05:42:50 +08:00
|
|
|
void test_barrier() {
|
2018-02-17 00:01:08 +08:00
|
|
|
//CHECK: call {{.*}} @llvm.arm.dmb(i32 1)
|
|
|
|
//CHECK: call {{.*}} @llvm.arm.dsb(i32 2)
|
|
|
|
//CHECK: call {{.*}} @llvm.arm.isb(i32 3)
|
|
|
|
__builtin_arm_dmb(1);
|
|
|
|
__builtin_arm_dsb(2);
|
|
|
|
__builtin_arm_isb(3);
|
2013-11-13 05:42:50 +08:00
|
|
|
}
|
2014-06-17 05:55:58 +08:00
|
|
|
|
|
|
|
unsigned rbit(unsigned a) {
|
2018-02-17 00:01:08 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.bitreverse.i32(i32 %a)
|
2014-06-17 05:55:58 +08:00
|
|
|
return __builtin_arm_rbit(a);
|
|
|
|
}
|
2014-08-14 03:18:14 +08:00
|
|
|
|
|
|
|
void prefetch(int i) {
|
|
|
|
__builtin_arm_prefetch(&i, 0, 1);
|
Allow prefetching from non-zero address spaces
Summary:
This is useful for targets which have prefetch instructions for non-default address spaces.
<rdar://problem/42662136>
Subscribers: nemanjai, javed.absar, hiraditya, kbarton, jkorous, dexonsmith, cfe-commits, llvm-commits, RKSimon, hfinkel, t.p.northover, craig.topper, anemet
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65254
llvm-svn: 367032
2019-07-26 00:11:57 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.prefetch.p0i8(i8* %{{.*}}, i32 0, i32 3, i32 1)
|
2014-08-14 03:18:14 +08:00
|
|
|
|
|
|
|
__builtin_arm_prefetch(&i, 1, 1);
|
Allow prefetching from non-zero address spaces
Summary:
This is useful for targets which have prefetch instructions for non-default address spaces.
<rdar://problem/42662136>
Subscribers: nemanjai, javed.absar, hiraditya, kbarton, jkorous, dexonsmith, cfe-commits, llvm-commits, RKSimon, hfinkel, t.p.northover, craig.topper, anemet
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65254
llvm-svn: 367032
2019-07-26 00:11:57 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.prefetch.p0i8(i8* %{{.*}}, i32 1, i32 3, i32 1)
|
2014-08-14 03:18:14 +08:00
|
|
|
|
|
|
|
__builtin_arm_prefetch(&i, 1, 0);
|
Allow prefetching from non-zero address spaces
Summary:
This is useful for targets which have prefetch instructions for non-default address spaces.
<rdar://problem/42662136>
Subscribers: nemanjai, javed.absar, hiraditya, kbarton, jkorous, dexonsmith, cfe-commits, llvm-commits, RKSimon, hfinkel, t.p.northover, craig.topper, anemet
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65254
llvm-svn: 367032
2019-07-26 00:11:57 +08:00
|
|
|
// CHECK: call {{.*}} @llvm.prefetch.p0i8(i8* %{{.*}}, i32 1, i32 3, i32 0)
|
2014-08-14 03:18:14 +08:00
|
|
|
}
|
2015-06-16 01:51:01 +08:00
|
|
|
|
2016-05-31 21:31:25 +08:00
|
|
|
void ldc(const void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @ldc(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.ldc(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_ldc(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ldcl(const void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @ldcl(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.ldcl(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_ldcl(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ldc2(const void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @ldc2(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.ldc2(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_ldc2(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ldc2l(const void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @ldc2l(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.ldc2l(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_ldc2l(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stc(void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @stc(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.stc(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_stc(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stcl(void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @stcl(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.stcl(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_stcl(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stc2(void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @stc2(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.stc2(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_stc2(1, 2, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stc2l(void *i) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @stc2l(i8* %i)
|
2016-05-31 21:31:25 +08:00
|
|
|
// CHECK: call void @llvm.arm.stc2l(i32 1, i32 2, i8* %i)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_stc2l(1, 2, i);
|
|
|
|
}
|
|
|
|
|
2016-05-19 21:04:34 +08:00
|
|
|
void cdp() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @cdp()
|
2016-05-19 21:04:34 +08:00
|
|
|
// CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_cdp(1, 2, 3, 4, 5, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cdp2() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @cdp2()
|
2016-05-19 21:04:34 +08:00
|
|
|
// CHECK: call void @llvm.arm.cdp2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
__builtin_arm_cdp2(1, 2, 3, 4, 5, 6);
|
|
|
|
}
|
|
|
|
|
2015-08-27 06:21:07 +08:00
|
|
|
unsigned mrc() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define i32 @mrc()
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc(i32 15, i32 0, i32 13, i32 0, i32 3)
|
2015-08-27 06:21:07 +08:00
|
|
|
// CHECK-NEXT: ret i32 [[R]]
|
|
|
|
return __builtin_arm_mrc(15, 0, 13, 0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned mrc2() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define i32 @mrc2()
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: [[R:%.*]] = call i32 @llvm.arm.mrc2(i32 15, i32 0, i32 13, i32 0, i32 3)
|
2015-08-27 06:21:07 +08:00
|
|
|
// CHECK-NEXT: ret i32 [[R]]
|
|
|
|
return __builtin_arm_mrc2(15, 0, 13, 0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mcr(unsigned a) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @mcr(i32 [[A:%.*]])
|
2015-08-27 06:21:07 +08:00
|
|
|
// CHECK: call void @llvm.arm.mcr(i32 15, i32 0, i32 [[A]], i32 13, i32 0, i32 3)
|
|
|
|
__builtin_arm_mcr(15, 0, a, 13, 0, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mcr2(unsigned a) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @mcr2(i32 [[A:%.*]])
|
2015-08-27 06:21:07 +08:00
|
|
|
// CHECK: call void @llvm.arm.mcr2(i32 15, i32 0, i32 [[A]], i32 13, i32 0, i32 3)
|
|
|
|
__builtin_arm_mcr2(15, 0, a, 13, 0, 3);
|
|
|
|
}
|
|
|
|
|
2016-06-17 08:59:41 +08:00
|
|
|
void mcrr(uint64_t a) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @mcrr(i64 %{{.*}})
|
2016-06-17 08:59:41 +08:00
|
|
|
// CHECK: call void @llvm.arm.mcrr(i32 15, i32 0, i32 %{{[0-9]+}}, i32 %{{[0-9]+}}, i32 0)
|
|
|
|
__builtin_arm_mcrr(15, 0, a, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mcrr2(uint64_t a) {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define void @mcrr2(i64 %{{.*}})
|
2016-06-17 08:59:41 +08:00
|
|
|
// CHECK: call void @llvm.arm.mcrr2(i32 15, i32 0, i32 %{{[0-9]+}}, i32 %{{[0-9]+}}, i32 0)
|
|
|
|
__builtin_arm_mcrr2(15, 0, a, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t mrrc() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define i64 @mrrc()
|
2016-06-17 08:59:41 +08:00
|
|
|
// CHECK: call { i32, i32 } @llvm.arm.mrrc(i32 15, i32 0, i32 0)
|
|
|
|
return __builtin_arm_mrrc(15, 0, 0);
|
2015-08-27 06:21:07 +08:00
|
|
|
}
|
|
|
|
|
2016-06-17 08:59:41 +08:00
|
|
|
uint64_t mrrc2() {
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK: define i64 @mrrc2()
|
2016-06-17 08:59:41 +08:00
|
|
|
// CHECK: call { i32, i32 } @llvm.arm.mrrc2(i32 15, i32 0, i32 0)
|
|
|
|
return __builtin_arm_mrrc2(15, 0, 0);
|
2015-08-27 06:21:07 +08:00
|
|
|
}
|
|
|
|
|
2015-06-16 01:51:01 +08:00
|
|
|
unsigned rsr() {
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: [[V0:[%A-Za-z0-9.]+]] = call i32 @llvm.read_register.i32(metadata ![[M0:.*]])
|
2015-06-16 01:51:01 +08:00
|
|
|
// CHECK-NEXT: ret i32 [[V0]]
|
|
|
|
return __builtin_arm_rsr("cp1:2:c3:c4:5");
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long long rsr64() {
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: [[V0:[%A-Za-z0-9.]+]] = call i64 @llvm.read_register.i64(metadata ![[M1:.*]])
|
2015-06-16 01:51:01 +08:00
|
|
|
// CHECK-NEXT: ret i64 [[V0]]
|
|
|
|
return __builtin_arm_rsr64("cp1:2:c3");
|
|
|
|
}
|
|
|
|
|
|
|
|
void *rsrp() {
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: [[V0:[%A-Za-z0-9.]+]] = call i32 @llvm.read_register.i32(metadata ![[M2:.*]])
|
2015-06-16 01:51:01 +08:00
|
|
|
// CHECK-NEXT: [[V1:[%A-Za-z0-9.]+]] = inttoptr i32 [[V0]] to i8*
|
|
|
|
// CHECK-NEXT: ret i8* [[V1]]
|
|
|
|
return __builtin_arm_rsrp("sysreg");
|
|
|
|
}
|
|
|
|
|
|
|
|
void wsr(unsigned v) {
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: call void @llvm.write_register.i32(metadata ![[M0]], i32 %v)
|
2015-06-16 01:51:01 +08:00
|
|
|
__builtin_arm_wsr("cp1:2:c3:c4:5", v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wsr64(unsigned long long v) {
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: call void @llvm.write_register.i64(metadata ![[M1]], i64 %v)
|
2015-06-16 01:51:01 +08:00
|
|
|
__builtin_arm_wsr64("cp1:2:c3", v);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wsrp(void *v) {
|
|
|
|
// CHECK: [[V0:[%A-Za-z0-9.]+]] = ptrtoint i8* %v to i32
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.write_register.i32(metadata ![[M2]], i32 [[V0]])
|
2015-06-16 01:51:01 +08:00
|
|
|
__builtin_arm_wsrp("sysreg", v);
|
|
|
|
}
|
|
|
|
|
2019-10-17 21:10:30 +08:00
|
|
|
unsigned int cls(uint32_t v) {
|
|
|
|
// CHECK: call i32 @llvm.arm.cls(i32 %v)
|
|
|
|
return __builtin_arm_cls(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int clsl(unsigned long v) {
|
|
|
|
// CHECK: call i32 @llvm.arm.cls(i32 %v)
|
|
|
|
return __builtin_arm_cls(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int clsll(uint64_t v) {
|
|
|
|
// CHECK: call i32 @llvm.arm.cls64(i64 %v)
|
|
|
|
return __builtin_arm_cls64(v);
|
|
|
|
}
|
|
|
|
|
2016-03-10 02:54:42 +08:00
|
|
|
// CHECK: ![[M0]] = !{!"cp1:2:c3:c4:5"}
|
|
|
|
// CHECK: ![[M1]] = !{!"cp1:2:c3"}
|
|
|
|
// CHECK: ![[M2]] = !{!"sysreg"}
|