summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/Builtins.h
Commit message (Collapse)AuthorAgeFilesLines
* [Builtins][Attributes][X86] Tag all X86 builtins with their required vector ↵Craig Topper2018-07-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | width. Add a min_vector_width function attribute and tag all x86 instrinsics with it This is part of an ongoing attempt at making 512 bit vectors illegal in the X86 backend type legalizer due to CPU frequency penalties associated with wide vectors on Skylake Server CPUs. We want the loop vectorizer to be able to emit IR containing wide vectors as intermediate operations in vectorized code and allow these wide vectors to be legalized to 256 bits by the X86 backend even though we are targetting a CPU that supports 512 bit vectors. This is similar to what happens with an AVX2 CPU, the vectorizer can emit wide vectors and the backend will split them. We want this splitting behavior, but still be able to use new Skylake instructions that work on 256-bit vectors and support things like masking and gather/scatter. Of course if the user uses explicit vector code in their source code we need to not split those operations. Especially if they have used any of the 512-bit vector intrinsics from immintrin.h. And we need to make it so that merely using the intrinsics produces the expected code in order to be backwards compatible. To support this goal, this patch adds a new IR function attribute "min-legal-vector-width" that can indicate the need for a minimum vector width to be legal in the backend. We need to ensure this attribute is set to the largest vector width needed by any intrinsics from immintrin.h that the function uses. The inliner will be reponsible for merging this attribute when a function is inlined. We may also need a way to limit inlining in the future as well, but we can discuss that in the future. To make things more complicated, there are two different ways intrinsics are implemented in immintrin.h. Either as an always_inline function containing calls to builtins(can be target specific or target independent) or vector extension code. Or as a macro wrapper around a taget specific builtin. I believe I've removed all cases where the macro was around a target independent builtin. To support the always_inline function case this patch adds attribute((min_vector_width(128))) that can be used to tag these functions with their vector width. All x86 intrinsic functions that operate on vectors have been tagged with this attribute. To support the macro case, all x86 specific builtins have also been tagged with the vector width that they require. Use of any builtin with this property will implicitly increase the min_vector_width of the function that calls it. I've done this as a new property in the attribute string for the builtin rather than basing it on the type string so that we can opt into it on a per builtin basis and avoid any impact to target independent builtins. There will be future work to support vectors passed as function arguments and supporting inline assembly. And whatever else we can find that isn't covered by this patch. Special thanks to Chandler who suggested this direction and reviewed a preview version of this patch. And thanks to Eric Christopher who has had many conversations with me about this issue. Differential Revision: https://reviews.llvm.org/D48617 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336583 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-31/+31
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
* [Builtins] Fix typos in a comment. NFCCraig Topper2018-04-251-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330842 91177308-0d34-0410-b5e6-96231b3b80d8
* Limit types of builtins that can be redeclared.Erich Keane2018-04-161-0/+11
| | | | | | | | | | | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033 Any usage of a builtin function that uses a va_list by reference will cause an assertion when redeclaring it. After discussion in the review, it was concluded that the correct way of accomplishing this fix is to make attempts to redeclare certain builtins an error. Unfortunately, doing this limitation for all builtins is likely a breaking change, so this commit simply limits it to types with custom type checking and those that take a reference. Two tests needed to be updated to make this work. Differential Revision: https://reviews.llvm.org/D45383 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330160 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenMP] Implement omp_is_initial_device() as builtinJonas Hahnfeld2017-10-171-0/+1
| | | | | | | | This allows to return the static value that we know at compile time. Differential Revision: https://reviews.llvm.org/D38968 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316001 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Add half load and store builtinsJan Vesely2017-09-071-2/+4
| | | | | | | | This enables load/stores of half type, without half being a legal type. Differential Revision: https://reviews.llvm.org/D37231 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312742 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Change Builtins name to be stored as StringRef instead of raw ↵Mehdi Amini2016-10-111-3/+2
| | | | | | | | | | | | | | pointers (NFC)" This reverts commit r283802. It introduces temporarily static initializers, because StringRef ctor isn't (yet) constexpr for string literals. I plan to get there this week, but apparently GCC is so terrible with these static initializer right now (10 min+ extra codegen time was reported) that I'll hold on to this patch till the constexpr one is ready, and land these at the same time. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283920 91177308-0d34-0410-b5e6-96231b3b80d8
* Change Builtins name to be stored as StringRef instead of raw pointers (NFC)Mehdi Amini2016-10-101-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283802 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some MS aliases for existing intrinsicsAlbert Gutowski2016-09-141-0/+7
| | | | | | | | | | | Reviewers: thakis, compnerd, majnemer, rsmith, rnk Subscribers: alexshap, cfe-commits Differential Revision: https://reviews.llvm.org/D24330 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281540 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverse commit 281375 (breaks building Chromium)Albert Gutowski2016-09-131-7/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281399 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some MS aliases for existing intrinsicsAlbert Gutowski2016-09-131-0/+7
| | | | | | | | | | | Reviewers: thakis, compnerd, majnemer, rsmith, rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24330 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281375 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Make OpenCL Builtins added according to the right version.Anastasia Stulova2016-07-041-1/+1
| | | | | | | | | | | | | Currently we only have OpenCL 2.0 Builtins i.e. pipes or address space conversions. They have to be added only in the version 2.0 compilation mode to make the identifiers available for use in the other versions. Review: http://reviews.llvm.org/D20249 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274509 91177308-0d34-0410-b5e6-96231b3b80d8
* [Feature] Add a builtin for indexing into parameter packs. Patch by Louis ↵Eric Fiselier2016-07-011-1/+4
| | | | | | | | | | | | | | | Dionne. This patch adds a __nth_element builtin that allows fetching the n-th type of a parameter pack with very little compile-time overhead. The patch was inspired by r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq builtin for efficiently creating a std::integer_sequence. Reviewed as D15421. http://reviews.llvm.org/D15421 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274316 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the Pure attribute to C99 builtin functions from ctype.h. This is a ↵Aaron Ballman2016-05-041-2/+7
| | | | | | | | corrected version of r266199 with test case fixes. Patch by Taewook Oh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268553 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverting r266199; it causes build bot failures.Aaron Ballman2016-04-131-7/+2
| | | | | | | http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/3255 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3517 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266201 91177308-0d34-0410-b5e6-96231b3b80d8
* Add functions declared in ctype.h to builtin function database. All ↵Aaron Ballman2016-04-131-2/+7
| | | | | | | | functions are annotated with nothrow and pure attribute, which enables better optimization. Patch by Taewook Oh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266199 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Refine pipe builtin supportXiuli Pan2016-03-041-6/+6
| | | | | | | | | | | | | | Summary: Refine the type builtin support as the request with http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160201/148637.html Reviewers: pekka.jaaskelainen, Anastasia, yaxunl Subscribers: rsmith, cfe-commits Differential Revision: http://reviews.llvm.org/D16876 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262692 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit: R258773 [OpenCL] Pipe builtin functionsXiuli Pan2016-01-261-0/+1
| | | | | | | | | | | | | | | | | | Fix arc patch fuzz error. Summary: Support for the pipe built-in functions for OpenCL 2.0. The pipe builtin functions may have infinite kinds of element types, one approach would be to just generate calls that would always use generic types such as void*. This patch is based on bader's opencl support patch on SPIR-V branch. Reviewers: Anastasia, pekka.jaaskelainen Subscribers: keryell, bader, cfe-commits Differential Revision: http://reviews.llvm.org/D15914 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258782 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[OpenCL] Pipe builtin functions"David Majnemer2016-01-261-1/+0
| | | | | | | This reverts commit r258773, it broke the build bots: http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/43853 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258775 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Pipe builtin functionsXiuli Pan2016-01-261-0/+1
| | | | | | | | | | | | | | | | Summary: Support for the pipe built-in functions for OpenCL 2.0. The pipe builtin functions may have infinite kinds of element types, one approach would be to just generate calls that would always use generic types such as void*. This patch is based on bader's opencl support patch on SPIR-V branch. Reviewers: Anastasia, pekka.jaaskelainen Subscribers: keryell, bader, cfe-commits Differential Revision: http://reviews.llvm.org/D15914 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258773 91177308-0d34-0410-b5e6-96231b3b80d8
* [Driver] Add support for -fno-builtin-foo options.Chad Rosier2016-01-061-0/+4
| | | | | | | Addresses PR4941 and rdar://6756912. http://reviews.llvm.org/D15195 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256937 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Implement __make_integer_seqDavid Majnemer2015-11-041-0/+7
| | | | | | | | | | | | | | | | | | This new builtin template allows for incredibly fast instantiations of templates like std::integer_sequence. Performance numbers follow: My work station has 64 GB of ram + 20 Xeon Cores at 2.8 GHz. __make_integer_seq<std::integer_sequence, int, 90000> takes 0.25 seconds. std::make_integer_sequence<int, 90000> takes unbound time, it is still running. Clang is consuming gigabytes of memory. Differential Revision: http://reviews.llvm.org/D13786 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252036 91177308-0d34-0410-b5e6-96231b3b80d8
* Make getTargetBuiltins return an ArrayRef instead of having two out ↵Craig Topper2015-10-191-8/+7
| | | | | | parameters of a pointer and length. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250681 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Allow parsing of host and device code simultaneously.Artem Belevich2015-09-221-2/+19
| | | | | | | | | | | | * adds -aux-triple option to specify target triple * propagates aux target info to AST context and Preprocessor * pulls in target specific preprocessor macros. * pulls in target-specific builtins from aux target. * sets appropriate host or device attribute on builtins. Differential Revision: http://reviews.llvm.org/D12917 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248299 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Add appropriate host/device attribute to builtins.Artem Belevich2015-09-221-0/+5
| | | | | | | | | The changes are part of attribute-based CUDA function overloading (D12453) and as such are only enabled when it's in effect (-fcuda-target-overloads). Differential Revision: http://reviews.llvm.org/D12122 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248296 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r245496 "[CUDA] Add appropriate host/device attribute to builtins."Artem Belevich2015-08-201-5/+0
| | | | | | It's breaking internal test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245592 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Add appropriate host/device attribute to builtins.Artem Belevich2015-08-191-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D12122 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245496 91177308-0d34-0410-b5e6-96231b3b80d8
* Continue the work from r243908 by adding a Features field to Builtin::InfoEric Christopher2015-08-061-0/+5
| | | | | | | | so that we can populate it on a per-target basis with required features. Future commits will start using this information for warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244286 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename the non-coding style conformant functions in namespace BuiltinsEric Christopher2015-08-061-37/+37
| | | | | | to match the rest of their brethren and reformat the bits that need it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244186 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused header includes.Eric Christopher2015-08-051-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244131 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename builtin_lang -> Langs to match the rest of the code a bit better.Eric Christopher2015-08-051-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244126 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused function GetBuiltinNames.Eric Christopher2015-08-051-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244125 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused comparison operators from the Builtin Info struct.Eric Christopher2015-08-051-7/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244111 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Accept pointers to any address space for builtin functionsTom Stellard2015-03-311-0/+6
| | | | | | | | As long as they don't have an address space explicitly defined. This allows builtins with pointer arguments to be used with OpenCL. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233706 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic: clean up bleeding whitespaceSaleem Abdulrasool2014-12-171-2/+2
| | | | | | Whitespace cleanup. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224439 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'Craig Topper2014-05-061-10/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208063 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactored Builtin::Context::isPrintfLike and isScanfLike into a helper ↵Aaron Ballman2014-01-031-0/+4
| | | | | | | | function. The implementations are identical, except for the format arguments being searched for. No functional changes intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198446 91177308-0d34-0410-b5e6-96231b3b80d8
* Only provide MS builtins when -fms-extensions is onReid Kleckner2013-11-131-1/+3
| | | | | | | | | | | We already have builtins that are only available in GNU mode, so this mirrors that. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2128 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194615 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a -fno-math-builtin option to the Clang -cc1Eli Bendersky2013-07-231-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186899 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify GetBuiltinNames by hoising the NoBuiltins argument out of it.Eli Bendersky2013-07-111-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186106 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow clang to build __clear_cache on ARM.Rafael Espindola2013-06-131-0/+7
| | | | | | | | | __clear_cache is special. It needs no signature, but is a real function in compiler_rt or libgcc. Patch by Andrew Turner. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183926 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable non-standard library builtins in non-gnu language modes.Benjamin Kramer2013-05-311-4/+6
| | | | | | Fixes PR16138. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183015 91177308-0d34-0410-b5e6-96231b3b80d8
* Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor notRichard Smith2013-01-171-0/+6
| | | | | | | to visit them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172769 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling2012-12-201-10/+10
| | | | | | which is wrong here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170721 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-10/+10
| | | | | | single attribute in the future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170500 91177308-0d34-0410-b5e6-96231b3b80d8
* Documentation cleanup:James Dennett2012-07-021-13/+13
| | | | | | | | | | | | * Primarily, added \brief to most of include/clang/Basic, instead of prefixing the comments with "DeclaredName - "; * Made some brief summaries significantly briefer; * Fixed up some erroneous uses of \see and \arg; * Fixed up some extraneous backslashes in \code...\endcode blocks; * Fixed up some typos/spelling errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159616 91177308-0d34-0410-b5e6-96231b3b80d8
* Documentation cleanup: reformatting/fixing up file comments so that they haveJames Dennett2012-07-021-4/+5
| | | | | | | | | \file and \brief markup and appear in Doxygen's summaries (and eventually at http://clang.llvm.org/doxygen/files.html). Fixed up another couple of minor glitches in the docs at the same time. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159517 91177308-0d34-0410-b5e6-96231b3b80d8
* Add returns_twice to functions that are known to return twice. This implementsRafael Espindola2011-10-121-0/+5
| | | | | | the same behavior of gcc by keeping the attribute out of the function type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141803 91177308-0d34-0410-b5e6-96231b3b80d8