[PATCH] D78076: [mlir] Support big endian in DenseElementsAttr

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 13:53:32 PDT 2020


rriddle added a comment.

Is there any way you can add a test for this?



================
Comment at: mlir/lib/IR/Attributes.cpp:531
   assert((bitPos % CHAR_BIT) == 0 && "expected bitPos to be 8-bit aligned");
-  const char *cptr = reinterpret_cast<const char *>(value.getRawData());
-  if (llvm::support::endian::system_endianness() ==
-      llvm::support::endianness::big)
-    cptr = cptr + 8 - llvm::divideCeil(bitWidth, CHAR_BIT);
-  std::copy_n(cptr, llvm::divideCeil(bitWidth, CHAR_BIT),
+  const char *dataPos = reinterpret_cast<const char *>(value.getRawData());
+  dataPos = getDataStartPos(dataPos, bitWidth);
----------------
Can you add in the reinterpret_cast and the copy_n to the static helper?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78076/new/

https://reviews.llvm.org/D78076





More information about the llvm-commits mailing list