[i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.
authorLiu, Chen3 <chen3.liu@intel.com>
Fri, 2 Apr 2021 00:45:26 +0000 (08:45 +0800)
committerLiu, Chen3 <chen3.liu@intel.com>
Wed, 14 Apr 2021 08:44:54 +0000 (16:44 +0800)
commit1c4108ab661d43e21b1d1c804d8a403e5b0cf7d6
tree1eeebc9da10aa89236009b0b8f2f34688145992b
parentbda20282cb94faa97b2e50cb592eff3dec94f6b0
[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
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/x86_32-align-linux.c [new file with mode: 0644]