Commit Graph

1108 Commits

Author SHA1 Message Date
Stephen Kelly cdacbfee79 Remove deprecated API
Reviewers: teemperor!

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341573 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 18:26:30 +00:00
Erik Pilkington 0eb34b9030 [Sema] Clean up some __builtin_*_chk diagnostics
Namely, print the likely macro name when it's used, and include the actual
computed sizes in the diagnostic message, which are sometimes not obvious.

rdar://43909200

Differential revision: https://reviews.llvm.org/D51697

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341566 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-06 17:19:33 +00:00
Craig Topper ead0755dee [X86] Add kshift intrinsics to match gcc and icc.
This adds the following intrinsics:
_kshiftli_mask8
_kshiftli_mask16
_kshiftli_mask32
_kshiftli_mask64
_kshiftri_mask8
_kshiftri_mask16
_kshiftri_mask32
_kshiftri_mask64

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341234 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-31 18:22:52 +00:00
Nick Desaulniers 87be98223c [SEMA] add more -Wfloat-conversion to compound assigment analysis
Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061

Reviewers: aaron.ballman, acoomans

Reviewed By: aaron.ballman, acoomans

Subscribers: acoomans, cfe-commits, srhines, pirama

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339581 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 16:38:07 +00:00
Stephen Kelly 7e2622ef40 Mark up deprecated methods as such
Reviewers: teemperor!

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339403 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 22:45:38 +00:00
Stephen Kelly 2dfd8132cf Port getLocEnd -> getEndLoc
Reviewers: teemperor!

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339386 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:09:38 +00:00
Stephen Kelly d7b659b592 Port getLocStart -> getBeginLoc
Reviewers: teemperor!

Subscribers: jholewinski, whisperity, jfb, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:08:08 +00:00
Stephen Kelly 467b2ee90d Add getEndLoc API to replace getLocEnd
Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339374 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 20:05:47 +00:00
Stephen Kelly 08cf6916b8 Add getBeginLoc API to replace getLocStart
Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339372 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 20:05:03 +00:00
JF Bastien ba544795b8 __c11_atomic_load's _Atomic can be const
Summary:
C++11 onwards specs the non-member functions atomic_load and atomic_load_explicit as taking the atomic<T> by const (potentially volatile) pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will fix this with DR459 (the current draft forgot to fix B.16, but that’s not the normative part).

clang’s lib/Headers/stdatomic.h implements these as #define to the __c11_* equivalent, which are builtins with custom typecheck. Fix the typecheck.

D47613 takes care of the libc++ side.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html

<rdar://problem/27426936>

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338743 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 17:35:46 +00:00
Fangrui Song abdbb605f2 Remove trailing space
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-30 19:24:48 +00:00
Richard Smith 354438d88c Fold -Wreturn-stack-address into general initialization lifetime
checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337743 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 21:21:22 +00:00
Erik Pilkington 31fe70446b [Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)
Thanks to Arthur O'Dwyer for the suggestion!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337706 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 16:24:14 +00:00
Fangrui Song 1a8f8375fb Change \t to spaces
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337530 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 08:19:20 +00:00
Erik Pilkington bc7f4ca3e4 [Sema] Add a new warning, -Wmemset-transposed-args
This diagnoses calls to memset that have the second and third arguments
transposed, for example:

  memset(buf, sizeof(buf), 0);

