summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Skrobov <Artyom.Skrobov@arm.com>2014-06-14 13:18:07 +0000
committerArtyom Skrobov <Artyom.Skrobov@arm.com>2014-06-14 13:18:07 +0000
commitab22d954818d6aa92d7e21dc8609aa178b532535 (patch)
tree79df94b2c8b99629cc9ee1951e7106b38b32b987
parent25e659b6fff576e53f3d2d80576a7cbe7db1c34d (diff)
downloadllvm-ab22d954818d6aa92d7e21dc8609aa178b532535.tar.gz
llvm-ab22d954818d6aa92d7e21dc8609aa178b532535.tar.bz2
llvm-ab22d954818d6aa92d7e21dc8609aa178b532535.tar.xz
Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in place
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210978 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/Hashing.h4
-rw-r--r--include/llvm/Support/Endian.h2
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h6
-rw-r--r--lib/MC/ELFObjectWriter.cpp2
-rw-r--r--lib/Support/DataExtractor.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/include/llvm/ADT/Hashing.h b/include/llvm/ADT/Hashing.h
index c636226545..abf02b8cc9 100644
--- a/include/llvm/ADT/Hashing.h
+++ b/include/llvm/ADT/Hashing.h
@@ -152,7 +152,7 @@ inline uint64_t fetch64(const char *p) {
uint64_t result;
memcpy(&result, p, sizeof(result));
if (sys::IsBigEndianHost)
- return sys::getSwappedBytes(result);
+ sys::swapByteOrder(result);
return result;
}
@@ -160,7 +160,7 @@ inline uint32_t fetch32(const char *p) {
uint32_t result;
memcpy(&result, p, sizeof(result));
if (sys::IsBigEndianHost)
- return sys::getSwappedBytes(result);
+ sys::swapByteOrder(result);
return result;
}
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h
index d394974ad3..455d0fc241 100644
--- a/include/llvm/Support/Endian.h
+++ b/include/llvm/Support/Endian.h
@@ -38,7 +38,7 @@ namespace endian {
template<typename value_type, endianness endian>
inline value_type byte_swap(value_type value) {
if (endian != native && sys::IsBigEndianHost != (endian == big))
- return sys::getSwappedBytes(value);
+ sys::swapByteOrder(value);
return value;
}
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index 3e9a68a2a3..11cc3b246a 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -245,14 +245,14 @@ protected:
void writeInt16BE(uint8_t *Addr, uint16_t Value) {
if (IsTargetLittleEndian)
- Value = sys::getSwappedBytes(Value);
+ sys::swapByteOrder(Value);
*Addr = (Value >> 8) & 0xFF;
*(Addr + 1) = Value & 0xFF;
}
void writeInt32BE(uint8_t *Addr, uint32_t Value) {
if (IsTargetLittleEndian)
- Value = sys::getSwappedBytes(Value);
+ sys::swapByteOrder(Value);
*Addr = (Value >> 24) & 0xFF;
*(Addr + 1) = (Value >> 16) & 0xFF;
*(Addr + 2) = (Value >> 8) & 0xFF;
@@ -261,7 +261,7 @@ protected:
void writeInt64BE(uint8_t *Addr, uint64_t Value) {
if (IsTargetLittleEndian)
- Value = sys::getSwappedBytes(Value);
+ sys::swapByteOrder(Value);
*Addr = (Value >> 56) & 0xFF;
*(Addr + 1) = (Value >> 48) & 0xFF;
*(Addr + 2) = (Value >> 40) & 0xFF;
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 0a17c33f7f..a98a13e0cd 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -1179,7 +1179,7 @@ prependCompressionHeader(uint64_t Size,
if (Size <= Magic.size() + sizeof(Size) + CompressedContents.size())
return false;
if (sys::IsLittleEndianHost)
- Size = sys::getSwappedBytes(Size);
+ sys::swapByteOrder(Size);
CompressedContents.insert(CompressedContents.begin(),
Magic.size() + sizeof(Size), 0);
std::copy(Magic.begin(), Magic.end(), CompressedContents.begin());
diff --git a/lib/Support/DataExtractor.cpp b/lib/Support/DataExtractor.cpp
index c320554b63..5d6d60a87f 100644
--- a/lib/Support/DataExtractor.cpp
+++ b/lib/Support/DataExtractor.cpp
@@ -21,7 +21,7 @@ static T getU(uint32_t *offset_ptr, const DataExtractor *de,
if (de->isValidOffsetForDataOfSize(offset, sizeof(val))) {
std::memcpy(&val, &Data[offset], sizeof(val));
if (sys::IsLittleEndianHost != isLittleEndian)
- val = sys::getSwappedBytes(val);
+ sys::swapByteOrder(val);
// Advance the offset
*offset_ptr += sizeof(val);