diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h --- a/clang/lib/Headers/arm_acle.h +++ b/clang/lib/Headers/arm_acle.h @@ -609,9 +609,13 @@ #define __arm_rsr(sysreg) __builtin_arm_rsr(sysreg) #define __arm_rsr64(sysreg) __builtin_arm_rsr64(sysreg) #define __arm_rsrp(sysreg) __builtin_arm_rsrp(sysreg) +#define __arm_rsrf(sysreg) __builtin_bit_cast(float, __arm_rsr(sysreg)) +#define __arm_rsrf64(sysreg) __builtin_bit_cast(double, __arm_rsr64(sysreg)) #define __arm_wsr(sysreg, v) __builtin_arm_wsr(sysreg, v) #define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v) #define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v) +#define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __builtin_bit_cast(uint32_t, v)) +#define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, __builtin_bit_cast(uint64_t, v)) /* Memory Tagging Extensions (MTE) Intrinsics */ #if __ARM_FEATURE_MEMORY_TAGGING diff --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c --- a/clang/test/CodeGen/arm_acle.c +++ b/clang/test/CodeGen/arm_acle.c @@ -822,6 +822,55 @@ __arm_wsrp("sysreg", v); } +// ARM-LABEL: test_rsrf +// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]]) +// AArch32: call i32 @llvm.read_register.i32(metadata ![[M2:[0-9]]]) +// ARM-NOT: uitofp +// ARM: bitcast +float test_rsrf() { +#ifdef __ARM_32BIT_STATE + return __arm_rsrf("cp1:2:c3:c4:5"); +#else + return __arm_rsrf("1:2:3:4:5"); +#endif +} +// ARM-LABEL: test_rsrf64 +// AArch64: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]]) +// AArch32: call i64 @llvm.read_register.i64(metadata ![[M3:[0-9]]]) +// ARM-NOT: uitofp +// ARM: bitcast +double test_rsrf64() { +#ifdef __ARM_32BIT_STATE + return __arm_rsrf64("cp1:2:c3"); +#else + return __arm_rsrf64("1:2:3:4:5"); +#endif +} +// ARM-LABEL: test_wsrf +// ARM-NOT: fptoui +// ARM: bitcast +// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %{{.*}}) +// AArch32: call void @llvm.write_register.i32(metadata ![[M2:[0-9]]], i32 %{{.*}}) +void test_wsrf(float v) { +#ifdef __ARM_32BIT_STATE + __arm_wsrf("cp1:2:c3:c4:5", v); +#else + __arm_wsrf("1:2:3:4:5", v); +#endif +} +// ARM-LABEL: test_wsrf64 +// ARM-NOT: fptoui +// ARM: bitcast +// AArch64: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %{{.*}}) +// AArch32: call void @llvm.write_register.i64(metadata ![[M3:[0-9]]], i64 %{{.*}}) +void test_wsrf64(double v) { +#ifdef __ARM_32BIT_STATE + __arm_wsrf64("cp1:2:c3", v); +#else + __arm_wsrf64("1:2:3:4:5", v); +#endif +} + // AArch32: ![[M2]] = !{!"cp1:2:c3:c4:5"} // AArch32: ![[M3]] = !{!"cp1:2:c3"} // AArch32: ![[M4]] = !{!"sysreg"}