mgrang updated this revision to Diff 181671. mgrang retitled this revision from "[COFF, ARM64] Declare __byteswap intrinsics" to "[COFF, ARM64] Add __byteswap intrinsics".
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56685/new/ https://reviews.llvm.org/D56685 Files: lib/Headers/intrin.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 @@ -1,9 +1,15 @@ +// REQUIRES: aarch64-registered-target + // 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 - 2>&1 | FileCheck %s -// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple arm64-windows -O1 \ +// 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 \ +// RUN: | FileCheck %s --check-prefix CHECK-IR #include <intrin.h> @@ -11,3 +17,18 @@ // CHECK: nop __nop(); } + +unsigned short check_byteswap_ushort(unsigned short val) { +// CHECK-IR: call i16 @llvm.bswap.i16(i16 %val) + return _byteswap_ushort(val); +} + +unsigned long check_byteswap_ulong(unsigned long val) { +// CHECK-IR: call i32 @llvm.bswap.i32(i32 %val) + return _byteswap_ulong(val); +} + +unsigned __int64 check_byteswap_uint64(unsigned __int64 val) { +// CHECK-IR: call i64 @llvm.bswap.i64(i64 %val) + return _byteswap_uint64(val); +} Index: lib/Headers/intrin.h =================================================================== --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -566,6 +566,16 @@ long _InterlockedAdd(long volatile *Addend, long Value); int _ReadStatusReg(int); void _WriteStatusReg(int, int); + +static inline unsigned short _byteswap_ushort (unsigned short val) { + return __builtin_bswap16(val); +} +static inline unsigned long _byteswap_ulong (unsigned long val) { + return __builtin_bswap32(val); +} +static inline unsigned __int64 _byteswap_uint64 (unsigned __int64 val) { + return __builtin_bswap64(val); +} #endif /*----------------------------------------------------------------------------*\
Index: test/Headers/ms-arm64-intrin.cpp =================================================================== --- test/Headers/ms-arm64-intrin.cpp +++ test/Headers/ms-arm64-intrin.cpp @@ -1,9 +1,15 @@ +// REQUIRES: aarch64-registered-target + // 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 - 2>&1 | FileCheck %s -// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple arm64-windows -O1 \ +// 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 \ +// RUN: | FileCheck %s --check-prefix CHECK-IR #include <intrin.h> @@ -11,3 +17,18 @@ // CHECK: nop __nop(); } + +unsigned short check_byteswap_ushort(unsigned short val) { +// CHECK-IR: call i16 @llvm.bswap.i16(i16 %val) + return _byteswap_ushort(val); +} + +unsigned long check_byteswap_ulong(unsigned long val) { +// CHECK-IR: call i32 @llvm.bswap.i32(i32 %val) + return _byteswap_ulong(val); +} + +unsigned __int64 check_byteswap_uint64(unsigned __int64 val) { +// CHECK-IR: call i64 @llvm.bswap.i64(i64 %val) + return _byteswap_uint64(val); +} Index: lib/Headers/intrin.h =================================================================== --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -566,6 +566,16 @@ long _InterlockedAdd(long volatile *Addend, long Value); int _ReadStatusReg(int); void _WriteStatusReg(int, int); + +static inline unsigned short _byteswap_ushort (unsigned short val) { + return __builtin_bswap16(val); +} +static inline unsigned long _byteswap_ulong (unsigned long val) { + return __builtin_bswap32(val); +} +static inline unsigned __int64 _byteswap_uint64 (unsigned __int64 val) { + return __builtin_bswap64(val); +} #endif /*----------------------------------------------------------------------------*\
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits