summaryrefslogtreecommitdiffstats
path: root/clang/lib/Headers/intrin.h
Commit message (Collapse)AuthorAgeFilesLines
* [X86] Remove forward declaration of _invpcid from intrin.h. Rely on inline ↵Craig Topper2019-11-251-1/+0
| | | | | | | | | | | version from immintrin.h The forward declaration had a cdecl calling convention, but the inline version did not. This leads to a conflict if the default calling convention is not cdecl. Fix this by just removing the forward declaration. Fixes PR41503
* [X86] Fix the implementation of __readcr3/__writecr3 to work in 64-bit modeCraig Topper2019-11-141-9/+16
| | | | | | | | | | | | We need to use a 64-bit type in 64-bit mode so a 64-bit register will get used in the generated assembly. I've also changed the constraints to just use "r" intead of "q". "q" forces to a only an a/b/c/d register in 32-bit mode, but I see no reason that would matter here. Fixes Nico's note in PR19301 over 4 years ago. Differential Revision: https://reviews.llvm.org/D70101
* Move the builtin headers to use the new license file header.Chandler Carruth2019-04-081-17/+3
| | | | | | | | | | | | | | | | | | Summary: These all had somewhat custom file headers with different text from the ones I searched for previously, and so I missed them. Thanks to Hal and Kristina and others who prompted me to fix this, and sorry it took so long. Reviewers: hfinkel Subscribers: mcrosier, javed.absar, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60406 llvm-svn: 357941
* [COFF, ARM64] Remove definitions for _byteswap library functionsTom Tan2019-02-111-9/+3
| | | | | | | | | | | | | _byteswap_* functions are are implemented in below file as normal function from libucrt.lib and declared in stdlib.h. Define them in intrin.h triggers lld error "conflicting comdat type" and "duplicate symbols" which was just added to LLD (https://reviews.llvm.org/D57324). C:\Program Files (x86)\Windows Kits\10\Source\10.0.17763.0\ucrt\stdlib\byteswap.cpp Differential Revision: https://reviews.llvm.org/D57915 llvm-svn: 353740
* [COFF, ARM64] Fix types for _ReadStatusReg, _WriteStatusRegEli Friedman2019-02-081-2/+2
| | | | | | | | | | r344765 added those intrinsics, but used the wrong types. Patch by Mike Hommey Differential Revision: https://reviews.llvm.org/D57636 llvm-svn: 353493
* [X86] Only define _XCR_XFEATURE_ENABLED_MASK in xsaveintrin.h when _MSC_VER ↵Craig Topper2019-01-181-1/+0
| | | | | | | | is defined. Remove from intrin.h. I think this was my intention when I added it xsaveintrin.h llvm-svn: 351568
* Recommit r351160 "[X86] Make _xgetbv/_xsetbv on non-windows platforms"Craig Topper2019-01-161-9/+0
| | | | | | V8 has been fixed now. llvm-svn: 351391
* Revert "[X86] Make _xgetbv/_xsetbv on non-windows platforms"Benjamin Kramer2019-01-151-0/+9
| | | | | | This reverts commit r351160. Breaks building v8. llvm-svn: 351210
* [X86] Make _xgetbv/_xsetbv on non-windows platformsCraig Topper2019-01-151-9/+0
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch attempts to redo what was tried in r278783, but was reverted. These intrinsics should be available on non-windows platforms with "xsave" feature check. But on Windows platforms they shouldn't have feature check since that's how MSVC behaves. To accomplish this I've added a MS builtin with no feature check. And a normal gcc builtin with a feature check. When _MSC_VER is not defined _xgetbv/_xsetbv will be macros pointing to the gcc builtin name. I've moved the forward declarations from intrin.h to immintrin.h to match the MSDN documentation and used that as the header file for the MS builtin. I'm not super happy with this implementation, and I'm open to suggestions for better ways to do it. Reviewers: rnk, RKSimon, spatel Reviewed By: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56686 llvm-svn: 351160
* [COFF, ARM64] Add __byteswap intrinsicsMandeep Singh Grang2019-01-151-0/+10
| | | | | | | | | | | | Reviewers: rnk, efriedma, ssijaric, TomTan, haripul Reviewed By: efriedma Subscribers: javed.absar, cfe-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D56685 llvm-svn: 351147
* [COFF, ARM64] Add __nop intrinsicMandeep Singh Grang2019-01-141-0/+3
| | | | | | | | | | | | Reviewers: rnk, efriedma, TomTan, haripul, ssijaric Reviewed By: rnk, efriedma Subscribers: javed.absar, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D56671 llvm-svn: 351135
* [Builltins][X86] Provide implementations of __lzcnt16, __lzcnt, __lzcnt64 ↵Craig Topper2018-12-141-3/+0
| | | | | | | | | | | | | | | | | | for MS compatibility. Remove declarations from intrin.h and implementations from lzcntintrin.h intrin.h had forward declarations for these and lzcntintrin.h had implementations that were only available with -mlzcnt or a -march that supported the lzcnt feature. For MS compatibility we should always have these builtins available regardless of X86 being the target or the CPU support the lzcnt instruction. The backends should be able to gracefully fallback to something support even if its just shifts and bit ops. Unfortunately, gcc also implements 2 of the 3 function names here on X86 when lzcnt feature is enabled. This patch adds builtins for these for MSVC compatibility and drops the forward declarations from intrin.h. To keep the gcc compatibility the two intrinsics that collided have been turned into macros that use the X86 specific builtins with the lzcnt feature check. These macros are only defined when _MSC_VER is not defined. Without them being macros we can get a redefinition error because -ms-extensions doesn't seem to set _MSC_VER but does make the MS builtins available. Should fix PR40014 Differential Revision: https://reviews.llvm.org/D55677 llvm-svn: 349098
* [MS] Zero out ECX in __cpuid in intrin.hReid Kleckner2018-11-061-1/+1
| | | | | | | | | | | | | | | | Summary: Some CPUID leafs depend on the value of ECX as well as EAX, but we left it uninitialized. Originally reported as https://crbug.com/901547 Reviewers: craig.topper, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54171 llvm-svn: 346265
* [COFF, ARM64] Implement InterlockedDecrement*_* builtinsMandeep Singh Grang2018-11-061-36/+9
| | | | | | | This is eight in a series of patches to move intrinsic definitions out of intrin.h. Differential: https://reviews.llvm.org/D54068 llvm-svn: 346208
* [COFF, ARM64] Implement InterlockedIncrement*_* builtinsMandeep Singh Grang2018-11-061-36/+9
| | | | | | | This is seventh in a series of patches to move intrinsic definitions out of intrin.h. Differential: https://reviews.llvm.org/D54067 llvm-svn: 346207
* [COFF, ARM64] Implement InterlockedAnd*_* builtinsMandeep Singh Grang2018-11-061-48/+12
| | | | | | | This is sixth in a series of patches to move intrinsic definitions out of intrin.h. Differential: https://reviews.llvm.org/D54066 llvm-svn: 346206
* [COFF, ARM64] Implement InterlockedXor*_* builtinsMandeep Singh Grang2018-11-061-48/+12
| | | | | | | | | This is fifth in a series of patches to move intrinsic definitions out of intrin.h. Note: This was reviewed and approved in D54065 but somehow that diff was messed up. Committing this again with the proper diff. llvm-svn: 346205
* Revert "[COFF, ARM64] Implement InterlockedXor*_* builtins"Mandeep Singh Grang2018-11-061-0/+735
| | | | | | This reverts commit cc3d3cd0fbeb88412d332354c261ff139c4ede6b. llvm-svn: 346192
* [COFF, ARM64] Implement InterlockedXor*_* builtinsMandeep Singh Grang2018-11-061-735/+0
| | | | | | | | | | | | | | Summary: This is fifth in a series of patches to move intrinsic definitions out of intrin.h. Reviewers: rnk, efriedma, mstorsjo, TomTan Reviewed By: efriedma Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D54065 llvm-svn: 346191
* [COFF, ARM64] Implement InterlockedOr*_* builtinsMandeep Singh Grang2018-11-061-48/+12
| | | | | | This is fourth in a series of patches to move intrinsic definitions out of intrin.h. llvm-svn: 346190
* [COFF, ARM64] Implement InterlockedCompareExchange*_* builtinsMandeep Singh Grang2018-11-061-84/+24
| | | | | | | | | | | | | | Summary: This is third in a series of patches to move intrinsic definitions out of intrin.h. Reviewers: rnk, efriedma, mstorsjo, TomTan Reviewed By: efriedma Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D54062 llvm-svn: 346189
* [COFF, ARM64] Implement InterlockedExchange*_* builtinsMandeep Singh Grang2018-11-021-60/+12
| | | | | | | | | | | | | | Summary: Windows SDK needs these intrinsics to be proper builtins. This is second in a series of patches to move intrinsic defintions out of intrin.h. Reviewers: rnk, mstorsjo, efriedma, TomTan Reviewed By: rnk, efriedma Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D54046 llvm-svn: 346044
* [ARM64] [Windows] Implement _InterlockedExchangeAdd*_* builtins.Eli Friedman2018-10-311-48/+12
| | | | | | | | | These apparently need to be proper builtins to handle the Windows SDK. Differential Revision: https://reviews.llvm.org/D53916 llvm-svn: 345779
* [COFF, ARM64] Add _ReadStatusReg and_WriteStatusReg intrinsicsMandeep Singh Grang2018-10-181-0/+2
| | | | | | | | | | | | Reviewers: rnk, compnerd, mstorsjo, efriedma, TomTan, haripul, javed.absar Reviewed By: efriedma Subscribers: dmajor, kristof.beyls, chrib, cfe-commits Differential Revision: https://reviews.llvm.org/D53115 llvm-svn: 344765
* [COFF, ARM64] Add _InterlockedAdd intrinsicMandeep Singh Grang2018-10-051-0/+1
| | | | | | | | | | | | Reviewers: rnk, mstorsjo, compnerd, TomTan, haripul, javed.absar, efriedma Reviewed By: efriedma Subscribers: efriedma, kristof.beyls, chrib, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D52811 llvm-svn: 343894
* [COFF, ARM64] Add __getReg intrinsicMandeep Singh Grang2018-10-041-0/+7
| | | | | | | | | | | | Reviewers: rnk, mstorsjo, compnerd, TomTan, haripul, javed.absar, efriedma Reviewed By: efriedma Subscribers: peter.smith, efriedma, kristof.beyls, chrib, cfe-commits Differential Revision: https://reviews.llvm.org/D52838 llvm-svn: 343824
* Make __shiftleft128 / __shiftright128 real compiler built-ins.Nico Weber2018-08-171-14/+0
| | | | | | | | | | | | r337619 added __shiftleft128 / __shiftright128 as functions in intrin.h. Microsoft's STL plans on using these functions, and they're using intrin0.h which just has declarations of built-ins to not pull in the huge intrin.h header in the standard library headers. That requires that these functions are real built-ins. https://reviews.llvm.org/D50907 llvm-svn: 340048
* [ms] Add __shiftleft128 / __shiftright128 intrinsicsNico Weber2018-07-201-0/+14
| | | | | | | | | | | | Carefully match the pattern matched by ISel so that this produces shld / shrd (unless Subtarget->isSHLDSlow() is true). Thanks to Craig Topper for providing the LLVM IR pattern that gets successfully matched. Fixes PR37755. llvm-svn: 337619
* [COFF] Add more missing MSVC ARM64 intrinsicsMandeep Singh Grang2018-07-171-2/+2
| | | | | | | | | | | | | | | | | | | Summary: Added the following intrinsics: _BitScanForward, _BitScanReverse, _BitScanForward64, _BitScanReverse64 _InterlockedAnd64, _InterlockedDecrement64, _InterlockedExchange64, _InterlockedExchangeAdd64, _InterlockedExchangeSub64, _InterlockedIncrement64, _InterlockedOr64, _InterlockedXor64. Reviewers: compnerd, mstorsjo, rnk, javed.absar Reviewed By: mstorsjo Subscribers: kristof.beyls, chrib, llvm-commits Differential Revision: https://reviews.llvm.org/D49445 llvm-svn: 337327
* [X86] Correct the inline assembly implementations of __movsb/w/d/q and ↵Craig Topper2018-06-211-7/+14
| | | | | | | | | | | | __stosw/d/q to mark registers/memory as modified The inline assembly for these didn't mark that edi, esi, ecx are modified by movs/stos instruction. It also didn't mark that memory is modified. This issue was reported to llvm-dev last year http://lists.llvm.org/pipermail/cfe-dev/2017-November/055863.html but no bug was ever filed. Differential Revision: https://reviews.llvm.org/D48448 llvm-svn: 335270
* [Intrinsics] Add/move some builtin declarations in intrin.h to get ↵Craig Topper2018-06-211-4/+7
| | | | | | | | | | ms-intrinsics.c to not issue warnings ud2 and int2c were missing declarations entirely. And the bitscans were only under x86_64, but they seem to be in BuiltinsARM.def as well and are tested by ms_intrinsics.c Differential Revision: https://reviews.llvm.org/D48187 llvm-svn: 335259
* [X86] Add inline assembly versions of ↵Craig Topper2018-06-141-10/+0
| | | | | | | | | | _InterlockedExchange_HLEAcquire/Release and _InterlockedCompareExchange_HLEAcquire/Release for MSVC compatibility. Clang/LLVM doesn't have a way to pass an HLE hint through to the X86 backend to emit HLE prefixed instructions. So this is a good short term fix. Differential Revision: https://reviews.llvm.org/D47672 llvm-svn: 334751
* [MS] Re-add support for the ARM interlocked bittest intrinscsReid Kleckner2018-06-071-0/+17
| | | | | | | | | | | | | | | 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. llvm-svn: 334239
* Reimplement the bittest intrinsic family as builtins with inline asmReid Kleckner2018-06-051-81/+0
| | | | | | | | | | | We need to implement _interlockedbittestandset as a builtin for windows.h, so we might as well do the whole family. It reduces code duplication anyway. Fixes PR33188, a long standing bug in our bittest implementation encountered by Chakra. llvm-svn: 333978
* [Headers] Fix the return type of _InterlockedCompareExchange_relMartin Storsjo2017-09-141-1/+1
| | | | | | This was a typo in SVN r282447, where it was added. llvm-svn: 313232
* [clang] Add ARM64 support to armintr.h for MSVC compatibilityMandeep Singh Grang2017-07-261-0/+4
| | | | | | | | | | | | | | Summary: This fixes compiling with headers from the Windows SDK for ARM64. Reviewers: compnerd, ruiu, mstorsjo Reviewed By: compnerd, mstorsjo Subscribers: mgorny, aemerson, javed.absar, kristof.beyls, llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D35862 llvm-svn: 309081
* [X86][LWP] Remove MSVC LWP intrinsics stubs.Simon Pilgrim2017-05-091-6/+0
| | | | | | Now provided in lwpintrin.h llvm-svn: 302559
* Implement _interlockedbittestandset as a builtinHans Wennborg2017-04-071-6/+0
| | | | | | | | | It's used by MS headers in VS 2017 without including intrin.h, so we can't implement it in the header anymore. Differential Revision: https://reviews.llvm.org/D31736 llvm-svn: 299782
* [X86] Implement __readgsqword (and the rest) as builtins (PR32373)Hans Wennborg2017-03-221-43/+0
| | | | | | | | | | | | | | It seems MS headers have started using __readgsqword, and since it's used in a header that doesn't include intrin.h, we can't implement it as an inline function anymore. That was already the case for __readfsdword, which Saleem added support for in r220859. This patch reuses that codegen to implement all of __read[fg]s{byte,word,dword,qword}. Differential Revision: https://reviews.llvm.org/D31248 llvm-svn: 298538
* [MS] Add support for __ud2 and __int2c MSVC intrinsicsReid Kleckner2017-03-061-2/+0
| | | | | | This was requested in PR31958 and elsewhere. llvm-svn: 297057
* Fix some warnings in intrin.hReid Kleckner2017-02-141-4/+6
| | | | llvm-svn: 295082
* [MS] Implement the __fastfail intrinsic as a builtinReid Kleckner2017-02-091-1/+0
| | | | | | | | | | __fastfail terminates the process immediately with a special system call. It does not run any process shutdown code or exception recovery logic. Fixes PR31854 llvm-svn: 294606
* [Windows] Remove functions in intrin.h that are defined in Builtin.def.Justin Lebar2017-01-051-90/+0
| | | | | | | | | | | | | | | | | | | | Summary: These duplicate declarations cause a problem for CUDA compiles on Windows. All implicitly-defined functions are host+device, and this applies to the declarations in Builtin.def. But then when we see the declarations in intrin.h, they have no attributes, so are host-only functions. This is an error. (A better fix might be to make these builtins host-only, but that is a much bigger change.) Reviewers: rnk Subscribers: cfe-commits, echristo Differential Revision: https://reviews.llvm.org/D28317 llvm-svn: 291128
* [inline-asm]No error for conflict between inputs\outputs and clobber listMarina Yatsina2016-12-261-14/+7
| | | | | | | | | | | | | | | | | | | | | | | | | According to extended asm syntax, a case where the clobber list includes a variable from the inputs or outputs should be an error - conflict. for example: const long double a = 0.0; int main() { char b; double t1 = a; __asm__ ("fucompp": "=a" (b) : "u" (t1), "t" (t1) : "cc", "st", "st(1)"); return 0; } This should conflict with the output - t1 which is st, and st which is st aswell. The patch fixes it. Commit on behald of Ziv Izhar. Differential Revision: https://reviews.llvm.org/D15075 llvm-svn: 290539
* Implement __stosb intrinsic as a volatile memsetAlbert Gutowski2016-10-141-5/+0
| | | | | | | | | | | | Summary: We need `__stosb` to be an intrinsic, because SecureZeroMemory function uses it without including intrin.h. Implementing it as a volatile memset is not consistent with MSDN specification, but it gives us target-independent IR while keeping the most important properties of `__stosb`. Reviewers: rnk, hans, thakis, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25334 llvm-svn: 284253
* Add 64-bit MS _Interlocked functions as builtins againAlbert Gutowski2016-10-131-78/+21
| | | | | | | | | | | | Summary: Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it) Reviewers: hans, majnemer, mstorsjo, rnk Subscribers: cfe-commits, aemerson Differential Revision: https://reviews.llvm.org/D25576 llvm-svn: 284172
* Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsicsAlbert Gutowski2016-10-131-8/+0
| | | | | | | | | | Reviewers: rnk, thakis, majnemer, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25540 llvm-svn: 284131
* Implement MS _BitScan intrinsicsAlbert Gutowski2016-10-121-28/+0
| | | | | | | | | | | | Summary: _BitScan intrinsics (and some others, for example _Interlocked and _bittest) are supposed to work on both ARM and x86. This is an attempt to isolate them, avoiding repeating their code or writing separate function for each builtin. Reviewers: hans, thakis, rnk, majnemer Subscribers: RKSimon, cfe-commits, aemerson Differential Revision: https://reviews.llvm.org/D25264 llvm-svn: 284060
* Implement MS read/write barriers and __faststorefence intrinsicAlbert Gutowski2016-10-101-30/+9
| | | | | | | | | | Reviewers: hans, rnk, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25442 llvm-svn: 283793
* Implement __emul, __emulu, _mul128 and _umul128 MS intrinsicsAlbert Gutowski2016-10-101-28/+10
| | | | | | | | | | Reviewers: rnk, thakis, majnemer, hans Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25353 llvm-svn: 283785
OpenPOWER on IntegriCloud