[clang] 02f67c0 - Use llvm::endianness::{big,little,native} (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 13 23:16:34 PDT 2023
Author: Kazu Hirata
Date: 2023-10-13T23:16:25-07:00
New Revision: 02f67c097de12dc9f6c97a68d9e180af79a2483b
URL: https://github.com/llvm/llvm-project/commit/02f67c097de12dc9f6c97a68d9e180af79a2483b
DIFF: https://github.com/llvm/llvm-project/commit/02f67c097de12dc9f6c97a68d9e180af79a2483b.diff
LOG: Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to
llvm::endianness while becoming an enum class. This patch replaces
{big,little,native} with llvm::endianness::{big,little,native}.
This patch completes the migration to llvm::endianness and
llvm::endianness::{big,little,native}. I'll post a separate patch to
remove the migration helpers in llvm/Support/Endian.h:
using endianness = llvm::endianness;
constexpr llvm::endianness big = llvm::endianness::big;
constexpr llvm::endianness little = llvm::endianness::little;
constexpr llvm::endianness native = llvm::endianness::native;
Added:
Modified:
clang/lib/CodeGen/CodeGenPGO.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/GlobalModuleIndex.cpp
clang/lib/Serialization/MultiOnDiskHashTable.h
llvm/include/llvm/Bitstream/BitstreamWriter.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/include/llvm/Support/Endian.h
llvm/include/llvm/Support/MD5.h
llvm/include/llvm/Support/OnDiskHashTable.h
llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
llvm/lib/MC/MCPseudoProbe.cpp
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/ProfileData/InstrProfWriter.cpp
llvm/lib/ProfileData/MemProf.cpp
llvm/lib/ProfileData/RawMemProfReader.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
llvm/unittests/DebugInfo/PDB/HashTableTest.cpp
llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
llvm/unittests/Support/BinaryStreamTest.cpp
llvm/unittests/Support/EndianStreamTest.cpp
llvm/unittests/Support/EndianTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index df6c76cde95f8d4..63cdd0a047bcd84 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -755,7 +755,8 @@ void PGOHash::combine(HashType Type) {
// Pass through MD5 if enough work has built up.
if (Count && Count % NumTypesPerWord == 0) {
using namespace llvm::support;
- uint64_t Swapped = endian::byte_swap<uint64_t, little>(Working);
+ uint64_t Swapped =
+ endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
Working = 0;
}
@@ -781,7 +782,8 @@ uint64_t PGOHash::finalize() {
MD5.update({(uint8_t)Working});
} else {
using namespace llvm::support;
- uint64_t Swapped = endian::byte_swap<uint64_t, little>(Working);
+ uint64_t Swapped =
+ endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
}
}
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 9ea8c8eacaa931b..cce403d7c6c44d0 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -912,9 +912,10 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
using namespace llvm::support;
SelectorTable &SelTable = Reader.getContext().Selectors;
- unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
+ unsigned N =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
IdentifierInfo *FirstII = Reader.getLocalIdentifier(
- F, endian::readNext<uint32_t, little, unaligned>(d));
+ F, endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d));
if (N == 0)
return SelTable.getNullarySelector(FirstII);
else if (N == 1)
@@ -924,7 +925,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
Args.push_back(FirstII);
for (unsigned I = 1; I != N; ++I)
Args.push_back(Reader.getLocalIdentifier(
- F, endian::readNext<uint32_t, little, unaligned>(d)));
+ F, endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d)));
return SelTable.getSelector(N, Args.data());
}
@@ -937,9 +938,11 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
data_type Result;
Result.ID = Reader.getGlobalSelectorID(
- F, endian::readNext<uint32_t, little, unaligned>(d));
- unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
- unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
+ F, endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d));
+ unsigned FullInstanceBits =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
+ unsigned FullFactoryBits =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
Result.InstanceBits = FullInstanceBits & 0x3;
Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
Result.FactoryBits = FullFactoryBits & 0x3;
@@ -950,14 +953,16 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
// Load instance methods
for (unsigned I = 0; I != NumInstanceMethods; ++I) {
if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>(
- F, endian::readNext<uint32_t, little, unaligned>(d)))
+ F,
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d)))
Result.Instance.push_back(Method);
}
// Load factory methods
for (unsigned I = 0; I != NumFactoryMethods; ++I) {
if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>(
- F, endian::readNext<uint32_t, little, unaligned>(d)))
+ F,
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d)))
Result.Factory.push_back(Method);
}
@@ -998,7 +1003,8 @@ static bool readBit(unsigned &Bits) {
IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
using namespace llvm::support;
- unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
+ unsigned RawID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
return Reader.getGlobalIdentifierID(F, RawID >> 1);
}
@@ -1016,7 +1022,8 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
unsigned DataLen) {
using namespace llvm::support;
- unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
+ unsigned RawID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
bool IsInteresting = RawID & 0x01;
// Wipe out the "is interesting" bit.
@@ -1039,8 +1046,10 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
return II;
}
- unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
- unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
+ unsigned ObjCOrBuiltinID =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
+ unsigned Bits =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
bool CPlusPlusOperatorKeyword = readBit(Bits);
bool HasRevertedTokenIDToIdentifier = readBit(Bits);
bool Poisoned = readBit(Bits);
@@ -1069,7 +1078,7 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
// definition.
if (HadMacroDefinition) {
uint32_t MacroDirectivesOffset =
- endian::readNext<uint32_t, little, unaligned>(d);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
DataLen -= 4;
Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
@@ -1083,7 +1092,8 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
SmallVector<uint32_t, 4> DeclIDs;
for (; DataLen > 0; DataLen -= 4)
DeclIDs.push_back(Reader.getGlobalDeclID(
- F, endian::readNext<uint32_t, little, unaligned>(d)));
+ F,
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d)));
Reader.SetGloballyVisibleDecls(II, DeclIDs);
}
@@ -1152,7 +1162,8 @@ ModuleFile *
ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
using namespace llvm::support;
- uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
+ uint32_t ModuleFileID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
return Reader.getLocalModuleFile(F, ModuleFileID);
}
@@ -1172,15 +1183,18 @@ ASTDeclContextNameLookupTrait::ReadKey(const unsigned char *d, unsigned) {
case DeclarationName::CXXLiteralOperatorName:
case DeclarationName::CXXDeductionGuideName:
Data = (uint64_t)Reader.getLocalIdentifier(
- F, endian::readNext<uint32_t, little, unaligned>(d));
+ F, endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d));
break;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector:
Data =
- (uint64_t)Reader.getLocalSelector(
- F, endian::readNext<uint32_t, little, unaligned>(
- d)).getAsOpaquePtr();
+ (uint64_t)Reader
+ .getLocalSelector(
+ F,
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(
+ d))
+ .getAsOpaquePtr();
break;
case DeclarationName::CXXOperatorName:
Data = *d++; // OverloadedOperatorKind
@@ -1203,7 +1217,8 @@ void ASTDeclContextNameLookupTrait::ReadDataInto(internal_key_type,
using namespace llvm::support;
for (unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
- uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
+ uint32_t LocalID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
Val.insert(Reader.getGlobalDeclID(F, LocalID));
}
}
@@ -2010,8 +2025,10 @@ HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
using namespace llvm::support;
internal_key_type ikey;
- ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
- ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
+ ikey.Size =
+ off_t(endian::readNext<uint64_t, llvm::endianness::little, unaligned>(d));
+ ikey.ModTime = time_t(
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(d));
ikey.Filename = (const char *)d;
ikey.Imported = true;
return ikey;
@@ -2039,9 +2056,9 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
HFI.DirInfo = (Flags >> 1) & 0x07;
HFI.IndexHeaderMapHeader = Flags & 0x01;
HFI.ControllingMacroID = Reader.getGlobalIdentifierID(
- M, endian::readNext<uint32_t, little, unaligned>(d));
+ M, endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d));
if (unsigned FrameworkOffset =
- endian::readNext<uint32_t, little, unaligned>(d)) {
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d)) {
// The framework offset is 1 greater than the actual offset,
// since 0 is used as an indicator for "no framework name".
StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
@@ -2051,7 +2068,8 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
assert((End - d) % 4 == 0 &&
"Wrong data length in HeaderFileInfo deserialization");
while (d != End) {
- uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
+ uint32_t LocalSMID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
auto HeaderRole = static_cast<ModuleMap::ModuleHeaderRole>(LocalSMID & 7);
LocalSMID >>= 3;
@@ -4030,8 +4048,9 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
// how it goes...
using namespace llvm::support;
ModuleKind Kind = static_cast<ModuleKind>(
- endian::readNext<uint8_t, little, unaligned>(Data));
- uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
+ endian::readNext<uint8_t, llvm::endianness::little, unaligned>(Data));
+ uint16_t Len =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(Data);
StringRef Name = StringRef((const char*)Data, Len);
Data += Len;
ModuleFile *OM = (Kind == MK_PrebuiltModule || Kind == MK_ExplicitModule ||
@@ -4047,21 +4066,21 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
}
SourceLocation::UIntTy SLocOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t IdentifierIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t MacroIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t PreprocessedEntityIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t SubmoduleIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t SelectorIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t DeclIDOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
uint32_t TypeIndexOffset =
- endian::readNext<uint32_t, little, unaligned>(Data);
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Data);
auto mapOffset = [&](uint32_t Offset, uint32_t BaseOffset,
RemapBuilder &Remap) {
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 27700c711d52fdd..739344b9a128dcf 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1873,7 +1873,7 @@ namespace {
void EmitKey(raw_ostream& Out, key_type_ref key, unsigned KeyLen) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
LE.write<uint64_t>(key.Size);
KeyLen -= 8;
LE.write<uint64_t>(key.ModTime);
@@ -1885,7 +1885,7 @@ namespace {
data_type_ref Data, unsigned DataLen) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
uint64_t Start = Out.tell(); (void)Start;
unsigned char Flags = (Data.AlreadyIncluded << 6)
@@ -2053,7 +2053,7 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
llvm::raw_svector_ostream Out(TableData);
// Make sure that no bucket is at offset 0
- endian::write<uint32_t>(Out, 0, little);
+ endian::write<uint32_t>(Out, 0, llvm::endianness::little);
BucketOffset = Generator.Emit(Out, GeneratorTrait);
}
@@ -3313,7 +3313,7 @@ class ASTMethodPoolTrait {
void EmitKey(raw_ostream& Out, Selector Sel, unsigned) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
uint64_t Start = Out.tell();
assert((Start >> 32) == 0 && "Selector key offset too large");
Writer.SetSelectorOffset(Sel, Start);
@@ -3330,7 +3330,7 @@ class ASTMethodPoolTrait {
data_type_ref Methods, unsigned DataLen) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
uint64_t Start = Out.tell(); (void)Start;
LE.write<uint32_t>(Methods.ID);
unsigned NumInstanceMethods = 0;
@@ -3453,7 +3453,7 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) {
ASTMethodPoolTrait Trait(*this);
llvm::raw_svector_ostream Out(MethodPool);
// Make sure that no bucket is at offset 0
- endian::write<uint32_t>(Out, 0, little);
+ endian::write<uint32_t>(Out, 0, llvm::endianness::little);
BucketOffset = Generator.Emit(Out, Trait);
}
@@ -3650,7 +3650,7 @@ class ASTIdentifierTableTrait {
IdentID ID, unsigned) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
auto MacroOffset = Writer.getMacroDirectivesOffset(II);
if (!isInterestingIdentifier(II, MacroOffset)) {
@@ -3749,7 +3749,7 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
- endian::write<uint32_t>(Out, 0, little);
+ endian::write<uint32_t>(Out, 0, llvm::endianness::little);
BucketOffset = Generator.Emit(Out, Trait);
}
@@ -3844,7 +3844,8 @@ class ASTDeclContextNameLookupTrait {
using namespace llvm::support;
- endian::write<uint32_t>(Out, Writer.getChain()->getModuleFileID(F), little);
+ endian::write<uint32_t>(Out, Writer.getChain()->getModuleFileID(F),
+ llvm::endianness::little);
}
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
@@ -3879,7 +3880,7 @@ class ASTDeclContextNameLookupTrait {
void EmitKey(raw_ostream &Out, DeclarationNameKey Name, unsigned) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
LE.write<uint8_t>(Name.getKind());
switch (Name.getKind()) {
case DeclarationName::Identifier:
@@ -3911,7 +3912,7 @@ class ASTDeclContextNameLookupTrait {
unsigned DataLen) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
uint64_t Start = Out.tell(); (void)Start;
for (unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
LE.write<uint32_t>(DeclIDs[I]);
@@ -5024,7 +5025,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
for (ModuleFile &M : Chain->ModuleMgr) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
LE.write<uint8_t>(static_cast<uint8_t>(M.Kind));
StringRef Name = M.isModule() ? M.ModuleName : M.FileName;
LE.write<uint16_t>(Name.size());
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp
index b4a49972ace2ee6..fb80a1998d0efe9 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -89,8 +89,10 @@ class IdentifierIndexReaderTrait {
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
using namespace llvm::support;
- unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
- unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
+ unsigned KeyLen =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
+ unsigned DataLen =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(d);
return std::make_pair(KeyLen, DataLen);
}
@@ -111,7 +113,8 @@ class IdentifierIndexReaderTrait {
data_type Result;
while (DataLen > 0) {
- unsigned ID = endian::readNext<uint32_t, little, unaligned>(d);
+ unsigned ID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
Result.push_back(ID);
DataLen -= 4;
}
@@ -511,7 +514,8 @@ namespace {
// The first bit indicates whether this identifier is interesting.
// That's all we care about.
using namespace llvm::support;
- unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
+ unsigned RawID =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
bool IsInteresting = RawID & 0x01;
return std::make_pair(k, IsInteresting);
}
@@ -729,7 +733,7 @@ class IdentifierIndexWriterTrait {
std::pair<unsigned,unsigned>
EmitKeyDataLength(raw_ostream& Out, key_type_ref Key, data_type_ref Data) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
unsigned KeyLen = Key.size();
unsigned DataLen = Data.size() * 4;
LE.write<uint16_t>(KeyLen);
@@ -745,7 +749,7 @@ class IdentifierIndexWriterTrait {
unsigned DataLen) {
using namespace llvm::support;
for (unsigned I = 0, N = Data.size(); I != N; ++I)
- endian::write<uint32_t>(Out, Data[I], little);
+ endian::write<uint32_t>(Out, Data[I], llvm::endianness::little);
}
};
@@ -824,7 +828,7 @@ bool GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
using namespace llvm::support;
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
- endian::write<uint32_t>(Out, 0, little);
+ endian::write<uint32_t>(Out, 0, llvm::endianness::little);
BucketOffset = Generator.Emit(Out, Trait);
}
diff --git a/clang/lib/Serialization/MultiOnDiskHashTable.h b/clang/lib/Serialization/MultiOnDiskHashTable.h
index adc97d57e0ac7f7..2402a628b512fbe 100644
--- a/clang/lib/Serialization/MultiOnDiskHashTable.h
+++ b/clang/lib/Serialization/MultiOnDiskHashTable.h
@@ -199,10 +199,12 @@ template<typename Info> class MultiOnDiskHashTable {
storage_type Ptr = Data;
- uint32_t BucketOffset = endian::readNext<uint32_t, little, unaligned>(Ptr);
+ uint32_t BucketOffset =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
// Read the list of overridden files.
- uint32_t NumFiles = endian::readNext<uint32_t, little, unaligned>(Ptr);
+ uint32_t NumFiles =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
// FIXME: Add a reserve() to TinyPtrVector so that we don't need to make
// an additional copy.
llvm::SmallVector<file_type, 16> OverriddenFiles;
@@ -311,7 +313,7 @@ class MultiOnDiskHashTableGenerator {
// Write our header information.
{
- endian::Writer Writer(OutStream, little);
+ endian::Writer Writer(OutStream, llvm::endianness::little);
// Reserve four bytes for the bucket offset.
Writer.write<uint32_t>(0);
diff --git a/llvm/include/llvm/Bitstream/BitstreamWriter.h b/llvm/include/llvm/Bitstream/BitstreamWriter.h
index 8a59d0444e36786..f7d362b5d70ceb3 100644
--- a/llvm/include/llvm/Bitstream/BitstreamWriter.h
+++ b/llvm/include/llvm/Bitstream/BitstreamWriter.h
@@ -139,10 +139,11 @@ class BitstreamWriter {
uint64_t NumOfFlushedBytes = GetNumOfFlushedBytes();
if (ByteNo >= NumOfFlushedBytes) {
- assert((!endian::readAtBitAlignment<uint8_t, little, unaligned>(
+ assert((!endian::readAtBitAlignment<uint8_t, llvm::endianness::little,
+ unaligned>(
&Out[ByteNo - NumOfFlushedBytes], StartBit)) &&
"Expected to be patching over 0-value placeholders");
- endian::writeAtBitAlignment<uint8_t, little, unaligned>(
+ endian::writeAtBitAlignment<uint8_t, llvm::endianness::little, unaligned>(
&Out[ByteNo - NumOfFlushedBytes], NewByte, StartBit);
return;
}
@@ -171,14 +172,14 @@ class BitstreamWriter {
assert(BytesRead >= 0 && static_cast<size_t>(BytesRead) == BytesFromDisk);
for (size_t i = 0; i < BytesFromBuffer; ++i)
Bytes[BytesFromDisk + i] = Out[i];
- assert((!endian::readAtBitAlignment<uint8_t, little, unaligned>(
- Bytes, StartBit)) &&
+ assert((!endian::readAtBitAlignment<uint8_t, llvm::endianness::little,
+ unaligned>(Bytes, StartBit)) &&
"Expected to be patching over 0-value placeholders");
}
// Update Bytes in terms of bit offset and value.
- endian::writeAtBitAlignment<uint8_t, little, unaligned>(Bytes, NewByte,
- StartBit);
+ endian::writeAtBitAlignment<uint8_t, llvm::endianness::little, unaligned>(
+ Bytes, NewByte, StartBit);
// Copy updated data back to the file FS and the buffer Out.
FS->seek(ByteNo);
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 172b4c9f6187532..5f54cbeb1b01eda 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -500,8 +500,10 @@ class InstrProfLookupTrait {
ReadKeyDataLength(const unsigned char *&D) {
using namespace support;
- offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
- offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
+ offset_type KeyLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
+ offset_type DataLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
return std::make_pair(KeyLen, DataLen);
}
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index d0ba5b10be02e62..1a066c10c1361d4 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -50,7 +50,7 @@ struct PortableMemInfoBlock {
switch (Id) {
#define MIBEntryDef(NameTag, Name, Type) \
case Meta::Name: { \
- Name = endian::readNext<Type, little, unaligned>(Ptr); \
+ Name = endian::readNext<Type, llvm::endianness::little, unaligned>(Ptr); \
} break;
#include "llvm/ProfileData/MIBEntryDef.inc"
#undef MIBEntryDef
@@ -66,7 +66,7 @@ struct PortableMemInfoBlock {
void serialize(const MemProfSchema &Schema, raw_ostream &OS) const {
using namespace support;
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
for (const Meta Id : Schema) {
switch (Id) {
#define MIBEntryDef(NameTag, Name, Type) \
@@ -187,7 +187,7 @@ struct Frame {
void serialize(raw_ostream &OS) const {
using namespace support;
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
// If the type of the GlobalValue::GUID changes, then we need to update
// the reader and the writer.
@@ -204,10 +204,14 @@ struct Frame {
static Frame deserialize(const unsigned char *Ptr) {
using namespace support;
- const uint64_t F = endian::readNext<uint64_t, little, unaligned>(Ptr);
- const uint32_t L = endian::readNext<uint32_t, little, unaligned>(Ptr);
- const uint32_t C = endian::readNext<uint32_t, little, unaligned>(Ptr);
- const bool I = endian::readNext<bool, little, unaligned>(Ptr);
+ const uint64_t F =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
+ const uint32_t L =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
+ const uint32_t C =
+ endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
+ const bool I =
+ endian::readNext<bool, llvm::endianness::little, unaligned>(Ptr);
return Frame(/*Function=*/F, /*LineOffset=*/L, /*Column=*/C,
/*IsInlineFrame=*/I);
}
@@ -466,14 +470,17 @@ class RecordLookupTrait {
ReadKeyDataLength(const unsigned char *&D) {
using namespace support;
- offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
- offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
+ offset_type KeyLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
+ offset_type DataLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
return std::make_pair(KeyLen, DataLen);
}
uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
using namespace support;
- return endian::readNext<external_key_type, little, unaligned>(D);
+ return endian::readNext<external_key_type, llvm::endianness::little,
+ unaligned>(D);
}
data_type ReadData(uint64_t K, const unsigned char *D,
@@ -514,7 +521,7 @@ class RecordWriterTrait {
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
offset_type N = sizeof(K);
LE.write<offset_type>(N);
offset_type M = V.serializedSize();
@@ -524,7 +531,7 @@ class RecordWriterTrait {
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
LE.write<uint64_t>(K);
}
@@ -552,7 +559,7 @@ class FrameWriterTrait {
static std::pair<offset_type, offset_type>
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
offset_type N = sizeof(K);
LE.write<offset_type>(N);
offset_type M = V.serializedSize();
@@ -562,7 +569,7 @@ class FrameWriterTrait {
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
LE.write<key_type>(K);
}
@@ -593,14 +600,17 @@ class FrameLookupTrait {
ReadKeyDataLength(const unsigned char *&D) {
using namespace support;
- offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);
- offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);
+ offset_type KeyLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
+ offset_type DataLen =
+ endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
return std::make_pair(KeyLen, DataLen);
}
uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
using namespace support;
- return endian::readNext<external_key_type, little, unaligned>(D);
+ return endian::readNext<external_key_type, llvm::endianness::little,
+ unaligned>(D);
}
data_type ReadData(uint64_t K, const unsigned char *D,
diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h
index 808446e615458f6..d4fc6b59e252f85 100644
--- a/llvm/include/llvm/Support/Endian.h
+++ b/llvm/include/llvm/Support/Endian.h
@@ -53,7 +53,7 @@ constexpr endianness system_endianness() { return llvm::endianness::native; }
template <typename value_type>
[[nodiscard]] inline value_type byte_swap(value_type value, endianness endian) {
- if (endian != native)
+ if (endian != llvm::endianness::native)
sys::swapByteOrder(value);
return value;
}
@@ -273,85 +273,120 @@ struct packed_endian_specific_integral {
} // end namespace detail
using ulittle16_t =
- detail::packed_endian_specific_integral<uint16_t, little, unaligned>;
+ detail::packed_endian_specific_integral<uint16_t, llvm::endianness::little,
+ unaligned>;
using ulittle32_t =
- detail::packed_endian_specific_integral<uint32_t, little, unaligned>;
+ detail::packed_endian_specific_integral<uint32_t, llvm::endianness::little,
+ unaligned>;
using ulittle64_t =
- detail::packed_endian_specific_integral<uint64_t, little, unaligned>;
+ detail::packed_endian_specific_integral<uint64_t, llvm::endianness::little,
+ unaligned>;
using little16_t =
- detail::packed_endian_specific_integral<int16_t, little, unaligned>;
+ detail::packed_endian_specific_integral<int16_t, llvm::endianness::little,
+ unaligned>;
using little32_t =
- detail::packed_endian_specific_integral<int32_t, little, unaligned>;
+ detail::packed_endian_specific_integral<int32_t, llvm::endianness::little,
+ unaligned>;
using little64_t =
- detail::packed_endian_specific_integral<int64_t, little, unaligned>;
+ detail::packed_endian_specific_integral<int64_t, llvm::endianness::little,
+ unaligned>;
using aligned_ulittle16_t =
- detail::packed_endian_specific_integral<uint16_t, little, aligned>;
+ detail::packed_endian_specific_integral<uint16_t, llvm::endianness::little,
+ aligned>;
using aligned_ulittle32_t =
- detail::packed_endian_specific_integral<uint32_t, little, aligned>;
+ detail::packed_endian_specific_integral<uint32_t, llvm::endianness::little,
+ aligned>;
using aligned_ulittle64_t =
- detail::packed_endian_specific_integral<uint64_t, little, aligned>;
+ detail::packed_endian_specific_integral<uint64_t, llvm::endianness::little,
+ aligned>;
using aligned_little16_t =
- detail::packed_endian_specific_integral<int16_t, little, aligned>;
+ detail::packed_endian_specific_integral<int16_t, llvm::endianness::little,
+ aligned>;
using aligned_little32_t =
- detail::packed_endian_specific_integral<int32_t, little, aligned>;
+ detail::packed_endian_specific_integral<int32_t, llvm::endianness::little,
+ aligned>;
using aligned_little64_t =
- detail::packed_endian_specific_integral<int64_t, little, aligned>;
+ detail::packed_endian_specific_integral<int64_t, llvm::endianness::little,
+ aligned>;
using ubig16_t =
- detail::packed_endian_specific_integral<uint16_t, big, unaligned>;
+ detail::packed_endian_specific_integral<uint16_t, llvm::endianness::big,
+ unaligned>;
using ubig32_t =
- detail::packed_endian_specific_integral<uint32_t, big, unaligned>;
+ detail::packed_endian_specific_integral<uint32_t, llvm::endianness::big,
+ unaligned>;
using ubig64_t =
- detail::packed_endian_specific_integral<uint64_t, big, unaligned>;
+ detail::packed_endian_specific_integral<uint64_t, llvm::endianness::big,
+ unaligned>;
using big16_t =
- detail::packed_endian_specific_integral<int16_t, big, unaligned>;
+ detail::packed_endian_specific_integral<int16_t, llvm::endianness::big,
+ unaligned>;
using big32_t =
- detail::packed_endian_specific_integral<int32_t, big, unaligned>;
+ detail::packed_endian_specific_integral<int32_t, llvm::endianness::big,
+ unaligned>;
using big64_t =
- detail::packed_endian_specific_integral<int64_t, big, unaligned>;
+ detail::packed_endian_specific_integral<int64_t, llvm::endianness::big,
+ unaligned>;
using aligned_ubig16_t =
- detail::packed_endian_specific_integral<uint16_t, big, aligned>;
+ detail::packed_endian_specific_integral<uint16_t, llvm::endianness::big,
+ aligned>;
using aligned_ubig32_t =
- detail::packed_endian_specific_integral<uint32_t, big, aligned>;
+ detail::packed_endian_specific_integral<uint32_t, llvm::endianness::big,
+ aligned>;
using aligned_ubig64_t =
- detail::packed_endian_specific_integral<uint64_t, big, aligned>;
+ detail::packed_endian_specific_integral<uint64_t, llvm::endianness::big,
+ aligned>;
using aligned_big16_t =
- detail::packed_endian_specific_integral<int16_t, big, aligned>;
+ detail::packed_endian_specific_integral<int16_t, llvm::endianness::big,
+ aligned>;
using aligned_big32_t =
- detail::packed_endian_specific_integral<int32_t, big, aligned>;
+ detail::packed_endian_specific_integral<int32_t, llvm::endianness::big,
+ aligned>;
using aligned_big64_t =
- detail::packed_endian_specific_integral<int64_t, big, aligned>;
+ detail::packed_endian_specific_integral<int64_t, llvm::endianness::big,
+ aligned>;
using unaligned_uint16_t =
- detail::packed_endian_specific_integral<uint16_t, native, unaligned>;
+ detail::packed_endian_specific_integral<uint16_t, llvm::endianness::native,
+ unaligned>;
using unaligned_uint32_t =
- detail::packed_endian_specific_integral<uint32_t, native, unaligned>;
+ detail::packed_endian_specific_integral<uint32_t, llvm::endianness::native,
+ unaligned>;
using unaligned_uint64_t =
- detail::packed_endian_specific_integral<uint64_t, native, unaligned>;
+ detail::packed_endian_specific_integral<uint64_t, llvm::endianness::native,
+ unaligned>;
using unaligned_int16_t =
- detail::packed_endian_specific_integral<int16_t, native, unaligned>;
+ detail::packed_endian_specific_integral<int16_t, llvm::endianness::native,
+ unaligned>;
using unaligned_int32_t =
- detail::packed_endian_specific_integral<int32_t, native, unaligned>;
+ detail::packed_endian_specific_integral<int32_t, llvm::endianness::native,
+ unaligned>;
using unaligned_int64_t =
- detail::packed_endian_specific_integral<int64_t, native, unaligned>;
+ detail::packed_endian_specific_integral<int64_t, llvm::endianness::native,
+ unaligned>;
template <typename T>
-using little_t = detail::packed_endian_specific_integral<T, little, unaligned>;
+using little_t =
+ detail::packed_endian_specific_integral<T, llvm::endianness::little,
+ unaligned>;
template <typename T>
-using big_t = detail::packed_endian_specific_integral<T, big, unaligned>;
+using big_t = detail::packed_endian_specific_integral<T, llvm::endianness::big,
+ unaligned>;
template <typename T>
using aligned_little_t =
- detail::packed_endian_specific_integral<T, little, aligned>;
+ detail::packed_endian_specific_integral<T, llvm::endianness::little,
+ aligned>;
template <typename T>
-using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;
+using aligned_big_t =
+ detail::packed_endian_specific_integral<T, llvm::endianness::big, aligned>;
namespace endian {
@@ -380,17 +415,23 @@ template <endianness E> [[nodiscard]] inline uint64_t read64(const void *P) {
}
[[nodiscard]] inline uint16_t read16le(const void *P) {
- return read16<little>(P);
+ return read16<llvm::endianness::little>(P);
}
[[nodiscard]] inline uint32_t read32le(const void *P) {
- return read32<little>(P);
+ return read32<llvm::endianness::little>(P);
}
[[nodiscard]] inline uint64_t read64le(const void *P) {
- return read64<little>(P);
+ return read64<llvm::endianness::little>(P);
+}
+[[nodiscard]] inline uint16_t read16be(const void *P) {
+ return read16<llvm::endianness::big>(P);
+}
+[[nodiscard]] inline uint32_t read32be(const void *P) {
+ return read32<llvm::endianness::big>(P);
+}
+[[nodiscard]] inline uint64_t read64be(const void *P) {
+ return read64<llvm::endianness::big>(P);
}
-[[nodiscard]] inline uint16_t read16be(const void *P) { return read16<big>(P); }
-[[nodiscard]] inline uint32_t read32be(const void *P) { return read32<big>(P); }
-[[nodiscard]] inline uint64_t read64be(const void *P) { return read64<big>(P); }
template <typename T, endianness E> inline void write(void *P, T V) {
*(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
@@ -416,12 +457,24 @@ template <endianness E> inline void write64(void *P, uint64_t V) {
write<uint64_t, E>(P, V);
}
-inline void write16le(void *P, uint16_t V) { write16<little>(P, V); }
-inline void write32le(void *P, uint32_t V) { write32<little>(P, V); }
-inline void write64le(void *P, uint64_t V) { write64<little>(P, V); }
-inline void write16be(void *P, uint16_t V) { write16<big>(P, V); }
-inline void write32be(void *P, uint32_t V) { write32<big>(P, V); }
-inline void write64be(void *P, uint64_t V) { write64<big>(P, V); }
+inline void write16le(void *P, uint16_t V) {
+ write16<llvm::endianness::little>(P, V);
+}
+inline void write32le(void *P, uint32_t V) {
+ write32<llvm::endianness::little>(P, V);
+}
+inline void write64le(void *P, uint64_t V) {
+ write64<llvm::endianness::little>(P, V);
+}
+inline void write16be(void *P, uint16_t V) {
+ write16<llvm::endianness::big>(P, V);
+}
+inline void write32be(void *P, uint32_t V) {
+ write32<llvm::endianness::big>(P, V);
+}
+inline void write64be(void *P, uint64_t V) {
+ write64<llvm::endianness::big>(P, V);
+}
} // end namespace endian
diff --git a/llvm/include/llvm/Support/MD5.h b/llvm/include/llvm/Support/MD5.h
index 61af6002696adf7..0e9f22d3bfdb46f 100644
--- a/llvm/include/llvm/Support/MD5.h
+++ b/llvm/include/llvm/Support/MD5.h
@@ -47,12 +47,12 @@ class MD5 {
// Our MD5 implementation returns the result in little endian, so the low
// word is first.
using namespace support;
- return endian::read<uint64_t, little>(data());
+ return endian::read<uint64_t, llvm::endianness::little>(data());
}
uint64_t high() const {
using namespace support;
- return endian::read<uint64_t, little>(data() + 8);
+ return endian::read<uint64_t, llvm::endianness::little>(data() + 8);
}
std::pair<uint64_t, uint64_t> words() const {
using namespace support;
diff --git a/llvm/include/llvm/Support/OnDiskHashTable.h b/llvm/include/llvm/Support/OnDiskHashTable.h
index bb90d8fc3ac7d0f..0a8cbbd8b18832a 100644
--- a/llvm/include/llvm/Support/OnDiskHashTable.h
+++ b/llvm/include/llvm/Support/OnDiskHashTable.h
@@ -149,7 +149,7 @@ template <typename Info> class OnDiskChainedHashTableGenerator {
/// Uses the provided Info instead of a stack allocated one.
offset_type Emit(raw_ostream &Out, Info &InfoObj) {
using namespace llvm::support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
// Now we're done adding entries, resize the bucket list if it's
// significantly too large. (This only happens if the number of
@@ -304,9 +304,11 @@ template <typename Info> class OnDiskChainedHashTable {
"buckets should be 4-byte aligned.");
using namespace llvm::support;
offset_type NumBuckets =
- endian::readNext<offset_type, little, aligned>(Buckets);
+ endian::readNext<offset_type, llvm::endianness::little, aligned>(
+ Buckets);
offset_type NumEntries =
- endian::readNext<offset_type, little, aligned>(Buckets);
+ endian::readNext<offset_type, llvm::endianness::little, aligned>(
+ Buckets);
return std::make_pair(NumBuckets, NumEntries);
}
@@ -357,19 +359,23 @@ template <typename Info> class OnDiskChainedHashTable {
offset_type Idx = KeyHash & (NumBuckets - 1);
const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
- offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
+ offset_type Offset =
+ endian::readNext<offset_type, llvm::endianness::little, aligned>(
+ Bucket);
if (Offset == 0)
return iterator(); // Empty bucket.
const unsigned char *Items = Base + Offset;
// 'Items' starts with a 16-bit unsigned integer representing the
// number of items in this bucket.
- unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
+ unsigned Len =
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(Items);
for (unsigned i = 0; i < Len; ++i) {
// Read the hash.
hash_value_type ItemHash =
- endian::readNext<hash_value_type, little, unaligned>(Items);
+ endian::readNext<hash_value_type, llvm::endianness::little,
+ unaligned>(Items);
// Determine the length of the key and the data.
const std::pair<offset_type, offset_type> &L =
@@ -467,7 +473,8 @@ class OnDiskIterableChainedHashTable : public OnDiskChainedHashTable<Info> {
// 'Items' starts with a 16-bit unsigned integer representing the
// number of items in this bucket.
NumItemsInBucketLeft =
- endian::readNext<uint16_t, little, unaligned>(Ptr);
+ endian::readNext<uint16_t, llvm::endianness::little, unaligned>(
+ Ptr);
}
Ptr += sizeof(hash_value_type); // Skip the hash.
// Determine the length of the key and the data.
diff --git a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
index 10409b9bdb2aaf1..4aed64966654420 100644
--- a/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
@@ -405,10 +405,10 @@ Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) {
auto Write32 = [FixupPtr, Endian = G.getEndianness()](int64_t Value) {
assert(isInt<32>(Value) && "Must be in signed 32-bit range");
uint32_t Imm = static_cast<int32_t>(Value);
- if (LLVM_LIKELY(Endian == little))
- endian::write32<little>(FixupPtr, Imm);
+ if (LLVM_LIKELY(Endian == llvm::endianness::little))
+ endian::write32<llvm::endianness::little>(FixupPtr, Imm);
else
- endian::write32<big>(FixupPtr, Imm);
+ endian::write32<llvm::endianness::big>(FixupPtr, Imm);
};
Edge::Kind Kind = E.getKind();
diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index ec9d0865888e45c..eb3894dbb3c254c 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -343,7 +343,7 @@ template <typename T> ErrorOr<T> MCPseudoProbeDecoder::readUnencodedNumber() {
if (Data + sizeof(T) > End) {
return std::error_code();
}
- T Val = endian::readNext<T, little, unaligned>(Data);
+ T Val = endian::readNext<T, llvm::endianness::little, unaligned>(Data);
return ErrorOr<T>(Val);
}
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 237caaaeca5a2ac..ddc11304742df76 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -1022,10 +1022,10 @@ template <class T>
static T swapToHostOrder(const unsigned char *&D, llvm::endianness Orig) {
using namespace support;
- if (Orig == little)
- return endian::readNext<T, little, unaligned>(D);
+ if (Orig == llvm::endianness::little)
+ return endian::readNext<T, llvm::endianness::little, unaligned>(D);
else
- return endian::readNext<T, big, unaligned>(D);
+ return endian::readNext<T, llvm::endianness::big, unaligned>(D);
}
static std::unique_ptr<ValueProfData> allocValueProfData(uint32_t TotalSize) {
@@ -1449,7 +1449,7 @@ static inline uint64_t read(const unsigned char *Buffer, size_t Offset) {
uint64_t Header::formatVersion() const {
using namespace support;
- return endian::byte_swap<uint64_t, little>(Version);
+ return endian::byte_swap<uint64_t, llvm::endianness::little>(Version);
}
Expected<Header> Header::readFromBuffer(const unsigned char *Buffer) {
@@ -1461,7 +1461,8 @@ Expected<Header> Header::readFromBuffer(const unsigned char *Buffer) {
H.Magic = read(Buffer, offsetOf(&Header::Magic));
// Check the magic number.
- uint64_t Magic = endian::byte_swap<uint64_t, little>(H.Magic);
+ uint64_t Magic =
+ endian::byte_swap<uint64_t, llvm::endianness::little>(H.Magic);
if (Magic != IndexedInstrProf::Magic)
return make_error<InstrProfError>(instrprof_error::bad_magic);
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 3800b23843fa9da..a920a31d0a4b229 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -112,10 +112,11 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
"not enough data to read binary id length");
uint64_t BILen = 0;
- if (Endian == little)
- BILen = endian::readNext<uint64_t, little, unaligned>(BI);
+ if (Endian == llvm::endianness::little)
+ BILen =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(BI);
else
- BILen = endian::readNext<uint64_t, big, unaligned>(BI);
+ BILen = endian::readNext<uint64_t, llvm::endianness::big, unaligned>(BI);
if (BILen == 0)
return make_error<InstrProfError>(instrprof_error::malformed,
@@ -800,7 +801,8 @@ data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
// Read hash.
if (D + sizeof(uint64_t) >= End)
return data_type();
- uint64_t Hash = endian::readNext<uint64_t, little, unaligned>(D);
+ uint64_t Hash =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(D);
// Initialize number of counters for GET_VERSION(FormatVersion) == 1.
uint64_t CountsSize = N / sizeof(uint64_t) - 1;
@@ -808,7 +810,8 @@ data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
if (GET_VERSION(FormatVersion) != IndexedInstrProf::ProfVersion::Version1) {
if (D + sizeof(uint64_t) > End)
return data_type();
- CountsSize = endian::readNext<uint64_t, little, unaligned>(D);
+ CountsSize =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(D);
}
// Read counter values.
if (D + CountsSize * sizeof(uint64_t) > End)
@@ -817,7 +820,8 @@ data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
CounterBuffer.clear();
CounterBuffer.reserve(CountsSize);
for (uint64_t J = 0; J < CountsSize; ++J)
- CounterBuffer.push_back(endian::readNext<uint64_t, little, unaligned>(D));
+ CounterBuffer.push_back(
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(D));
DataBuffer.emplace_back(K, Hash, std::move(CounterBuffer));
@@ -1001,8 +1005,8 @@ bool IndexedInstrProfReader::hasFormat(const MemoryBuffer &DataBuffer) {
if (DataBuffer.getBufferSize() < 8)
return false;
- uint64_t Magic =
- endian::read<uint64_t, little, aligned>(DataBuffer.getBufferStart());
+ uint64_t Magic = endian::read<uint64_t, llvm::endianness::little, aligned>(
+ DataBuffer.getBufferStart());
// Verify that it's magical.
return Magic == IndexedInstrProf::Magic;
}
@@ -1016,10 +1020,10 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
if (Version >= IndexedInstrProf::Version4) {
const IndexedInstrProf::Summary *SummaryInLE =
reinterpret_cast<const IndexedInstrProf::Summary *>(Cur);
- uint64_t NFields =
- endian::byte_swap<uint64_t, little>(SummaryInLE->NumSummaryFields);
- uint64_t NEntries =
- endian::byte_swap<uint64_t, little>(SummaryInLE->NumCutoffEntries);
+ uint64_t NFields = endian::byte_swap<uint64_t, llvm::endianness::little>(
+ SummaryInLE->NumSummaryFields);
+ uint64_t NEntries = endian::byte_swap<uint64_t, llvm::endianness::little>(
+ SummaryInLE->NumCutoffEntries);
uint32_t SummarySize =
IndexedInstrProf::Summary::getSize(NFields, NEntries);
std::unique_ptr<IndexedInstrProf::Summary> SummaryData =
@@ -1028,7 +1032,7 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
const uint64_t *Src = reinterpret_cast<const uint64_t *>(SummaryInLE);
uint64_t *Dst = reinterpret_cast<uint64_t *>(SummaryData.get());
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
- Dst[I] = endian::byte_swap<uint64_t, little>(Src[I]);
+ Dst[I] = endian::byte_swap<uint64_t, llvm::endianness::little>(Src[I]);
SummaryEntryVector DetailedSummary;
for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
@@ -1085,11 +1089,12 @@ Error IndexedInstrProfReader::readHeader() {
/* UseCS */ true);
// Read the hash type and start offset.
IndexedInstrProf::HashT HashType = static_cast<IndexedInstrProf::HashT>(
- endian::byte_swap<uint64_t, little>(Header->HashType));
+ endian::byte_swap<uint64_t, llvm::endianness::little>(Header->HashType));
if (HashType > IndexedInstrProf::HashT::Last)
return error(instrprof_error::unsupported_hash_type);
- uint64_t HashOffset = endian::byte_swap<uint64_t, little>(Header->HashOffset);
+ uint64_t HashOffset =
+ endian::byte_swap<uint64_t, llvm::endianness::little>(Header->HashOffset);
// The hash table with profile counts comes next.
auto IndexPtr = std::make_unique<InstrProfReaderIndex<OnDiskHashTableImplV3>>(
@@ -1100,19 +1105,23 @@ Error IndexedInstrProfReader::readHeader() {
if (GET_VERSION(Header->formatVersion()) >= 8 &&
Header->formatVersion() & VARIANT_MASK_MEMPROF) {
uint64_t MemProfOffset =
- endian::byte_swap<uint64_t, little>(Header->MemProfOffset);
+ endian::byte_swap<uint64_t, llvm::endianness::little>(
+ Header->MemProfOffset);
const unsigned char *Ptr = Start + MemProfOffset;
// The value returned from RecordTableGenerator.Emit.
const uint64_t RecordTableOffset =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
// The offset in the stream right before invoking
// FrameTableGenerator.Emit.
const uint64_t FramePayloadOffset =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
// The value returned from FrameTableGenerator.Emit.
const uint64_t FrameTableOffset =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
// Read the schema.
auto SchemaOr = memprof::readMemProfSchema(Ptr);
@@ -1137,10 +1146,13 @@ Error IndexedInstrProfReader::readHeader() {
// is higher than 9 (when it was introduced).
if (GET_VERSION(Header->formatVersion()) >= 9) {
uint64_t BinaryIdOffset =
- endian::byte_swap<uint64_t, little>(Header->BinaryIdOffset);
+ endian::byte_swap<uint64_t, llvm::endianness::little>(
+ Header->BinaryIdOffset);
const unsigned char *Ptr = Start + BinaryIdOffset;
// Read binary ids size.
- BinaryIdsSize = support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ BinaryIdsSize =
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
if (BinaryIdsSize % sizeof(uint64_t))
return error(instrprof_error::bad_header);
// Set the binary ids start.
@@ -1153,31 +1165,37 @@ Error IndexedInstrProfReader::readHeader() {
if (GET_VERSION(Header->formatVersion()) >= 10 &&
Header->formatVersion() & VARIANT_MASK_TEMPORAL_PROF) {
uint64_t TemporalProfTracesOffset =
- endian::byte_swap<uint64_t, little>(Header->TemporalProfTracesOffset);
+ endian::byte_swap<uint64_t, llvm::endianness::little>(
+ Header->TemporalProfTracesOffset);
const unsigned char *Ptr = Start + TemporalProfTracesOffset;
const auto *PtrEnd = (const unsigned char *)DataBuffer->getBufferEnd();
// Expect at least two 64 bit fields: NumTraces, and TraceStreamSize
if (Ptr + 2 * sizeof(uint64_t) > PtrEnd)
return error(instrprof_error::truncated);
const uint64_t NumTraces =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
TemporalProfTraceStreamSize =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
for (unsigned i = 0; i < NumTraces; i++) {
// Expect at least two 64 bit fields: Weight and NumFunctions
if (Ptr + 2 * sizeof(uint64_t) > PtrEnd)
return error(instrprof_error::truncated);
TemporalProfTraceTy Trace;
Trace.Weight =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
const uint64_t NumFunctions =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
// Expect at least NumFunctions 64 bit fields
if (Ptr + NumFunctions * sizeof(uint64_t) > PtrEnd)
return error(instrprof_error::truncated);
for (unsigned j = 0; j < NumFunctions; j++) {
const uint64_t NameRef =
- support::endian::readNext<uint64_t, little, unaligned>(Ptr);
+ support::endian::readNext<uint64_t, llvm::endianness::little,
+ unaligned>(Ptr);
Trace.FunctionNameRefs.push_back(NameRef);
}
TemporalProfTraces.push_back(std::move(Trace));
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 2873e06266e4439..6892654b00ea46c 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -80,7 +80,8 @@ class ProfOStream {
std::string &Data = SOStream.str(); // with flush
for (int K = 0; K < NItems; K++) {
for (int I = 0; I < P[K].N; I++) {
- uint64_t Bytes = endian::byte_swap<uint64_t, little>(P[K].D[I]);
+ uint64_t Bytes =
+ endian::byte_swap<uint64_t, llvm::endianness::little>(P[K].D[I]);
Data.replace(P[K].Pos + I * sizeof(uint64_t), sizeof(uint64_t),
(const char *)&Bytes, sizeof(uint64_t));
}
@@ -120,7 +121,7 @@ class InstrProfRecordWriterTrait {
EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
offset_type N = K.size();
LE.write<offset_type>(N);
@@ -147,7 +148,7 @@ class InstrProfRecordWriterTrait {
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type) {
using namespace support;
- endian::Writer LE(Out, little);
+ endian::Writer LE(Out, llvm::endianness::little);
for (const auto &ProfileData : *V) {
const InstrProfRecord &ProfRecord = ProfileData.second;
if (NamedInstrProfRecord::hasCSFlagInHash(ProfileData.first))
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 3255cba4dd0ca86..db34de704a3c325 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -13,7 +13,7 @@ void IndexedMemProfRecord::serialize(const MemProfSchema &Schema,
raw_ostream &OS) {
using namespace support;
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write<uint64_t>(AllocSites.size());
for (const IndexedAllocationInfo &N : AllocSites) {
@@ -40,13 +40,15 @@ IndexedMemProfRecord::deserialize(const MemProfSchema &Schema,
IndexedMemProfRecord Record;
// Read the meminfo nodes.
- const uint64_t NumNodes = endian::readNext<uint64_t, little, unaligned>(Ptr);
+ const uint64_t NumNodes =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
for (uint64_t I = 0; I < NumNodes; I++) {
IndexedAllocationInfo Node;
const uint64_t NumFrames =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
for (uint64_t J = 0; J < NumFrames; J++) {
- const FrameId Id = endian::readNext<FrameId, little, unaligned>(Ptr);
+ const FrameId Id =
+ endian::readNext<FrameId, llvm::endianness::little, unaligned>(Ptr);
Node.CallStack.push_back(Id);
}
Node.Info.deserialize(Schema, Ptr);
@@ -55,14 +57,16 @@ IndexedMemProfRecord::deserialize(const MemProfSchema &Schema,
}
// Read the callsite information.
- const uint64_t NumCtxs = endian::readNext<uint64_t, little, unaligned>(Ptr);
+ const uint64_t NumCtxs =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
for (uint64_t J = 0; J < NumCtxs; J++) {
const uint64_t NumFrames =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
llvm::SmallVector<FrameId> Frames;
Frames.reserve(NumFrames);
for (uint64_t K = 0; K < NumFrames; K++) {
- const FrameId Id = endian::readNext<FrameId, little, unaligned>(Ptr);
+ const FrameId Id =
+ endian::readNext<FrameId, llvm::endianness::little, unaligned>(Ptr);
Frames.push_back(Id);
}
Record.CallSites.push_back(Frames);
@@ -90,7 +94,7 @@ Expected<MemProfSchema> readMemProfSchema(const unsigned char *&Buffer) {
const unsigned char *Ptr = Buffer;
const uint64_t NumSchemaIds =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
if (NumSchemaIds > static_cast<uint64_t>(Meta::Size)) {
return make_error<InstrProfError>(instrprof_error::malformed,
"memprof schema invalid");
@@ -98,7 +102,8 @@ Expected<MemProfSchema> readMemProfSchema(const unsigned char *&Buffer) {
MemProfSchema Result;
for (size_t I = 0; I < NumSchemaIds; I++) {
- const uint64_t Tag = endian::readNext<uint64_t, little, unaligned>(Ptr);
+ const uint64_t Tag =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
if (Tag >= static_cast<uint64_t>(Meta::Size)) {
return make_error<InstrProfError>(instrprof_error::malformed,
"memprof schema invalid");
diff --git a/llvm/lib/ProfileData/RawMemProfReader.cpp b/llvm/lib/ProfileData/RawMemProfReader.cpp
index 0716ec53ce3f43c..284e5ec6346523e 100644
--- a/llvm/lib/ProfileData/RawMemProfReader.cpp
+++ b/llvm/lib/ProfileData/RawMemProfReader.cpp
@@ -87,7 +87,7 @@ llvm::SmallVector<SegmentEntry> readSegmentEntries(const char *Ptr) {
using namespace support;
const uint64_t NumItemsToRead =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
llvm::SmallVector<SegmentEntry> Items;
for (uint64_t I = 0; I < NumItemsToRead; I++) {
Items.push_back(*reinterpret_cast<const SegmentEntry *>(
@@ -101,10 +101,11 @@ readMemInfoBlocks(const char *Ptr) {
using namespace support;
const uint64_t NumItemsToRead =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>> Items;
for (uint64_t I = 0; I < NumItemsToRead; I++) {
- const uint64_t Id = endian::readNext<uint64_t, little, unaligned>(Ptr);
+ const uint64_t Id =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
const MemInfoBlock MIB = *reinterpret_cast<const MemInfoBlock *>(Ptr);
Items.push_back({Id, MIB});
// Only increment by size of MIB since readNext implicitly increments.
@@ -117,16 +118,19 @@ CallStackMap readStackInfo(const char *Ptr) {
using namespace support;
const uint64_t NumItemsToRead =
- endian::readNext<uint64_t, little, unaligned>(Ptr);
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
CallStackMap Items;
for (uint64_t I = 0; I < NumItemsToRead; I++) {
- const uint64_t StackId = endian::readNext<uint64_t, little, unaligned>(Ptr);
- const uint64_t NumPCs = endian::readNext<uint64_t, little, unaligned>(Ptr);
+ const uint64_t StackId =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
+ const uint64_t NumPCs =
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
SmallVector<uint64_t> CallStack;
for (uint64_t J = 0; J < NumPCs; J++) {
- CallStack.push_back(endian::readNext<uint64_t, little, unaligned>(Ptr));
+ CallStack.push_back(
+ endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr));
}
Items[StackId] = CallStack;
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index e8e468ed7370c79..256bdb833a0b187 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -502,7 +502,7 @@ ErrorOr<T> SampleProfileReaderBinary::readUnencodedNumber() {
}
using namespace support;
- T Val = endian::readNext<T, little, unaligned>(Data);
+ T Val = endian::readNext<T, llvm::endianness::little, unaligned>(Data);
return Val;
}
@@ -531,8 +531,8 @@ SampleProfileReaderBinary::readStringFromTable(size_t *RetIdx) {
if (!SR.data()) {
assert(MD5NameMemStart);
using namespace support;
- uint64_t FID = endian::read<uint64_t, little>(MD5NameMemStart +
- (*Idx) * sizeof(uint64_t));
+ uint64_t FID = endian::read<uint64_t, llvm::endianness::little>(
+ MD5NameMemStart + (*Idx) * sizeof(uint64_t));
SR = MD5StringBuf.emplace_back(std::to_string(FID));
}
if (RetIdx)
diff --git a/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp b/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
index 3da19b90a28a9c0..d1f04e9b28a347a 100644
--- a/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
+++ b/llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp
@@ -34,7 +34,9 @@ class DiscontiguousStream : public WritableBinaryStream {
uint32_t block_size() const { return 1; }
uint32_t block_count() const { return Blocks.size(); }
- endianness getEndian() const override { return little; }
+ llvm::endianness getEndian() const override {
+ return llvm::endianness::little;
+ }
Error readBytes(uint64_t Offset, uint64_t Size,
ArrayRef<uint8_t> &Buffer) override {
@@ -412,7 +414,7 @@ TEST(MappedBlockStreamTest, TestWriteContiguousStreamRef) {
F.block_size(), F.layout(), F, F.Allocator);
// First write "Test Str" into the source stream.
- MutableBinaryByteStream SourceStream(SrcData, little);
+ MutableBinaryByteStream SourceStream(SrcData, llvm::endianness::little);
BinaryStreamWriter SourceWriter(SourceStream);
EXPECT_THAT_ERROR(SourceWriter.writeCString("Test Str"), Succeeded());
EXPECT_EQ(SrcDataBytes, std::vector<uint8_t>(
diff --git a/llvm/unittests/DebugInfo/PDB/HashTableTest.cpp b/llvm/unittests/DebugInfo/PDB/HashTableTest.cpp
index 57f0dcf23db02cb..6d17332f4907958 100644
--- a/llvm/unittests/DebugInfo/PDB/HashTableTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/HashTableTest.cpp
@@ -147,7 +147,7 @@ TEST(HashTableTest, Serialization) {
}
std::vector<uint8_t> Buffer(Table.calculateSerializedLength());
- MutableBinaryByteStream Stream(Buffer, little);
+ MutableBinaryByteStream Stream(Buffer, llvm::endianness::little);
BinaryStreamWriter Writer(Stream);
EXPECT_THAT_ERROR(Table.commit(Writer), Succeeded());
// We should have written precisely the number of bytes we calculated earlier.
@@ -251,7 +251,7 @@ TEST(HashTableTest, NonTrivialValueType) {
}
std::vector<uint8_t> Buffer(Table.calculateSerializedLength());
- MutableBinaryByteStream Stream(Buffer, little);
+ MutableBinaryByteStream Stream(Buffer, llvm::endianness::little);
BinaryStreamWriter Writer(Stream);
EXPECT_THAT_ERROR(Table.commit(Writer), Succeeded());
// We should have written precisely the number of bytes we calculated earlier.
diff --git a/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp b/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
index 2f7c061944064c7..1253f7c7ead7cc0 100644
--- a/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
@@ -47,12 +47,12 @@ TEST(StringTableBuilderTest, Simple) {
EXPECT_EQ(6U, Distinct.size());
std::vector<uint8_t> Buffer(Builder.calculateSerializedSize());
- MutableBinaryByteStream OutStream(Buffer, little);
+ MutableBinaryByteStream OutStream(Buffer, llvm::endianness::little);
BinaryStreamWriter Writer(OutStream);
EXPECT_THAT_ERROR(Builder.commit(Writer), Succeeded());
// Reads the contents back.
- BinaryByteStream InStream(Buffer, little);
+ BinaryByteStream InStream(Buffer, llvm::endianness::little);
BinaryStreamReader Reader(InStream);
PDBStringTable Table;
EXPECT_THAT_ERROR(Table.reload(Reader), Succeeded());
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index 3f581445a2d6295..dcc8d3b237ff318 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -110,9 +110,11 @@ TEST(AArch32_Relocations, Thumb_Call_J1J2) {
constexpr HalfWords ImmMask = FixupInfo<Thumb_Call>::ImmMask;
static std::array<HalfWords, 3> MemPresets{
- makeHalfWords<little>({0xff, 0xf7, 0xfe, 0xef}), // common
- makeHalfWords<little>({0x00, 0x00, 0x00, 0x00}), // zeros
- makeHalfWords<little>({0xff, 0xff, 0xff, 0xff}), // ones
+ makeHalfWords<llvm::endianness::little>(
+ {0xff, 0xf7, 0xfe, 0xef}), // common
+ makeHalfWords<llvm::endianness::little>(
+ {0x00, 0x00, 0x00, 0x00}), // zeros
+ makeHalfWords<llvm::endianness::little>({0xff, 0xff, 0xff, 0xff}), // ones
};
auto EncodeDecode = [ImmMask](int64_t In, MutableHalfWords &Mem) {
@@ -146,9 +148,11 @@ TEST(AArch32_Relocations, Thumb_Call_Bare) {
constexpr HalfWords ImmMask = FixupInfo<Thumb_Call>::ImmMask;
static std::array<HalfWords, 3> MemPresets{
- makeHalfWords<little>({0xff, 0xf7, 0xfe, 0xef}), // common
- makeHalfWords<little>({0x00, 0x00, 0x00, 0x00}), // zeros
- makeHalfWords<little>({0xff, 0xff, 0xff, 0xff}), // ones
+ makeHalfWords<llvm::endianness::little>(
+ {0xff, 0xf7, 0xfe, 0xef}), // common
+ makeHalfWords<llvm::endianness::little>(
+ {0x00, 0x00, 0x00, 0x00}), // zeros
+ makeHalfWords<llvm::endianness::little>({0xff, 0xff, 0xff, 0xff}), // ones
};
auto EncodeDecode = [ImmMask](int64_t In, MutableHalfWords &Mem) {
@@ -217,9 +221,11 @@ TEST(AArch32_Relocations, Thumb_MovtAbs) {
static std::array<uint8_t, 3> Registers{0, 5, 12};
static std::array<HalfWords, 3> MemPresets{
- makeHalfWords<little>({0xff, 0xf7, 0xfe, 0xef}), // common
- makeHalfWords<little>({0x00, 0x00, 0x00, 0x00}), // zeros
- makeHalfWords<little>({0xff, 0xff, 0xff, 0xff}), // ones
+ makeHalfWords<llvm::endianness::little>(
+ {0xff, 0xf7, 0xfe, 0xef}), // common
+ makeHalfWords<llvm::endianness::little>(
+ {0x00, 0x00, 0x00, 0x00}), // zeros
+ makeHalfWords<llvm::endianness::little>({0xff, 0xff, 0xff, 0xff}), // ones
};
auto EncodeDecode = [ImmMask](uint32_t In, MutableHalfWords &Mem) {
diff --git a/llvm/unittests/Support/BinaryStreamTest.cpp b/llvm/unittests/Support/BinaryStreamTest.cpp
index 037aa596e7bba3f..70cd4036fb2a665 100644
--- a/llvm/unittests/Support/BinaryStreamTest.cpp
+++ b/llvm/unittests/Support/BinaryStreamTest.cpp
@@ -102,7 +102,8 @@ class BrokenStream : public WritableBinaryStream {
BumpPtrAllocator Allocator;
};
-constexpr endianness Endians[] = {big, little, native};
+constexpr llvm::endianness Endians[] = {
+ llvm::endianness::big, llvm::endianness::little, llvm::endianness::native};
constexpr uint32_t NumEndians = std::size(Endians);
constexpr uint32_t NumStreams = 2 * NumEndians;
@@ -931,7 +932,7 @@ TEST_F(BinaryStreamTest, BinaryItemStream) {
Objects.push_back(BinaryItemStreamObject(Buffer));
}
- BinaryItemStream<BinaryItemStreamObject> ItemStream(big);
+ BinaryItemStream<BinaryItemStreamObject> ItemStream(llvm::endianness::big);
ItemStream.setItems(Objects);
BinaryStreamReader Reader(ItemStream);
diff --git a/llvm/unittests/Support/EndianStreamTest.cpp b/llvm/unittests/Support/EndianStreamTest.cpp
index 1e800ff5570b926..2bab71c547b1ecb 100644
--- a/llvm/unittests/Support/EndianStreamTest.cpp
+++ b/llvm/unittests/Support/EndianStreamTest.cpp
@@ -20,7 +20,7 @@ TEST(EndianStream, WriteInt32LE) {
{
raw_svector_ostream OS(data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write(static_cast<int32_t>(-1362446643));
}
@@ -35,7 +35,7 @@ TEST(EndianStream, WriteInt32BE) {
{
raw_svector_ostream OS(data);
- endian::Writer BE(OS, big);
+ endian::Writer BE(OS, llvm::endianness::big);
BE.write(static_cast<int32_t>(-1362446643));
}
@@ -51,7 +51,7 @@ TEST(EndianStream, WriteFloatLE) {
{
raw_svector_ostream OS(data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write(12345.0f);
}
@@ -66,7 +66,7 @@ TEST(EndianStream, WriteFloatBE) {
{
raw_svector_ostream OS(data);
- endian::Writer BE(OS, big);
+ endian::Writer BE(OS, llvm::endianness::big);
BE.write(12345.0f);
}
@@ -81,7 +81,7 @@ TEST(EndianStream, WriteInt64LE) {
{
raw_svector_ostream OS(data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write(static_cast<int64_t>(-136244664332342323));
}
@@ -100,7 +100,7 @@ TEST(EndianStream, WriteInt64BE) {
{
raw_svector_ostream OS(data);
- endian::Writer BE(OS, big);
+ endian::Writer BE(OS, llvm::endianness::big);
BE.write(static_cast<int64_t>(-136244664332342323));
}
@@ -119,7 +119,7 @@ TEST(EndianStream, WriteDoubleLE) {
{
raw_svector_ostream OS(data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write(-2349214918.58107);
}
@@ -138,7 +138,7 @@ TEST(EndianStream, WriteDoubleBE) {
{
raw_svector_ostream OS(data);
- endian::Writer BE(OS, big);
+ endian::Writer BE(OS, llvm::endianness::big);
BE.write(-2349214918.58107);
}
@@ -157,7 +157,7 @@ TEST(EndianStream, WriteArrayLE) {
{
raw_svector_ostream OS(Data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write<uint16_t>({0x1234, 0x5678});
}
@@ -172,7 +172,7 @@ TEST(EndianStream, WriteVectorLE) {
{
raw_svector_ostream OS(Data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
std::vector<uint16_t> Vec{0x1234, 0x5678};
LE.write<uint16_t>(Vec);
}
@@ -188,7 +188,7 @@ TEST(EndianStream, WriteFloatArrayLE) {
{
raw_svector_ostream OS(Data);
- endian::Writer LE(OS, little);
+ endian::Writer LE(OS, llvm::endianness::little);
LE.write<float>({12345.0f, 12346.0f});
}
diff --git a/llvm/unittests/Support/EndianTest.cpp b/llvm/unittests/Support/EndianTest.cpp
index b5e4a9c8d14a359..ab7dfc3800691de 100644
--- a/llvm/unittests/Support/EndianTest.cpp
+++ b/llvm/unittests/Support/EndianTest.cpp
@@ -23,12 +23,17 @@ TEST(Endian, Read) {
unsigned char bigval[] = {0x00, 0x01, 0x02, 0x03, 0x04};
unsigned char littleval[] = {0x00, 0x04, 0x03, 0x02, 0x01};
int32_t BigAsHost = 0x00010203;
- EXPECT_EQ(BigAsHost, (endian::read<int32_t, big, unaligned>(bigval)));
+ EXPECT_EQ(BigAsHost,
+ (endian::read<int32_t, llvm::endianness::big, unaligned>(bigval)));
int32_t LittleAsHost = 0x02030400;
- EXPECT_EQ(LittleAsHost,(endian::read<int32_t, little, unaligned>(littleval)));
+ EXPECT_EQ(
+ LittleAsHost,
+ (endian::read<int32_t, llvm::endianness::little, unaligned>(littleval)));
- EXPECT_EQ((endian::read<int32_t, big, unaligned>(bigval + 1)),
- (endian::read<int32_t, little, unaligned>(littleval + 1)));
+ EXPECT_EQ(
+ (endian::read<int32_t, llvm::endianness::big, unaligned>(bigval + 1)),
+ (endian::read<int32_t, llvm::endianness::little, unaligned>(littleval +
+ 1)));
}
TEST(Endian, ReadBitAligned) {
@@ -36,35 +41,43 @@ TEST(Endian, ReadBitAligned) {
unsigned char littleval[] = {0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff};
unsigned char bigval[] = {0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0};
EXPECT_EQ(
- (endian::readAtBitAlignment<int, little, unaligned>(&littleval[0], 6)),
+ (endian::readAtBitAlignment<int, llvm::endianness::little, unaligned>(
+ &littleval[0], 6)),
0x0);
- EXPECT_EQ((endian::readAtBitAlignment<int, big, unaligned>(&bigval[0], 6)),
+ EXPECT_EQ((endian::readAtBitAlignment<int, llvm::endianness::big, unaligned>(
+ &bigval[0], 6)),
0x0);
// Test to make sure that signed right shift of 0xf0000000 is masked
// properly.
unsigned char littleval2[] = {0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00};
unsigned char bigval2[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
EXPECT_EQ(
- (endian::readAtBitAlignment<int, little, unaligned>(&littleval2[0], 4)),
+ (endian::readAtBitAlignment<int, llvm::endianness::little, unaligned>(
+ &littleval2[0], 4)),
0x0f000000);
- EXPECT_EQ((endian::readAtBitAlignment<int, big, unaligned>(&bigval2[0], 4)),
+ EXPECT_EQ((endian::readAtBitAlignment<int, llvm::endianness::big, unaligned>(
+ &bigval2[0], 4)),
0x0f000000);
// Test to make sure left shift of start bit doesn't overflow.
EXPECT_EQ(
- (endian::readAtBitAlignment<int, little, unaligned>(&littleval2[0], 1)),
+ (endian::readAtBitAlignment<int, llvm::endianness::little, unaligned>(
+ &littleval2[0], 1)),
0x78000000);
- EXPECT_EQ((endian::readAtBitAlignment<int, big, unaligned>(&bigval2[0], 1)),
+ EXPECT_EQ((endian::readAtBitAlignment<int, llvm::endianness::big, unaligned>(
+ &bigval2[0], 1)),
0x78000000);
// Test to make sure 64-bit int doesn't overflow.
unsigned char littleval3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char bigval3[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- EXPECT_EQ((endian::readAtBitAlignment<int64_t, little, unaligned>(
- &littleval3[0], 4)),
- 0x0f00000000000000);
EXPECT_EQ(
- (endian::readAtBitAlignment<int64_t, big, unaligned>(&bigval3[0], 4)),
+ (endian::readAtBitAlignment<int64_t, llvm::endianness::little, unaligned>(
+ &littleval3[0], 4)),
+ 0x0f00000000000000);
+ EXPECT_EQ(
+ (endian::readAtBitAlignment<int64_t, llvm::endianness::big, unaligned>(
+ &bigval3[0], 4)),
0x0f00000000000000);
}
@@ -72,8 +85,8 @@ TEST(Endian, WriteBitAligned) {
// This test ensures that signed right shift of 0xffffaa is masked
// properly.
unsigned char bigval[8] = {0x00};
- endian::writeAtBitAlignment<int32_t, big, unaligned>(bigval, (int)0xffffaaaa,
- 4);
+ endian::writeAtBitAlignment<int32_t, llvm::endianness::big, unaligned>(
+ bigval, (int)0xffffaaaa, 4);
EXPECT_EQ(bigval[0], 0xff);
EXPECT_EQ(bigval[1], 0xfa);
EXPECT_EQ(bigval[2], 0xaa);
@@ -84,8 +97,8 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval[7], 0x0f);
unsigned char littleval[8] = {0x00};
- endian::writeAtBitAlignment<int32_t, little, unaligned>(littleval,
- (int)0xffffaaaa, 4);
+ endian::writeAtBitAlignment<int32_t, llvm::endianness::little, unaligned>(
+ littleval, (int)0xffffaaaa, 4);
EXPECT_EQ(littleval[0], 0xa0);
EXPECT_EQ(littleval[1], 0xaa);
EXPECT_EQ(littleval[2], 0xfa);
@@ -98,8 +111,8 @@ TEST(Endian, WriteBitAligned) {
// This test makes sure 1<<31 doesn't overflow.
// Test to make sure left shift of start bit doesn't overflow.
unsigned char bigval2[8] = {0x00};
- endian::writeAtBitAlignment<int32_t, big, unaligned>(bigval2, (int)0xffffffff,
- 1);
+ endian::writeAtBitAlignment<int32_t, llvm::endianness::big, unaligned>(
+ bigval2, (int)0xffffffff, 1);
EXPECT_EQ(bigval2[0], 0xff);
EXPECT_EQ(bigval2[1], 0xff);
EXPECT_EQ(bigval2[2], 0xff);
@@ -110,8 +123,8 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval2[7], 0x01);
unsigned char littleval2[8] = {0x00};
- endian::writeAtBitAlignment<int32_t, little, unaligned>(littleval2,
- (int)0xffffffff, 1);
+ endian::writeAtBitAlignment<int32_t, llvm::endianness::little, unaligned>(
+ littleval2, (int)0xffffffff, 1);
EXPECT_EQ(littleval2[0], 0xfe);
EXPECT_EQ(littleval2[1], 0xff);
EXPECT_EQ(littleval2[2], 0xff);
@@ -123,7 +136,7 @@ TEST(Endian, WriteBitAligned) {
// Test to make sure 64-bit int doesn't overflow.
unsigned char bigval64[16] = {0x00};
- endian::writeAtBitAlignment<int64_t, big, unaligned>(
+ endian::writeAtBitAlignment<int64_t, llvm::endianness::big, unaligned>(
bigval64, (int64_t)0xffffffffffffffff, 1);
EXPECT_EQ(bigval64[0], 0xff);
EXPECT_EQ(bigval64[1], 0xff);
@@ -143,7 +156,7 @@ TEST(Endian, WriteBitAligned) {
EXPECT_EQ(bigval64[15], 0x01);
unsigned char littleval64[16] = {0x00};
- endian::writeAtBitAlignment<int64_t, little, unaligned>(
+ endian::writeAtBitAlignment<int64_t, llvm::endianness::little, unaligned>(
littleval64, (int64_t)0xffffffffffffffff, 1);
EXPECT_EQ(littleval64[0], 0xfe);
EXPECT_EQ(littleval64[1], 0xff);
@@ -165,23 +178,26 @@ TEST(Endian, WriteBitAligned) {
TEST(Endian, Write) {
unsigned char data[5];
- endian::write<int32_t, big, unaligned>(data, -1362446643);
+ endian::write<int32_t, llvm::endianness::big, unaligned>(data, -1362446643);
EXPECT_EQ(data[0], 0xAE);
EXPECT_EQ(data[1], 0xCA);
EXPECT_EQ(data[2], 0xB6);
EXPECT_EQ(data[3], 0xCD);
- endian::write<int32_t, big, unaligned>(data + 1, -1362446643);
+ endian::write<int32_t, llvm::endianness::big, unaligned>(data + 1,
+ -1362446643);
EXPECT_EQ(data[1], 0xAE);
EXPECT_EQ(data[2], 0xCA);
EXPECT_EQ(data[3], 0xB6);
EXPECT_EQ(data[4], 0xCD);
- endian::write<int32_t, little, unaligned>(data, -1362446643);
+ endian::write<int32_t, llvm::endianness::little, unaligned>(data,
+ -1362446643);
EXPECT_EQ(data[0], 0xCD);
EXPECT_EQ(data[1], 0xB6);
EXPECT_EQ(data[2], 0xCA);
EXPECT_EQ(data[3], 0xAE);
- endian::write<int32_t, little, unaligned>(data + 1, -1362446643);
+ endian::write<int32_t, llvm::endianness::little, unaligned>(data + 1,
+ -1362446643);
EXPECT_EQ(data[1], 0xCD);
EXPECT_EQ(data[2], 0xB6);
EXPECT_EQ(data[3], 0xCA);
More information about the cfe-commits
mailing list