LLVM 20.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

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.
 
template<typename value_type , std::size_t alignment = unaligned>
value_type read (const void *memory, endianness endian)
 Read a value of a particular endianness from memory.
 
template<typename value_type , endianness endian, std::size_t alignment>
value_type read (const void *memory)
 
template<typename value_type , std::size_t alignment = unaligned, 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.
 
template<typename value_type , endianness endian, std::size_t alignment = unaligned, typename CharT >
value_type readNext (const CharT *&memory)
 
template<typename value_type , std::size_t alignment = unaligned>
void write (void *memory, value_type value, endianness endian)
 Write a value to memory with a particular endianness.
 
template<typename value_type , endianness endian, std::size_t alignment>
void write (void *memory, value_type value)
 
template<typename value_type , std::size_t alignment = unaligned, typename CharT >
void writeNext (CharT *&memory, value_type value, endianness endian)
 Write a value of a particular endianness, and increment the buffer past that value.
 
template<typename value_type , endianness endian, std::size_t alignment = unaligned, typename CharT >
void writeNext (CharT *&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.
 
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.
 
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 , 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_array (raw_ostream &os, ArrayRef< value_type > values, endianness endian)
 
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)
 
template<typename value_type >
void write (SmallVectorImpl< char > &Out, value_type V, endianness E)
 

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

References byte_swap(), and value.

◆ byte_swap() [2/2]

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

◆ read() [1/3]

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

Definition at line 69 of file Endian.h.

◆ read() [2/3]

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

Read a value of a particular endianness from memory.

Definition at line 58 of file Endian.h.

References LLVM_ASSUME_ALIGNED.

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

◆ read() [3/3]

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

Definition at line 398 of file Endian.h.

References P.

◆ read16() [1/2]

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

Definition at line 412 of file Endian.h.

References P.

◆ read16() [2/2]

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

◆ read16be()

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

Definition at line 431 of file Endian.h.

References P.

Referenced by M68kDisassembler::getInstruction().

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

References P.

◆ read32() [2/2]

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

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

References P.

◆ read64() [2/2]

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

Definition at line 408 of file Endian.h.

References E, and P.

Referenced by llvm::dwarf_linker::parallel::SectionDescriptor::getIntVal(), and 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 127 of file Endian.h.

References assert(), and LLVM_ASSUME_ALIGNED.

Referenced by llvm::BitstreamWriter::BackpatchByte().

◆ readNext() [1/2]

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

Definition at line 86 of file Endian.h.

◆ readNext() [2/2]

template<typename value_type , std::size_t alignment = unaligned, 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 77 of file Endian.h.

◆ 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 54 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 37 of file EndianStream.h.

References value, and llvm::raw_ostream::write().

◆ write() [3/6]

template<typename value_type >
void llvm::support::endian::write ( SmallVectorImpl< char > &  Out,
value_type  V,
endianness  E 
)
inline

Definition at line 61 of file EndianStream.h.

References llvm::SmallVectorImpl< T >::append(), and E.

◆ write() [4/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 102 of file Endian.h.

References value.

◆ write() [5/6]

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

◆ write() [6/6]

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

Definition at line 441 of file Endian.h.

References P.

◆ write16() [1/2]

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

Definition at line 455 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 445 of file Endian.h.

References E, and P.

◆ write16be()

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

Definition at line 474 of file Endian.h.

References P.

◆ write16le()

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

Definition at line 465 of file Endian.h.

References P.

Referenced by llvm::jitlink::finalizeBlockRelax().

◆ write32() [1/2]

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

Definition at line 458 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 448 of file Endian.h.

References E, and P.

◆ write32be()

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

Definition at line 477 of file Endian.h.

References P.

Referenced by llvm::jitlink::aarch32::applyFixupData(), and 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 461 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 451 of file Endian.h.

References E, and P.

◆ write64be()

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

Definition at line 480 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 48 of file EndianStream.h.

References value, and write().

◆ write< float >()

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

Definition at line 43 of file EndianStream.h.

References value, and write().

◆ write_array()

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

Definition at line 28 of file EndianStream.h.

References value, values(), and llvm::raw_ostream::write().

Referenced by llvm::mcdxbc::PSVRuntimeInfo::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 162 of file Endian.h.

References assert(), LLVM_ASSUME_ALIGNED, and value.

◆ writeNext() [1/2]

template<typename value_type , endianness endian, std::size_t alignment = unaligned, typename CharT >
void llvm::support::endian::writeNext ( CharT *&  memory,
value_type  value 
)
inline

Definition at line 117 of file Endian.h.

References value.

◆ writeNext() [2/2]

template<typename value_type , std::size_t alignment = unaligned, typename CharT >
void llvm::support::endian::writeNext ( CharT *&  memory,
value_type  value,
endianness  endian 
)
inline

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

Definition at line 110 of file Endian.h.

References value, and write().