LLVM  5.0.0
Classes | Typedefs | Functions
llvm::support::endian Namespace Reference

Classes

struct  Writer
 Adapter to write values to a stream in a particular byte order. More...
 

Typedefs

template<typename value_type >
using make_unsigned_t = typename std::make_unsigned< value_type >::type
 

Functions

constexpr endianness system_endianness ()
 
template<typename value_type >
value_type byte_swap (value_type value, endianness endian)
 
template<typename value_type , endianness endian>
value_type byte_swap (value_type value)
 Swap the bytes of value to match the given endianness. More...
 
template<typename value_type , std::size_t alignment>
value_type read (const void *memory, endianness endian)
 Read a value of a particular endianness from memory. More...
 
template<typename value_type , endianness endian, std::size_t alignment>
value_type read (const void *memory)
 
template<typename value_type , std::size_t alignment, typename CharT >
value_type readNext (const CharT *&memory, endianness endian)
 Read a value of a particular endianness from a buffer, and increment the buffer past that value. More...
 
template<typename value_type , endianness endian, std::size_t alignment, typename CharT >
value_type readNext (const CharT *&memory)
 
template<typename value_type , std::size_t alignment>
void write (void *memory, value_type value, endianness endian)
 Write a value to memory with a particular endianness. More...
 
template<typename value_type , endianness endian, std::size_t alignment>
void write (void *memory, value_type value)
 
template<typename value_type , endianness endian, std::size_t alignment>
value_type readAtBitAlignment (const void *memory, uint64_t startBit)
 Read a value of a particular endianness from memory, for a location that starts at the given bit offset within the first byte. More...
 
template<typename value_type , endianness endian, std::size_t alignment>
void writeAtBitAlignment (void *memory, value_type value, uint64_t startBit)
 Write a value to memory with a particular endianness, for a location that starts at the given bit offset within the first byte. More...
 
template<typename T >
T read (const void *P, endianness E)
 
template<typename T , endianness E>
T read (const void *P)
 
uint16_t read16 (const void *P, endianness E)
 
uint32_t read32 (const void *P, endianness E)
 
uint64_t read64 (const void *P, endianness E)
 
template<endianness E>
uint16_t read16 (const void *P)
 
template<endianness E>
uint32_t read32 (const void *P)
 
template<endianness E>
uint64_t read64 (const void *P)
 
uint16_t read16le (const void *P)
 
uint32_t read32le (const void *P)
 
uint64_t read64le (const void *P)
 
uint16_t read16be (const void *P)
 
uint32_t read32be (const void *P)
 
uint64_t read64be (const void *P)
 
template<typename T >
void write (void *P, T V, endianness E)
 
template<typename T , endianness E>
void write (void *P, T V)
 
void write16 (void *P, uint16_t V, endianness E)
 
void write32 (void *P, uint32_t V, endianness E)
 
void write64 (void *P, uint64_t V, endianness E)
 
template<endianness E>
void write16 (void *P, uint16_t V)
 
template<endianness E>
void write32 (void *P, uint32_t V)
 
template<endianness E>
void write64 (void *P, uint64_t V)
 
void write16le (void *P, uint16_t V)
 
void write32le (void *P, uint32_t V)
 
void write64le (void *P, uint64_t V)
 
void write16be (void *P, uint16_t V)
 
void write32be (void *P, uint32_t V)
 
void write64be (void *P, uint64_t V)
 

Typedef Documentation

template<typename value_type >
using llvm::support::endian::make_unsigned_t = typedef typename std::make_unsigned<value_type>::type

Definition at line 115 of file Endian.h.

Function Documentation

template<typename value_type >
value_type llvm::support::endian::byte_swap ( value_type  value,
endianness  endian 
)
inline

Definition at line 52 of file Endian.h.

References llvm::support::native, llvm::sys::swapByteOrder(), and system_endianness().

template<typename value_type , endianness endian>
value_type llvm::support::endian::byte_swap ( value_type  value)
inline

Swap the bytes of value to match the given endianness.

Definition at line 60 of file Endian.h.

template<typename value_type , std::size_t alignment>
value_type llvm::support::endian::read ( const void *  memory,
endianness  endian 
)
inline
template<typename value_type , endianness endian, std::size_t alignment>
value_type llvm::support::endian::read ( const void *  memory)
inline

Definition at line 79 of file Endian.h.

template<typename T >
T llvm::support::endian::read ( const void *  P,
endianness  E 
)
inline

Definition at line 340 of file Endian.h.

References E, and P.

template<typename T , endianness E>
T llvm::support::endian::read ( const void *  P)
inline

Definition at line 344 of file Endian.h.

uint16_t llvm::support::endian::read16 ( const void *  P,
endianness  E 
)
inline

Definition at line 348 of file Endian.h.

References E, and P.

template<endianness E>
uint16_t llvm::support::endian::read16 ( const void *  P)
inline

Definition at line 358 of file Endian.h.

References P.

uint16_t llvm::support::endian::read16be ( const void *  P)
inline

Definition at line 371 of file Endian.h.

References P.

