Use llvm::endianness::{big,little,native} (NFC)

Note that llvm::support::endianness has been renamed to
llvm::endianness while becoming an enum class as opposed to an
enum. This patch replaces support::{big,little,native} with
llvm::endianness::{big,little,native}.
This commit is contained in:
Kazu Hirata 2023-10-12 21:21:44 -07:00
parent 2045cca0c3
commit 4a0ccfa865
142 changed files with 463 additions and 391 deletions

View File

@ -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<uint8_t>(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<uint8_t>(OffsetPair),
support::little);
llvm::endianness::little);
encodeULEB128(OffsetEntry.StartOffset, OS);
encodeULEB128(OffsetEntry.EndOffset, OS);
Func(OffsetEntry.Index);
}
support::endian::write(OS, static_cast<uint8_t>(EndOfList), support::little);
support::endian::write(OS, static_cast<uint8_t>(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<uint8_t>(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<uint8_t>(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<DebugBufferVector> Header = getDWARF5Header(
{static_cast<uint32_t>(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<uint16_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint64_t>(Entry.LowPC),
support::little);
llvm::endianness::little);
support::endian::write(*LocStream, static_cast<uint64_t>(Entry.HighPC),
support::little);
llvm::endianness::little);
support::endian::write(*LocStream, static_cast<uint16_t>(Entry.Expr.size()),
support::little);
llvm::endianness::little);
*LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
Entry.Expr.size());
LocSectionOffset += 2 * 8 + 2 + Entry.Expr.size();
@ -618,15 +622,17 @@ std::unique_ptr<DebugBufferVector> DebugLocWriter::getBuffer() {
void DebugLocWriter::finalize(DIEBuilder &DIEBldr, DIE &Die) {}
static void writeEmptyListDwarf5(raw_svector_ostream &Stream) {
support::endian::write(Stream, static_cast<uint32_t>(4), support::little);
support::endian::write(Stream, static_cast<uint32_t>(4),
llvm::endianness::little);
support::endian::write(Stream, static_cast<uint8_t>(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<uint8_t>(dwarf::DW_LLE_end_of_list), support::little);
support::endian::write(Stream,
static_cast<uint8_t>(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<uint8_t>(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<uint32_t>(Entry.HighPC - Entry.LowPC),
support::little);
llvm::endianness::little);
support::endian::write(LocStream, static_cast<uint16_t>(Entry.Expr.size()),
support::little);
llvm::endianness::little);
LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
Entry.Expr.size());
}
support::endian::write(LocStream,
static_cast<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint32_t>(SizeOfArraySection + RelativeOffset),
support::little);
llvm::endianness::little);
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
{static_cast<uint32_t>(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<uint16_t>(5),
support::little);
llvm::endianness::little);
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(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(),

View File

@ -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<char *>(&Swapped) + Index, Size);
Contents.append(Entry.begin(), Entry.end());

View File

@ -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));
}

View File

@ -1210,7 +1210,7 @@ static void readCallGraphsFromObjectFiles(COFFLinkerContext &ctx) {
ArrayRef<uint8_t> 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;

View File

@ -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())

View File

@ -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<uint8_t> 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<uint8_t> relocatedDebugContents =
relocateDebugChunk(*debugChunk);
FixedStreamArray<object::FpoData> 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<uint8_t> 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) {

View File

@ -219,7 +219,7 @@ template <endianness E> 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]);
}

View File

