[all-commits] [llvm/llvm-project] 3a7be2: [mlir] Support big endian in DenseElementsAttr

Haruki Imai via All-commits all-commits at lists.llvm.org
Mon May 4 15:17:32 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3a7be241f252215e8a2cf26e8a301fd2a8269b58
      https://github.com/llvm/llvm-project/commit/3a7be241f252215e8a2cf26e8a301fd2a8269b58
  Author: Haruki Imai <imaihal at jp.ibm.com>
  Date:   2020-05-04 (Mon, 04 May 2020)

  Changed paths:
    M mlir/lib/IR/Attributes.cpp

  Log Message:
  -----------
  [mlir] Support big endian in DenseElementsAttr

This std::copy_n copies 8 byte data (APInt raw data) by 1 byte from the
beginning of char array. This is no problem in little endian, but the
data is not copied correctly in big endian because the data should be
copied from the end of the char array.

- Example of 4 byte data (such as float32)

Little endian (First 4 bytes):
Address | 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
Data    | 0xcd 0xcc 0x8c 0x3f 0x00 0x00 0x00 0x00

Big endian (Last 4 bytes):
Address | 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
Data    | 0x00 0x00 0x00 0x00 0x3f 0x8c 0xcc 0xcd

In general, when it copies N(N<8) byte data in big endian, the start
address should be incremented by (8 - N) bytes.
The original code has no problem when it includes 8 byte data(such as
 double) even in big endian.

Differential Revision: https://reviews.llvm.org/D78076




More information about the All-commits mailing list