[PowerPC] Fix __builtin_pdepd and __builtin_pextd to be 64-bit and P10 only.
authorAmy Kwan <amy.kwan1@ibm.com>
Tue, 15 Feb 2022 16:47:55 +0000 (10:47 -0600)
committerAmy Kwan <amy.kwan1@ibm.com>
Tue, 15 Feb 2022 18:30:50 +0000 (12:30 -0600)
commit5dc0a1657be14df68bfc33deb2fb75476acdaec8
tree25bc26b920bdbf2e6ae4651c324a5bd32bf292d6
parent6bd72fa661a892ebd3bafa46817f281b091138aa
[PowerPC] Fix __builtin_pdepd and __builtin_pextd to be 64-bit and P10 only.

The `__builtin_pdepd` and `__builtin_pextd` are P10 builtins that are meant to
be used under 64-bit only. For instance, when the builtins are compiled under
32-bit mode:
```
$ cat t.c
unsigned long long foo(unsigned long long a, unsigned long long b) {
  return __builtin_pextd(a,b);
}

$ clang -c t.c -mcpu=pwr10 -m32
ExpandIntegerResult #0: t31: i64 = llvm.ppc.pextd TargetConstant:i32<6928>, t28, t29

fatal error: error in backend: Do not know how to expand the result of this operator!
```
This patch adds sema checking for these builtins to compile under 64-bit
mode only and on P10. The builtins will emit a diagnostic when they are compiled on
non-P10 compilations and on 32-bit mode.

Differential Revision: https://reviews.llvm.org/D118753
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/PowerPC/builtins-ppc-pwr10-64bit.c [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll