LLVM  14.0.0git
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 = std::make_unsigned_t< value_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 std::make_unsigned_t<value_type>

Definition at line 112 of file Endian.h.

Function Documentation

◆ byte_swap() [1/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 57 of file Endian.h.

References byte_swap().

◆ byte_swap() [2/2]

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

◆ read() [1/4]

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

Definition at line 76 of file Endian.h.

◆ read() [2/4]

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

Read a value of a particular endianness from memory.

Definition at line 63 of file Endian.h.

References LLVM_ASSUME_ALIGNED, memcpy(), and ret().

Referenced by llvm::sys::fs::copy_file_internal(), llvm::getRandomBytes(), and llvm::sys::fs::md5_contents().

◆ read() [3/4]

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

Definition at line 356 of file Endian.h.

References P.

◆ read() [4/4]

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

Definition at line 352 of file Endian.h.

References E, and P.

◆ read16() [1/2]

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

Definition at line 370 of file Endian.h.

References P.

◆ read16() [2/2]

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

Definition at line 360 of file Endian.h.

References E, and P.

◆ read16be()

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

Definition at line 383 of file Endian.h.

References P.

◆ read16le()

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

◆ read32() [1/2]

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

Definition at line 373 of file Endian.h.

References P.

◆ read32() [2/2]

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

Definition at line 363 of file Endian.h.

References E, and 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]

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

Definition at line 376 of file Endian.h.

References P.

◆ read64() [2/2]

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

Definition at line 366 of file Endian.h.

References E, and P.

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

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

References assert(), LLVM_ASSUME_ALIGNED, memcpy(), and val.

◆ readNext() [1/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 91 of file Endian.h.

◆ readNext() [2/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 83 of file Endian.h.

References ret().

◆ system_endianness()

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

◆ write() [1/6]

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

Definition at line 45 of file EndianStream.h.

References write().

◆ write() [2/6]

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

Definition at line 28 of file EndianStream.h.

References llvm::raw_ostream::write().

◆ write() [3/6]

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

Definition at line 107 of file Endian.h.

◆ write() [4/6]

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

◆ write() [5/6]

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

Definition at line 391 of file Endian.h.

References P.

◆ write() [6/6]

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

Definition at line 387 of file Endian.h.

References E, and P.

◆ write16() [1/2]

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

Definition at line 405 of file Endian.h.

References P.

◆ write16() [2/2]

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

Definition at line 395 of file Endian.h.

References E, and P.

◆ write16be()

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

Definition at line 418 of file Endian.h.

References P.

◆ write16le()

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

Definition at line 415 of file Endian.h.

References P.

Referenced by llvm::add16().

◆ write32() [1/2]

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

Definition at line 408 of file Endian.h.

References P.

◆ write32() [2/2]

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

Definition at line 398 of file Endian.h.

References E, and P.

◆ write32be()

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

Definition at line 419 of file Endian.h.

References P.

Referenced by llvm::StringTableBuilder::write().

◆ write32le()

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

◆ write64() [1/2]

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

Definition at line 411 of file Endian.h.

References P.

◆ write64() [2/2]

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

Definition at line 401 of file Endian.h.

References E, and P.

◆ write64be()

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

Definition at line 420 of file Endian.h.

References P.

◆ write64le()

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

◆ write< double >()

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

Definition at line 39 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 34 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 151 of file Endian.h.

References assert(), LLVM_ASSUME_ALIGNED, memcpy(), and val.