@ -933,7 +933,7 @@ mergeAttributesSection(const SmallVector<InputSectionBase *, 0> &sections) {
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)) {

View File

@ -604,9 +604,9 @@ template <class ELFT> void ObjFile<ELFT>::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 {

View File

@ -320,7 +320,7 @@ static std::optional<size_t> getRecordSize(StringRef segname, StringRef name) {
static Error parseCallGraph(ArrayRef<uint8_t> data,
std::vector<CallGraphEntry> &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;

View File

@ -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) {

View File

@ -42,9 +42,9 @@ Expected<ProcessInfo> 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<RegisterValue> 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;

View File

@ -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 {

View File

@ -168,7 +168,8 @@ public:
unsigned BytesRead;
if (BitcodeBytes.size() >= NextChar + sizeof(word_t)) {
BytesRead = sizeof(word_t);
CurWord = support::endian::read<word_t, support::little>(NextCharPtr);
CurWord =
support::endian::read<word_t, llvm::endianness::little>(NextCharPtr);
} else {
// Short read.
BytesRead = BitcodeBytes.size() - NextChar;

View File

@ -75,7 +75,8 @@ class BitstreamWriter {
std::vector<BlockInfo> BlockInfoRecords;
void WriteWord(unsigned Value) {
Value = support::endian::byte_swap<uint32_t, support::little>(Value);
Value =
support::endian::byte_swap<uint32_t, llvm::endianness::little>(Value);
Out.append(reinterpret_cast<const char *>(&Value),
reinterpret_cast<const char *>(&Value + 1));
}

View File

@ -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<uint8_t> &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<uint8_t> &Buffer) override;

View File

@ -107,10 +107,9 @@ namespace detail {
template <typename T>
struct EndianAdapter final
: public FormatAdapter<support::detail::packed_endian_specific_integral<
T, support::little, support::unaligned>> {
using EndianType =
support::detail::packed_endian_specific_integral<T, support::little,
support::unaligned>;
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<EndianType>(std::move(Item)) {}
@ -122,10 +121,9 @@ struct EndianAdapter final
} // namespace detail
template <typename T>
detail::EndianAdapter<T>
fmtle(support::detail::packed_endian_specific_integral<T, support::little,
support::unaligned>
Value) {
detail::EndianAdapter<T> fmtle(support::detail::packed_endian_specific_integral<
T, llvm::endianness::little, support::unaligned>
Value) {
return detail::EndianAdapter<T>(std::move(Value));
}
} // namespace pdb

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> 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<ELFT>::getBytesInAddress() const {
template <class ELFT>
StringRef ELFObjectFile<ELFT>::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<ELFT>::getFileFormatName() const {
}
template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::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;

View File

@ -90,10 +90,10 @@ public:
using Off = packed<uint>;
};
using ELF32LE = ELFType<support::little, false>;
using ELF32BE = ELFType<support::big, false>;
using ELF64LE = ELFType<support::little, true>;
using ELF64BE = ELFType<support::big, true>;
using ELF32LE = ELFType<llvm::endianness::little, false>;
using ELF32BE = ELFType<llvm::endianness::big, false>;
using ELF64LE = ELFType<llvm::endianness::little, true>;
using ELF64BE = ELFType<llvm::endianness::big, true>;
// Use an alignment of 2 for the typedefs since that is the worst case for
// ELF files in archives.

View File

@ -42,7 +42,7 @@ class FaultMapParser {
template <typename T> static T read(const uint8_t *P, const uint8_t *E) {
assert(P + sizeof(T) <= E && "out of bounds read!");
return support::endian::read<T, support::little>(P);
return support::endian::read<T, llvm::endianness::little>(P);
}
public:

View File

@ -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<T, support::big>(&Bytes[ByteIndex]);
Value = support::endian::read<T, llvm::endianness::big>(&Bytes[ByteIndex]);
}
};

View File

@ -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)

View File

@ -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<uint8_t>(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);

View File

@ -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<uint8_t> Data,
uint32_t RecordCountHint) {
BinaryStreamReader Reader(Data, support::little);
BinaryStreamReader Reader(Data, llvm::endianness::little);
reset(Reader, RecordCountHint);
}

View File

@ -34,7 +34,7 @@ SimpleTypeSerializer::~SimpleTypeSerializer() = default;
template <typename T>
ArrayRef<uint8_t> 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.

View File

@ -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!");

View File

@ -470,7 +470,7 @@ static void resolveTypeIndexReferences(ArrayRef<uint8_t> 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<TypeIndex> Run;

View File

@ -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<FunctionInfo> 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<uint64_t> OptAddr = getAddress(*AddressIndex)) {
auto ExpectedFI = FunctionInfo::decode(Data, *OptAddr);
if (ExpectedFI) {
@ -284,10 +286,11 @@ llvm::Expected<LookupResult> 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<uint64_t> OptAddr = getAddress(*AddressIndex))
return FunctionInfo::lookup(Data, *this, *OptAddr, Addr);
return createStringError(std::errc::invalid_argument,

View File

@ -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<BinaryStreamReader>(*DataOrErr, support::little);
ReaderPrecomp = std::make_unique<BinaryStreamReader>(
*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))

View File

@ -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;

View File

@ -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,

View File

@ -265,7 +265,7 @@ createLinkGraphFromELFObject_aarch32(MemoryBufferRef ObjectBuffer) {
case Triple::arm:
case Triple::thumb: {
auto &ELFFile = cast<ELFObjectFile<ELF32LE>>(**ELFObj).getELFFile();
return ELFLinkGraphBuilder_aarch32<support::little>(
return ELFLinkGraphBuilder_aarch32<llvm::endianness::little>(
(*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<ELFObjectFile<ELF32BE>>(**ELFObj).getELFFile();
return ELFLinkGraphBuilder_aarch32<support::big>(
return ELFLinkGraphBuilder_aarch32<llvm::endianness::big>(
(*ELFObj)->getFileName(), ELFFile, TT, std::move(*Features),
ArmCfg)
.buildGraph();

View File

@ -506,26 +506,26 @@ void link_ELF_ppc64(std::unique_ptr<LinkGraph> G,
Expected<std::unique_ptr<LinkGraph>>
createLinkGraphFromELFObject_ppc64(MemoryBufferRef ObjectBuffer) {
return createLinkGraphFromELFObject_ppc64<support::big>(
return createLinkGraphFromELFObject_ppc64<llvm::endianness::big>(
std::move(ObjectBuffer));
}
Expected<std::unique_ptr<LinkGraph>>
createLinkGraphFromELFObject_ppc64le(MemoryBufferRef ObjectBuffer) {
return createLinkGraphFromELFObject_ppc64<support::little>(
return createLinkGraphFromELFObject_ppc64<llvm::endianness::little>(
std::move(ObjectBuffer));
}
/// jit-link the given object buffer, which must be a ELF ppc64 object file.
void link_ELF_ppc64(std::unique_ptr<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx) {
return link_ELF_ppc64<support::big>(std::move(G), std::move(Ctx));
return link_ELF_ppc64<llvm::endianness::big>(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<LinkGraph> G,
std::unique_ptr<JITLinkContext> Ctx) {
return link_ELF_ppc64<support::little>(std::move(G), std::move(Ctx));
return link_ELF_ppc64<llvm::endianness::little>(std::move(G), std::move(Ctx));
}
} // end namespace llvm::jitlink

View File

@ -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<LinkGraph>("", Triple(), 0, support::native, nullptr);
auto G = std::make_unique<LinkGraph>("", Triple(), 0,
llvm::endianness::native, nullptr);
orc::AllocGroupSmallMap<Block *> ContentBlocks;
orc::ExecutorAddr NextAddr(0x100000);

View File

@ -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() {

View File

@ -113,8 +113,9 @@ llvm::orc::createDWARFContext(LinkGraph &G) {
std::make_unique<SmallVectorMemoryBuffer>(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));
}

View File

@ -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;

View File

@ -35,7 +35,8 @@ static void or32AArch64Imm(void *L, uint64_t Imm) {
}
template <class T> static void write(bool isBE, void *P, T V) {
isBE ? write<T, support::big>(P, V) : write<T, support::little>(P, V);
isBE ? write<T, llvm::endianness::big>(P, V)
: write<T, llvm::endianness::little>(P, V);
}
static void write32AArch64Addr(void *L, uint64_t Imm) {

View File

@ -318,18 +318,24 @@ protected:
std::string ErrorStr;
void writeInt16BE(uint8_t *Addr, uint16_t Value) {
llvm::support::endian::write<uint16_t>(
Addr, Value, IsTargetLittleEndian ? support::little : support::big);
llvm::support::endian::write<uint16_t>(Addr, Value,
IsTargetLittleEndian
? llvm::endianness::little
: llvm::endianness::big);
}
void writeInt32BE(uint8_t *Addr, uint32_t Value) {
llvm::support::endian::write<uint32_t>(
Addr, Value, IsTargetLittleEndian ? support::little : support::big);
llvm::support::endian::write<uint32_t>(Addr, Value,
IsTargetLittleEndian
? llvm::endianness::little
: llvm::endianness::big);
}
void writeInt64BE(uint8_t *Addr, uint64_t Value) {
llvm::support::endian::write<uint64_t>(
Addr, Value, IsTargetLittleEndian ? support::little : support::big);
llvm::support::endian::write<uint64_t>(Addr, Value,
IsTargetLittleEndian
? llvm::endianness::little
: llvm::endianness::big);
}
virtual void setMipsABI(const ObjectFile &Obj) {

View File

@ -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;

View File

@ -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<const char *>(&BaseData), InfoSize);
uint32_t ResourceCount = static_cast<uint32_t>(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<const char *>(&Res), BindingSize);
@ -126,22 +126,22 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
}
support::endian::write(OS, static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(sizeof(v0::SignatureElement)),
support::little);
llvm::endianness::little);
// write the signature elements.
OS.write(reinterpret_cast<const char *>(&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<uint32_t>(MaskVector),
support::little);
llvm::endianness::little);
support::endian::write_array(OS, ArrayRef<uint32_t>(PatchOrPrimMasks),
support::little);
llvm::endianness::little);
for (const auto &MaskVector : InputOutputMap)
support::endian::write_array(OS, ArrayRef<uint32_t>(MaskVector),
support::little);
llvm::endianness::little);
support::endian::write_array(OS, ArrayRef<uint32_t>(InputPatchMap),
support::little);
llvm::endianness::little);
support::endian::write_array(OS, ArrayRef<uint32_t>(PatchOutputMap),
support::little);
llvm::endianness::little);
}
void Signature::write(raw_ostream &OS) {

View File

@ -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]

View File

@ -137,7 +137,8 @@ public:
// Support for endian-specific data.
template <typename value_type> void writebe(value_type Value) {
Value = support::endian::byte_swap<value_type>(Value, support::big);
Value =
support::endian::byte_swap<value_type>(Value, llvm::endianness::big);
write(reinterpret_cast<const char *>(&Value), sizeof(value_type));
}
};

View File

@ -33,11 +33,11 @@ MCAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
auto TW = createObjectTargetWriter();
switch (TW->getFormat()) {
case Triple::ELF:
return createELFObjectWriter(cast<MCELFObjectTargetWriter>(std::move(TW)), OS,
Endian == support::little);
return createELFObjectWriter(cast<MCELFObjectTargetWriter>(std::move(TW)),
OS, Endian == llvm::endianness::little);
case Triple::MachO:
return createMachObjectWriter(cast<MCMachObjectTargetWriter>(std::move(TW)),
OS, Endian == support::little);
OS, Endian == llvm::endianness::little);
case Triple::COFF:
return createWinCOFFObjectWriter(
cast<MCWinCOFFObjectTargetWriter>(std::move(TW)), OS);
@ -72,7 +72,7 @@ MCAsmBackend::createDwoObjectWriter(raw_pwrite_stream &OS,
case Triple::ELF:
return createELFDwoObjectWriter(
cast<MCELFObjectTargetWriter>(std::move(TW)), OS, DwoOS,
Endian == support::little);
Endian == llvm::endianness::little);
case Triple::Wasm:
return createWasmDwoObjectWriter(
cast<MCWasmObjectTargetWriter>(std::move(TW)), OS, DwoOS);

View File

@ -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)

View File

@ -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

View File

@ -30,7 +30,7 @@ class DXContainerObjectWriter : public MCObjectWriter {
public:
DXContainerObjectWriter(std::unique_ptr<MCDXContainerTargetWriter> MOTW,
raw_pwrite_stream &OS)
: W(OS, support::little), TargetObjectWriter(std::move(MOTW)) {}
: W(OS, llvm::endianness::little), TargetObjectWriter(std::move(MOTW)) {}
~DXContainerObjectWriter() override {}

View File

@ -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;

View File

@ -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<char *>(&Swapped) + Index, Size));
}

View File

@ -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);

View File

@ -24,7 +24,7 @@ class SPIRVObjectWriter : public MCObjectWriter {
public:
SPIRVObjectWriter(std::unique_ptr<MCSPIRVObjectTargetWriter> MOTW,
raw_pwrite_stream &OS)
: W(OS, support::little), TargetObjectWriter(std::move(MOTW)) {}
: W(OS, llvm::endianness::little), TargetObjectWriter(std::move(MOTW)) {}
~SPIRVObjectWriter() override {}

View File

@ -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 {

View File

@ -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

View File

@ -448,7 +448,7 @@ public:
XCOFFObjectWriter::XCOFFObjectWriter(
std::unique_ptr<MCXCOFFObjectTargetWriter> 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}),

View File

@ -1987,8 +1987,9 @@ template <class ELFT> void ELFWriter<ELFT>::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<uint16_t>(Obj.Entry),
support::big);
llvm::endianness::big);
HexData = IHexRecord::getLine(IHexRecord::StartAddr80x86, 0, Data);
} else {
support::endian::write(Data, static_cast<uint32_t>(Obj.Entry),
support::big);
llvm::endianness::big);
HexData = IHexRecord::getLine(IHexRecord::StartAddr, 0, Data);
}
memcpy(Buf, HexData.data(), HexData.size());

