HomePhabricator

[i386] Modify the alignment of __m128/__m256/__m512 vector type according i386…

Authored by LiuChen3 on Apr 1 2021, 5:45 PM.

Description

[i386] Modify the alignment of m128/m256/__m512 vector type according i386 abi.

According to i386 System V ABI:

  1. when __m256 are required to be passed on the stack, the stack pointer must be aligned on a 0 mod 32 byte boundary at the time of the call.
  2. when __m512 are required to be passed on the stack, the stack pointer must be aligned on a 0 mod 64 byte boundary at the time of the call.

The current method of clang passing __m512 parameter are as follow:

  1. when target supports avx512, passing it with 64 byte alignment;
  2. when target supports avx, passing it with 32 byte alignment;
  3. Otherwise, passing it with 16 byte alignment.

Passing __m256 parameter are as follow:

  1. when target supports avx or avx512, passing it with 32 byte alignment;
  2. Otherwise, passing it with 16 byte alignment.

This pach will passing m128/m256/__m512 following i386 System V ABI and
apply it to Linux only since other System V OS (e.g Darwin, PS4 and FreeBSD) don't
want to spend any effort dealing with the ramifications of ABI breaks at present.

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