1 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s 2 // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s 3 4 #include <x86intrin.h> 5 test__bswapd(int X)6int test__bswapd(int X) { 7 // CHECK-LABEL: test__bswapd 8 // CHECK: call i32 @llvm.bswap.i32 9 return __bswapd(X); 10 } 11 test_bswap(int X)12int test_bswap(int X) { 13 // CHECK-LABEL: test_bswap 14 // CHECK: call i32 @llvm.bswap.i32 15 return _bswap(X); 16 } 17 test__bswapq(long long X)18long test__bswapq(long long X) { 19 // CHECK-LABEL: test__bswapq 20 // CHECK: call i64 @llvm.bswap.i64 21 return __bswapq(X); 22 } 23 test_bswap64(long long X)24long test_bswap64(long long X) { 25 // CHECK-LABEL: test_bswap64 26 // CHECK: call i64 @llvm.bswap.i64 27 return _bswap64(X); 28 } 29 30 // Test constexpr handling. 31 #if defined(__cplusplus) && (__cplusplus >= 201103L) 32 33 char bswapd_0[__bswapd(0x00000000) == 0x00000000 ? 1 : -1]; 34 char bswapd_1[__bswapd(0x01020304) == 0x04030201 ? 1 : -1]; 35 36 char bswap_0[_bswap(0x00000000) == 0x00000000 ? 1 : -1]; 37 char bswap_1[_bswap(0x10203040) == 0x40302010 ? 1 : -1]; 38 39 char bswapq_0[__bswapq(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1]; 40 char bswapq_1[__bswapq(0x0102030405060708ULL) == 0x0807060504030201 ? 1 : -1]; 41 42 char bswap64_0[_bswap64(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1]; 43 char bswap64_1[_bswap64(0x1020304050607080ULL) == 0x8070605040302010 ? 1 : -1]; 44 45 #endif 46