[PATCH] D56685: [COFF, ARM64] Declare __byteswap intrinsics
Mandeep Singh Grang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 14 15:27:48 PST 2019
mgrang created this revision.
mgrang added reviewers: rnk, efriedma, ssijaric, TomTan, haripul.
Herald added subscribers: kristof.beyls, javed.absar.
Repository:
rC Clang
https://reviews.llvm.org/D56685
Files:
lib/Headers/arm64intr.h
test/Headers/ms-arm64-intrin.cpp
Index: test/Headers/ms-arm64-intrin.cpp
===================================================================
--- test/Headers/ms-arm64-intrin.cpp
+++ test/Headers/ms-arm64-intrin.cpp
@@ -3,6 +3,11 @@
// RUN: -ffreestanding -fsyntax-only -Werror \
// RUN: -isystem %S/Inputs/include %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-windows \
+// RUN: -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN: -ffreestanding -fsyntax-only -Werror \
+// RUN: -isystem %S/Inputs/include %s -S -o - -emit-llvm 2>&1 | FileCheck %s --check-prefix CHECK-IR
+
// REQUIRES: aarch64-registered-target
#include <intrin.h>
@@ -11,3 +16,66 @@
// CHECK: nop
__nop();
}
+
+unsigned short check_byteswap_ushort_1() {
+// CHECK-IR: ret i16 256
+ return _byteswap_ushort(1);
+}
+unsigned short check_byteswap_ushort_2() {
+// CHECK-IR: ret i16 512
+ return _byteswap_ushort(2);
+}
+unsigned short check_byteswap_ushort_3() {
+// CHECK-IR: ret i16 768
+ return _byteswap_ushort(3);
+}
+unsigned short check_byteswap_ushort_4() {
+// CHECK-IR: ret i16 1024
+ return _byteswap_ushort(4);
+}
+unsigned short check_byteswap_ushort_5() {
+// CHECK-IR: ret i16 1280
+ return _byteswap_ushort(5);
+}
+
+unsigned long check_byteswap_ulong_1() {
+// CHECK-IR: ret i32 16777216
+ return _byteswap_ulong(1);
+}
+unsigned long check_byteswap_ulong_2() {
+// CHECK-IR: ret i32 33554432
+ return _byteswap_ulong(2);
+}
+unsigned long check_byteswap_ulong_3() {
+// CHECK-IR: ret i32 50331648
+ return _byteswap_ulong(3);
+}
+unsigned long check_byteswap_ulong_4() {
+// CHECK-IR: ret i32 67108864
+ return _byteswap_ulong(4);
+}
+unsigned long check_byteswap_ulong_5() {
+// CHECK-IR: ret i32 83886080
+ return _byteswap_ulong(5);
+}
+
+unsigned __int64 check_byteswap_uint64_1() {
+// CHECK-IR: ret i64 72057594037927936
+ return _byteswap_uint64(1);
+}
+unsigned __int64 check_byteswap_uint64_2() {
+// CHECK-IR: ret i64 144115188075855872
+ return _byteswap_uint64(2);
+}
+unsigned __int64 check_byteswap_uint64_3() {
+// CHECK-IR: ret i64 216172782113783808
+ return _byteswap_uint64(3);
+}
+unsigned __int64 check_byteswap_uint64_4() {
+// CHECK-IR: ret i64 288230376151711744
+ return _byteswap_uint64(4);
+}
+unsigned __int64 check_byteswap_uint64_5() {
+// CHECK-IR: ret i64 360287970189639680
+ return _byteswap_uint64(5);
+}
Index: lib/Headers/arm64intr.h
===================================================================
--- lib/Headers/arm64intr.h
+++ lib/Headers/arm64intr.h
@@ -45,5 +45,9 @@
_ARM64_BARRIER_OSHLD = 0x1
} _ARM64INTR_BARRIER_TYPE;
+#define _byteswap_ushort __builtin_bswap16
+#define _byteswap_ulong __builtin_bswap32
+#define _byteswap_uint64 __builtin_bswap64
+
#endif /* __ARM64INTR_H */
#endif /* _MSC_VER */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56685.181657.patch
Type: text/x-patch
Size: 2767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190114/47c9611b/attachment.bin>
More information about the cfe-commits
mailing list