View File

@ -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;

View File

@ -203,11 +203,12 @@ static bool isBSDLike(object::Archive::Kind Kind) {
template <class T>
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 <class T> 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(

View File

@ -1907,7 +1907,7 @@ Error ResourceSectionRef::load(const COFFObjectFile *O, const SectionRef &S) {
Expected<StringRef> 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<coff_relocation> OrigRelocs = Obj->getRelocations(COFFSect);
Relocs.reserve(OrigRelocs.size());

View File

@ -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

View File

@ -182,7 +182,7 @@ toDebugS(ArrayRef<CodeViewYAML::YAMLDebugSubsection> Subsections,
}
uint8_t *Buffer = Allocator.Allocate<uint8_t>(Size);
MutableArrayRef<uint8_t> Output(Buffer, Size);
BinaryStreamWriter Writer(Output, support::little);
BinaryStreamWriter Writer(Output, llvm::endianness::little);
Err(Writer.writeInteger<uint32_t>(COFF::DEBUG_SECTION_MAGIC));
for (const auto &B : Builders) {
@ -314,7 +314,8 @@ template <typename value_type>
raw_ostream &operator<<(raw_ostream &OS,
const binary_le_impl<value_type> &BLE) {
char Buffer[sizeof(BLE.Value)];
support::endian::write<value_type, support::little>(Buffer, BLE.Value);
support::endian::write<value_type, llvm::endianness::little>(Buffer,
BLE.Value);
OS.write(Buffer, sizeof(BLE.Value));
return OS;
}

View File

@ -900,7 +900,7 @@ YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC,
std::vector<YAMLDebugSubsection>
llvm::CodeViewYAML::fromDebugS(ArrayRef<uint8_t> Data,
const StringsAndChecksumsRef &SC) {
BinaryStreamReader Reader(Data, support::little);
BinaryStreamReader Reader(Data, llvm::endianness::little);
uint32_t Magic;
ExitOnError Err("Invalid .debug$S section!");

View File

@ -784,7 +784,7 @@ std::vector<LeafRecord>
llvm::CodeViewYAML::fromDebugT(ArrayRef<uint8_t> 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<uint8_t> llvm::CodeViewYAML::toDebugT(ArrayRef<LeafRecord> Leafs,
}
uint8_t *ResultBuffer = Alloc.Allocate<uint8_t>(Size);
MutableArrayRef<uint8_t> 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<uint32_t>(COFF::DEBUG_SECTION_MAGIC));

View File

@ -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;
}

View File

@ -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<uint64_t>(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;

View File

@ -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<uint64_t>(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<raw_pwrite_stream &>(*OutputStream), support::little);
static_cast<raw_pwrite_stream &>(*OutputStream),
llvm::endianness::little);
for (uint32_t LayoutIdx = 0; LayoutIdx < SectionHdrLayout.size();
LayoutIdx++) {
assert(IndexMap[LayoutIdx] < SecHdrTable.size() &&

View File

@ -75,7 +75,7 @@ static Expected<uint64_t> parseVersion(StringRef &Buf) {
"Expecting version number.");
uint64_t Version =
support::endian::read<uint64_t, support::little>(Buf.data());
support::endian::read<uint64_t, llvm::endianness::little>(Buf.data());
if (Version != remarks::CurrentRemarkVersion)
return createStringError(std::errc::illegal_byte_sequence,
"Mismatching remark version. Got %" PRId64
@ -90,7 +90,7 @@ static Expected<uint64_t> parseStrTabSize(StringRef &Buf) {
return createStringError(std::errc::illegal_byte_sequence,
"Expecting string table size.");
uint64_t StrTabSize =
support::endian::read<uint64_t, support::little>(Buf.data());
support::endian::read<uint64_t, llvm::endianness::little>(Buf.data());
Buf = Buf.drop_front(sizeof(uint64_t));
return StrTabSize;
}

View File

@ -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.

View File

@ -191,7 +191,7 @@ Error ELFAttributeParser::parseSubsection(uint32_t length) {
Error ELFAttributeParser::parse(ArrayRef<uint8_t> 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.

View File

@ -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) {

View File

@ -685,7 +685,7 @@ void AArch64MCCodeEmitter::encodeInstruction(const MCInst &MI,
}
uint64_t Binary = getBinaryCodeForInstr(MI, Fixups, STI);
support::endian::write<uint32_t>(CB, Binary, support::little);
support::endian::write<uint32_t>(CB, Binary, llvm::endianness::little);
++MCNumEmitted; // Keep track of the # of mi's emitted.
}

View File

@ -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; };

View File

@ -142,11 +142,11 @@ void R600MCCodeEmitter::encodeInstruction(const MCInst &MI,
}
void R600MCCodeEmitter::emit(uint32_t Value, SmallVectorImpl<char> &CB) const {
support::endian::write(CB, Value, support::little);
support::endian::write(CB, Value, llvm::endianness::little);
}
void R600MCCodeEmitter::emit(uint64_t Value, SmallVectorImpl<char> &CB) const {
support::endian::write(CB, Value, support::little);
support::endian::write(CB, Value, llvm::endianness::little);
}
unsigned R600MCCodeEmitter::getHWReg(unsigned RegNo) const {

View File

@ -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);
}

View File

@ -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()))) {}

View File

@ -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<MCObjectTargetWriter>
createObjectTargetWriter() const override {
return createARMWinCOFFObjectWriter();

View File

@ -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<uint16_t>(CB, Binary, Endian);

View File

@ -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;

View File

@ -97,7 +97,7 @@ void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
support::endian::write<uint64_t>(&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);
}

View File

@ -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);

View File

@ -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)) {

View File

@ -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;

View File

@ -60,8 +60,9 @@ CSKYMCCodeEmitter::getImmOpValueMSBSize(const MCInst &MI, unsigned Idx,
static void writeData(uint32_t Bin, unsigned Size, SmallVectorImpl<char> &CB) {
if (Size == 4)
support::endian::write(CB, static_cast<uint16_t>(Bin >> 16),
support::little);
support::endian::write(CB, static_cast<uint16_t>(Bin), support::little);
llvm::endianness::little);
support::endian::write(CB, static_cast<uint16_t>(Bin),
llvm::endianness::little);
}
void CSKYMCCodeEmitter::expandJBTF(const MCInst &MI, SmallVectorImpl<char> &CB,

View File

@ -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,

View File

@ -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<MCObjectTargetWriter>
createObjectTargetWriter() const override {

View File

@ -443,7 +443,7 @@ void HexagonMCCodeEmitter::encodeSingleInstruction(
Binary |= SubBits0 | (SubBits1 << 16);
}
support::endian::write<uint32_t>(CB, Binary, support::little);
support::endian::write<uint32_t>(CB, Binary, llvm::endianness::little);
++MCNumEmitted;
}

View File

@ -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<char> Data,

View File

@ -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<uint32_t>(CB, Value, support::big);
support::endian::write<uint32_t>(CB, Value, llvm::endianness::big);
}
// Encode Lanai Memory Operand

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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; }

View File

@ -82,11 +82,11 @@ template <typename value_t> 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;

View File

@ -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<uint16_t>(CB, static_cast<uint16_t>(Word),
support::big);
llvm::endianness::big);
Word >>= 16;
}
}

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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];
}

View File

@ -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<MCObjectTargetWriter>

View File

@ -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<uint16_t>(CB, Binary, Endian);
} else if (IsLittleEndian && isMicroMips(STI)) {

Some files were not shown because too many files have changed in this diff Show More