diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp index 22ca8c5acccf..7a532fbbb5c2 100644 --- a/bolt/lib/Core/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -124,14 +124,14 @@ writeAddressRanges(raw_svector_ostream &Stream, const DebugAddressRangesVector &AddressRanges, const bool WriteRelativeRanges = false) { for (const DebugAddressRange &Range : AddressRanges) { - support::endian::write(Stream, Range.LowPC, support::little); + support::endian::write(Stream, Range.LowPC, llvm::endianness::little); support::endian::write( Stream, WriteRelativeRanges ? Range.HighPC - Range.LowPC : Range.HighPC, - support::little); + llvm::endianness::little); } // Finish with 0 entries. - support::endian::write(Stream, 0ULL, support::little); - support::endian::write(Stream, 0ULL, support::little); + support::endian::write(Stream, 0ULL, llvm::endianness::little); + support::endian::write(Stream, 0ULL, llvm::endianness::little); return AddressRanges.size() * 16 + 16; } @@ -209,13 +209,15 @@ getDWARF5Header(const LocListsRangelistsHeader &Header) { getDWARF5RngListLocListHeaderSize() - sizeof(UnitLengthType); support::endian::write(*HeaderStream, Header.UnitLength + HeaderSize, - support::little); - support::endian::write(*HeaderStream, Header.Version, support::little); - support::endian::write(*HeaderStream, Header.AddressSize, support::little); + llvm::endianness::little); + support::endian::write(*HeaderStream, Header.Version, + llvm::endianness::little); + support::endian::write(*HeaderStream, Header.AddressSize, + llvm::endianness::little); support::endian::write(*HeaderStream, Header.SegmentSelector, - support::little); + llvm::endianness::little); support::endian::write(*HeaderStream, Header.OffsetEntryCount, - support::little); + llvm::endianness::little); return HeaderBuffer; } @@ -254,17 +256,18 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries, } support::endian::write(OS, static_cast(BaseAddressx), - support::little); + llvm::endianness::little); uint32_t BaseIndex = AddrWriter.getIndexFromAddress(Base, CU); encodeULEB128(BaseIndex, OS); for (auto &OffsetEntry : Offsets) { support::endian::write(OS, static_cast(OffsetPair), - support::little); + llvm::endianness::little); encodeULEB128(OffsetEntry.StartOffset, OS); encodeULEB128(OffsetEntry.EndOffset, OS); Func(OffsetEntry.Index); } - support::endian::write(OS, static_cast(EndOfList), support::little); + support::endian::write(OS, static_cast(EndOfList), + llvm::endianness::little); return true; } @@ -291,7 +294,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) { const DebugAddressRange &Range = Ranges[I]; support::endian::write(*CUBodyStream, static_cast(dwarf::DW_RLE_startx_length), - support::little); + llvm::endianness::little); uint32_t Index = AddrWriter->getIndexFromAddress(Range.LowPC, *CU); encodeULEB128(Index, *CUBodyStream); encodeULEB128(Range.HighPC - Range.LowPC, *CUBodyStream); @@ -301,7 +304,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) { if (WrittenStartxLength) support::endian::write(*CUBodyStream, static_cast(dwarf::DW_RLE_end_of_list), - support::little); + llvm::endianness::little); CurrentOffset = CUBodyBuffer->size(); return RangeEntries.size() - 1; } @@ -315,7 +318,7 @@ void DebugRangeListsSectionWriter::finalizeSection() { const uint32_t SizeOfArraySection = RangeEntries.size() * SizeOfArrayEntry; for (uint32_t Offset : RangeEntries) support::endian::write(*CUArrayStream, Offset + SizeOfArraySection, - support::little); + llvm::endianness::little); std::unique_ptr Header = getDWARF5Header( {static_cast(SizeOfArraySection + CUBodyBuffer.get()->size()), @@ -359,17 +362,17 @@ void DebugARangesSectionWriter::writeARangesSection( uint32_t Size = 8 + 4 + 2 * sizeof(uint64_t) * (AddressRanges.size() + 1); // Header field #1: set size. - support::endian::write(RangesStream, Size, support::little); + support::endian::write(RangesStream, Size, llvm::endianness::little); // Header field #2: version number, 2 as per the specification. support::endian::write(RangesStream, static_cast(2), - support::little); + llvm::endianness::little); assert(CUMap.count(Offset) && "Original CU offset is not found in CU Map"); // Header field #3: debug info offset of the correspondent compile unit. support::endian::write( RangesStream, static_cast(CUMap.find(Offset)->second.Offset), - support::little); + llvm::endianness::little); // Header field #4: address size. // 8 since we only write ELF64 binaries for now. @@ -380,7 +383,7 @@ void DebugARangesSectionWriter::writeARangesSection( // Padding before address table - 4 bytes in the 64-bit-pointer case. support::endian::write(RangesStream, static_cast(0), - support::little); + llvm::endianness::little); writeAddressRanges(RangesStream, AddressRanges, true); } @@ -473,10 +476,10 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) { break; case 4: support::endian::write(*AddressStream, static_cast(Address), - support::little); + llvm::endianness::little); break; case 8: - support::endian::write(*AddressStream, Address, support::little); + support::endian::write(*AddressStream, Address, llvm::endianness::little); break; } }; @@ -492,11 +495,12 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) { void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) { // Need to layout all sections within .debug_addr // Within each section sort Address by index. - const endianness Endian = - BC->DwCtx->isLittleEndian() ? support::little : support::big; + const endianness Endian = BC->DwCtx->isLittleEndian() + ? llvm::endianness::little + : llvm::endianness::big; const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection(); DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec, - Endian == support::little, 0); + Endian == llvm::endianness::little, 0); DWARFDebugAddrTable AddrTable; DIDumpOptions DumpOpts; constexpr uint32_t HeaderSize = 8; @@ -594,11 +598,11 @@ void DebugLocWriter::addList(DIEBuilder &DIEBldr, DIE &Die, DIEValue &AttrInfo, for (const DebugLocationEntry &Entry : LocList) { support::endian::write(*LocStream, static_cast(Entry.LowPC), - support::little); + llvm::endianness::little); support::endian::write(*LocStream, static_cast(Entry.HighPC), - support::little); + llvm::endianness::little); support::endian::write(*LocStream, static_cast(Entry.Expr.size()), - support::little); + llvm::endianness::little); *LocStream << StringRef(reinterpret_cast(Entry.Expr.data()), Entry.Expr.size()); LocSectionOffset += 2 * 8 + 2 + Entry.Expr.size(); @@ -618,15 +622,17 @@ std::unique_ptr DebugLocWriter::getBuffer() { void DebugLocWriter::finalize(DIEBuilder &DIEBldr, DIE &Die) {} static void writeEmptyListDwarf5(raw_svector_ostream &Stream) { - support::endian::write(Stream, static_cast(4), support::little); + support::endian::write(Stream, static_cast(4), + llvm::endianness::little); support::endian::write(Stream, static_cast(dwarf::DW_LLE_start_end), - support::little); + llvm::endianness::little); const char Zeroes[16] = {0}; Stream << StringRef(Zeroes, 16); encodeULEB128(0, Stream); - support::endian::write( - Stream, static_cast(dwarf::DW_LLE_end_of_list), support::little); + support::endian::write(Stream, + static_cast(dwarf::DW_LLE_end_of_list), + llvm::endianness::little); } static void writeLegacyLocList(DIEValue &AttrInfo, @@ -645,21 +651,21 @@ static void writeLegacyLocList(DIEValue &AttrInfo, for (const DebugLocationEntry &Entry : LocList) { support::endian::write(LocStream, static_cast(dwarf::DW_LLE_startx_length), - support::little); + llvm::endianness::little); const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU); encodeULEB128(Index, LocStream); support::endian::write(LocStream, static_cast(Entry.HighPC - Entry.LowPC), - support::little); + llvm::endianness::little); support::endian::write(LocStream, static_cast(Entry.Expr.size()), - support::little); + llvm::endianness::little); LocStream << StringRef(reinterpret_cast(Entry.Expr.data()), Entry.Expr.size()); } support::endian::write(LocStream, static_cast(dwarf::DW_LLE_end_of_list), - support::little); + llvm::endianness::little); replaceLocValbyForm(DIEBldr, Die, AttrInfo, AttrInfo.getForm(), EntryOffset); } @@ -701,7 +707,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo, const DebugLocationEntry &Entry = LocList[I]; support::endian::write(LocBodyStream, static_cast(dwarf::DW_LLE_startx_length), - support::little); + llvm::endianness::little); const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU); encodeULEB128(Index, LocBodyStream); encodeULEB128(Entry.HighPC - Entry.LowPC, LocBodyStream); @@ -713,7 +719,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo, if (WrittenStartxLength) support::endian::write(LocBodyStream, static_cast(dwarf::DW_LLE_end_of_list), - support::little); + llvm::endianness::little); } void DebugLoclistWriter::addList(DIEBuilder &DIEBldr, DIE &Die, @@ -753,7 +759,7 @@ void DebugLoclistWriter::finalizeDWARF5(DIEBuilder &DIEBldr, DIE &Die) { support::endian::write( *LocArrayStream, static_cast(SizeOfArraySection + RelativeOffset), - support::little); + llvm::endianness::little); std::unique_ptr Header = getDWARF5Header( {static_cast(SizeOfArraySection + LocBodyBuffer.get()->size()), @@ -884,11 +890,11 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit, if (RetVal == ProcessedBaseOffsets.end() || StrOffsetSectionWasModified) { // Writing out the header for each section. support::endian::write(*StrOffsetsStream, CurrentSectionSize + 4, - support::little); + llvm::endianness::little); support::endian::write(*StrOffsetsStream, static_cast(5), - support::little); + llvm::endianness::little); support::endian::write(*StrOffsetsStream, static_cast(0), - support::little); + llvm::endianness::little); uint64_t BaseOffset = StrOffsetsBuffer->size(); ProcessedBaseOffsets[*Val] = BaseOffset; @@ -897,7 +903,8 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit, StrListBaseAttrInfo.getForm(), DIEInteger(BaseOffset)); for (const auto &Entry : IndexToAddressMap) - support::endian::write(*StrOffsetsStream, Entry.second, support::little); + support::endian::write(*StrOffsetsStream, Entry.second, + llvm::endianness::little); } else { DIEBldr.replaceValue(&Die, dwarf::DW_AT_str_offsets_base, StrListBaseAttrInfo.getForm(), diff --git a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp index 316b83cfbd38..51038dbead33 100644 --- a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp +++ b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp @@ -248,7 +248,8 @@ void PseudoProbeRewriter::encodePseudoProbes() { auto EmitInt = [&](uint64_t Value, uint32_t Size) { const bool IsLittleEndian = BC.AsmInfo->isLittleEndian(); uint64_t Swapped = support::endian::byte_swap( - Value, IsLittleEndian ? support::little : support::big); + Value, + IsLittleEndian ? llvm::endianness::little : llvm::endianness::big); unsigned Index = IsLittleEndian ? 0 : 8 - Size; auto Entry = StringRef(reinterpret_cast(&Swapped) + Index, Size); Contents.append(Entry.begin(), Entry.end()); diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp index 5071b7b79d23..a4c808e4c9a0 100644 --- a/lld/COFF/DebugTypes.cpp +++ b/lld/COFF/DebugTypes.cpp @@ -311,7 +311,7 @@ Error TpiSource::mergeDebugT(TypeMerger *m) { "use remapTpiWithGHashes when ghash is enabled"); CVTypeArray types; - BinaryStreamReader reader(file->debugTypes, support::little); + BinaryStreamReader reader(file->debugTypes, llvm::endianness::little); cantFail(reader.readArray(types, reader.getLength())); // When dealing with PCH.OBJ, some indices were already merged. @@ -588,7 +588,7 @@ void TpiSource::loadGHashes() { ownedGHashes = false; } else { CVTypeArray types; - BinaryStreamReader reader(file->debugTypes, support::little); + BinaryStreamReader reader(file->debugTypes, llvm::endianness::little); cantFail(reader.readArray(types, reader.getLength())); assignGHashesFromVector(GloballyHashedType::hashTypes(types)); } diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 278f5e71b14f..0fbfefdf43cf 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1210,7 +1210,7 @@ static void readCallGraphsFromObjectFiles(COFFLinkerContext &ctx) { ArrayRef contents; cantFail( obj->getCOFFObj()->getSectionContents(obj->callgraphSec, contents)); - BinaryStreamReader reader(contents, support::little); + BinaryStreamReader reader(contents, llvm::endianness::little); while (!reader.empty()) { uint32_t fromIndex, toIndex; uint64_t count; diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index a7a08fb2fa6e..b66ef418b303 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -709,7 +709,7 @@ void ObjFile::initializeFlags() { DebugSubsectionArray subsections; - BinaryStreamReader reader(data, support::little); + BinaryStreamReader reader(data, llvm::endianness::little); ExitOnError exitOnErr; exitOnErr(reader.readArray(subsections, data.size())); @@ -775,7 +775,7 @@ void ObjFile::initializeDependencies() { // Get the first type record. It will indicate if this object uses a type // server (/Zi) or a PCH file (/Yu). CVTypeArray types; - BinaryStreamReader reader(data, support::little); + BinaryStreamReader reader(data, llvm::endianness::little); cantFail(reader.readArray(types, reader.getLength())); CVTypeArray::Iterator firstType = types.begin(); if (firstType == types.end()) diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index 0c4e0a80cf9a..f77ff0d4eab8 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -656,7 +656,7 @@ Error PDBLinker::writeAllModuleSymbolRecords(ObjFile *file, auto contents = SectionChunk::consumeDebugMagic(sectionContents, ".debug$S"); DebugSubsectionArray subsections; - BinaryStreamReader reader(contents, support::little); + BinaryStreamReader reader(contents, llvm::endianness::little); exitOnErr(reader.readArray(subsections, contents.size())); uint32_t nextRelocIndex = 0; @@ -758,7 +758,7 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) { ArrayRef contents = debugChunk->getContents(); contents = SectionChunk::consumeDebugMagic(contents, ".debug$S"); DebugSubsectionArray subsections; - BinaryStreamReader reader(contents, support::little); + BinaryStreamReader reader(contents, llvm::endianness::little); ExitOnError exitOnErr; exitOnErr(reader.readArray(subsections, contents.size())); debugChunk->sortRelocations(); @@ -868,7 +868,7 @@ Error UnrelocatedDebugSubsection::commit(BinaryStreamWriter &writer) const { debugChunk->file->debugTypesObj) { TpiSource *source = debugChunk->file->debugTypesObj; DebugInlineeLinesSubsectionRef inlineeLines; - BinaryStreamReader storageReader(relocatedBytes, support::little); + BinaryStreamReader storageReader(relocatedBytes, llvm::endianness::little); ExitOnError exitOnErr; exitOnErr(inlineeLines.initialize(storageReader)); for (const InlineeSourceLine &line : inlineeLines) { @@ -962,7 +962,7 @@ void DebugSHandler::finish() { // Copy each frame data record, add in rvaStart, translate string table // indices, and add the record to the PDB. DebugFrameDataSubsectionRef fds; - BinaryStreamReader reader(subsecData, support::little); + BinaryStreamReader reader(subsecData, llvm::endianness::little); exitOnErr(fds.initialize(reader)); for (codeview::FrameData fd : fds) { fd.RvaStart += rvaStart; @@ -1050,7 +1050,8 @@ void PDBLinker::addDebugSymbols(TpiSource *source) { ArrayRef relocatedDebugContents = relocateDebugChunk(*debugChunk); FixedStreamArray fpoRecords; - BinaryStreamReader reader(relocatedDebugContents, support::little); + BinaryStreamReader reader(relocatedDebugContents, + llvm::endianness::little); uint32_t count = relocatedDebugContents.size() / sizeof(object::FpoData); exitOnErr(reader.readArray(fpoRecords, count)); @@ -1772,7 +1773,7 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr, ArrayRef contents = SectionChunk::consumeDebugMagic(dbgC->getContents(), ".debug$S"); DebugSubsectionArray subsections; - BinaryStreamReader reader(contents, support::little); + BinaryStreamReader reader(contents, llvm::endianness::little); exitOnErr(reader.readArray(subsections, contents.size())); for (const DebugSubsectionRecord &ss : subsections) { diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index d5a335c65932..d6c70aeba95d 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -219,7 +219,7 @@ template static uint32_t readShuffle(const uint8_t *loc) { // words in a big-endian order. That is why we have to swap these // words to get a correct value. uint32_t v = read32(loc); - if (E == support::little) + if (E == llvm::endianness::little) return (v << 16) | (v >> 16); return v; } @@ -237,12 +237,12 @@ static void writeShuffleValue(uint8_t *loc, uint64_t v, uint8_t bitsSize, uint8_t shift) { // See comments in readShuffle for purpose of this code. uint16_t *words = (uint16_t *)loc; - if (E == support::little) + if (E == llvm::endianness::little) std::swap(words[0], words[1]); writeValue(loc, v, bitsSize, shift); - if (E == support::little) + if (E == llvm::endianness::little) std::swap(words[0], words[1]); } diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index d0d75118e30d..6413dcd7dcd7 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -933,7 +933,7 @@ mergeAttributesSection(const SmallVector §ions) { const auto &attributesTags = RISCVAttrs::getRISCVAttributeTags(); for (const InputSectionBase *sec : sections) { RISCVAttributeParser parser; - if (Error e = parser.parse(sec->content(), support::little)) + if (Error e = parser.parse(sec->content(), llvm::endianness::little)) warn(toString(sec) + ": " + llvm::toString(std::move(e))); for (const auto &tag : attributesTags) { switch (RISCVAttrs::AttrType(tag.attr)) { diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 3413586f6b85..a0d4be8ff988 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -604,9 +604,9 @@ template void ObjFile::parse(bool ignoreComdats) { check(this->getObj().getSectionContents(sec)); StringRef name = check(obj.getSectionName(sec, shstrtab)); this->sections[i] = &InputSection::discarded; - if (Error e = - attributes.parse(contents, ekind == ELF32LEKind ? support::little - : support::big)) { + if (Error e = attributes.parse(contents, ekind == ELF32LEKind + ? llvm::endianness::little + : llvm::endianness::big)) { InputSection isec(*this, sec, name); warn(toString(&isec) + ": " + llvm::toString(std::move(e))); } else { diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp index 8f737beee768..09c6ea9b19b5 100644 --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -320,7 +320,7 @@ static std::optional getRecordSize(StringRef segname, StringRef name) { static Error parseCallGraph(ArrayRef data, std::vector &callGraph) { TimeTraceScope timeScope("Parsing call graph section"); - BinaryStreamReader reader(data, support::little); + BinaryStreamReader reader(data, llvm::endianness::little); while (!reader.empty()) { uint32_t fromIndex, toIndex; uint64_t count; diff --git a/lld/wasm/WriterUtils.cpp b/lld/wasm/WriterUtils.cpp index ead22291b5eb..cc8ed0b1de23 100644 --- a/lld/wasm/WriterUtils.cpp +++ b/lld/wasm/WriterUtils.cpp @@ -111,12 +111,12 @@ void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg) { void writeU32(raw_ostream &os, uint32_t number, const Twine &msg) { debugWrite(os.tell(), msg + "[0x" + utohexstr(number) + "]"); - support::endian::write(os, number, support::little); + support::endian::write(os, number, llvm::endianness::little); } void writeU64(raw_ostream &os, uint64_t number, const Twine &msg) { debugWrite(os.tell(), msg + "[0x" + utohexstr(number) + "]"); - support::endian::write(os, number, support::little); + support::endian::write(os, number, llvm::endianness::little); } void writeValueType(raw_ostream &os, ValType type, const Twine &msg) { diff --git a/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp b/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp index 7ccc9210daad..da4dc10d4b87 100644 --- a/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp +++ b/lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp @@ -42,9 +42,9 @@ Expected ProcessInfo::create(StringRef response) { process_info.m_triple = fromHex(elements["triple"]); StringRef endian_str = elements["endian"]; if (endian_str == "little") - process_info.m_endian = support::little; + process_info.m_endian = llvm::endianness::little; else if (endian_str == "big") - process_info.m_endian = support::big; + process_info.m_endian = llvm::endianness::big; else return make_parsing_error("ProcessInfo: endian"); @@ -84,7 +84,7 @@ JThreadsInfo::parseRegisters(const StructuredData::Dictionary &Dict, return make_parsing_error("JThreadsInfo: register key[{0}]", i); auto RegValOr = - parseRegisterValue(RegInfos[Register], ValueStr, support::big); + parseRegisterValue(RegInfos[Register], ValueStr, llvm::endianness::big); if (!RegValOr) return RegValOr.takeError(); Result[Register] = std::move(*RegValOr); @@ -214,9 +214,10 @@ Expected parseRegisterValue(const RegisterInfo &Info, StringExtractor(HexValue).GetHexBytes(Bytes, '\xcc'); RegisterValue Value; Status ST; - Value.SetFromMemoryData( - Info, Bytes.data(), Bytes.size(), - Endian == support::little ? eByteOrderLittle : eByteOrderBig, ST); + Value.SetFromMemoryData(Info, Bytes.data(), Bytes.size(), + Endian == llvm::endianness::little ? eByteOrderLittle + : eByteOrderBig, + ST); if (ST.Fail()) return ST.ToError(); return Value; diff --git a/llvm/include/llvm/BinaryFormat/MsgPack.h b/llvm/include/llvm/BinaryFormat/MsgPack.h index 7fe6442e3373..01edae0ee0eb 100644 --- a/llvm/include/llvm/BinaryFormat/MsgPack.h +++ b/llvm/include/llvm/BinaryFormat/MsgPack.h @@ -21,7 +21,7 @@ namespace llvm { namespace msgpack { /// The endianness of all multi-byte encoded values in MessagePack. -constexpr llvm::endianness Endianness = support::big; +constexpr llvm::endianness Endianness = llvm::endianness::big; /// The first byte identifiers of MessagePack object formats. namespace FirstByte { diff --git a/llvm/include/llvm/Bitstream/BitstreamReader.h b/llvm/include/llvm/Bitstream/BitstreamReader.h index 978ab7c2422b..dbc98d1ad725 100644 --- a/llvm/include/llvm/Bitstream/BitstreamReader.h +++ b/llvm/include/llvm/Bitstream/BitstreamReader.h @@ -168,7 +168,8 @@ public: unsigned BytesRead; if (BitcodeBytes.size() >= NextChar + sizeof(word_t)) { BytesRead = sizeof(word_t); - CurWord = support::endian::read(NextCharPtr); + CurWord = + support::endian::read(NextCharPtr); } else { // Short read. BytesRead = BitcodeBytes.size() - NextChar; diff --git a/llvm/include/llvm/Bitstream/BitstreamWriter.h b/llvm/include/llvm/Bitstream/BitstreamWriter.h index 423af4c2cc6c..8a59d0444e36 100644 --- a/llvm/include/llvm/Bitstream/BitstreamWriter.h +++ b/llvm/include/llvm/Bitstream/BitstreamWriter.h @@ -75,7 +75,8 @@ class BitstreamWriter { std::vector BlockInfoRecords; void WriteWord(unsigned Value) { - Value = support::endian::byte_swap(Value); + Value = + support::endian::byte_swap(Value); Out.append(reinterpret_cast(&Value), reinterpret_cast(&Value + 1)); } diff --git a/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h b/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h index 39593b759bb5..04a64d28e0cc 100644 --- a/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h +++ b/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h @@ -54,7 +54,9 @@ public: createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator); - llvm::endianness getEndian() const override { return support::little; } + llvm::endianness getEndian() const override { + return llvm::endianness::little; + } Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; @@ -119,7 +121,9 @@ public: createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator, bool AltFpm = false); - llvm::endianness getEndian() const override { return support::little; } + llvm::endianness getEndian() const override { + return llvm::endianness::little; + } Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h b/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h index ed745eaf9727..01de8b49dd78 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h @@ -107,10 +107,9 @@ namespace detail { template struct EndianAdapter final : public FormatAdapter> { - using EndianType = - support::detail::packed_endian_specific_integral; + T, llvm::endianness::little, support::unaligned>> { + using EndianType = support::detail::packed_endian_specific_integral< + T, llvm::endianness::little, support::unaligned>; explicit EndianAdapter(EndianType &&Item) : FormatAdapter(std::move(Item)) {} @@ -122,10 +121,9 @@ struct EndianAdapter final } // namespace detail template -detail::EndianAdapter -fmtle(support::detail::packed_endian_specific_integral - Value) { +detail::EndianAdapter fmtle(support::detail::packed_endian_specific_integral< + T, llvm::endianness::little, support::unaligned> + Value) { return detail::EndianAdapter(std::move(Value)); } } // namespace pdb diff --git a/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h index fba688309ec1..2bc66b11e270 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/MachOBuilder.h @@ -507,7 +507,7 @@ struct MachO64LE { using NList = MachO::nlist_64; using Relocation = MachO::relocation_info; - static constexpr llvm::endianness Endianness = support::little; + static constexpr llvm::endianness Endianness = llvm::endianness::little; static constexpr uint32_t Magic = MachO::MH_MAGIC_64; static constexpr MachO::LoadCommandType SegmentCmd = MachO::LC_SEGMENT_64; static constexpr MachO::LoadCommandType SymTabCmd = MachO::LC_SYMTAB; diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h index 05d816671b1a..1683543082e2 100644 --- a/llvm/include/llvm/MC/MCMachObjectWriter.h +++ b/llvm/include/llvm/MC/MCMachObjectWriter.h @@ -131,7 +131,8 @@ public: : TargetObjectWriter(std::move(MOTW)), StringTable(TargetObjectWriter->is64Bit() ? StringTableBuilder::MachO64 : StringTableBuilder::MachO), - W(OS, IsLittleEndian ? support::little : support::big) {} + W(OS, + IsLittleEndian ? llvm::endianness::little : llvm::endianness::big) {} support::endian::Writer W; diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h index 24ed885d7b65..a548b2c15c5f 100644 --- a/llvm/include/llvm/Object/COFF.h +++ b/llvm/include/llvm/Object/COFF.h @@ -1298,7 +1298,8 @@ private: class ResourceSectionRef { public: ResourceSectionRef() = default; - explicit ResourceSectionRef(StringRef Ref) : BBS(Ref, support::little) {} + explicit ResourceSectionRef(StringRef Ref) + : BBS(Ref, llvm::endianness::little) {} Error load(const COFFObjectFile *O); Error load(const COFFObjectFile *O, const SectionRef &S); diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index dc3d6bb58710..d7947d85739e 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -458,8 +458,9 @@ public: bool isDyldType() const { return isDyldELFObject; } static bool classof(const Binary *v) { - return v->getType() == getELFType(ELFT::TargetEndianness == support::little, - ELFT::Is64Bits); + return v->getType() == + getELFType(ELFT::TargetEndianness == llvm::endianness::little, + ELFT::Is64Bits); } elf_symbol_iterator_range getDynamicSymbolIterators() const override; @@ -1128,7 +1129,8 @@ ELFObjectFile::ELFObjectFile(MemoryBufferRef Object, ELFFile EF, const Elf_Shdr *DotSymtabSec, const Elf_Shdr *DotSymtabShndx) : ELFObjectFileBase( - getELFType(ELFT::TargetEndianness == support::little, ELFT::Is64Bits), + getELFType(ELFT::TargetEndianness == llvm::endianness::little, + ELFT::Is64Bits), Object), EF(EF), DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec), DotSymtabShndxSec(DotSymtabShndx) {} @@ -1197,7 +1199,8 @@ uint8_t ELFObjectFile::getBytesInAddress() const { template StringRef ELFObjectFile::getFileFormatName() const { - constexpr bool IsLittleEndian = ELFT::TargetEndianness == support::little; + constexpr bool IsLittleEndian = + ELFT::TargetEndianness == llvm::endianness::little; switch (EF.getHeader().e_ident[ELF::EI_CLASS]) { case ELF::ELFCLASS32: switch (EF.getHeader().e_machine) { @@ -1275,7 +1278,7 @@ StringRef ELFObjectFile::getFileFormatName() const { } template Triple::ArchType ELFObjectFile::getArch() const { - bool IsLittleEndian = ELFT::TargetEndianness == support::little; + bool IsLittleEndian = ELFT::TargetEndianness == llvm::endianness::little; switch (EF.getHeader().e_machine) { case ELF::EM_68K: return Triple::m68k; diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h index f7a1d02e534c..45fc52288bdd 100644 --- a/llvm/include/llvm/Object/ELFTypes.h +++ b/llvm/include/llvm/Object/ELFTypes.h @@ -90,10 +90,10 @@ public: using Off = packed; }; -using ELF32LE = ELFType; -using ELF32BE = ELFType; -using ELF64LE = ELFType; -using ELF64BE = ELFType; +using ELF32LE = ELFType; +using ELF32BE = ELFType; +using ELF64LE = ELFType; +using ELF64BE = ELFType; // Use an alignment of 2 for the typedefs since that is the worst case for // ELF files in archives. diff --git a/llvm/include/llvm/Object/FaultMapParser.h b/llvm/include/llvm/Object/FaultMapParser.h index bed2dba154f3..028d3900d945 100644 --- a/llvm/include/llvm/Object/FaultMapParser.h +++ b/llvm/include/llvm/Object/FaultMapParser.h @@ -42,7 +42,7 @@ class FaultMapParser { template static T read(const uint8_t *P, const uint8_t *E) { assert(P + sizeof(T) <= E && "out of bounds read!"); - return support::endian::read(P); + return support::endian::read(P); } public: diff --git a/llvm/include/llvm/Object/GOFF.h b/llvm/include/llvm/Object/GOFF.h index 31f2f82fffd6..91762457ae05 100644 --- a/llvm/include/llvm/Object/GOFF.h +++ b/llvm/include/llvm/Object/GOFF.h @@ -69,7 +69,7 @@ protected: static void get(const uint8_t *Bytes, uint8_t ByteIndex, T &Value) { assert(ByteIndex + sizeof(T) <= GOFF::RecordLength && "Byte index out of bounds!"); - Value = support::endian::read(&Bytes[ByteIndex]); + Value = support::endian::read(&Bytes[ByteIndex]); } }; diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index 5b71c984b5d5..172b4c9f6187 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -416,9 +416,9 @@ private: if (!ShouldSwapBytes) return llvm::endianness::native; if (llvm::endianness::native == llvm::endianness::little) - return support::big; + return llvm::endianness::big; else - return support::little; + return llvm::endianness::little; } inline uint8_t getNumPaddingBytes(uint64_t SizeInBytes) { @@ -477,7 +477,7 @@ class InstrProfLookupTrait { // Endianness of the input value profile data. // It should be LE by default, but can be changed // for testing purpose. - llvm::endianness ValueProfDataEndianness = support::little; + llvm::endianness ValueProfDataEndianness = llvm::endianness::little; public: InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion) diff --git a/llvm/lib/DebugInfo/BTF/BTFParser.cpp b/llvm/lib/DebugInfo/BTF/BTFParser.cpp index d1ed5d097e14..4bc0c94340b4 100644 --- a/llvm/lib/DebugInfo/BTF/BTFParser.cpp +++ b/llvm/lib/DebugInfo/BTF/BTFParser.cpp @@ -203,13 +203,12 @@ const BTF::CommonType VoidTypeInst = {0, BTF::BTF_KIND_UNKN << 24, {0}}; // `BTFParser::Types` vector and the process stops. Error BTFParser::parseTypesInfo(ParseContext &Ctx, uint64_t TypesInfoStart, StringRef RawData) { - using support::big; - using support::little; using support::endian::byte_swap; TypesBuffer = OwningArrayRef(arrayRefFromStringRef(RawData)); // Switch endianness if necessary. - endianness Endianness = Ctx.Obj.isLittleEndian() ? little : big; + endianness Endianness = Ctx.Obj.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big; uint32_t *TypesBuffer32 = (uint32_t *)TypesBuffer.data(); for (uint64_t I = 0; I < TypesBuffer.size() / 4; ++I) TypesBuffer32[I] = byte_swap(TypesBuffer32[I], Endianness); diff --git a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp index 460f95d96a29..2343386e031c 100644 --- a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp +++ b/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp @@ -69,13 +69,13 @@ void LazyRandomTypeCollection::reset(BinaryStreamReader &Reader, } void LazyRandomTypeCollection::reset(StringRef Data, uint32_t RecordCountHint) { - BinaryStreamReader Reader(Data, support::little); + BinaryStreamReader Reader(Data, llvm::endianness::little); reset(Reader, RecordCountHint); } void LazyRandomTypeCollection::reset(ArrayRef Data, uint32_t RecordCountHint) { - BinaryStreamReader Reader(Data, support::little); + BinaryStreamReader Reader(Data, llvm::endianness::little); reset(Reader, RecordCountHint); } diff --git a/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp index cf0c877fdbf8..25725853fb39 100644 --- a/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp +++ b/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp @@ -34,7 +34,7 @@ SimpleTypeSerializer::~SimpleTypeSerializer() = default; template ArrayRef SimpleTypeSerializer::serialize(T &Record) { - BinaryStreamWriter Writer(ScratchBuffer, support::little); + BinaryStreamWriter Writer(ScratchBuffer, llvm::endianness::little); TypeRecordMapping Mapping(Writer); // Write the record prefix first with a dummy length but real kind. diff --git a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp index 5fb8d497b957..e52f3e56f115 100644 --- a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -20,8 +20,8 @@ using namespace llvm::codeview; SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator, CodeViewContainer Container) - : Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream), - Mapping(Writer, Container) {} + : Storage(Allocator), Stream(RecordBuffer, llvm::endianness::little), + Writer(Stream), Mapping(Writer, Container) {} Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) { assert(!CurrentSymbol && "Already in a symbol mapping!"); diff --git a/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp index e903a37a8c8e..59e2a85c4d4c 100644 --- a/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -470,7 +470,7 @@ static void resolveTypeIndexReferences(ArrayRef RecordData, RecordData = RecordData.drop_front(sizeof(RecordPrefix)); - BinaryStreamReader Reader(RecordData, support::little); + BinaryStreamReader Reader(RecordData, llvm::endianness::little); for (const auto &Ref : Refs) { Reader.setOffset(Ref.Offset); FixedStreamArray Run; diff --git a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp index 7e6eec71d1ad..1fe90ef579a3 100644 --- a/llvm/lib/DebugInfo/GSYM/GsymReader.cpp +++ b/llvm/lib/DebugInfo/GSYM/GsymReader.cpp @@ -74,7 +74,8 @@ GsymReader::parse() { break; case GSYM_CIGAM: // This is a GSYM file, but not native endianness. - Endian = sys::IsBigEndianHost ? support::little : support::big; + Endian = sys::IsBigEndianHost ? llvm::endianness::little + : llvm::endianness::big; Swap.reset(new SwappedData); break; default: @@ -82,7 +83,7 @@ GsymReader::parse() { "not a GSYM file"); } - bool DataIsLittleEndian = HostByteOrder != support::little; + bool DataIsLittleEndian = HostByteOrder != llvm::endianness::little; // Read a correctly byte swapped header if we need to. if (Swap) { DataExtractor Data(MemBuffer->getBuffer(), DataIsLittleEndian, 4); @@ -259,10 +260,11 @@ llvm::Expected GsymReader::getFunctionInfo(uint64_t Addr) const { // Address info offsets size should have been checked in parse(). assert(*AddressIndex < AddrInfoOffsets.size()); auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex]; - assert((Endian == support::big || Endian == support::little) && - "Endian must be either big or little"); + assert( + (Endian == llvm::endianness::big || Endian == llvm::endianness::little) && + "Endian must be either big or little"); DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), - Endian == support::little, 4); + Endian == llvm::endianness::little, 4); if (std::optional OptAddr = getAddress(*AddressIndex)) { auto ExpectedFI = FunctionInfo::decode(Data, *OptAddr); if (ExpectedFI) { @@ -284,10 +286,11 @@ llvm::Expected GsymReader::lookup(uint64_t Addr) const { // Address info offsets size should have been checked in parse(). assert(*AddressIndex < AddrInfoOffsets.size()); auto AddrInfoOffset = AddrInfoOffsets[*AddressIndex]; - assert((Endian == support::big || Endian == support::little) && - "Endian must be either big or little"); + assert( + (Endian == llvm::endianness::big || Endian == llvm::endianness::little) && + "Endian must be either big or little"); DataExtractor Data(MemBuffer->getBuffer().substr(AddrInfoOffset), - Endian == support::little, 4); + Endian == llvm::endianness::little, 4); if (std::optional OptAddr = getAddress(*AddressIndex)) return FunctionInfo::lookup(Data, *this, *OptAddr, Addr); return createStringError(std::errc::invalid_argument, diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp index d14d81f3f76d..d1789fe587f3 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp @@ -349,7 +349,7 @@ Error LVCodeViewReader::initializeFileAndStringTables( if (Error E = Reader.readFixedString(Contents, SubSectionSize)) return createStringError(errorToErrorCode(std::move(E)), getFileName()); - BinaryStreamRef ST(Contents, support::little); + BinaryStreamRef ST(Contents, llvm::endianness::little); switch (DebugSubsectionKind(SubType)) { case DebugSubsectionKind::FileChecksums: if (Error E = CVFileChecksumTable.initialize(ST)) @@ -478,8 +478,8 @@ Error LVCodeViewReader::loadPrecompiledObject(PrecompRecord &Precomp, if (Magic != COFF::DEBUG_SECTION_MAGIC) return errorCodeToError(object_error::parse_failed); - ReaderPrecomp = - std::make_unique(*DataOrErr, support::little); + ReaderPrecomp = std::make_unique( + *DataOrErr, llvm::endianness::little); cantFail( ReaderPrecomp->readArray(CVTypesPrecomp, ReaderPrecomp->getLength())); @@ -550,7 +550,7 @@ Error LVCodeViewReader::traverseTypeSection(StringRef SectionName, // Get the first type record. It will indicate if this object uses a type // server (/Zi) or a PCH file (/Yu). CVTypeArray CVTypes; - BinaryStreamReader Reader(*DataOrErr, support::little); + BinaryStreamReader Reader(*DataOrErr, llvm::endianness::little); cantFail(Reader.readArray(CVTypes, Reader.getLength())); CVTypeArray::Iterator FirstType = CVTypes.begin(); @@ -664,7 +664,7 @@ Error LVCodeViewReader::traverseSymbolSection(StringRef SectionName, if (Magic != COFF::DEBUG_SECTION_MAGIC) return createStringError(object_error::parse_failed, getFileName()); - BinaryStreamReader FSReader(Data, support::little); + BinaryStreamReader FSReader(Data, llvm::endianness::little); if (Error Err = initializeFileAndStringTables(FSReader)) return Err; @@ -752,7 +752,8 @@ Error LVCodeViewReader::traverseSymbolSection(StringRef SectionName, W.printString("Symbol Name", SymbolName); }); - BinaryStreamReader Reader(FunctionLineTables[SymbolName], support::little); + BinaryStreamReader Reader(FunctionLineTables[SymbolName], + llvm::endianness::little); DebugLinesSubsectionRef Lines; if (Error E = Lines.initialize(Reader)) diff --git a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp index 85c22483fa90..cddee3e1c273 100644 --- a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp @@ -107,7 +107,7 @@ static inline bool isCodeViewDebugSubsection(object::SectionRef Section, return false; } - Reader = BinaryStreamReader(*ContentsOrErr, support::little); + Reader = BinaryStreamReader(*ContentsOrErr, llvm::endianness::little); uint32_t Magic; if (Reader.bytesRemaining() < sizeof(uint32_t)) return false; diff --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp index 0496847a0c26..1fd2a33d3f11 100644 --- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp @@ -45,7 +45,8 @@ COFFLinkGraphBuilder::getPointerSize(const object::COFFObjectFile &Obj) { llvm::endianness COFFLinkGraphBuilder::getEndianness(const object::COFFObjectFile &Obj) { - return Obj.isLittleEndian() ? support::little : support::big; + return Obj.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big; } uint64_t COFFLinkGraphBuilder::getSectionSize(const object::COFFObjectFile &Obj, diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp index 525ece4eea9c..23946c7de9ad 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp @@ -265,7 +265,7 @@ createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) { case Triple::arm: case Triple::thumb: { auto &ELFFile = cast>(**ELFObj).getELFFile(); - return ELFLinkGraphBuilder_aarch32( + return ELFLinkGraphBuilder_aarch32( (*ELFObj)->getFileName(), ELFFile, TT, std::move(*Features), ArmCfg) .buildGraph(); @@ -273,7 +273,7 @@ createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) { case Triple::armeb: case Triple::thumbeb: { auto &ELFFile = cast>(**ELFObj).getELFFile(); - return ELFLinkGraphBuilder_aarch32( + return ELFLinkGraphBuilder_aarch32( (*ELFObj)->getFileName(), ELFFile, TT, std::move(*Features), ArmCfg) .buildGraph(); diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp index a095059496dc..bf1d22ac9a43 100644 --- a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp @@ -506,26 +506,26 @@ void link_ELF_ppc64(std::unique_ptr G, Expected> createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer) { - return createLinkGraphFromELFObject_ppc64( + return createLinkGraphFromELFObject_ppc64( std::move(ObjectBuffer)); } Expected> createLinkGraphFromELFObject_ppc64le(MemoryBufferRef ObjectBuffer) { - return createLinkGraphFromELFObject_ppc64( + return createLinkGraphFromELFObject_ppc64( std::move(ObjectBuffer)); } /// jit-link the given object buffer, which must be a ELF ppc64 object file. void link_ELF_ppc64(std::unique_ptr G, std::unique_ptr Ctx) { - return link_ELF_ppc64(std::move(G), std::move(Ctx)); + return link_ELF_ppc64(std::move(G), std::move(Ctx)); } /// jit-link the given object buffer, which must be a ELF ppc64le object file. void link_ELF_ppc64le(std::unique_ptr G, std::unique_ptr Ctx) { - return link_ELF_ppc64(std::move(G), std::move(Ctx)); + return link_ELF_ppc64(std::move(G), std::move(Ctx)); } } // end namespace llvm::jitlink diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp index 57e17aa78fed..474a0b5160bc 100644 --- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp @@ -155,8 +155,8 @@ void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr, "__---.finalize", "__R--.finalize", "__-W-.finalize", "__RW-.finalize", "__--X.finalize", "__R-X.finalize", "__-WX.finalize", "__RWX.finalize"}; - auto G = - std::make_unique("", Triple(), 0, support::native, nullptr); + auto G = std::make_unique("", Triple(), 0, + llvm::endianness::native, nullptr); orc::AllocGroupSmallMap ContentBlocks; orc::ExecutorAddr NextAddr(0x100000); diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp index 8afedd016f9a..bcbc429cae12 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp @@ -108,7 +108,8 @@ MachOLinkGraphBuilder::getPointerSize(const object::MachOObjectFile &Obj) { llvm::endianness MachOLinkGraphBuilder::getEndianness(const object::MachOObjectFile &Obj) { - return Obj.isLittleEndian() ? support::little : support::big; + return Obj.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big; } Section &MachOLinkGraphBuilder::getCommonSection() { diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp index febd2e73aa17..b541db3672f4 100644 --- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp @@ -113,8 +113,9 @@ llvm::orc::createDWARFContext(LinkGraph &G) { std::make_unique(std::move(SecData)); } } - auto Ctx = DWARFContext::create(DWARFSectionData, G.getPointerSize(), - G.getEndianness() == support::little); + auto Ctx = + DWARFContext::create(DWARFSectionData, G.getPointerSize(), + G.getEndianness() == llvm::endianness::little); dumpDWARFContext(*Ctx); return std::make_pair(std::move(Ctx), std::move(DWARFSectionData)); } diff --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp index 6959b068aa6e..cdc1158ce1c4 100644 --- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp @@ -374,7 +374,7 @@ void GDBJITDebugInfoRegistrationPlugin::modifyPassConfigForMachO( case Triple::aarch64: // Supported, continue. assert(LG.getPointerSize() == 8 && "Graph has incorrect pointer size"); - assert(LG.getEndianness() == support::little && + assert(LG.getEndianness() == llvm::endianness::little && "Graph has incorrect endianness"); break; default: @@ -384,7 +384,7 @@ void GDBJITDebugInfoRegistrationPlugin::modifyPassConfigForMachO( << "MachO graph " << LG.getName() << "(triple = " << LG.getTargetTriple().str() << ", pointer size = " << LG.getPointerSize() << ", endianness = " - << (LG.getEndianness() == support::big ? "big" : "little") + << (LG.getEndianness() == llvm::endianness::big ? "big" : "little") << ")\n"; }); return; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index d439b1b4ebfb..9fdabf310d6e 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -35,7 +35,8 @@ static void or32AArch64Imm(void *L, uint64_t Imm) { } template static void write(bool isBE, void *P, T V) { - isBE ? write(P, V) : write(P, V); + isBE ? write(P, V) + : write(P, V); } static void write32AArch64Addr(void *L, uint64_t Imm) { diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h index 1ae3ac179787..73e2b365f109 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h @@ -318,18 +318,24 @@ protected: std::string ErrorStr; void writeInt16BE(uint8_t *Addr, uint16_t Value) { - llvm::support::endian::write( - Addr, Value, IsTargetLittleEndian ? support::little : support::big); + llvm::support::endian::write(Addr, Value, + IsTargetLittleEndian + ? llvm::endianness::little + : llvm::endianness::big); } void writeInt32BE(uint8_t *Addr, uint32_t Value) { - llvm::support::endian::write( - Addr, Value, IsTargetLittleEndian ? support::little : support::big); + llvm::support::endian::write(Addr, Value, + IsTargetLittleEndian + ? llvm::endianness::little + : llvm::endianness::big); } void writeInt64BE(uint8_t *Addr, uint64_t Value) { - llvm::support::endian::write( - Addr, Value, IsTargetLittleEndian ? support::little : support::big); + llvm::support::endian::write(Addr, Value, + IsTargetLittleEndian + ? llvm::endianness::little + : llvm::endianness::big); } virtual void setMipsABI(const ObjectFile &Obj) { diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp index 49ed27e265d4..c1256563d0d6 100644 --- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp +++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp @@ -57,7 +57,7 @@ static void initELFHeader(typename ELFT::Ehdr &ElfHeader, uint16_t Machine) { ElfHeader.e_ident[EI_MAG2] = ElfMagic[EI_MAG2]; ElfHeader.e_ident[EI_MAG3] = ElfMagic[EI_MAG3]; ElfHeader.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32; - bool IsLittleEndian = ELFT::TargetEndianness == support::little; + bool IsLittleEndian = ELFT::TargetEndianness == llvm::endianness::little; ElfHeader.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB; ElfHeader.e_ident[EI_VERSION] = EV_CURRENT; ElfHeader.e_ident[EI_OSABI] = ELFOSABI_NONE; diff --git a/llvm/lib/MC/DXContainerPSVInfo.cpp b/llvm/lib/MC/DXContainerPSVInfo.cpp index bdc6f79a68c0..48182fcd31df 100644 --- a/llvm/lib/MC/DXContainerPSVInfo.cpp +++ b/llvm/lib/MC/DXContainerPSVInfo.cpp @@ -87,15 +87,15 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { } // Write the size of the info. - support::endian::write(OS, InfoSize, support::little); + support::endian::write(OS, InfoSize, llvm::endianness::little); // Write the info itself. OS.write(reinterpret_cast(&BaseData), InfoSize); uint32_t ResourceCount = static_cast(Resources.size()); - support::endian::write(OS, ResourceCount, support::little); + support::endian::write(OS, ResourceCount, llvm::endianness::little); if (ResourceCount > 0) - support::endian::write(OS, BindingSize, support::little); + support::endian::write(OS, BindingSize, llvm::endianness::little); for (const auto &Res : Resources) OS.write(reinterpret_cast(&Res), BindingSize); @@ -126,22 +126,22 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { } support::endian::write(OS, static_cast(StrTabBuilder.getSize()), - support::little); + llvm::endianness::little); // Write the string table. StrTabBuilder.write(OS); // Write the index table size, then table. support::endian::write(OS, static_cast(IndexBuffer.size()), - support::little); + llvm::endianness::little); for (auto I : IndexBuffer) - support::endian::write(OS, I, support::little); + support::endian::write(OS, I, llvm::endianness::little); if (SignatureElements.size() > 0) { // write the size of the signature elements. support::endian::write(OS, static_cast(sizeof(v0::SignatureElement)), - support::little); + llvm::endianness::little); // write the signature elements. OS.write(reinterpret_cast(&SignatureElements[0]), @@ -150,16 +150,16 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { for (const auto &MaskVector : OutputVectorMasks) support::endian::write_array(OS, ArrayRef(MaskVector), - support::little); + llvm::endianness::little); support::endian::write_array(OS, ArrayRef(PatchOrPrimMasks), - support::little); + llvm::endianness::little); for (const auto &MaskVector : InputOutputMap) support::endian::write_array(OS, ArrayRef(MaskVector), - support::little); + llvm::endianness::little); support::endian::write_array(OS, ArrayRef(InputPatchMap), - support::little); + llvm::endianness::little); support::endian::write_array(OS, ArrayRef(PatchOutputMap), - support::little); + llvm::endianness::little); } void Signature::write(raw_ostream &OS) { diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 816aa2132109..8490fefe7ff5 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -152,8 +152,9 @@ struct ELFWriter { public: ELFWriter(ELFObjectWriter &OWriter, raw_pwrite_stream &OS, bool IsLittleEndian, DwoMode Mode) - : OWriter(OWriter), - W(OS, IsLittleEndian ? support::little : support::big), Mode(Mode) {} + : OWriter(OWriter), W(OS, IsLittleEndian ? llvm::endianness::little + : llvm::endianness::big), + Mode(Mode) {} void WriteWord(uint64_t Word) { if (is64Bit()) @@ -406,8 +407,8 @@ void ELFWriter::writeHeader(const MCAssembler &Asm) { W.OS << char(is64Bit() ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS] // e_ident[EI_DATA] - W.OS << char(W.Endian == support::little ? ELF::ELFDATA2LSB - : ELF::ELFDATA2MSB); + W.OS << char(W.Endian == llvm::endianness::little ? ELF::ELFDATA2LSB + : ELF::ELFDATA2MSB); W.OS << char(ELF::EV_CURRENT); // e_ident[EI_VERSION] // e_ident[EI_OSABI] diff --git a/llvm/lib/MC/GOFFObjectWriter.cpp b/llvm/lib/MC/GOFFObjectWriter.cpp index 33244cbf88d9..addeb6db9596 100644 --- a/llvm/lib/MC/GOFFObjectWriter.cpp +++ b/llvm/lib/MC/GOFFObjectWriter.cpp @@ -137,7 +137,8 @@ public: // Support for endian-specific data. template void writebe(value_type Value) { - Value = support::endian::byte_swap(Value, support::big); + Value = + support::endian::byte_swap(Value, llvm::endianness::big); write(reinterpret_cast(&Value), sizeof(value_type)); } }; diff --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp index 0e6fee8643df..4b1064a07e83 100644 --- a/llvm/lib/MC/MCAsmBackend.cpp +++ b/llvm/lib/MC/MCAsmBackend.cpp @@ -33,11 +33,11 @@ MCAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const { auto TW = createObjectTargetWriter(); switch (TW->getFormat()) { case Triple::ELF: - return createELFObjectWriter(cast(std::move(TW)), OS, - Endian == support::little); + return createELFObjectWriter(cast(std::move(TW)), + OS, Endian == llvm::endianness::little); case Triple::MachO: return createMachObjectWriter(cast(std::move(TW)), - OS, Endian == support::little); + OS, Endian == llvm::endianness::little); case Triple::COFF: return createWinCOFFObjectWriter( cast(std::move(TW)), OS); @@ -72,7 +72,7 @@ MCAsmBackend::createDwoObjectWriter(raw_pwrite_stream &OS, case Triple::ELF: return createELFDwoObjectWriter( cast(std::move(TW)), OS, DwoOS, - Endian == support::little); + Endian == llvm::endianness::little); case Triple::Wasm: return createWasmDwoObjectWriter( cast(std::move(TW)), OS, DwoOS); diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index c71f0250a31d..55558820b670 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -606,7 +606,7 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, // Duplicate V into Data as byte vector to reduce number of // writes done. As such, do endian conversion here. for (unsigned I = 0; I != VSize; ++I) { - unsigned index = Endian == support::little ? I : (VSize - I - 1); + unsigned index = Endian == llvm::endianness::little ? I : (VSize - I - 1); Data[I] = uint8_t(V >> (index * 8)); } for (unsigned I = VSize; I < MaxChunkSize; ++I) diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index f09997ebdf10..d234ce110918 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -654,7 +654,7 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout, } unsigned NumGaps = J - I - 1; - support::endian::Writer LEWriter(OS, support::little); + support::endian::Writer LEWriter(OS, llvm::endianness::little); unsigned Bias = 0; // We must split the range into chunks of MaxDefRange, this is a fundamental diff --git a/llvm/lib/MC/MCDXContainerWriter.cpp b/llvm/lib/MC/MCDXContainerWriter.cpp index 028bfe6e79a1..0580dc7e4282 100644 --- a/llvm/lib/MC/MCDXContainerWriter.cpp +++ b/llvm/lib/MC/MCDXContainerWriter.cpp @@ -30,7 +30,7 @@ class DXContainerObjectWriter : public MCObjectWriter { public: DXContainerObjectWriter(std::unique_ptr MOTW, raw_pwrite_stream &OS) - : W(OS, support::little), TargetObjectWriter(std::move(MOTW)) {} + : W(OS, llvm::endianness::little), TargetObjectWriter(std::move(MOTW)) {} ~DXContainerObjectWriter() override {} diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 189fe2b23842..7925fba876f8 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -1940,8 +1940,9 @@ void MCDwarfFrameEmitter::encodeAdvanceLoc(MCContext &Context, if (AddrDelta == 0) return; - llvm::endianness E = - Context.getAsmInfo()->isLittleEndian() ? support::little : support::big; + llvm::endianness E = Context.getAsmInfo()->isLittleEndian() + ? llvm::endianness::little + : llvm::endianness::big; if (isUIntN(6, AddrDelta)) { uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta; diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 7f9c0c3b0b8d..2371cb238441 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -137,7 +137,7 @@ void MCStreamer::emitIntValue(uint64_t Value, unsigned Size) { "Invalid size"); const bool IsLittleEndian = Context.getAsmInfo()->isLittleEndian(); uint64_t Swapped = support::endian::byte_swap( - Value, IsLittleEndian ? support::little : support::big); + Value, IsLittleEndian ? llvm::endianness::little : llvm::endianness::big); unsigned Index = IsLittleEndian ? 0 : 8 - Size; emitBytes(StringRef(reinterpret_cast(&Swapped) + Index, Size)); } diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 04097dfe2e9f..d17e6e125d87 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -630,7 +630,7 @@ void MachObjectWriter::computeSymbolTable( // Set the Index and the IsExtern bit. unsigned Index = Rel.Sym->getIndex(); assert(isInt<24>(Index)); - if (W.Endian == support::little) + if (W.Endian == llvm::endianness::little) Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27); else Rel.MRE.r_word1 = (Rel.MRE.r_word1 & 0xff) | Index << 8 | (1 << 4); diff --git a/llvm/lib/MC/SPIRVObjectWriter.cpp b/llvm/lib/MC/SPIRVObjectWriter.cpp index cb49f5eeca8d..39856e96e9be 100644 --- a/llvm/lib/MC/SPIRVObjectWriter.cpp +++ b/llvm/lib/MC/SPIRVObjectWriter.cpp @@ -24,7 +24,7 @@ class SPIRVObjectWriter : public MCObjectWriter { public: SPIRVObjectWriter(std::unique_ptr MOTW, raw_pwrite_stream &OS) - : W(OS, support::little), TargetObjectWriter(std::move(MOTW)) {} + : W(OS, llvm::endianness::little), TargetObjectWriter(std::move(MOTW)) {} ~SPIRVObjectWriter() override {} diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index bb8c68410a6b..b99df3837cc2 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1438,12 +1438,12 @@ void WasmObjectWriter::prepareImports( uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) { - support::endian::Writer MainWriter(*OS, support::little); + support::endian::Writer MainWriter(*OS, llvm::endianness::little); W = &MainWriter; if (IsSplitDwarf) { uint64_t TotalSize = writeOneObject(Asm, Layout, DwoMode::NonDwoOnly); assert(DwoOS); - support::endian::Writer DwoWriter(*DwoOS, support::little); + support::endian::Writer DwoWriter(*DwoOS, llvm::endianness::little); W = &DwoWriter; return TotalSize + writeOneObject(Asm, Layout, DwoMode::DwoOnly); } else { diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index fd8af1f8cdb8..1f73cb9884e0 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -260,7 +260,7 @@ void COFFSymbol::set_name_offset(uint32_t Offset) { WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter, raw_pwrite_stream &OS, DwoMode Mode) - : OWriter(OWriter), W(OS, support::little), Mode(Mode) { + : OWriter(OWriter), W(OS, llvm::endianness::little), Mode(Mode) { Header.Machine = OWriter.TargetObjectWriter->getMachine(); // Some relocations on ARM64 (the 21 bit ADRP relocations) have a slightly // limited range for the immediate offset (+/- 1 MB); create extra offset diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp index f1cce9b8c94d..343e2fc877bc 100644 --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -448,7 +448,7 @@ public: XCOFFObjectWriter::XCOFFObjectWriter( std::unique_ptr MOTW, raw_pwrite_stream &OS) - : W(OS, support::big), TargetObjectWriter(std::move(MOTW)), + : W(OS, llvm::endianness::big), TargetObjectWriter(std::move(MOTW)), Strings(StringTableBuilder::XCOFF), Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false, CsectGroups{&ProgramCodeCsects, &ReadOnlyCsects}), diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp index eaeef11b127e..0a54d3798d8b 100644 --- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp @@ -1987,8 +1987,9 @@ template void ELFWriter::writeEhdr() { Ehdr.e_ident[EI_MAG2] = 'L'; Ehdr.e_ident[EI_MAG3] = 'F'; Ehdr.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32; - Ehdr.e_ident[EI_DATA] = - ELFT::TargetEndianness == support::big ? ELFDATA2MSB : ELFDATA2LSB; + Ehdr.e_ident[EI_DATA] = ELFT::TargetEndianness == llvm::endianness::big + ? ELFDATA2MSB + : ELFDATA2LSB; Ehdr.e_ident[EI_VERSION] = EV_CURRENT; Ehdr.e_ident[EI_OSABI] = Obj.OSABI; Ehdr.e_ident[EI_ABIVERSION] = Obj.ABIVersion; @@ -2695,11 +2696,11 @@ uint64_t IHexWriter::writeEntryPointRecord(uint8_t *Buf) { if (Obj.Entry <= 0xFFFFFU) { Data[0] = ((Obj.Entry & 0xF0000U) >> 12) & 0xFF; support::endian::write(&Data[2], static_cast(Obj.Entry), - support::big); + llvm::endianness::big); HexData = IHexRecord::getLine(IHexRecord::StartAddr80x86, 0, Data); } else { support::endian::write(Data, static_cast(Obj.Entry), - support::big); + llvm::endianness::big); HexData = IHexRecord::getLine(IHexRecord::StartAddr, 0, Data); } memcpy(Buf, HexData.data(), HexData.size()); diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp index bf9a1ce1de88..fdd87824e229 100644 --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -1421,7 +1421,7 @@ BigArchive::BigArchive(MemoryBufferRef Source, Error &Err) // 64-bit global symbol tables, we need to merge them into a single table. raw_string_ostream Out(MergedGlobalSymtabBuf); uint64_t SymNum = SymtabInfos[0].SymNum + SymtabInfos[1].SymNum; - write(Out, SymNum, support::big); + write(Out, SymNum, llvm::endianness::big); // Merge symbol offset. Out << SymtabInfos[0].SymbolOffsetTable; Out << SymtabInfos[1].SymbolOffsetTable; diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp index a67c657b48ba..2f70c9edd13e 100644 --- a/llvm/lib/Object/ArchiveWriter.cpp +++ b/llvm/lib/Object/ArchiveWriter.cpp @@ -203,11 +203,12 @@ static bool isBSDLike(object::Archive::Kind Kind) { template static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val) { support::endian::write(Out, Val, - isBSDLike(Kind) ? support::little : support::big); + isBSDLike(Kind) ? llvm::endianness::little + : llvm::endianness::big); } template static void printLE(raw_ostream &Out, T Val) { - support::endian::write(Out, Val, support::little); + support::endian::write(Out, Val, llvm::endianness::little); } static void printRestOfMemberHeader( diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 08eb0d034c53..574f7a7cf1f4 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -1907,7 +1907,7 @@ Error ResourceSectionRef::load(const COFFObjectFile *O, const SectionRef &S) { Expected Contents = Section.getContents(); if (!Contents) return Contents.takeError(); - BBS = BinaryByteStream(*Contents, support::little); + BBS = BinaryByteStream(*Contents, llvm::endianness::little); const coff_section *COFFSect = Obj->getCOFFSection(Section); ArrayRef OrigRelocs = Obj->getRelocations(COFFSect); Relocs.reserve(OrigRelocs.size()); diff --git a/llvm/lib/Object/WindowsResource.cpp b/llvm/lib/Object/WindowsResource.cpp index 0764dc8f7523..61ca49e290da 100644 --- a/llvm/lib/Object/WindowsResource.cpp +++ b/llvm/lib/Object/WindowsResource.cpp @@ -50,7 +50,7 @@ WindowsResource::WindowsResource(MemoryBufferRef Source) : Binary(Binary::ID_WinRes, Source) { size_t LeadingSize = WIN_RES_MAGIC_SIZE + WIN_RES_NULL_ENTRY_SIZE; BBS = BinaryByteStream(Data.getBuffer().drop_front(LeadingSize), - support::little); + llvm::endianness::little); } // static diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp index 015c293fba46..7088223b9b67 100644 --- a/llvm/lib/ObjectYAML/COFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp @@ -182,7 +182,7 @@ toDebugS(ArrayRef Subsections, } uint8_t *Buffer = Allocator.Allocate(Size); MutableArrayRef Output(Buffer, Size); - BinaryStreamWriter Writer(Output, support::little); + BinaryStreamWriter Writer(Output, llvm::endianness::little); Err(Writer.writeInteger(COFF::DEBUG_SECTION_MAGIC)); for (const auto &B : Builders) { @@ -314,7 +314,8 @@ template raw_ostream &operator<<(raw_ostream &OS, const binary_le_impl &BLE) { char Buffer[sizeof(BLE.Value)]; - support::endian::write(Buffer, BLE.Value); + support::endian::write(Buffer, + BLE.Value); OS.write(Buffer, sizeof(BLE.Value)); return OS; } diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp index 02f053bb0e0f..662eb63f835d 100644 --- a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp +++ b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp @@ -900,7 +900,7 @@ YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC, std::vector llvm::CodeViewYAML::fromDebugS(ArrayRef Data, const StringsAndChecksumsRef &SC) { - BinaryStreamReader Reader(Data, support::little); + BinaryStreamReader Reader(Data, llvm::endianness::little); uint32_t Magic; ExitOnError Err("Invalid .debug$S section!"); diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp index e4e2b2a6d21a..99689786a13c 100644 --- a/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp +++ b/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp @@ -784,7 +784,7 @@ std::vector llvm::CodeViewYAML::fromDebugT(ArrayRef DebugTorP, StringRef SectionName) { ExitOnError Err("Invalid " + std::string(SectionName) + " section!"); - BinaryStreamReader Reader(DebugTorP, support::little); + BinaryStreamReader Reader(DebugTorP, llvm::endianness::little); CVTypeArray Types; uint32_t Magic; @@ -813,7 +813,7 @@ ArrayRef llvm::CodeViewYAML::toDebugT(ArrayRef Leafs, } uint8_t *ResultBuffer = Alloc.Allocate(Size); MutableArrayRef Output(ResultBuffer, Size); - BinaryStreamWriter Writer(Output, support::little); + BinaryStreamWriter Writer(Output, llvm::endianness::little); ExitOnError Err("Error writing type record to " + std::string(SectionName) + " section"); Err(Writer.writeInteger(COFF::DEBUG_SECTION_MAGIC)); diff --git a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp index 7ad878f04c88..ccf768c06aeb 100644 --- a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp +++ b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp @@ -33,7 +33,7 @@ constexpr uint32_t MaxRawDataSize = UINT32_MAX; class XCOFFWriter { public: XCOFFWriter(XCOFFYAML::Object &Obj, raw_ostream &OS, yaml::ErrorHandler EH) - : Obj(Obj), W(OS, support::big), ErrHandler(EH), + : Obj(Obj), W(OS, llvm::endianness::big), ErrHandler(EH), StrTblBuilder(StringTableBuilder::XCOFF) { Is64Bit = Obj.Header.Magic == (llvm::yaml::Hex16)XCOFF::XCOFF64; } diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index efcc24513056..2873e06266e4 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -49,9 +49,9 @@ namespace llvm { class ProfOStream { public: ProfOStream(raw_fd_ostream &FD) - : IsFDOStream(true), OS(FD), LE(FD, support::little) {} + : IsFDOStream(true), OS(FD), LE(FD, llvm::endianness::little) {} ProfOStream(raw_string_ostream &STR) - : IsFDOStream(false), OS(STR), LE(STR, support::little) {} + : IsFDOStream(false), OS(STR), LE(STR, llvm::endianness::little) {} uint64_t tell() { return OS.tell(); } void write(uint64_t V) { LE.write(V); } @@ -106,7 +106,7 @@ public: using hash_value_type = uint64_t; using offset_type = uint64_t; - llvm::endianness ValueProfDataEndianness = support::little; + llvm::endianness ValueProfDataEndianness = llvm::endianness::little; InstrProfSummaryBuilder *SummaryBuilder; InstrProfSummaryBuilder *CSSummaryBuilder; diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp index 74990238d379..c11cd4dfa6a5 100644 --- a/llvm/lib/ProfileData/SampleProfWriter.cpp +++ b/llvm/lib/ProfileData/SampleProfWriter.cpp @@ -353,7 +353,7 @@ std::error_code SampleProfileWriterExtBinaryBase::writeNameTable() { // retrieve the name using the name index without having to read the // whole name table. encodeULEB128(NameTable.size(), OS); - support::endian::Writer Writer(OS, support::little); + support::endian::Writer Writer(OS, llvm::endianness::little); for (auto N : V) Writer.write(hashFuncName(N)); return sampleprof_error::success; @@ -394,7 +394,7 @@ std::error_code SampleProfileWriterExtBinaryBase::writeCSNameTableSection() { auto &OS = *OutputStream; encodeULEB128(OrderedContexts.size(), OS); - support::endian::Writer Writer(OS, support::little); + support::endian::Writer Writer(OS, llvm::endianness::little); for (auto Context : OrderedContexts) { auto Frames = Context.getContextFrames(); encodeULEB128(Frames.size(), OS); @@ -741,7 +741,7 @@ void SampleProfileWriterExtBinaryBase::setToCompressSection(SecType Type) { } void SampleProfileWriterExtBinaryBase::allocSecHdrTable() { - support::endian::Writer Writer(*OutputStream, support::little); + support::endian::Writer Writer(*OutputStream, llvm::endianness::little); Writer.write(static_cast(SectionHdrLayout.size())); SecHdrTableOffset = OutputStream->tell(); @@ -771,7 +771,8 @@ std::error_code SampleProfileWriterExtBinaryBase::writeSecHdrTable() { // but it needs to be read before SecLBRProfile (the order in // SectionHdrLayout). So we use IndexMap above to switch the order. support::endian::SeekableWriter Writer( - static_cast(*OutputStream), support::little); + static_cast(*OutputStream), + llvm::endianness::little); for (uint32_t LayoutIdx = 0; LayoutIdx < SectionHdrLayout.size(); LayoutIdx++) { assert(IndexMap[LayoutIdx] < SecHdrTable.size() && diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp index 8a7d00aa1dc0..947adbba10a2 100644 --- a/llvm/lib/Remarks/YAMLRemarkParser.cpp +++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp @@ -75,7 +75,7 @@ static Expected parseVersion(StringRef &Buf) { "Expecting version number."); uint64_t Version = - support::endian::read(Buf.data()); + support::endian::read(Buf.data()); if (Version != remarks::CurrentRemarkVersion) return createStringError(std::errc::illegal_byte_sequence, "Mismatching remark version. Got %" PRId64 @@ -90,7 +90,7 @@ static Expected parseStrTabSize(StringRef &Buf) { return createStringError(std::errc::illegal_byte_sequence, "Expecting string table size."); uint64_t StrTabSize = - support::endian::read(Buf.data()); + support::endian::read(Buf.data()); Buf = Buf.drop_front(sizeof(uint64_t)); return StrTabSize; } diff --git a/llvm/lib/Support/CodeGenCoverage.cpp b/llvm/lib/Support/CodeGenCoverage.cpp index d5ab77b9c66f..0df45b4ff2ba 100644 --- a/llvm/lib/Support/CodeGenCoverage.cpp +++ b/llvm/lib/Support/CodeGenCoverage.cpp @@ -58,7 +58,8 @@ bool CodeGenCoverage::parse(MemoryBuffer &Buffer, StringRef BackendName) { if (std::distance(CurPtr, Buffer.getBufferEnd()) < 8) return false; // Data is invalid. Not enough bytes for another rule id. - uint64_t RuleID = support::endian::read64(CurPtr, support::native); + uint64_t RuleID = + support::endian::read64(CurPtr, llvm::endianness::native); CurPtr += 8; // ~0ull terminates the rule id list. diff --git a/llvm/lib/Support/ELFAttributeParser.cpp b/llvm/lib/Support/ELFAttributeParser.cpp index 3deaab877b38..d3100c9ebb21 100644 --- a/llvm/lib/Support/ELFAttributeParser.cpp +++ b/llvm/lib/Support/ELFAttributeParser.cpp @@ -191,7 +191,7 @@ Error ELFAttributeParser::parseSubsection(uint32_t length) { Error ELFAttributeParser::parse(ArrayRef section, llvm::endianness endian) { unsigned sectionNumber = 0; - de = DataExtractor(section, endian == support::little, 0); + de = DataExtractor(section, endian == llvm::endianness::little, 0); // For early returns, we have more specific errors, consume the Error in // cursor. diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp index be248125d826..c7ff14c252f1 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -40,7 +40,8 @@ protected: public: AArch64AsmBackend(const Target &T, const Triple &TT, bool IsLittleEndian) - : MCAsmBackend(IsLittleEndian ? support::little : support::big), + : MCAsmBackend(IsLittleEndian ? llvm::endianness::little + : llvm::endianness::big), TheTriple(TT) {} unsigned getNumFixupKinds() const override { @@ -360,7 +361,7 @@ AArch64AsmBackend::getFixupKind(StringRef Name) const { /// getFixupKindContainereSizeInBytes - The number of bytes of the /// container involved in big endian or 0 if the item is little endian unsigned AArch64AsmBackend::getFixupKindContainereSizeInBytes(unsigned Kind) const { - if (Endian == support::little) + if (Endian == llvm::endianness::little) return 0; switch (Kind) { diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp index 727f79909811..dbc4323a860f 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp @@ -685,7 +685,7 @@ void AArch64MCCodeEmitter::encodeInstruction(const MCInst &MI, } uint64_t Binary = getBinaryCodeForInstr(MI, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); ++MCNumEmitted; // Keep track of the # of mi's emitted. } diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp index 65efb553d9d6..e18c04e62314 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp @@ -28,7 +28,7 @@ namespace { class AMDGPUAsmBackend : public MCAsmBackend { public: - AMDGPUAsmBackend(const Target &T) : MCAsmBackend(support::little) {} + AMDGPUAsmBackend(const Target &T) : MCAsmBackend(llvm::endianness::little) {} unsigned getNumFixupKinds() const override { return AMDGPU::NumTargetFixupKinds; }; diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp index bbbfbe4faa0f..6c539df7677e 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp @@ -142,11 +142,11 @@ void R600MCCodeEmitter::encodeInstruction(const MCInst &MI, } void R600MCCodeEmitter::emit(uint32_t Value, SmallVectorImpl &CB) const { - support::endian::write(CB, Value, support::little); + support::endian::write(CB, Value, llvm::endianness::little); } void R600MCCodeEmitter::emit(uint64_t Value, SmallVectorImpl &CB) const { - support::endian::write(CB, Value, support::little); + support::endian::write(CB, Value, llvm::endianness::little); } unsigned R600MCCodeEmitter::getHWReg(unsigned RegNo) const { diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 34ff0732c9fd..9230ff7baeda 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -196,8 +196,9 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const { assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && "Invalid kind!"); - return (Endian == support::little ? InfosLE - : InfosBE)[Kind - FirstTargetFixupKind]; + return (Endian == llvm::endianness::little + ? InfosLE + : InfosBE)[Kind - FirstTargetFixupKind]; } void ARMAsmBackend::handleAssemblerFlag(MCAssemblerFlag Flag) { @@ -493,7 +494,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, // inst{14-12} = Mid3; // inst{7-0} = Lo8; Value = (Hi4 << 16) | (i << 26) | (Mid3 << 12) | (Lo8); - return swapHalfWords(Value, Endian == support::little); + return swapHalfWords(Value, Endian == llvm::endianness::little); } case ARM::fixup_arm_thumb_upper_8_15: if (IsResolved || !STI->getTargetTriple().isOSBinFormatELF()) @@ -532,7 +533,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, // Same addressing mode as fixup_arm_pcrel_10, // but with 16-bit halfwords swapped. if (Kind == ARM::fixup_t2_ldst_pcrel_12) - return swapHalfWords(Value, Endian == support::little); + return swapHalfWords(Value, Endian == llvm::endianness::little); return Value; } @@ -565,7 +566,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, out |= (Value & 0x700) << 4; out |= (Value & 0x0FF); - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_arm_condbranch: @@ -602,7 +603,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, out |= (Value & 0x1FF800) << 5; // imm6 field out |= (Value & 0x0007FF); // imm11 field - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_t2_condbranch: { Value = Value - 4; @@ -620,7 +621,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, out |= (Value & 0x1F800) << 5; // imm6 field out |= (Value & 0x007FF); // imm11 field - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_arm_thumb_bl: { if (!isInt<25>(Value - 4) || @@ -656,7 +657,8 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, uint32_t FirstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10Bits); uint32_t SecondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) | (uint16_t)imm11Bits); - return joinHalfWords(FirstHalf, SecondHalf, Endian == support::little); + return joinHalfWords(FirstHalf, SecondHalf, + Endian == llvm::endianness::little); } case ARM::fixup_arm_thumb_blx: { // The value doesn't encode the low two bits (always zero) and is offset by @@ -692,7 +694,8 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, uint32_t FirstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10HBits); uint32_t SecondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) | ((uint16_t)imm10LBits) << 1); - return joinHalfWords(FirstHalf, SecondHalf, Endian == support::little); + return joinHalfWords(FirstHalf, SecondHalf, + Endian == llvm::endianness::little); } case ARM::fixup_thumb_adr_pcrel_10: case ARM::fixup_arm_thumb_cp: @@ -783,7 +786,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, // Same addressing mode as fixup_arm_pcrel_10, but with 16-bit halfwords // swapped. if (Kind == ARM::fixup_t2_pcrel_10) - return swapHalfWords(Value, Endian == support::little); + return swapHalfWords(Value, Endian == llvm::endianness::little); return Value; } @@ -814,7 +817,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, // Same addressing mode as fixup_arm_pcrel_9, but with 16-bit halfwords // swapped. if (Kind == ARM::fixup_t2_pcrel_9) - return swapHalfWords(Value, Endian == support::little); + return swapHalfWords(Value, Endian == llvm::endianness::little); return Value; } @@ -840,7 +843,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, EncValue |= (Value & 0x800) << 15; EncValue |= (Value & 0x700) << 4; EncValue |= (Value & 0xff); - return swapHalfWords(EncValue, Endian == support::little); + return swapHalfWords(EncValue, Endian == llvm::endianness::little); } case ARM::fixup_bf_branch: { const char *FixupDiagnostic = reasonForFixupRelaxation(Fixup, Value); @@ -849,7 +852,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, return 0; } uint32_t out = (((Value - 4) >> 1) & 0xf) << 23; - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_bf_target: case ARM::fixup_bfl_target: @@ -865,7 +868,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, out |= (((Value - 4) >> 1) & 0x1) << 11; out |= (((Value - 4) >> 1) & 0x7fe); out |= (((Value - 4) >> 1) & HighBitMask) << 5; - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_bfcsel_else_target: { // If this is a fixup of a branch future's else target then it should be a @@ -879,7 +882,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, return 0; } uint32_t out = ((Value >> 2) & 1) << 17; - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } case ARM::fixup_wls: case ARM::fixup_le: { @@ -894,7 +897,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, real_value = -real_value; out |= ((real_value >> 1) & 0x1) << 11; out |= ((real_value >> 1) & 0x7fe); - return swapHalfWords(out, Endian == support::little); + return swapHalfWords(out, Endian == llvm::endianness::little); } } } @@ -1089,7 +1092,7 @@ void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, // Used to point to big endian bytes. unsigned FullSizeBytes; - if (Endian == support::big) { + if (Endian == llvm::endianness::big) { FullSizeBytes = getFixupKindContainerSizeBytes(Kind); assert((Offset + FullSizeBytes) <= Data.size() && "Invalid fixup size!"); assert(NumBytes <= FullSizeBytes && "Invalid fixup size!"); @@ -1099,7 +1102,8 @@ void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, // the fixup value. The Value has been "split up" into the appropriate // bitfields above. for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little ? i : (FullSizeBytes - 1 - i); + unsigned Idx = + Endian == llvm::endianness::little ? i : (FullSizeBytes - 1 - i); Data[Offset + Idx] |= uint8_t((Value >> (i * 8)) & 0xff); } } @@ -1348,12 +1352,12 @@ MCAsmBackend *llvm::createARMLEAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) { - return createARMAsmBackend(T, STI, MRI, Options, support::little); + return createARMAsmBackend(T, STI, MRI, Options, llvm::endianness::little); } MCAsmBackend *llvm::createARMBEAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) { - return createARMAsmBackend(T, STI, MRI, Options, support::big); + return createARMAsmBackend(T, STI, MRI, Options, llvm::endianness::big); } diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h index ace573c8fa96..ac0c9b101cae 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h @@ -22,7 +22,8 @@ public: const MachO::CPUSubTypeARM Subtype; ARMAsmBackendDarwin(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI) - : ARMAsmBackend(T, STI.getTargetTriple().isThumb(), support::little), + : ARMAsmBackend(T, STI.getTargetTriple().isThumb(), + llvm::endianness::little), MRI(MRI), TT(STI.getTargetTriple()), Subtype((MachO::CPUSubTypeARM)cantFail( MachO::getCPUSubType(STI.getTargetTriple()))) {} diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h index 6e447df9e4cb..86ce6efe662a 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h @@ -17,7 +17,7 @@ namespace { class ARMAsmBackendWinCOFF : public ARMAsmBackend { public: ARMAsmBackendWinCOFF(const Target &T, bool isThumb) - : ARMAsmBackend(T, isThumb, support::little) {} + : ARMAsmBackend(T, isThumb, llvm::endianness::little) {} std::unique_ptr createObjectTargetWriter() const override { return createARMWinCOFFObjectWriter(); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp index 616dd6dba754..3f37acff292b 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp @@ -1899,7 +1899,8 @@ void ARMMCCodeEmitter::encodeInstruction(const MCInst &MI, else llvm_unreachable("Unexpected instruction size!"); - auto Endian = IsLittleEndian ? support::little : support::big; + auto Endian = + IsLittleEndian ? llvm::endianness::little : llvm::endianness::big; uint32_t Binary = getBinaryCodeForInstr(MI, Fixups, STI); if (Size == 2) { support::endian::write(CB, Binary, Endian); diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h index d6a30e4dfa22..3081fe1fd58c 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.h @@ -29,7 +29,7 @@ struct MCFixupKindInfo; class AVRAsmBackend : public MCAsmBackend { public: AVRAsmBackend(Triple::OSType OSType) - : MCAsmBackend(support::little), OSType(OSType) {} + : MCAsmBackend(llvm::endianness::little), OSType(OSType) {} void adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t &Value, MCContext *Ctx = nullptr) const; diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp index 9172a52e18e4..fccc4ee9f74a 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp @@ -97,7 +97,7 @@ void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, support::endian::write(&Data[Fixup.getOffset()], Value, Endian); } else if (Fixup.getKind() == FK_PCRel_4) { Value = (uint32_t)((Value - 8) / 8); - if (Endian == support::little) { + if (Endian == llvm::endianness::little) { Data[Fixup.getOffset() + 1] = 0x10; support::endian::write32le(&Data[Fixup.getOffset() + 4], Value); } else { @@ -131,12 +131,12 @@ MCAsmBackend *llvm::createBPFAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &) { - return new BPFAsmBackend(support::little); + return new BPFAsmBackend(llvm::endianness::little); } MCAsmBackend *llvm::createBPFbeAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &) { - return new BPFAsmBackend(support::big); + return new BPFAsmBackend(llvm::endianness::big); } diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp index 420a2aad480a..b807d6904004 100644 --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp @@ -116,8 +116,8 @@ void BPFMCCodeEmitter::encodeInstruction(const MCInst &MI, const MCSubtargetInfo &STI) const { unsigned Opcode = MI.getOpcode(); raw_svector_ostream OS(CB); - support::endian::Writer OSE(OS, - IsLittleEndian ? support::little : support::big); + support::endian::Writer OSE(OS, IsLittleEndian ? llvm::endianness::little + : llvm::endianness::big); if (Opcode == BPF::LD_imm64 || Opcode == BPF::LD_pseudo) { uint64_t Value = getBinaryCodeForInstr(MI, Fixups, STI); diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp index d53d2e9e00e9..76f5a5fc831f 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.cpp @@ -223,7 +223,7 @@ void CSKYAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, // For each byte of the fragment that the fixup touches, mask in the // bits from the fixup value. - bool IsLittleEndian = (Endian == support::little); + bool IsLittleEndian = (Endian == llvm::endianness::little); bool IsInstFixup = (Kind >= FirstTargetFixupKind); if (IsLittleEndian && IsInstFixup && (NumBytes == 4)) { diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h index 09b3ce6cc82b..8a2f743bdee6 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYAsmBackend.h @@ -20,7 +20,7 @@ class CSKYAsmBackend : public MCAsmBackend { public: CSKYAsmBackend(const MCSubtargetInfo &STI, const MCTargetOptions &OP) - : MCAsmBackend(support::little) {} + : MCAsmBackend(llvm::endianness::little) {} unsigned int getNumFixupKinds() const override { return CSKY::NumTargetFixupKinds; diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp index 4437c5c998ea..fc5ddde07f62 100644 --- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp +++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp @@ -60,8 +60,9 @@ CSKYMCCodeEmitter::getImmOpValueMSBSize(const MCInst &MI, unsigned Idx, static void writeData(uint32_t Bin, unsigned Size, SmallVectorImpl &CB) { if (Size == 4) support::endian::write(CB, static_cast(Bin >> 16), - support::little); - support::endian::write(CB, static_cast(Bin), support::little); + llvm::endianness::little); + support::endian::write(CB, static_cast(Bin), + llvm::endianness::little); } void CSKYMCCodeEmitter::expandJBTF(const MCInst &MI, SmallVectorImpl &CB, diff --git a/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp index 77007d853d95..4a73cbbea3fc 100644 --- a/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp +++ b/llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp @@ -72,7 +72,8 @@ public: class DXILAsmBackend : public MCAsmBackend { public: - DXILAsmBackend(const MCSubtargetInfo &STI) : MCAsmBackend(support::little) {} + DXILAsmBackend(const MCSubtargetInfo &STI) + : MCAsmBackend(llvm::endianness::little) {} ~DXILAsmBackend() override = default; void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp index 12c84ceb5fd2..76b4dc4e5afa 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp @@ -62,10 +62,9 @@ class HexagonAsmBackend : public MCAsmBackend { public: HexagonAsmBackend(const Target &T, const Triple &TT, uint8_t OSABI, StringRef CPU) - : MCAsmBackend(support::little), OSABI(OSABI), CPU(CPU), relaxedCnt(0), - MCII(T.createMCInstrInfo()), RelaxTarget(new MCInst *), - Extender(nullptr), MaxPacketSize(HexagonMCInstrInfo::packetSize(CPU)) - {} + : MCAsmBackend(llvm::endianness::little), OSABI(OSABI), CPU(CPU), + relaxedCnt(0), MCII(T.createMCInstrInfo()), RelaxTarget(new MCInst *), + Extender(nullptr), MaxPacketSize(HexagonMCInstrInfo::packetSize(CPU)) {} std::unique_ptr createObjectTargetWriter() const override { diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp index 8bf4d0a41298..96ec81cd86ab 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp @@ -443,7 +443,7 @@ void HexagonMCCodeEmitter::encodeSingleInstruction( Binary |= SubBits0 | (SubBits1 << 16); } - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); ++MCNumEmitted; } diff --git a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp index 3c2a3ac69224..08ca577a4785 100644 --- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp +++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp @@ -46,7 +46,7 @@ class LanaiAsmBackend : public MCAsmBackend { public: LanaiAsmBackend(const Target &T, Triple::OSType OST) - : MCAsmBackend(support::big), OSType(OST) {} + : MCAsmBackend(llvm::endianness::big), OSType(OST) {} void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef Data, diff --git a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCCodeEmitter.cpp b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCCodeEmitter.cpp index 5f9c2a100223..d09966e3695c 100644 --- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCCodeEmitter.cpp +++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCCodeEmitter.cpp @@ -178,7 +178,7 @@ void LanaiMCCodeEmitter::encodeInstruction( unsigned Value = getBinaryCodeForInstr(Inst, Fixups, SubtargetInfo); ++MCNumEmitted; // Keep track of the number of emitted insns. - support::endian::write(CB, Value, support::big); + support::endian::write(CB, Value, llvm::endianness::big); } // Encode Lanai Memory Operand diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h index ae9bb8af0419..f840f9fa2b6a 100644 --- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h +++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.h @@ -31,8 +31,8 @@ class LoongArchAsmBackend : public MCAsmBackend { public: LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, const MCTargetOptions &Options) - : MCAsmBackend(support::little), STI(STI), OSABI(OSABI), Is64Bit(Is64Bit), - TargetOptions(Options) {} + : MCAsmBackend(llvm::endianness::little), STI(STI), OSABI(OSABI), + Is64Bit(Is64Bit), TargetOptions(Options) {} ~LoongArchAsmBackend() override {} void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp index 03fb9e008ae9..fbe817a2b547 100644 --- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp +++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp @@ -296,7 +296,7 @@ void LoongArchMCCodeEmitter::expandToVectorLDI( } MCInst TmpInst = MCInstBuilder(Opc).addOperand(MI.getOperand(0)).addImm(Imm); uint32_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); } void LoongArchMCCodeEmitter::encodeInstruction( @@ -326,7 +326,7 @@ void LoongArchMCCodeEmitter::encodeInstruction( llvm_unreachable("Unhandled encodeInstruction length!"); case 4: { uint32_t Bits = getBinaryCodeForInstr(MI, Fixups, STI); - support::endian::write(CB, Bits, support::little); + support::endian::write(CB, Bits, llvm::endianness::little); break; } } diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp index b66557ec6c3a..1b85e6df379c 100644 --- a/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp +++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kAsmBackend.cpp @@ -41,7 +41,7 @@ namespace { class M68kAsmBackend : public MCAsmBackend { public: - M68kAsmBackend(const Target &T) : MCAsmBackend(support::big) {} + M68kAsmBackend(const Target &T) : MCAsmBackend(llvm::endianness::big) {} unsigned getNumFixupKinds() const override { return 0; } diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h b/llvm/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h index e52b4961e3c8..1376b06bef6f 100644 --- a/llvm/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h +++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h @@ -82,11 +82,11 @@ template value_t swapWord(value_t Val) { const unsigned NumWords = sizeof(Val) / 2; if (NumWords <= 1) return Val; - Val = support::endian::byte_swap(Val, support::big); + Val = support::endian::byte_swap(Val, llvm::endianness::big); value_t NewVal = 0; for (unsigned i = 0U; i != NumWords; ++i) { uint16_t Part = (Val >> (i * 16)) & 0xFFFF; - Part = support::endian::byte_swap(Part, support::big); + Part = support::endian::byte_swap(Part, llvm::endianness::big); NewVal |= (Part << (i * 16)); } return NewVal; diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp index 7fc5395671cf..16460f0a105b 100644 --- a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp +++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp @@ -218,7 +218,7 @@ void M68kMCCodeEmitter::encodeInstruction(const MCInst &MI, for (uint64_t Word : Data) { for (int i = 0; i < 4 && InstSize > 0; ++i, InstSize -= 16) { support::endian::write(CB, static_cast(Word), - support::big); + llvm::endianness::big); Word >>= 16; } } diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp index a667f457bd03..bd9f6279445a 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp @@ -34,7 +34,7 @@ class MSP430AsmBackend : public MCAsmBackend { public: MSP430AsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI) - : MCAsmBackend(support::little), OSABI(OSABI) {} + : MCAsmBackend(llvm::endianness::little), OSABI(OSABI) {} ~MSP430AsmBackend() override = default; void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp index 985906a35331..51428552d8af 100644 --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp @@ -94,7 +94,8 @@ void MSP430MCCodeEmitter::encodeInstruction(const MCInst &MI, size_t WordCount = Size / 2; while (WordCount--) { - support::endian::write(CB, (uint16_t)BinaryOpCode, support::little); + support::endian::write(CB, (uint16_t)BinaryOpCode, + llvm::endianness::little); BinaryOpCode >>= 16; } } diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp index 71f333d0d0c3..7eca49e709a0 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp @@ -281,7 +281,7 @@ void MipsAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, bool microMipsLEByteOrder = needsMMLEByteOrder((unsigned) Kind); for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little + unsigned Idx = Endian == llvm::endianness::little ? (microMipsLEByteOrder ? calculateMMLEIndex(i) : i) : (FullSize - 1 - i); CurVal |= (uint64_t)((uint8_t)Data[Offset + Idx]) << (i*8); @@ -293,7 +293,7 @@ void MipsAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, // Write out the fixed up bytes back to the code/data bits. for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little + unsigned Idx = Endian == llvm::endianness::little ? (microMipsLEByteOrder ? calculateMMLEIndex(i) : i) : (FullSize - 1 - i); Data[Offset + Idx] = (uint8_t)((CurVal >> (i*8)) & 0xff); @@ -519,7 +519,7 @@ getFixupKindInfo(MCFixupKind Kind) const { assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && "Invalid kind!"); - if (Endian == support::little) + if (Endian == llvm::endianness::little) return LittleEndianInfos[Kind - FirstTargetFixupKind]; return BigEndianInfos[Kind - FirstTargetFixupKind]; } diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h index 749223a6d01b..228a0b4c407c 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h @@ -32,7 +32,8 @@ class MipsAsmBackend : public MCAsmBackend { public: MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, bool N32) - : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big), + : MCAsmBackend(TT.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big), TheTriple(TT), IsN32(N32) {} std::unique_ptr diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp index 6a81a842be7b..73ee44eec22c 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp @@ -206,7 +206,8 @@ void MipsMCCodeEmitter::encodeInstruction(const MCInst &MI, if (!Size) llvm_unreachable("Desc.getSize() returns 0"); - auto Endian = IsLittleEndian ? support::little : support::big; + auto Endian = + IsLittleEndian ? llvm::endianness::little : llvm::endianness::big; if (Size == 2) { support::endian::write(CB, Binary, Endian); } else if (IsLittleEndian && isMicroMips(STI)) { diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp index 89d04dbe378e..8bd27571a750 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp @@ -87,7 +87,8 @@ protected: Triple TT; public: PPCAsmBackend(const Target &T, const Triple &TT) - : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big), + : MCAsmBackend(TT.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big), TT(TT) {} unsigned getNumFixupKinds() const override { @@ -132,7 +133,7 @@ public: assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && "Invalid kind!"); - return (Endian == support::little + return (Endian == llvm::endianness::little ? InfosLE : InfosBE)[Kind - FirstTargetFixupKind]; } @@ -154,7 +155,8 @@ public: // from the fixup value. The Value has been "split up" into the appropriate // bitfields above. for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little ? i : (NumBytes - 1 - i); + unsigned Idx = + Endian == llvm::endianness::little ? i : (NumBytes - 1 - i); Data[Offset + i] |= uint8_t((Value >> (Idx * 8)) & 0xff); } } diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp index e06b4cdd4e4d..910b5892d033 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp @@ -508,7 +508,8 @@ void PPCMCCodeEmitter::encodeInstruction(const MCInst &MI, // Output the constant in big/little endian byte order. unsigned Size = getInstSizeInBytes(MI); - llvm::endianness E = IsLittleEndian ? support::little : support::big; + llvm::endianness E = + IsLittleEndian ? llvm::endianness::little : llvm::endianness::big; switch (Size) { case 0: break; diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp index ca5aeb943c3b..765d44c4575b 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp @@ -238,7 +238,7 @@ bool RISCVAsmBackend::relaxDwarfLineAddr(MCDwarfLineAddrFragment &DF, OS << uint8_t(dwarf::DW_LNS_fixed_advance_pc); Offset = OS.tell(); Fixup = RISCV::getRelocPairForSize(2); - support::endian::write(OS, 0, support::little); + support::endian::write(OS, 0, llvm::endianness::little); } const MCBinaryExpr &MBE = cast(AddrDelta); @@ -303,15 +303,15 @@ bool RISCVAsmBackend::relaxDwarfCFA(MCDwarfCallFrameFragment &DF, AddFixups(0, {ELF::R_RISCV_SET6, ELF::R_RISCV_SUB6}); } else if (isUInt<8>(Value)) { OS << uint8_t(dwarf::DW_CFA_advance_loc1); - support::endian::write(OS, 0, support::little); + support::endian::write(OS, 0, llvm::endianness::little); AddFixups(1, {ELF::R_RISCV_SET8, ELF::R_RISCV_SUB8}); } else if (isUInt<16>(Value)) { OS << uint8_t(dwarf::DW_CFA_advance_loc2); - support::endian::write(OS, 0, support::little); + support::endian::write(OS, 0, llvm::endianness::little); AddFixups(1, {ELF::R_RISCV_SET16, ELF::R_RISCV_SUB16}); } else if (isUInt<32>(Value)) { OS << uint8_t(dwarf::DW_CFA_advance_loc4); - support::endian::write(OS, 0, support::little); + support::endian::write(OS, 0, llvm::endianness::little); AddFixups(1, {ELF::R_RISCV_SET32, ELF::R_RISCV_SUB32}); } else { llvm_unreachable("unsupported CFA encoding"); diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h index 0ea1f32e8296..95596ad5944c 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h @@ -31,8 +31,8 @@ class RISCVAsmBackend : public MCAsmBackend { public: RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, const MCTargetOptions &Options) - : MCAsmBackend(support::little, RISCV::fixup_riscv_relax), STI(STI), - OSABI(OSABI), Is64Bit(Is64Bit), TargetOptions(Options) { + : MCAsmBackend(llvm::endianness::little, RISCV::fixup_riscv_relax), + STI(STI), OSABI(OSABI), Is64Bit(Is64Bit), TargetOptions(Options) { RISCVFeatures::validate(STI.getTargetTriple(), STI.getFeatureBits()); } ~RISCVAsmBackend() override = default; diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp index 716c3ac14d11..c5f2d92e9e47 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp @@ -137,7 +137,7 @@ void RISCVMCCodeEmitter::expandFunctionCall(const MCInst &MI, // Emit AUIPC Ra, Func with R_RISCV_CALL relocation type. TmpInst = MCInstBuilder(RISCV::AUIPC).addReg(Ra).addExpr(CallExpr); Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); if (MI.getOpcode() == RISCV::PseudoTAIL || MI.getOpcode() == RISCV::PseudoJump) @@ -147,7 +147,7 @@ void RISCVMCCodeEmitter::expandFunctionCall(const MCInst &MI, // Emit JALR Ra, Ra, 0 TmpInst = MCInstBuilder(RISCV::JALR).addReg(Ra).addReg(Ra).addImm(0); Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); } // Expand PseudoAddTPRel to a simple ADD with the correct relocation. @@ -186,7 +186,7 @@ void RISCVMCCodeEmitter::expandAddTPRel(const MCInst &MI, .addOperand(SrcReg) .addOperand(TPReg); uint32_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); } static unsigned getInvertedBranchOp(unsigned BrOp) { @@ -240,14 +240,14 @@ void RISCVMCCodeEmitter::expandLongCondBr(const MCInst &MI, Opcode == RISCV::PseudoLongBNE ? RISCV::C_BEQZ : RISCV::C_BNEZ; MCInst TmpInst = MCInstBuilder(InvOpc).addReg(SrcReg1).addImm(6); uint16_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); Offset = 2; } else { unsigned InvOpc = getInvertedBranchOp(Opcode); MCInst TmpInst = MCInstBuilder(InvOpc).addReg(SrcReg1).addReg(SrcReg2).addImm(8); uint32_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); Offset = 4; } @@ -255,7 +255,7 @@ void RISCVMCCodeEmitter::expandLongCondBr(const MCInst &MI, MCInst TmpInst = MCInstBuilder(RISCV::JAL).addReg(RISCV::X0).addOperand(SrcSymbol); uint32_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI); - support::endian::write(CB, Binary, support::little); + support::endian::write(CB, Binary, llvm::endianness::little); Fixups.clear(); if (SrcSymbol.isExpr()) { @@ -306,12 +306,12 @@ void RISCVMCCodeEmitter::encodeInstruction(const MCInst &MI, llvm_unreachable("Unhandled encodeInstruction length!"); case 2: { uint16_t Bits = getBinaryCodeForInstr(MI, Fixups, STI); - support::endian::write(CB, Bits, support::little); + support::endian::write(CB, Bits, llvm::endianness::little); break; } case 4: { uint32_t Bits = getBinaryCodeForInstr(MI, Fixups, STI); - support::endian::write(CB, Bits, support::little); + support::endian::write(CB, Bits, llvm::endianness::little); break; } } diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp index 016f3c4bf922..1b80e4b9277b 100644 --- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp +++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVAsmBackend.cpp @@ -59,5 +59,5 @@ MCAsmBackend *llvm::createSPIRVAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &) { - return new SPIRVAsmBackend(support::little); + return new SPIRVAsmBackend(llvm::endianness::little); } diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVMCCodeEmitter.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVMCCodeEmitter.cpp index 60b68dea934a..8aea26d9963c 100644 --- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVMCCodeEmitter.cpp +++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVMCCodeEmitter.cpp @@ -78,10 +78,10 @@ static void emitOperand(const MCOperand &Op, SmallVectorImpl &CB) { if (Op.isReg()) { // Emit the id index starting at 1 (0 is an invalid index). support::endian::write( - CB, Register::virtReg2Index(Op.getReg()) + 1, support::little); + CB, Register::virtReg2Index(Op.getReg()) + 1, llvm::endianness::little); } else if (Op.isImm()) { support::endian::write(CB, static_cast(Op.getImm()), - support::little); + llvm::endianness::little); } else { llvm_unreachable("Unexpected operand type in VReg"); } @@ -113,7 +113,7 @@ void SPIRVMCCodeEmitter::encodeInstruction(const MCInst &MI, const uint64_t OpCode = getBinaryCodeForInstr(MI, Fixups, STI); const uint32_t NumWords = MI.getNumOperands() + 1; const uint32_t FirstWord = (NumWords << 16) | OpCode; - support::endian::write(CB, FirstWord, support::little); + support::endian::write(CB, FirstWord, llvm::endianness::little); // Emit the instruction arguments (emitting the output type first if present). if (hasType(MI, MCII)) diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp index 2c0696e8048b..9e14f96b6caa 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp @@ -136,8 +136,9 @@ namespace { public: SparcAsmBackend(const Target &T) - : MCAsmBackend(StringRef(T.getName()) == "sparcel" ? support::little - : support::big), + : MCAsmBackend(StringRef(T.getName()) == "sparcel" + ? llvm::endianness::little + : llvm::endianness::big), TheTarget(T), Is64Bit(StringRef(TheTarget.getName()) == "sparcv9") {} unsigned getNumFixupKinds() const override { @@ -264,7 +265,7 @@ namespace { assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && "Invalid kind!"); - if (Endian == support::little) + if (Endian == llvm::endianness::little) return InfosLE[Kind - FirstTargetFixupKind]; return InfosBE[Kind - FirstTargetFixupKind]; @@ -355,7 +356,8 @@ namespace { // from the fixup value. The Value has been "split up" into the // appropriate bitfields above. for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little ? i : (NumBytes - 1) - i; + unsigned Idx = + Endian == llvm::endianness::little ? i : (NumBytes - 1) - i; Data[Offset + Idx] |= uint8_t((Value >> (i * 8)) & 0xff); } } diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp index 9b3282e0736c..42357e3b1aa9 100644 --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp @@ -93,8 +93,9 @@ void SparcMCCodeEmitter::encodeInstruction(const MCInst &MI, const MCSubtargetInfo &STI) const { unsigned Bits = getBinaryCodeForInstr(MI, Fixups, STI); support::endian::write(CB, Bits, - Ctx.getAsmInfo()->isLittleEndian() ? support::little - : support::big); + Ctx.getAsmInfo()->isLittleEndian() + ? llvm::endianness::little + : llvm::endianness::big); // Some instructions have phantom operands that only contribute a fixup entry. unsigned SymOpNo = 0; diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp index 20dcf74cb8d9..eafe41124897 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp @@ -107,8 +107,7 @@ static uint64_t extractBitsForFixup(MCFixupKind Kind, uint64_t Value, namespace { class SystemZMCAsmBackend : public MCAsmBackend { public: - SystemZMCAsmBackend() - : MCAsmBackend(support::big) {} + SystemZMCAsmBackend() : MCAsmBackend(llvm::endianness::big) {} // Override MCAsmBackend unsigned getNumFixupKinds() const override { diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp index 38d163b37080..2773a7aabab7 100644 --- a/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp +++ b/llvm/lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp @@ -97,7 +97,8 @@ protected: const Target &TheTarget; public: - VEAsmBackend(const Target &T) : MCAsmBackend(support::little), TheTarget(T) {} + VEAsmBackend(const Target &T) + : MCAsmBackend(llvm::endianness::little), TheTarget(T) {} unsigned getNumFixupKinds() const override { return VE::NumTargetFixupKinds; } @@ -174,7 +175,7 @@ public: for (uint64_t i = 0; i < Count; i += 8) support::endian::write(OS, 0x7900000000000000ULL, - support::little); + llvm::endianness::little); return true; } @@ -207,7 +208,8 @@ public: // from the fixup value. The Value has been "split up" into the // appropriate bitfields above. for (unsigned i = 0; i != NumBytes; ++i) { - unsigned Idx = Endian == support::little ? i : (NumBytes - 1) - i; + unsigned Idx = + Endian == llvm::endianness::little ? i : (NumBytes - 1) - i; Data[Offset + Idx] |= static_cast((Value >> (i * 8)) & 0xff); } } diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp index bb643d23e618..31a07fab042d 100644 --- a/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp @@ -82,7 +82,7 @@ void VEMCCodeEmitter::encodeInstruction(const MCInst &MI, SmallVectorImpl &Fixups, const MCSubtargetInfo &STI) const { uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI); - support::endian::write(CB, Bits, support::little); + support::endian::write(CB, Bits, llvm::endianness::little); ++MCNumEmitted; // Keep track of the # of mi's emitted. } diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp index 85bb52c03e80..ffab67f8ab2b 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp @@ -35,7 +35,7 @@ class WebAssemblyAsmBackend final : public MCAsmBackend { public: explicit WebAssemblyAsmBackend(bool Is64Bit, bool IsEmscripten) - : MCAsmBackend(support::little), Is64Bit(Is64Bit), + : MCAsmBackend(llvm::endianness::little), Is64Bit(Is64Bit), IsEmscripten(IsEmscripten) {} unsigned getNumFixupKinds() const override { diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp index 634ed10d4df5..aaca213c4afe 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -112,16 +112,20 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( break; case WebAssembly::OPERAND_SIGNATURE: case WebAssembly::OPERAND_VEC_I8IMM: - support::endian::write(OS, MO.getImm(), support::little); + support::endian::write(OS, MO.getImm(), + llvm::endianness::little); break; case WebAssembly::OPERAND_VEC_I16IMM: - support::endian::write(OS, MO.getImm(), support::little); + support::endian::write(OS, MO.getImm(), + llvm::endianness::little); break; case WebAssembly::OPERAND_VEC_I32IMM: - support::endian::write(OS, MO.getImm(), support::little); + support::endian::write(OS, MO.getImm(), + llvm::endianness::little); break; case WebAssembly::OPERAND_VEC_I64IMM: - support::endian::write(OS, MO.getImm(), support::little); + support::endian::write(OS, MO.getImm(), + llvm::endianness::little); break; case WebAssembly::OPERAND_GLOBAL: Ctx.reportError( @@ -137,10 +141,10 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( } else if (MO.isSFPImm()) { uint32_t F = MO.getSFPImm(); - support::endian::write(OS, F, support::little); + support::endian::write(OS, F, llvm::endianness::little); } else if (MO.isDFPImm()) { uint64_t D = MO.getDFPImm(); - support::endian::write(OS, D, support::little); + support::endian::write(OS, D, llvm::endianness::little); } else if (MO.isExpr()) { const MCOperandInfo &Info = Desc.operands()[I]; llvm::MCFixupKind FixupKind; diff --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp index 49651da63ecf..967c7574355d 100644 --- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -194,7 +194,7 @@ template static bool consume(InternalInstruction *insn, T &ptr) { uint64_t offset = insn->readerCursor - insn->startLocation; if (offset + sizeof(T) > r.size()) return true; - ptr = support::endian::read(&r[offset], support::little); + ptr = support::endian::read(&r[offset], llvm::endianness::little); insn->readerCursor += sizeof(T); return false; } diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp index fbb2fc138d7c..e01ce4f43143 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp @@ -137,7 +137,7 @@ class X86AsmBackend : public MCAsmBackend { public: X86AsmBackend(const Target &T, const MCSubtargetInfo &STI) - : MCAsmBackend(support::little), STI(STI), + : MCAsmBackend(llvm::endianness::little), STI(STI), MCII(T.createMCInstrInfo()) { if (X86AlignBranchWithin32BBoundaries) { // At the moment, this defaults to aligning fused branches, unconditional diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp index 61417a2f2455..db4484bb57c1 100644 --- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp +++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaAsmBackend.cpp @@ -30,7 +30,8 @@ class XtensaMCAsmBackend : public MCAsmBackend { public: XtensaMCAsmBackend(uint8_t osABI, bool isLE) - : MCAsmBackend(support::little), OSABI(osABI), IsLittleEndian(isLE) {} + : MCAsmBackend(llvm::endianness::little), OSABI(osABI), + IsLittleEndian(isLE) {} unsigned getNumFixupKinds() const override { return Xtensa::NumTargetFixupKinds; diff --git a/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp b/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp index 3fee0e5d5259..423c45e22bf8 100644 --- a/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp +++ b/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp @@ -87,7 +87,8 @@ static llvm::Error parseDataBuffer(const char *DataBuf, size_t DataSize, continue; } DataPtr += sizeof(Header); - uint64_t Count = llvm::support::endian::read64(DataPtr, support::native); + uint64_t Count = + llvm::support::endian::read64(DataPtr, llvm::endianness::native); DataPtr += sizeof(Count); struct perf_branch_entry Entry; diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp index c2de9edf07fe..46ec4bdc2870 100644 --- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp +++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp @@ -370,8 +370,9 @@ static llvm::Error handleObjectFile(ObjectFile &Obj, return Err; // Save the GSYM file to disk. - llvm::endianness Endian = - Obj.makeTriple().isLittleEndian() ? support::little : support::big; + llvm::endianness Endian = Obj.makeTriple().isLittleEndian() + ? llvm::endianness::little + : llvm::endianness::big; std::optional OptSegmentSize; if (SegmentSize > 0) diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 0709f292a492..d73d247599b9 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -1903,7 +1903,8 @@ static Error runChecks(Session &S, Triple TT, SubtargetFeatures Features) { RuntimeDyldChecker Checker( IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, GetGOTInfo, - S.ES.getTargetTriple().isLittleEndian() ? support::little : support::big, + S.ES.getTargetTriple().isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big, TT, StringRef(), Features, dbgs()); std::string CheckLineStart = "# " + CheckName + ":"; diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 89d59e2a77ad..537c18bf3440 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -685,8 +685,9 @@ public: // using the .long directive, or .byte directive if fewer than 4 bytes // remaining if (Bytes.size() >= 4) { - OS << format("\t.long 0x%08" PRIx32 " ", - support::endian::read32(Bytes.data())); + OS << format( + "\t.long 0x%08" PRIx32 " ", + support::endian::read32(Bytes.data())); OS.indent(42); } else { OS << format("\t.byte 0x%02" PRIx8, Bytes[0]); @@ -1168,7 +1169,7 @@ static uint64_t dumpARMELFData(uint64_t SectionAddr, uint64_t Index, ArrayRef MappingSymbols, const MCSubtargetInfo &STI, raw_ostream &OS) { llvm::endianness Endian = - Obj.isLittleEndian() ? support::little : support::big; + Obj.isLittleEndian() ? llvm::endianness::little : llvm::endianness::big; size_t Start = OS.tell(); OS << format("%8" PRIx64 ": ", SectionAddr + Index); if (Index + 4 <= End) { diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp index dd9db338ece2..9738fd49343a 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp +++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp @@ -891,7 +891,7 @@ Error ResourceFileWriter::visitIconOrCursorResource(const RCResource *Base) { if (!File) return File.takeError(); - BinaryStreamReader Reader((*File)->getBuffer(), support::little); + BinaryStreamReader Reader((*File)->getBuffer(), llvm::endianness::little); // Read the file headers. // - At the beginning, ICONDIR/NEWHEADER header. diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h index d809890ee8e8..9413a0eecdac 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.h +++ b/llvm/tools/llvm-rc/ResourceFileWriter.h @@ -183,8 +183,8 @@ private: uint64_t writeObject(const ArrayRef Data); template uint64_t writeInt(const T &Value) { - support::detail::packed_endian_specific_integral + support::detail::packed_endian_specific_integral< + T, llvm::endianness::little, support::unaligned> Object(Value); return writeObject(Object); } diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index bdfb8acec069..9c24b0b8db35 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -1106,7 +1106,7 @@ void COFFDumper::initializeFileAndStringTables(BinaryStreamReader &Reader) { if (Error E = Reader.readFixedString(Contents, SubSectionSize)) reportError(std::move(E), Obj->getFileName()); - BinaryStreamRef ST(Contents, support::little); + BinaryStreamRef ST(Contents, llvm::endianness::little); switch (DebugSubsectionKind(SubType)) { case DebugSubsectionKind::FileChecksums: if (Error E = CVFileChecksumTable.initialize(ST)) @@ -1148,7 +1148,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, reportError(errorCodeToError(object_error::parse_failed), Obj->getFileName()); - BinaryStreamReader FSReader(Data, support::little); + BinaryStreamReader FSReader(Data, llvm::endianness::little); initializeFileAndStringTables(FSReader); // TODO: Convert this over to using ModuleSubstreamVisitor. @@ -1302,7 +1302,8 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, ListScope S(W, "FunctionLineTable"); W.printString("LinkageName", Name); - BinaryStreamReader Reader(FunctionLineTables[Name], support::little); + BinaryStreamReader Reader(FunctionLineTables[Name], + llvm::endianness::little); DebugLinesSubsectionRef LineInfo; if (Error E = LineInfo.initialize(Reader)) @@ -2091,10 +2092,10 @@ void COFFDumper::printStackMap() const { if (Obj->isLittleEndian()) prettyPrintStackMap( - W, StackMapParser(StackMapContentsArray)); + W, StackMapParser(StackMapContentsArray)); else prettyPrintStackMap( - W, StackMapParser(StackMapContentsArray)); + W, StackMapParser(StackMapContentsArray)); } void COFFDumper::printAddrsig() { diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 93b645cdfc1a..586119a10b4f 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -2842,7 +2842,7 @@ template void ELFDumper::printArchSpecificInfo() { if (Obj.isLE()) printAttributes(ELF::SHT_ARM_ATTRIBUTES, std::make_unique(&W), - support::little); + llvm::endianness::little); else reportUniqueWarning("attribute printing not implemented for big-endian " "ARM objects"); @@ -2851,7 +2851,7 @@ template void ELFDumper::printArchSpecificInfo() { if (Obj.isLE()) printAttributes(ELF::SHT_RISCV_ATTRIBUTES, std::make_unique(&W), - support::little); + llvm::endianness::little); else reportUniqueWarning("attribute printing not implemented for big-endian " "RISC-V objects"); @@ -2859,7 +2859,7 @@ template void ELFDumper::printArchSpecificInfo() { case EM_MSP430: printAttributes(ELF::SHT_MSP430_ATTRIBUTES, std::make_unique(&W), - support::little); + llvm::endianness::little); break; case EM_MIPS: { printMipsABIFlags(); @@ -6002,9 +6002,9 @@ template void GNUELFDumper::printNotes() { return Error::success(); } else if (Name == "CORE") { if (Type == ELF::NT_FILE) { - DataExtractor DescExtractor(Descriptor, - ELFT::TargetEndianness == support::little, - sizeof(Elf_Addr)); + DataExtractor DescExtractor( + Descriptor, ELFT::TargetEndianness == llvm::endianness::little, + sizeof(Elf_Addr)); if (Expected NoteOrErr = readCoreNote(DescExtractor)) { printCoreNote(OS, *NoteOrErr); return Error::success(); @@ -7699,9 +7699,9 @@ template void LLVMELFDumper::printNotes() { return Error::success(); } else if (Name == "CORE") { if (Type == ELF::NT_FILE) { - DataExtractor DescExtractor(Descriptor, - ELFT::TargetEndianness == support::little, - sizeof(Elf_Addr)); + DataExtractor DescExtractor( + Descriptor, ELFT::TargetEndianness == llvm::endianness::little, + sizeof(Elf_Addr)); if (Expected N = readCoreNote(DescExtractor)) { printCoreNoteLLVMStyle(*N, W); return Error::success(); diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp index fb5a58747e50..0a23ad772e4c 100644 --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -734,10 +734,10 @@ void MachODumper::printStackMap() const { if (Obj->isLittleEndian()) prettyPrintStackMap( - W, StackMapParser(StackMapContentsArray)); + W, StackMapParser(StackMapContentsArray)); else prettyPrintStackMap( - W, StackMapParser(StackMapContentsArray)); + W, StackMapParser(StackMapContentsArray)); } void MachODumper::printCGProfile() { diff --git a/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp b/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp index fb085ecaa76e..53370054f5e9 100644 --- a/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp +++ b/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp @@ -26,7 +26,7 @@ std::string stripUTF16(const ArrayRef &UTF16Str) { for (UTF16 Ch : UTF16Str) { // UTF16Str will have swapped byte order in case of big-endian machines. // Swap it back in such a case. - uint16_t ChValue = support::endian::byte_swap(Ch, support::little); + uint16_t ChValue = support::endian::byte_swap(Ch, llvm::endianness::little); if (ChValue <= 0xFF) Result += ChValue; else diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index d947be7f1fd8..107b555a99fa 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -978,7 +978,9 @@ static int linkAndVerify() { if (!Checker) Checker = std::make_unique( IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, - GetStubInfo, Obj.isLittleEndian() ? support::little : support::big, + GetStubInfo, + Obj.isLittleEndian() ? llvm::endianness::little + : llvm::endianness::big, TheTriple, MCPU, SubtargetFeatures(), dbgs()); auto FileName = sys::path::filename(InputFile); diff --git a/llvm/tools/obj2yaml/coff2yaml.cpp b/llvm/tools/obj2yaml/coff2yaml.cpp index 604799fb2737..2f80e62f8772 100644 --- a/llvm/tools/obj2yaml/coff2yaml.cpp +++ b/llvm/tools/obj2yaml/coff2yaml.cpp @@ -123,7 +123,7 @@ initializeFileAndStringTable(const llvm::object::COFFObjectFile &Obj, cantFail(Obj.getSectionContents(COFFSection, sectionData)); - BinaryStreamReader Reader(sectionData, support::little); + BinaryStreamReader Reader(sectionData, llvm::endianness::little); uint32_t Magic; Err(Reader.readInteger(Magic)); diff --git a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp index 3eda776fdf6a..5c961998a415 100644 --- a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp +++ b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp @@ -182,7 +182,7 @@ protected: uint32_t Size = Count * sizeof(TypeIndexOffset); uint8_t *Buffer = GlobalState->Allocator.Allocate(Size); MutableArrayRef Bytes(Buffer, Size); - Storage = MutableBinaryByteStream(Bytes, support::little); + Storage = MutableBinaryByteStream(Bytes, llvm::endianness::little); BinaryStreamWriter Writer(Storage); for (const auto I : Indices) consumeError(Writer.writeObject(GlobalState->AllOffsets[I])); diff --git a/llvm/unittests/ExecutionEngine/JITLink/JITLinkMocks.cpp b/llvm/unittests/ExecutionEngine/JITLink/JITLinkMocks.cpp index 158333b10622..c40ce7adb0b5 100644 --- a/llvm/unittests/ExecutionEngine/JITLink/JITLinkMocks.cpp +++ b/llvm/unittests/ExecutionEngine/JITLink/JITLinkMocks.cpp @@ -52,7 +52,8 @@ TEST(JITLinkMocks, SmokeTest) { // Check that the testing infrastructure defaults can "link" a graph // successfully. auto G = std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, - support::little, getGenericEdgeKindName); + llvm::endianness::little, + getGenericEdgeKindName); ArrayRef Content = "hello, world!"; auto &Sec = diff --git a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp index 711f35fc7683..a94ad0859ebb 100644 --- a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp +++ b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp @@ -61,12 +61,12 @@ static ArrayRef BlockContent(BlockContentBytes); TEST(LinkGraphTest, Construction) { // Check that LinkGraph construction works as expected. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); EXPECT_EQ(G.getName(), "foo"); EXPECT_EQ(G.getTargetTriple().str(), "x86_64-apple-darwin"); EXPECT_EQ(G.getPointerSize(), 8U); - EXPECT_EQ(G.getEndianness(), support::little); + EXPECT_EQ(G.getEndianness(), llvm::endianness::little); EXPECT_TRUE(G.external_symbols().empty()); EXPECT_TRUE(G.absolute_symbols().empty()); EXPECT_TRUE(G.defined_symbols().empty()); @@ -75,7 +75,7 @@ TEST(LinkGraphTest, Construction) { TEST(LinkGraphTest, AddressAccess) { // Check that we can get addresses for blocks, symbols, and edges. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = @@ -94,7 +94,7 @@ TEST(LinkGraphTest, AddressAccess) { TEST(LinkGraphTest, SectionEmpty) { // Check that Section::empty behaves as expected. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write); @@ -112,7 +112,7 @@ TEST(LinkGraphTest, SectionEmpty) { TEST(LinkGraphTest, BlockAndSymbolIteration) { // Check that we can iterate over blocks within Sections and across sections. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write); @@ -165,7 +165,7 @@ TEST(LinkGraphTest, BlockAndSymbolIteration) { TEST(LinkGraphTest, ContentAccessAndUpdate) { // Check that we can make a defined symbol external. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -254,7 +254,7 @@ TEST(LinkGraphTest, ContentAccessAndUpdate) { TEST(LinkGraphTest, MakeExternal) { // Check that we can make defined and absolute symbols external. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -324,7 +324,7 @@ TEST(LinkGraphTest, MakeExternal) { TEST(LinkGraphTest, MakeAbsolute) { // Check that we can make defined and external symbols absolute. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -393,7 +393,7 @@ TEST(LinkGraphTest, MakeAbsolute) { TEST(LinkGraphTest, MakeDefined) { // Check that we can make an external symbol defined. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -441,7 +441,7 @@ TEST(LinkGraphTest, MakeDefined) { TEST(LinkGraphTest, TransferDefinedSymbol) { // Check that we can transfer a defined symbol from one block to another. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -476,7 +476,7 @@ TEST(LinkGraphTest, TransferDefinedSymbol) { TEST(LinkGraphTest, TransferDefinedSymbolAcrossSections) { // Check that we can transfer a defined symbol from an existing block in one // section to another. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write); @@ -510,7 +510,7 @@ TEST(LinkGraphTest, TransferDefinedSymbolAcrossSections) { TEST(LinkGraphTest, TransferBlock) { // Check that we can transfer a block (and all associated symbols) from one // section to another. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write); @@ -558,7 +558,7 @@ TEST(LinkGraphTest, TransferBlock) { TEST(LinkGraphTest, MergeSections) { // Check that we can transfer a block (and all associated symbols) from one // section to another. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec1 = G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write); @@ -644,7 +644,7 @@ TEST(LinkGraphTest, MergeSections) { TEST(LinkGraphTest, SplitBlock) { // Check that the LinkGraph::splitBlock test works as expected. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -740,7 +740,7 @@ TEST(LinkGraphTest, SplitBlock) { } TEST(LinkGraphTest, GraphAllocationMethods) { - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); // Test allocation of sized, uninitialized buffer. @@ -761,7 +761,7 @@ TEST(LinkGraphTest, GraphAllocationMethods) { TEST(LinkGraphTest, IsCStringBlockTest) { // Check that the LinkGraph::splitBlock test works as expected. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto &Sec = G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write); @@ -786,7 +786,7 @@ TEST(LinkGraphTest, IsCStringBlockTest) { TEST(LinkGraphTest, BasicLayoutHonorsNoAlloc) { // Check that BasicLayout honors NoAlloc. - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); // Create a regular section and block. diff --git a/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp index c6f4b962a002..f0f3dd117c6f 100644 --- a/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp +++ b/llvm/unittests/ExecutionEngine/JITLink/MemoryManagerErrorTests.cpp @@ -19,7 +19,8 @@ using namespace llvm::jitlink; TEST(MemoryManagerErrorTest, ErrorOnFirstAllocate) { // Check that we can get addresses for blocks, symbols, and edges. auto G = std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, - support::little, getGenericEdgeKindName); + llvm::endianness::little, + getGenericEdgeKindName); ArrayRef Content = "hello, world!"; auto &Sec = diff --git a/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp index fb932e756c72..e33aa63b5e4c 100644 --- a/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp +++ b/llvm/unittests/ExecutionEngine/JITLink/StubsTests.cpp @@ -60,7 +60,7 @@ GenerateStub(LinkGraph &G, size_t PointerSize, Edge::Kind PointerEdgeKind) { TEST(StubsTest, StubsGeneration_x86_64) { const char PointerJumpStubContent[6] = { static_cast(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00}; - LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little, + LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, llvm::endianness::little, getGenericEdgeKindName); auto [PointerSym, StubSym] = GenerateStub(G, 8U, x86_64::Pointer64); @@ -80,7 +80,7 @@ TEST(StubsTest, StubsGeneration_aarch64) { 0x10, 0x02, 0x40, (char)0xf9u, // LDR x16, [x16, @pageoff12] 0x00, 0x02, 0x1f, (char)0xd6u // BR x16 }; - LinkGraph G("foo", Triple("aarch64-linux-gnu"), 8, support::little, + LinkGraph G("foo", Triple("aarch64-linux-gnu"), 8, llvm::endianness::little, getGenericEdgeKindName); auto [PointerSym, StubSym] = GenerateStub(G, 8U, aarch64::Pointer64); @@ -100,8 +100,8 @@ TEST(StubsTest, StubsGeneration_aarch64) { TEST(StubsTest, StubsGeneration_i386) { const char PointerJumpStubContent[6] = { static_cast(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00}; - LinkGraph G("foo", Triple("i386-unknown-linux-gnu"), 4, support::little, - getGenericEdgeKindName); + LinkGraph G("foo", Triple("i386-unknown-linux-gnu"), 4, + llvm::endianness::little, getGenericEdgeKindName); auto [PointerSym, StubSym] = GenerateStub(G, 4U, i386::Pointer32); EXPECT_EQ(std::distance(StubSym.getBlock().edges().begin(), @@ -129,7 +129,7 @@ TEST(StubsTest, StubsGeneration_loongarch32) { 0x00, 0x4c // jr $t8 }; - LinkGraph G("foo", Triple("loongarch32"), 4, support::little, + LinkGraph G("foo", Triple("loongarch32"), 4, llvm::endianness::little, getGenericEdgeKindName); auto [PointerSym, StubSym] = GenerateStub(G, 4U, loongarch::Pointer32); @@ -161,7 +161,7 @@ TEST(StubsTest, StubsGeneration_loongarch64) { 0x00, 0x4c // jr $t8 }; - LinkGraph G("foo", Triple("loongarch64"), 8, support::little, + LinkGraph G("foo", Triple("loongarch64"), 8, llvm::endianness::little, getGenericEdgeKindName); auto [PointerSym, StubSym] = GenerateStub(G, 8U, loongarch::Pointer64); diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp index c943eaf3bd7f..91659240c9d6 100644 --- a/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/ObjectLinkingLayerTest.cpp @@ -39,9 +39,9 @@ protected: }; TEST_F(ObjectLinkingLayerTest, AddLinkGraph) { - auto G = - std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, - support::little, x86_64::getEdgeKindName); + auto G = std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, + llvm::endianness::little, + x86_64::getEdgeKindName); auto &Sec1 = G->createSection("__data", MemProt::Read | MemProt::Write); auto &B1 = G->createContentBlock(Sec1, BlockContent, @@ -104,9 +104,9 @@ TEST_F(ObjectLinkingLayerTest, ClaimLateDefinedWeakSymbols) { ObjLinkingLayer.addPlugin(std::make_unique()); - auto G = - std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, - support::little, x86_64::getEdgeKindName); + auto G = std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, + llvm::endianness::little, + x86_64::getEdgeKindName); auto &DataSec = G->createSection("__data", MemProt::Read | MemProt::Write); auto &DataBlock = G->createContentBlock(DataSec, BlockContent, @@ -158,9 +158,9 @@ TEST_F(ObjectLinkingLayerTest, HandleErrorDuringPostAllocationPass) { ObjLinkingLayer.addPlugin(std::make_unique()); - auto G = - std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, - support::little, x86_64::getEdgeKindName); + auto G = std::make_unique("foo", Triple("x86_64-apple-darwin"), 8, + llvm::endianness::little, + x86_64::getEdgeKindName); auto &DataSec = G->createSection("__data", MemProt::Read | MemProt::Write); auto &DataBlock = G->createContentBlock(DataSec, BlockContent, diff --git a/llvm/unittests/MC/StringTableBuilderTest.cpp b/llvm/unittests/MC/StringTableBuilderTest.cpp index 91f2b3b97e11..05f469a229bf 100644 --- a/llvm/unittests/MC/StringTableBuilderTest.cpp +++ b/llvm/unittests/MC/StringTableBuilderTest.cpp @@ -58,8 +58,8 @@ TEST(StringTableBuilderTest, BasicWinCOFF) { std::string Expected; - ExpectedSize = - support::endian::byte_swap(ExpectedSize); + ExpectedSize = support::endian::byte_swap( + ExpectedSize); Expected.append((const char*)&ExpectedSize, 4); Expected += "pygmy hippopotamus"; Expected += '\x00'; diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp index 9c6d15552174..494e3c18c81c 100644 --- a/llvm/unittests/ProfileData/InstrProfTest.cpp +++ b/llvm/unittests/ProfileData/InstrProfTest.cpp @@ -844,13 +844,13 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_big_endian) { Writer.addRecord({"callee3", 0x1235, {3, 4}}, Err); // Set big endian output. - Writer.setValueProfDataEndianness(support::big); + Writer.setValueProfDataEndianness(llvm::endianness::big); auto Profile = Writer.writeBuffer(); readProfile(std::move(Profile)); // Set big endian input. - Reader->setValueProfDataEndianness(support::big); + Reader->setValueProfDataEndianness(llvm::endianness::big); Expected R = Reader->getInstrProfRecord("caller", 0x1234); EXPECT_THAT_ERROR(R.takeError(), Succeeded()); @@ -867,7 +867,7 @@ TEST_P(MaybeSparseInstrProfTest, get_icall_data_read_write_big_endian) { ASSERT_EQ(StringRef((const char *)VD[2].Value, 7), StringRef("callee1")); // Restore little endian default: - Writer.setValueProfDataEndianness(support::little); + Writer.setValueProfDataEndianness(llvm::endianness::little); } TEST_P(MaybeSparseInstrProfTest, get_icall_data_merge1) { diff --git a/llvm/unittests/Support/ARMAttributeParser.cpp b/llvm/unittests/Support/ARMAttributeParser.cpp index ef3da3fc7504..4bde0eeb9503 100644 --- a/llvm/unittests/Support/ARMAttributeParser.cpp +++ b/llvm/unittests/Support/ARMAttributeParser.cpp @@ -35,7 +35,7 @@ bool testBuildAttr(unsigned Tag, unsigned Value, reinterpret_cast(OS.str().c_str()), OS.str().size()); ARMAttributeParser Parser; - cantFail(Parser.parse(Bytes, support::little)); + cantFail(Parser.parse(Bytes, llvm::endianness::little)); std::optional Attr = Parser.getAttributeValue(ExpectedTag); return Attr && *Attr == ExpectedValue; @@ -43,7 +43,7 @@ bool testBuildAttr(unsigned Tag, unsigned Value, void testParseError(ArrayRef bytes, const char *msg) { ARMAttributeParser parser; - Error e = parser.parse(bytes, support::little); + Error e = parser.parse(bytes, llvm::endianness::little); EXPECT_STREQ(toString(std::move(e)).c_str(), msg); } diff --git a/llvm/unittests/Support/BinaryStreamTest.cpp b/llvm/unittests/Support/BinaryStreamTest.cpp index 6ceadd6ce169..037aa596e7bb 100644 --- a/llvm/unittests/Support/BinaryStreamTest.cpp +++ b/llvm/unittests/Support/BinaryStreamTest.cpp @@ -266,7 +266,7 @@ TEST_F(BinaryStreamTest, StreamRefBounds) { TEST_F(BinaryStreamTest, StreamRefDynamicSize) { StringRef Strings[] = {"1", "2", "3", "4"}; - AppendingBinaryByteStream Stream(support::little); + AppendingBinaryByteStream Stream(llvm::endianness::little); BinaryStreamWriter Writer(Stream); BinaryStreamReader Reader(Stream); @@ -320,7 +320,7 @@ TEST_F(BinaryStreamTest, DropOperations) { initializeInput(InputData, 1); ArrayRef Result; - BinaryStreamRef Original(InputData, support::little); + BinaryStreamRef Original(InputData, llvm::endianness::little); ASSERT_EQ(InputData.size(), Original.getLength()); EXPECT_THAT_ERROR(Original.readBytes(0, InputData.size(), Result), @@ -835,7 +835,7 @@ TEST_F(BinaryStreamTest, StreamWriterPadToAlignment) { // This test may seem excessive but it is checking for past bugs and corner // cases by making sure that the stream is allowed to grow and that // both multiple pad chunks and single chunk extensions work. - AppendingBinaryByteStream Stream(support::little); + AppendingBinaryByteStream Stream(llvm::endianness::little); BinaryStreamWriter Writer(Stream); // Offset 0: '0' @@ -874,7 +874,7 @@ TEST_F(BinaryStreamTest, StreamWriterPadToAlignment) { TEST_F(BinaryStreamTest, StreamWriterAppend) { StringRef Strings[] = {"First", "Second", "Third", "Fourth"}; - AppendingBinaryByteStream Stream(support::little); + AppendingBinaryByteStream Stream(llvm::endianness::little); BinaryStreamWriter Writer(Stream); for (auto &Str : Strings) { diff --git a/llvm/unittests/Support/CSKYAttributeParserTest.cpp b/llvm/unittests/Support/CSKYAttributeParserTest.cpp index d3967fb0ea3c..1d39d14899f8 100644 --- a/llvm/unittests/Support/CSKYAttributeParserTest.cpp +++ b/llvm/unittests/Support/CSKYAttributeParserTest.cpp @@ -81,7 +81,7 @@ static bool testAttributeInt(unsigned Tag, unsigned Value, unsigned ExpectedTag, OS.str().size()); CSKYAttributeParser Parser; - cantFail(Parser.parse(Bytes, support::little)); + cantFail(Parser.parse(Bytes, llvm::endianness::little)); std::optional Attr = Parser.getAttributeValue(ExpectedTag); return Attr && *Attr == ExpectedValue; @@ -98,7 +98,7 @@ static bool testAttributeString(unsigned Tag, const char *Value, OS.str().size()); CSKYAttributeParser Parser; - cantFail(Parser.parse(Bytes, support::little)); + cantFail(Parser.parse(Bytes, llvm::endianness::little)); std::optional Attr = Parser.getAttributeString(ExpectedTag); return Attr && *Attr == ExpectedValue; @@ -113,7 +113,7 @@ static void testParseError(unsigned Tag, unsigned Value, const char *msg) { OS.str().size()); CSKYAttributeParser Parser; - Error e = Parser.parse(Bytes, support::little); + Error e = Parser.parse(Bytes, llvm::endianness::little); EXPECT_STREQ(toString(std::move(e)).c_str(), msg); } diff --git a/llvm/unittests/Support/ELFAttributeParserTest.cpp b/llvm/unittests/Support/ELFAttributeParserTest.cpp index 74d031e58a8b..38e7b09cc3c7 100644 --- a/llvm/unittests/Support/ELFAttributeParserTest.cpp +++ b/llvm/unittests/Support/ELFAttributeParserTest.cpp @@ -31,7 +31,7 @@ public: static void testParseError(ArrayRef bytes, const char *msg) { AttributeHeaderParser parser; - Error e = parser.parse(bytes, support::little); + Error e = parser.parse(bytes, llvm::endianness::little); EXPECT_STREQ(toString(std::move(e)).c_str(), msg); } diff --git a/llvm/unittests/Support/RISCVAttributeParserTest.cpp b/llvm/unittests/Support/RISCVAttributeParserTest.cpp index cdbec0cf2ddb..a9ede29c659c 100644 --- a/llvm/unittests/Support/RISCVAttributeParserTest.cpp +++ b/llvm/unittests/Support/RISCVAttributeParserTest.cpp @@ -42,7 +42,7 @@ static bool testAttribute(unsigned Tag, unsigned Value, unsigned ExpectedTag, OS.str().size()); RISCVAttributeParser Parser; - cantFail(Parser.parse(Bytes, support::little)); + cantFail(Parser.parse(Bytes, llvm::endianness::little)); std::optional Attr = Parser.getAttributeValue(ExpectedTag); return Attr && *Attr == ExpectedValue;