forked from OSchip/llvm-project
Read/write external resource alignment tag in little-endian
https://reviews.llvm.org/D126446 added support for encoding binary blobs in MLIR assembly. To enable cross-architecture compatibility, these need to be encoded in little-endian format. This patch is a first step in that direction by reading and writing the alignment tag that those blobs are prefixed by in little-endian format. This fixes assertion failures in several test cases on big-endian platforms. The actual content of the blob is not yet handled here. Differential Revision: https://reviews.llvm.org/D129483
This commit is contained in:
parent
af40f99e2b
commit
de9a7260ac
|
@ -2685,8 +2685,9 @@ private:
|
|||
uint32_t dataAlignment) final {
|
||||
printFn(key, [&](raw_ostream &os) {
|
||||
// Store the blob in a hex string containing the alignment and the data.
|
||||
llvm::support::ulittle32_t dataAlignmentLE(dataAlignment);
|
||||
os << "\"0x"
|
||||
<< llvm::toHex(StringRef(reinterpret_cast<char *>(&dataAlignment),
|
||||
<< llvm::toHex(StringRef(reinterpret_cast<char *>(&dataAlignmentLE),
|
||||
sizeof(dataAlignment)))
|
||||
<< llvm::toHex(StringRef(data.data(), data.size())) << "\"";
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "llvm/ADT/ScopeExit.h"
|
||||
#include "llvm/ADT/StringSet.h"
|
||||
#include "llvm/ADT/bit.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include <algorithm>
|
||||
|
@ -2349,7 +2350,7 @@ public:
|
|||
"expected hex string blob for key '" + key +
|
||||
"' to encode alignment in first 4 bytes");
|
||||
}
|
||||
uint32_t align = 0;
|
||||
llvm::support::ulittle32_t align;
|
||||
memcpy(&align, blobData->data(), sizeof(uint32_t));
|
||||
|
||||
// Get the data portion of the blob.
|
||||
|
|
Loading…
Reference in New Issue