[PATCH] D69297: [ARM][AArch64] Implement __arm_rsrf, __arm_rsrf64, __arm_wsrf & __arm_wsrf64
Victor Campos via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 22 03:44:11 PDT 2019
vhscampos created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.
Adding support for ACLE intrinsics.
Patch by Michael Platings.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69297
Files:
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c
Index: clang/test/CodeGen/arm_acle.c
===================================================================
--- clang/test/CodeGen/arm_acle.c
+++ 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"}
Index: clang/lib/Headers/arm_acle.h
===================================================================
--- clang/lib/Headers/arm_acle.h
+++ clang/lib/Headers/arm_acle.h
@@ -613,6 +613,35 @@
#define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v)
#define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v)
+static __inline__ float __attribute__((__always_inline__, __nodebug__))
+__bit_cast_to_float_from_uint32(uint32_t __from) {
+ float __to;
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+ return __to;
+}
+static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__))
+__bit_cast_to_uint32_from_float(float __from) {
+ uint32_t __to;
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+ return __to;
+}
+static __inline__ double __attribute__((__always_inline__, __nodebug__))
+__bit_cast_to_double_from_uint64(uint64_t __from) {
+ double __to;
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+ return __to;
+}
+static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__))
+__bit_cast_to_uint64_from_double(double __from) {
+ uint64_t __to;
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+ return __to;
+}
+#define __arm_rsrf(sysreg) __bit_cast_to_float_from_uint32(__arm_rsr(sysreg))
+#define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __bit_cast_to_uint32_from_float(v))
+#define __arm_rsrf64(sysreg) __bit_cast_to_double_from_uint64(__arm_rsr64(sysreg))
+#define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, __bit_cast_to_uint64_from_double(v))
+
/* Memory Tagging Extensions (MTE) Intrinsics */
#if __ARM_FEATURE_MEMORY_TAGGING
#define __arm_mte_create_random_tag(__ptr, __mask) __builtin_arm_irg(__ptr, __mask)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69297.226014.patch
Type: text/x-patch
Size: 3452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191022/287b7127/attachment.bin>
More information about the cfe-commits
mailing list