uint16_t llvm::support::endian::read16le ( const void *  P)
inline
uint32_t llvm::support::endian::read32 ( const void *  P,
endianness  E 
)
inline

Definition at line 351 of file Endian.h.

References E, and P.

template<endianness E>
uint32_t llvm::support::endian::read32 ( const void *  P)
inline

Definition at line 361 of file Endian.h.

References P.

uint32_t llvm::support::endian::read32be ( const void *  P)
inline
uint32_t llvm::support::endian::read32le ( const void *  P)
inline
uint64_t llvm::support::endian::read64 ( const void *  P,
endianness  E 
)
inline

Definition at line 354 of file Endian.h.

References E, and P.

template<endianness E>
uint64_t llvm::support::endian::read64 ( const void *  P)
inline

Definition at line 364 of file Endian.h.

References P.

uint64_t llvm::support::endian::read64be ( const void *  P)
inline
uint64_t llvm::support::endian::read64le ( const void *  P)
inline
template<typename value_type , endianness endian, std::size_t alignment>
value_type llvm::support::endian::readAtBitAlignment ( const void *  memory,
uint64_t  startBit 
)
inline

Read a value of a particular endianness from memory, for a location that starts at the given bit offset within the first byte.

Definition at line 120 of file Endian.h.

References assert(), and LLVM_ASSUME_ALIGNED.

template<typename value_type , std::size_t alignment, typename CharT >
value_type llvm::support::endian::readNext ( const CharT *&  memory,
endianness  endian 
)
inline

Read a value of a particular endianness from a buffer, and increment the buffer past that value.

Definition at line 86 of file Endian.h.

template<typename value_type , endianness endian, std::size_t alignment, typename CharT >
value_type llvm::support::endian::readNext ( const CharT *&  memory)
inline

Definition at line 94 of file Endian.h.

constexpr endianness llvm::support::endian::system_endianness ( )

Definition at line 47 of file Endian.h.

References llvm::support::big, llvm::sys::IsBigEndianHost, and llvm::support::little.

Referenced by byte_swap().

template<typename value_type , std::size_t alignment>
void llvm::support::endian::write ( void *  memory,
value_type  value,
endianness  endian 
)
inline

Write a value to memory with a particular endianness.

Definition at line 100 of file Endian.h.

References LLVM_ASSUME_ALIGNED.

Referenced by llvm::sys::fs::copy_file(), and llvm::support::endian::Writer< endian >::write().

template<typename value_type , endianness endian, std::size_t alignment>
void llvm::support::endian::write ( void *  memory,
value_type  value 
)
inline

Definition at line 110 of file Endian.h.

template<typename T >
void llvm::support::endian::write ( void *  P,
T  V,
endianness  E 
)
inline

Definition at line 375 of file Endian.h.

References E, and P.

template<typename T , endianness E>
void llvm::support::endian::write ( void *  P,
T  V 
)
inline

Definition at line 379 of file Endian.h.

void llvm::support::endian::write16 ( void *  P,
uint16_t  V,
endianness  E 
)
inline

Definition at line 383 of file Endian.h.

References E, and P.

template<endianness E>
void llvm::support::endian::write16 ( void *  P,
uint16_t  V 
)
inline

Definition at line 393 of file Endian.h.

References P.

void llvm::support::endian::write16be ( void *  P,
uint16_t  V 
)
inline

Definition at line 406 of file Endian.h.

References P.

void llvm::support::endian::write16le ( void *  P,
uint16_t  V 
)
inline

Definition at line 403 of file Endian.h.

References P.

void llvm::support::endian::write32 ( void *  P,
uint32_t  V,
endianness  E 
)
inline

Definition at line 386 of file Endian.h.

References E, and P.

template<endianness E>
void llvm::support::endian::write32 ( void *  P,
uint32_t  V 
)
inline

Definition at line 396 of file Endian.h.

References P.

void llvm::support::endian::write32be ( void *  P,
uint32_t  V 
)
inline

Definition at line 407 of file Endian.h.

References P.

void llvm::support::endian::write32le ( void *  P,
uint32_t  V 
)
inline
void llvm::support::endian::write64 ( void *  P,
uint64_t  V,
endianness  E 
)
inline

Definition at line 389 of file Endian.h.

References E, and P.

template<endianness E>
void llvm::support::endian::write64 ( void *  P,
uint64_t  V 
)
inline

Definition at line 399 of file Endian.h.

References P.

void llvm::support::endian::write64be ( void *  P,
uint64_t  V 
)
inline

Definition at line 408 of file Endian.h.

References P.

void llvm::support::endian::write64le ( void *  P,
uint64_t  V 
)
inline

Definition at line 405 of file Endian.h.

References P.

template<typename value_type , endianness endian, std::size_t alignment>
void llvm::support::endian::writeAtBitAlignment ( void *  memory,
value_type  value,
uint64_t  startBit 
)
inline

Write a value to memory with a particular endianness, for a location that starts at the given bit offset within the first byte.

Definition at line 154 of file Endian.h.

References assert(), and LLVM_ASSUME_ALIGNED.