15 #ifndef LLVM_SUPPORT_SWAPBYTEORDER_H
16 #define LLVM_SUPPORT_SWAPBYTEORDER_H
19 #include "llvm/Support/DataTypes.h"
29 #if defined(_MSC_VER) && !defined(_DEBUG)
32 return _byteswap_ushort(value);
34 uint16_t
Hi = value << 8;
35 uint16_t
Lo = value >> 8;
43 #if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC))
44 return __builtin_bswap32(value);
45 #elif defined(_MSC_VER) && !defined(_DEBUG)
46 return _byteswap_ulong(value);
48 uint32_t Byte0 = value & 0x000000FF;
49 uint32_t Byte1 = value & 0x0000FF00;
50 uint32_t Byte2 = value & 0x00FF0000;
51 uint32_t Byte3 = value & 0xFF000000;
52 return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24);
59 #if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC))
60 return __builtin_bswap64(value);
61 #elif defined(_MSC_VER) && !defined(_DEBUG)
62 return _byteswap_uint64(value);
66 return (Hi << 32) |
Lo;
80 #if __LONG_MAX__ == __INT_MAX__
83 #elif __LONG_MAX__ == __LONG_LONG_MAX__
87 #error "Unknown long size!"
void swapByteOrder(T &Value)
uint32_t SwapByteOrder_32(uint32_t value)
SwapByteOrder_32 - This function returns a byte-swapped representation of the 32-bit argument...
uint16_t SwapByteOrder_16(uint16_t value)
SwapByteOrder_16 - This function returns a byte-swapped representation of the 16-bit argument...
uint64_t SwapByteOrder_64(uint64_t value)
SwapByteOrder_64 - This function returns a byte-swapped representation of the 64-bit argument...
unsigned char getSwappedBytes(unsigned char C)
LLVM Value Representation.