This is done by checking if the third argument is a literal 0, or if the second
is a sizeof expression (and the third isn't). The first check is also done for
calls to bzero.

Differential revision: https://reviews.llvm.org/D49112

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337470 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-19 16:46:15 +00:00
Krzysztof Parzyszek a58a89b042 [Hexagon] Diagnose intrinsics not supported by selected CPU/HVX
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336933 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-12 18:54:04 +00:00
Alex Lorenz 7d013cb1a2 [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %tu/%td on Darwin
The '%tu'/'%td' as formatting specifiers have been used to print out the
NSInteger/NSUInteger values for a long time. Typically their ABI matches, but that's
not the case on watchOS. The ABI difference boils down to the following:

- Regular 32-bit darwin targets (like armv7) use 'ptrdiff_t' of type 'int',
  which matches 'NSInteger'.
- WatchOS arm target (armv7k) uses 'ptrdiff_t' of type 'long', which doesn't
  match 'NSInteger' of type 'int'.

Because of this ABI difference these specifiers trigger -Wformat warnings only
for watchOS builds, which is really inconvenient for cross-platform code.

This patch avoids this -Wformat warning for '%tu'/'%td' and NS[U]Integer only,
and instead uses the new -Wformat-pedantic warning that JF introduced in
https://reviews.llvm.org/D47290. This is acceptable because Darwin guarantees that,
despite the watchOS ABI differences, sizeof(ptrdiff_t) == sizeof(NS[U]Integer),
and alignof(ptrdiff_t) == alignof(NS[U]Integer) so the warning is therefore noisy
for pedantic reasons.

I'll update public documentation to ensure that this behaviour is properly
communicated.

rdar://41739204

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-05 22:51:11 +00:00
Michael Kruse 2926189c9b [Sema] Consider all format_arg attributes.
If a function has multiple format_arg attributes, clang only considers
the first it finds (because AttributeLists are in reverse order, not
necessarily the textually first) and ignores all others.

Loop over all FormatArgAttr to print warnings for all declared
format_arg attributes.

For instance, libintl's ngettext (select plural or singular version of
format string) has two __format_arg__ attributes.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336239 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-04 01:37:11 +00:00
Craig Topper 4fed1565d7 [X86] Remove masking from the avx512 rotate builtins. Use a select builtin instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336036 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-30 01:32:14 +00:00
Craig Topper 0af2982d58 [X86] Remove masking from the avx512 packed sqrt builtins. Use select builtins instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335945 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-29 05:43:33 +00:00
JF Bastien d71d946f36 [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin
Summary:
Pick D42933 back up, and make NSInteger/NSUInteger with %zu/%zi specifiers on Darwin warn only in pedantic mode. The default -Wformat recently started warning for the following code because of the added support for analysis for the '%zi' specifier.

     NSInteger i = NSIntegerMax;
     NSLog(@"max NSInteger = %zi", i);

The problem is that on armv7 %zi is 'long', and NSInteger is typedefed to 'int' in Foundation. We should avoid this warning as it's inconvenient to our users: it's target specific (happens only on armv7 and not arm64), and breaks their existing code. We should also silence the warning for the '%zu' specifier to ensure consistency. This is acceptable because Darwin guarantees that, despite the unfortunate choice of typedef, sizeof(size_t) == sizeof(NS[U]Integer), the warning is therefore noisy for pedantic reasons. Once this is in I'll update public documentation.

Related discussion on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2018-May/058050.html

<rdar://36874921&40501559>

Reviewers: ahatanak, vsapsai, alexshap, aaron.ballman, javed.absar, jfb, rjmccall

Subscribers: kristof.beyls, aheejin, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-22 21:54:40 +00:00
Chandler Carruth 6fe85e4ee4 [x86] Teach the builtin argument range check to allow invalid ranges in
dead code.

This is important for C++ templates that essentially compute the valid
input in a way that is constant and will cause all the invalid cases to
be dead code that is deleted. Code in the wild actually does this and
GCC also accepts these kinds of patterns so it is important to support
it.

To make this work, we provide a non-error path to diagnose these issues,
and use a default-error warning instead. This keeps the relatively
strict handling but prevents nastiness like SFINAE on these errors. It
also allows us to safely use the system to diagnose this only when it
occurs at runtime (in emitted code).

Entertainingly, this required fixing the syntax in various other ways
for the x86 test because we never bothered to diagnose that the returns
were invalid.

Since debugging these compile failures was super confusing, I've also
improved the diagnostic to actually say what the value was. Most of the
checks I've made ignore this to simplify maintenance, but I've checked
it in a few places to make sure the diagnsotic is working.

Depends on D48462. Without that, we might actually crash some part of
the compiler after bypassing the error here.

Thanks to Richard, Ben Kramer, and especially Craig Topper for all the
help here.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335309 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 23:46:09 +00:00
Craig Topper 3cf091f277 [X86] Remove masking from the 512-bit floating point max/min builtins. Use select in IR instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335200 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-21 05:01:01 +00:00
Aaron Ballman 4ede2bf4c9 Implement semantic checking for __builtin_signbit.
r242675 changed the signature for the signbit builtin but did not introduce proper semantic checking to ensure the arguments are as-expected. This patch groups the signbit builtin along with the other fp classification builtins. Fixes PR28172.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335050 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-19 14:59:11 +00:00
Aaron Ballman ac1b00383a Reverting due to line ending changes; will reapply after addressing that.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335049 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-19 14:53:20 +00:00
Aaron Ballman 21630d5d23 Implement semantic checking for __builtin_signbit.
r242675 changed the signature for the signbit builtin but did not introduce proper semantic checking to ensure the arguments are as-expected. This patch groups the signbit builtin along with the other fp classification builtins. Fixes PR28172.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335048 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-19 14:36:04 +00:00
Craig Topper 1f93913caa [X86] __builtin_ia32_prord512_mask, __builtin_ia32_prorq512_mask, __builtin_ia32_shufpd should only accept an ICE constant.
The rotates also need to check for the immediate to fit in 8-bits. Shufpd already checks its immediate range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334847 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-15 17:40:37 +00:00
Craig Topper 1299c54848 [X86] The immediate argument to getmantpd*_mask should be an ICE and it should only be 4 bits wide.
We already checked this for the scalar version, but missed the vector version somehow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334846 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-15 17:03:32 +00:00
Craig Topper 744535e476 [X86] Rename __builtin_ia32_pslldqi128 to __builtin_ia32_pslldqi128_byteshift and similar for other sizes. Remove the multiply by 8 from the header files.
The previous names took the shift amount in bits to match gcc and required a multiply by 8 in the header. This creates a misleading error message when we check the range of the immediate to the builtin since the allowed range also got multiplied by 8.

This commit changes the builtins to use a byte shift amount to match the underlying instruction and the Intel intrinsic.

Fixes the remaining issue from PR37795.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334773 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 22:02:35 +00:00
Erich Keane 79be246d39 Correct behavior of __builtin_*_overflow and constexpr.
Enable these builtins to be called across a lambda
boundary with captureless const/constexpr, as brought up by 
Eli here: https://reviews.llvm.org/D48040

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334597 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 13:25:11 +00:00
Craig Topper 46c05521ad [X86] Remove masking from avx512vbmi2 concat and shift by immediate builtins. Use select builtins instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334577 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 07:19:28 +00:00
Luke Geeson 362dc486cc [AArch64] Corrected FP16 Intrinsic range checks in Clang + added Sema tests
Summary:
This fixes the ranges for the vcvth family of FP16 intrinsics in the clang front end. Previously it was accepting incorrect ranges
-Changed builtin range checking in SemaChecking
-added tests SemaCheck changes - included in  their own file since no similar one exists
-modified existing tests to reflect new ranges

Reviewers: SjoerdMeijer, javed.absar

Reviewed By: SjoerdMeijer

Subscribers: kristof.beyls, cfe-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334489 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 09:54:27 +00:00
Craig Topper 638e493dca [X86] Properly account for the immediate being multiplied by 8 in the immediate range checking for BI__builtin_ia32_psrldqi128 and friends.
The limit was set to 1023 which only up to 127*8. It needs to be 2047 to allow 255*8.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334416 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-11 16:34:10 +00:00
Craig Topper adc6bb61d2 [X86] Remove masking from dbpsadbw builtins, use select builtin instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334385 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-11 06:18:29 +00:00
Craig Topper 8c949cc596 [X86] Remove masking from the 512-bit packed floating point add/sub/mul/div builtins. Use select in IR instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334359 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-10 06:01:42 +00:00
Craig Topper 3cef3a6363 [X86] Fold masking into subvector extract builtins.
I'm looking into making the select builtins require avx512f, avx512bw, or avx512vl since masking operations generally require those features.

The extract builtins are funny because the 512-bit versions return a 128 or 256 bit vector with masking even when avx512vl is not supported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334330 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 21:50:07 +00:00
Craig Topper 8c873daccc [X86] Add builtins for vpermq/vpermpd instructions to enable target feature checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334311 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 18:00:25 +00:00
Craig Topper a344be6ba4 [X86] Change immediate type for some builtins from char to int.
These builtins are all handled by CGBuiltin.cpp so it doesn't much matter what the immediate type is, but int matches the intrinsic spec.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 18:00:22 +00:00
Craig Topper a90c85acaf [X86] Add builtins for shufps and shufpd to enable target feature and immediate range checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334266 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 07:18:33 +00:00
Craig Topper ff71c0eccc [X86] Add builtins for pshufd, pshuflw, and pshufhw to enable target feature and immediate range checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334265 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 06:13:16 +00:00
Craig Topper c38646b332 [X86] Add subvector insert and extract builtins to enable target feature checking and immediate range checking.
Test changes are due to differences in how we generate undef elements now. We also changed the types used for extractf128_si256/insertf128_si256 to match the signature of the builtin that previously existed which this patch resurrects. This also matches gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334261 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 03:24:47 +00:00
Craig Topper 3abc771329 [X86] Add builtins for vpermilps/pd instructions to enable target feature checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334256 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 00:59:27 +00:00
Craig Topper 1efc613997 [X86] Add builtins for blend with immediate control to enforce target feature requirements and check immediate range.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334249 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-08 00:00:21 +00:00
Craig Topper 9399467959 [X86] Add builtins for shuff32x4/shuff64x2/shufi32x4/shuff64x2 to enable target feature checking and immediate range checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334244 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 23:03:08 +00:00
Reid Kleckner c1c07cca8c [MS] Re-add support for the ARM interlocked bittest intrinscs
Adds support for these intrinsics, which are ARM and ARM64 only:
  _interlockedbittestandreset_acq
  _interlockedbittestandreset_rel
  _interlockedbittestandreset_nf
  _interlockedbittestandset_acq
  _interlockedbittestandset_rel
  _interlockedbittestandset_nf

Refactor the bittest intrinsic handling to decompose each intrinsic into
its action, its width, and its atomicity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334239 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 21:39:04 +00:00
Craig Topper 2dbbac4ddd [X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.
We still emit shufflevector instructions we just do it from CGBuiltin.cpp now. This ensures the intrinsics that use this are only available on CPUs that support the feature.

I also added range checking to the immediate, but only checked it is 8 bits or smaller. We should maybe be stricter since we never use all 8 bits, but gcc doesn't seem to do that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334237 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 21:27:41 +00:00
Craig Topper 3b4ec91916 [X86] Add back builtins for _mm_slli_si128/_mm_srli_si128 and similar intrinsics.
We still lower them to native shuffle IR, but we do it in CGBuiltin.cpp now. This allows us to check the target feature and ensure the immediate fits in 8 bits.

This also improves our -O0 codegen slightly because we're able to see the zeroinitializer in the shuffle. It looks like it got lost behind a store+load previously.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334208 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 17:28:03 +00:00
Craig Topper 57ebd133fb [X86] Add back _mask, _maskz, and _mask3 builtins for some 512-bit fmadd/fmsub/fmaddsub/fmsubadd builtins.
Summary:
We recently switch to using a selects in the intrinsics header files for FMA instructions. But the 512-bit versions support flavors with rounding mode which must be an Integer Constant Expression. This has forced those intrinsics to be implemented as macros. As it stands now the mask and mask3 intrinsics evaluate one of their macro arguments twice. If that argument itself is another intrinsic macro, we can end up over expanding macros. Or if its something we can CSE later it would show up multiple times when it shouldn't.

I tried adding __extension__ around the macro and making it an expression statement and declaring a local variable. But whatever name you choose for the local variable can never be used as the name of an input to the macro in user code. If that happens you would end up with the same name on the LHS and RHS of an assignment after expansion. We might be safe if we use __ in front of the variable names because those names are reserved and user code shouldn't use that, but I wasn't sure I wanted to make that claim.

The other option which I've chosen here, is to add back _mask, _maskz, and _mask3 flavors of the builtin which we will expand in CGBuiltin.cpp to replicate the argument as needed and insert any fneg needed on the third operand to make a subtract. The _maskz isn't truly necessary if we have an unmasked version or if we use the masked version with a -1 mask and wrap a select around it. But I've chosen to make things more uniform.

I separated out the scalar builtin handling to avoid too many things going on in EmitX86FMAExpr. It was different enough due to the extract and insert that the minor duplication of the CreateCall was probably worth it.

Reviewers: tkrupa, RKSimon, spatel, GBuella

Reviewed By: tkrupa

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334159 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-07 02:46:02 +00:00
Craig Topper 26b20caa52 [X86] Add builtins for vector element insert and extract for different 128 and 256 bit vector types. Use them to implement the extract and insert intrinsics.
Previously we were just using extended vector operations in the header file.

This unfortunately allowed non-constant indices to be used with the intrinsics. This is incompatible with gcc, icc, and MSVC. It also introduces a different performance characteristic because non-constant index gets lowered to a vector store and an element sized load.

By adding the builtins we can check for the index to be a constant and ensure its in range of the vector element count.

User code still has the option to use extended vector operations themselves if they need non-constant indexing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334057 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 00:24:55 +00:00
Craig Topper 3faed8de63 [X86] Make __builtin_ia32_vec_ext_v2si require ICE for its index argument. Add warnings for out of range indices for __builtin_ia32_vec_ext_v2si, __builtin_ia32_vec_ext_v4hi, and __builtin_ia32_vec_set_v4hi.
These should take a constant value for an index and that constant should be a valid element number.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334051 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 21:54:35 +00:00