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 */ 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 @@ -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); +}