Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in...
authorArtyom Skrobov <Artyom.Skrobov@arm.com>
Sat, 14 Jun 2014 13:18:07 +0000 (13:18 +0000)
committerArtyom Skrobov <Artyom.Skrobov@arm.com>
Sat, 14 Jun 2014 13:18:07 +0000 (13:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210978 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/Hashing.h
include/llvm/Support/Endian.h
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
lib/MC/ELFObjectWriter.cpp
lib/Support/DataExtractor.cpp

index c636226545cbffa6bef1716c8c85c8fa9ca2451b..abf02b8cc9d557e5692a6a3e12f3c38ea4faa703 100644 (file)
@@ -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;
 }
 
index d394974ad3bb97e055846453b3a62c576a3742cf..455d0fc241f2184a4677349684b48091646ab6d0 100644 (file)
@@ -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;
 }
 
index 3e9a68a2a300d2cb78fd35fc5737d0bcde15475b..11cc3b246acaa458384c0686af22540a9d7b24d6 100644 (file)
@@ -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;
index 0a17c33f7fbf5cda426edf023fa3787c47f296e1..a98a13e0cd42aac0df11d5609cbbc8ae9d10a901 100644 (file)
@@ -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());
index c320554b6365b15d1bfba38376511c89fba5dfc9..5d6d60a87fbfa2af12a2cdbfcb5f884f0fa8719b 100644 (file)
@@ -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);