14#ifndef LLVM_SUPPORT_SWAPBYTEORDER_H
15#define LLVM_SUPPORT_SWAPBYTEORDER_H
22#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
23 defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
26#include <sys/machine.h>
30#define BIG_ENDIAN 4321
31#define LITTLE_ENDIAN 1234
32#if defined(_BIG_ENDIAN)
33#define BYTE_ORDER BIG_ENDIAN
35#define BYTE_ORDER LITTLE_ENDIAN
38#define BIG_ENDIAN 4321
39#define LITTLE_ENDIAN 1234
40#define BYTE_ORDER BIG_ENDIAN
42#if !defined(BYTE_ORDER) && !defined(_WIN32)
43#include <machine/endian.h>
51#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
76 return llvm::bit_cast<float>(
llvm::byteswap(llvm::bit_cast<uint32_t>(
C)));
80 return llvm::bit_cast<double>(
llvm::byteswap(llvm::bit_cast<uint64_t>(
C)));
85 return static_cast<T>(
This file implements the C++20 <bit> header.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
static const bool IsLittleEndianHost
unsigned char getSwappedBytes(unsigned char C)
constexpr bool IsBigEndianHost
void swapByteOrder(T &Value)
This is an optimization pass for GlobalISel generic memory operations.
constexpr T byteswap(T V) noexcept
Reverses the bytes in the given integer value V.