]> granicus.if.org Git - clang/commit
[PPC64LE] Implement little-endian semantics for vec_pack family
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 6 Jun 2014 15:10:47 +0000 (15:10 +0000)
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 6 Jun 2014 15:10:47 +0000 (15:10 +0000)
commita4c4db1f56bea32f1736a77e4d5556d66d399c72
treea91c258b30af24ec1b979152cc48e8c8d2e95f66
parentb07a1f40dae10582100bd099edb64dfc9d6ce71d
[PPC64LE] Implement little-endian semantics for vec_pack family

The PowerPC vector-pack instructions are defined architecturally with
a big-endian bias, in that the vector element numbering is assumed to
be "left to right" regardless of whether the processor is in
big-endian or little-endian mode.  This definition is unnatural for
little-endian code generation.

To facilitate ease of porting, the vec_pack and related interfaces are
designed to use natural element ordering, so that elements are
numbered according to little-endian design principles when code is
generated for a little-endian target.  The vec_pack calls are
implemented as calls to vec_perm, specifying selection of the
odd-numbered vector elements.  For little endian, this means the
odd-numbered elements counting from the right end of the register.
Since the underlying instructions count from the left end, we must
instead select the even-numbered vector elements for little endian to
achieve the desired semantics.

The correctness of this code is tested by the new pack.c test added in
a previous patch.  I plan to later make the existing ppc32 Altivec
compile-time tests work for ppc64 and ppc64le as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210340 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Headers/altivec.h