LLVM  9.0.0svn
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)
 
template<typename value_type >
void write (raw_ostream &os, value_type value, endianness endian)
 
template<>
void write< float > (raw_ostream &os, float value, endianness endian)
 
template<>
void write< double > (raw_ostream &os, double value, endianness endian)
 
template<typename value_type >
void write (raw_ostream &os, ArrayRef< value_type > vals, endianness endian)
 

Typedef Documentation

◆ make_unsigned_t

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

Definition at line 114 of file Endian.h.

Function Documentation

◆ byte_swap() [1/2]

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

◆ byte_swap() [2/2]

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 59 of file Endian.h.

◆ read() [1/4]

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

◆ read() [2/4]

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

Definition at line 78 of file Endian.h.

◆ read() [3/4]

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

Definition at line 339 of file Endian.h.

References E, and P.

◆ read() [4/4]

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

Definition at line 343 of file Endian.h.

◆ read16() [1/2]

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

Definition at line 347 of file Endian.h.

References E, and P.

◆ read16() [2/2]

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

Definition at line 357 of file Endian.h.

References P.

◆ read16be()

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

Definition at line 370 of file Endian.h.

References P.

◆ read16le()

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

◆ read32() [1/2]

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

Definition at line 350 of file Endian.h.

References E, and P.

◆ read32() [2/2]

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

Definition at line 360 of file Endian.h.

References P.

◆ read32be()

uint32_t llvm::support::endian::read32be ( const void *  P)
inline

◆ read32le()

uint32_t llvm::support::endian::read32le ( const void *  P)
inline

◆ read64() [1/2]

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

Definition at line 353 of file Endian.h.

References E, and P.

Referenced by llvm::CodeGenCoverage::parse().

◆ read64() [2/2]

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

Definition at line 363 of file Endian.h.

References P.

◆ read64be()

uint64_t llvm::support::endian::read64be ( const void *  P)
inline

◆ read64le()

uint64_t llvm::support::endian::read64le ( const void *  P)
inline

◆ readAtBitAlignment()

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 119 of file Endian.h.

References assert(), and LLVM_ASSUME_ALIGNED.

◆ readNext() [1/2]

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 85 of file Endian.h.

◆ readNext() [2/2]

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 93 of file Endian.h.

◆ system_endianness()

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

Definition at line 46 of file Endian.h.

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

Referenced by byte_swap().

◆ write() [1/6]

template<typename value_type >
void llvm::support::endian::write ( raw_ostream os,
value_type  value,
endianness  endian 
)
inline

Definition at line 27 of file EndianStream.h.

References llvm::raw_ostream::write().

◆ write() [2/6]

template<typename value_type >
void llvm::support::endian::write ( raw_ostream os,
ArrayRef< value_type >  vals,
endianness  endian 
)
inline

Definition at line 44 of file EndianStream.h.

References write().

◆ write() [3/6]

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

◆ write() [4/6]

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

◆ write() [5/6]

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

Definition at line 374 of file Endian.h.

References E, and P.

◆ write() [6/6]

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

Definition at line 378 of file Endian.h.

◆ write16() [1/2]

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

Definition at line 382 of file Endian.h.

References E, and P.

◆ write16() [2/2]

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

Definition at line 392 of file Endian.h.

References P.

◆ write16be()

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

Definition at line 405 of file Endian.h.

References P.

◆ write16le()

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

Definition at line 402 of file Endian.h.

References P.

Referenced by llvm::object::WindowsResourceCOFFWriter::write().

◆ write32() [1/2]

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

Definition at line 385 of file Endian.h.

References E, and P.

◆ write32() [2/2]

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

Definition at line 395 of file Endian.h.

References P.

◆ write32be()

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

Definition at line 406 of file Endian.h.

References P.

◆ write32le()

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

◆ write64() [1/2]

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

Definition at line 388 of file Endian.h.

References E, and P.

◆ write64() [2/2]

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

Definition at line 398 of file Endian.h.

References P.

◆ write64be()

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

Definition at line 407 of file Endian.h.

References P.

◆ write64le()

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

Definition at line 404 of file Endian.h.

References P.

◆ write< double >()

template<>
void llvm::support::endian::write< double > ( raw_ostream os,
double  value,
endianness  endian 
)
inline

Definition at line 38 of file EndianStream.h.

References llvm::DoubleToBits(), and write().

◆ write< float >()

template<>
void llvm::support::endian::write< float > ( raw_ostream os,
float  value,
endianness  endian 
)
inline

Definition at line 33 of file EndianStream.h.

References llvm::FloatToBits(), and write().

◆ writeAtBitAlignment()

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 153 of file Endian.h.

References assert(), LLVM_ASSUME_ALIGNED, and llvm::support::detail::PickAlignment< T, alignment >::value.