[PATCH] D156814: [NFC] Refactor byteswapped writes
Chris Bieneman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 18:39:27 PDT 2023
This revision was automatically updated to reflect the committed changes.
beanz marked an inline comment as done.
Closed by commit rGb46d0353d4a8: [NFC] Refactor byteswapped writes (authored by beanz).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156814/new/
https://reviews.llvm.org/D156814
Files:
llvm/lib/MC/DXContainerPSVInfo.cpp
Index: llvm/lib/MC/DXContainerPSVInfo.cpp
===================================================================
--- llvm/lib/MC/DXContainerPSVInfo.cpp
+++ llvm/lib/MC/DXContainerPSVInfo.cpp
@@ -8,6 +8,7 @@
#include "llvm/MC/DXContainerPSVInfo.h"
#include "llvm/BinaryFormat/DXContainer.h"
+#include "llvm/Support/EndianStream.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -31,24 +32,16 @@
InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo);
BindingSize = sizeof(dxbc::PSV::v2::ResourceBindInfo);
}
- uint32_t InfoSizeSwapped = InfoSize;
- if (sys::IsBigEndianHost)
- sys::swapByteOrder(InfoSizeSwapped);
// Write the size of the info.
- OS.write(reinterpret_cast<const char *>(&InfoSizeSwapped), sizeof(uint32_t));
+
+ support::endian::write(OS, InfoSize, support::little);
// Write the info itself.
OS.write(reinterpret_cast<const char *>(&BaseData), InfoSize);
uint32_t ResourceCount = static_cast<uint32_t>(Resources.size());
- uint32_t BindingSizeSwapped = BindingSize;
- if (sys::IsBigEndianHost) {
- sys::swapByteOrder(ResourceCount);
- sys::swapByteOrder(BindingSizeSwapped);
- }
- OS.write(reinterpret_cast<const char *>(&ResourceCount), sizeof(uint32_t));
- OS.write(reinterpret_cast<const char *>(&BindingSizeSwapped),
- sizeof(uint32_t));
+ support::endian::write(OS, ResourceCount, support::little);
+ support::endian::write(OS, BindingSize, support::little);
for (const auto &Res : Resources)
OS.write(reinterpret_cast<const char *>(&Res), BindingSize);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156814.549222.patch
Type: text/x-patch
Size: 1557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/aabe8f6c/attachment.bin>
More information about the llvm-commits
mailing list