HomePhabricator

[mlir] Support big endian in DenseElementsAttr

Authored by imaihal on Mon, May 4, 10:59 AM.

Description

[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

Details

Committed
mehdi_aminiMon, May 4, 3:17 PM
Differential Revision
D78076: [mlir] Support big endian in DenseElementsAttr
Parents
rG6939fe6e0853: [lld-macho] Support X86_64_RELOC_SIGNED_{1,2,4}
Branches
Unknown
Tags
Unknown