if (Header->Magic == HMAP_HeaderMagicNumber &&
Header->Version == HMAP_HeaderVersion)
NeedsByteSwap = false;
- else if (Header->Magic == llvm::ByteSwap_32(HMAP_HeaderMagicNumber) &&
- Header->Version == llvm::ByteSwap_16(HMAP_HeaderVersion))
+ else if (Header->Magic == llvm::byteswap<uint32_t>(HMAP_HeaderMagicNumber) &&
+ Header->Version == llvm::byteswap<uint16_t>(HMAP_HeaderVersion))
NeedsByteSwap = true; // Mixed endianness headermap.
else
return false; // Not a header map.
unsigned HeaderMapImpl::getEndianAdjustedWord(unsigned X) const {
if (!NeedsBSwap) return X;
- return llvm::ByteSwap_32(X);
+ return llvm::byteswap<uint32_t>(X);
}
/// getHeader - Return a reference to the file header, in unbyte-swapped form.
// type records are. Swap the byte order for better entropy. A better ghash
// won't need this.
uint32_t startIdx =
- ByteSwap_64(*reinterpret_cast<uint64_t *>(&ghash)) % tableSize;
+ llvm::byteswap<uint64_t>(*reinterpret_cast<uint64_t *>(&ghash)) %
+ tableSize;
// Do a linear probe starting at startIdx.
uint32_t idx = startIdx;
case Opcode::eType8:
return m_data.inst8;
case Opcode::eType16:
- return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ return GetEndianSwap() ? llvm::byteswap<uint16_t>(m_data.inst16)
+ : m_data.inst16;
case Opcode::eType16_2:
break;
case Opcode::eType32:
case Opcode::eType8:
return m_data.inst8;
case Opcode::eType16:
- return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ return GetEndianSwap() ? llvm::byteswap<uint16_t>(m_data.inst16)
+ : m_data.inst16;
case Opcode::eType16_2: // passthrough
case Opcode::eType32:
- return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ return GetEndianSwap() ? llvm::byteswap<uint32_t>(m_data.inst32)
+ : m_data.inst32;
case Opcode::eType64:
break;
case Opcode::eTypeBytes:
case Opcode::eType8:
return m_data.inst8;
case Opcode::eType16:
- return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ return GetEndianSwap() ? llvm::byteswap<uint16_t>(m_data.inst16)
+ : m_data.inst16;
case Opcode::eType16_2: // passthrough
case Opcode::eType32:
- return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ return GetEndianSwap() ? llvm::byteswap<uint32_t>(m_data.inst32)
+ : m_data.inst32;
case Opcode::eType64:
- return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : m_data.inst64;
+ return GetEndianSwap() ? llvm::byteswap<uint64_t>(m_data.inst64)
+ : m_data.inst64;
case Opcode::eTypeBytes:
break;
}
buf = GetOpcodeDataBytes();
break;
case Opcode::eType16:
- *(uint16_t *)swap_buf = llvm::ByteSwap_16(m_data.inst16);
+ *(uint16_t *)swap_buf = llvm::byteswap<uint16_t>(m_data.inst16);
buf = swap_buf;
break;
case Opcode::eType16_2:
buf = swap_buf;
break;
case Opcode::eType32:
- *(uint32_t *)swap_buf = llvm::ByteSwap_32(m_data.inst32);
+ *(uint32_t *)swap_buf = llvm::byteswap<uint32_t>(m_data.inst32);
buf = swap_buf;
break;
case Opcode::eType64:
- *(uint32_t *)swap_buf = llvm::ByteSwap_64(m_data.inst64);
+ *(uint32_t *)swap_buf = llvm::byteswap<uint64_t>(m_data.inst64);
buf = swap_buf;
break;
case Opcode::eTypeBytes:
if (header.magic == llvm::MachO::MH_CIGAM ||
header.magic == llvm::MachO::MH_CIGAM_64) {
- header.magic = llvm::ByteSwap_32(header.magic);
- header.cputype = llvm::ByteSwap_32(header.cputype);
- header.cpusubtype = llvm::ByteSwap_32(header.cpusubtype);
- header.filetype = llvm::ByteSwap_32(header.filetype);
- header.ncmds = llvm::ByteSwap_32(header.ncmds);
- header.sizeofcmds = llvm::ByteSwap_32(header.sizeofcmds);
- header.flags = llvm::ByteSwap_32(header.flags);
+ header.magic = llvm::byteswap<uint32_t>(header.magic);
+ header.cputype = llvm::byteswap<uint32_t>(header.cputype);
+ header.cpusubtype = llvm::byteswap<uint32_t>(header.cpusubtype);
+ header.filetype = llvm::byteswap<uint32_t>(header.filetype);
+ header.ncmds = llvm::byteswap<uint32_t>(header.ncmds);
+ header.sizeofcmds = llvm::byteswap<uint32_t>(header.sizeofcmds);
+ header.flags = llvm::byteswap<uint32_t>(header.flags);
}
return true;
return 0;
if (endian::InlHostByteOrder() == lldb::eByteOrderBig)
- value = llvm::ByteSwap_32(value);
+ value = llvm::byteswap<uint32_t>(value);
*((uint32_t *)dst) = value;
} else if (length == 8) {
uint32_t value1 = pseudo_state->ReadFromPseudoAddress(addr, success);
return 0;
if (endian::InlHostByteOrder() == lldb::eByteOrderBig) {
- value1 = llvm::ByteSwap_32(value1);
- value2 = llvm::ByteSwap_32(value2);
+ value1 = llvm::byteswap<uint32_t>(value1);
+ value2 = llvm::byteswap<uint32_t>(value2);
}
((uint32_t *)dst)[0] = value1;
((uint32_t *)dst)[1] = value2;
uint32_t value;
memcpy (&value, dst, sizeof (uint32_t));
if (endian::InlHostByteOrder() == lldb::eByteOrderBig)
- value = llvm::ByteSwap_32(value);
+ value = llvm::byteswap<uint32_t>(value);
pseudo_state->StoreToPseudoAddress(addr, value);
return length;
memcpy(&value2, static_cast<const uint8_t *>(dst) + sizeof(uint32_t),
sizeof(uint32_t));
if (endian::InlHostByteOrder() == lldb::eByteOrderBig) {
- value1 = llvm::ByteSwap_32(value1);
- value2 = llvm::ByteSwap_32(value2);
+ value1 = llvm::byteswap<uint32_t>(value1);
+ value2 = llvm::byteswap<uint32_t>(value2);
}
pseudo_state->StoreToPseudoAddress(addr, value1);
return false;
if (header.magic == llvm::MachO::MH_CIGAM ||
header.magic == llvm::MachO::MH_CIGAM_64) {
- header.magic = llvm::ByteSwap_32(header.magic);
- header.cputype = llvm::ByteSwap_32(header.cputype);
- header.cpusubtype = llvm::ByteSwap_32(header.cpusubtype);
- header.filetype = llvm::ByteSwap_32(header.filetype);
- header.ncmds = llvm::ByteSwap_32(header.ncmds);
- header.sizeofcmds = llvm::ByteSwap_32(header.sizeofcmds);
- header.flags = llvm::ByteSwap_32(header.flags);
+ header.magic = llvm::byteswap<uint32_t>(header.magic);
+ header.cputype = llvm::byteswap<uint32_t>(header.cputype);
+ header.cpusubtype = llvm::byteswap<uint32_t>(header.cpusubtype);
+ header.filetype = llvm::byteswap<uint32_t>(header.filetype);
+ header.ncmds = llvm::byteswap<uint32_t>(header.ncmds);
+ header.sizeofcmds = llvm::byteswap<uint32_t>(header.sizeofcmds);
+ header.flags = llvm::byteswap<uint32_t>(header.flags);
}
if (header.magic == llvm::MachO::MH_MAGIC ||
uint16_t offset) const {
uint32_t value = data[offset / 4];
if (m_byte_order != endian::InlHostByteOrder())
- value = llvm::ByteSwap_32(value);
+ value = llvm::byteswap<uint32_t>(value);
return (value >> ((3 - (offset % 4)) * 8)) & 0xff;
}
offset_t offset) {
uint16_t value;
memcpy(&value, ptr + offset, 2);
- return llvm::ByteSwap_16(value);
+ return llvm::byteswap<uint16_t>(value);
}
static inline uint32_t ReadSwapInt32(const unsigned char *ptr,
offset_t offset) {
uint32_t value;
memcpy(&value, ptr + offset, 4);
- return llvm::ByteSwap_32(value);
+ return llvm::byteswap<uint32_t>(value);
}
static inline uint64_t ReadSwapInt64(const unsigned char *ptr,
offset_t offset) {
uint64_t value;
memcpy(&value, ptr + offset, 8);
- return llvm::ByteSwap_64(value);
+ return llvm::byteswap<uint64_t>(value);
}
static inline uint16_t ReadSwapInt16(const void *ptr) {
uint16_t value;
memcpy(&value, ptr, 2);
- return llvm::ByteSwap_16(value);
+ return llvm::byteswap<uint16_t>(value);
}
static inline uint32_t ReadSwapInt32(const void *ptr) {
uint32_t value;
memcpy(&value, ptr, 4);
- return llvm::ByteSwap_32(value);
+ return llvm::byteswap<uint32_t>(value);
}
static inline uint64_t ReadSwapInt64(const void *ptr) {
uint64_t value;
memcpy(&value, ptr, 8);
- return llvm::ByteSwap_64(value);
+ return llvm::byteswap<uint64_t>(value);
}
static inline uint64_t ReadMaxInt64(const uint8_t *data, size_t byte_size,
uint32_t CPUType;
memcpy(&CPUType, Data.data() + 4, sizeof(uint32_t));
if (Magic == MachO::MH_CIGAM_64)
- CPUType = ByteSwap_32(CPUType);
+ CPUType = llvm::byteswap<uint32_t>(CPUType);
LLVM_DEBUG({
dbgs() << "jitLink_MachO: cputype = " << format("0x%08" PRIx32, CPUType)
APInt APInt::byteSwap() const {
assert(BitWidth >= 16 && BitWidth % 8 == 0 && "Cannot byteswap!");
if (BitWidth == 16)
- return APInt(BitWidth, ByteSwap_16(uint16_t(U.VAL)));
+ return APInt(BitWidth, llvm::byteswap<uint16_t>(U.VAL));
if (BitWidth == 32)
- return APInt(BitWidth, ByteSwap_32(unsigned(U.VAL)));
+ return APInt(BitWidth, llvm::byteswap<uint32_t>(U.VAL));
if (BitWidth <= 64) {
- uint64_t Tmp1 = ByteSwap_64(U.VAL);
+ uint64_t Tmp1 = llvm::byteswap<uint64_t>(U.VAL);
Tmp1 >>= (64 - BitWidth);
return APInt(BitWidth, Tmp1);
}
APInt Result(getNumWords() * APINT_BITS_PER_WORD, 0);
for (unsigned I = 0, N = getNumWords(); I != N; ++I)
- Result.U.pVal[I] = ByteSwap_64(U.pVal[N - I - 1]);
+ Result.U.pVal[I] = llvm::byteswap<uint64_t>(U.pVal[N - I - 1]);
if (Result.BitWidth != BitWidth) {
Result.lshrInPlace(Result.BitWidth - BitWidth);
Result.BitWidth = BitWidth;
if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
for (UTF16 &I : ByteSwapped)
- I = llvm::ByteSwap_16(I);
+ I = llvm::byteswap<uint16_t>(I);
Src = &ByteSwapped[0];
SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1;
}
if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) {
ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
for (UTF32 &I : ByteSwapped)
- I = llvm::ByteSwap_32(I);
+ I = llvm::byteswap<uint32_t>(I);
Src = &ByteSwapped[0];
SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1;
}