summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Builtins.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Builtins][Attributes][X86] Tag all X86 builtins with their required vector ↵Craig Topper2018-07-091-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 336583
* Limit types of builtins that can be redeclared.Erich Keane2018-04-161-0/+7
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 330160
* [OpenMP] Implement omp_is_initial_device() as builtinJonas Hahnfeld2017-10-171-1/+2
| | | | | | | | This allows to return the static value that we know at compile time. Differential Revision: https://reviews.llvm.org/D38968 llvm-svn: 316001
* [OpenCL] Add half load and store builtinsJan Vesely2017-09-071-2/+7
| | | | | | | | This enables load/stores of half type, without half being a legal type. Differential Revision: https://reviews.llvm.org/D37231 llvm-svn: 312742
* [OpenCL] Make OpenCL Builtins added according to the right version.Anastasia Stulova2016-07-041-1/+2
| | | | | | | | | | 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 llvm-svn: 274509
* Recommit: R258773 [OpenCL] Pipe builtin functionsXiuli Pan2016-01-261-1/+2
| | | | | | | | | | | | | | | | | 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 llvm-svn: 258782
* Revert "[OpenCL] Pipe builtin functions"David Majnemer2016-01-261-2/+1
| | | | | | | This reverts commit r258773, it broke the build bots: http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/43853 llvm-svn: 258775
* [OpenCL] Pipe builtin functionsXiuli Pan2016-01-261-1/+2
| | | | | | | | | | | | | | | | 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 llvm-svn: 258773
* [Driver] Add support for -fno-builtin-foo options.Chad Rosier2016-01-061-2/+12
| | | | | | | Addresses PR4941 and rdar://6756912. http://reviews.llvm.org/D15195 llvm-svn: 256937
* Make getTargetBuiltins return an ArrayRef instead of having two out ↵Craig Topper2015-10-191-15/+8
| | | | | | parameters of a pointer and length. NFC llvm-svn: 250681
* [CUDA] Allow parsing of host and device code simultaneously.Artem Belevich2015-09-221-3/+16
| | | | | | | | | | | | * 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 llvm-svn: 248299
* Doxygen fix InitializeBuiltins -> initializeBuiltinsIsmail Donmez2015-09-151-1/+1
| | | | llvm-svn: 247668
* Test commitRachel Craik2015-09-141-2/+2
| | | | | | Remove some trailing whitespace llvm-svn: 247560
* Make sure the Features field of the Builtin Info struct is always ↵Craig Topper2015-08-071-6/+5
| | | | | | | | initialized. Silences -Wmissing-field-initializers. While there convert 0 in the BUILTIN macros to nullptr. llvm-svn: 244307
* Rename the non-coding style conformant functions in namespace BuiltinsEric Christopher2015-08-061-9/+9
| | | | | | to match the rest of their brethren and reformat the bits that need it. llvm-svn: 244186
* Remove unused header includes.Eric Christopher2015-08-051-1/+0
| | | | llvm-svn: 244131
* Rename builtin_lang -> Langs to match the rest of the code a bit better.Eric Christopher2015-08-051-9/+10
| | | | llvm-svn: 244126
* Remove unused function GetBuiltinNames.Eric Christopher2015-08-051-13/+0
| | | | llvm-svn: 244125
* CodeGen: make target builtins support languagesSaleem Abdulrasool2014-07-021-1/+1
| | | | | | | | | | This extends the target builtin support to allow language specific annotations (i.e. LANGBUILTIN). This is to allow MSVC compatibility whilst retaining the ability to have EABI targets use a __builtin_ prefix. This is merely to allow uniformity in the EABI case where the unprefixed name is provided as an alias in the header. llvm-svn: 212196
* [C++11] Use 'nullptr'.Craig Topper2014-05-081-3/+3
| | | | llvm-svn: 208280
* Refactored Builtin::Context::isPrintfLike and isScanfLike into a helper ↵Aaron Ballman2014-01-031-28/+23
| | | | | | | | function. The implementations are identical, except for the format arguments being searched for. No functional changes intended. llvm-svn: 198446
* Only provide MS builtins when -fms-extensions is onReid Kleckner2013-11-131-1/+4
| | | | | | | | | | | 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 llvm-svn: 194615
* Add a -fno-math-builtin option to the Clang -cc1Eli Bendersky2013-07-231-3/+18
| | | | llvm-svn: 186899
* Simplify GetBuiltinNames by hoising the NoBuiltins argument out of it.Eli Bendersky2013-07-111-4/+3
| | | | llvm-svn: 186106
* Disable non-standard library builtins in non-gnu language modes.Benjamin Kramer2013-05-311-5/+4
| | | | | | Fixes PR16138. llvm-svn: 183015
* Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling2012-12-201-6/+6
| | | | | | which is wrong here. llvm-svn: 170721
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-6/+6
| | | | | | single attribute in the future. llvm-svn: 170500
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Allow the preprocessor to be constructed without performing target-Douglas Gregor2011-09-011-2/+6
| | | | | | | | and language-specific initialization. Use this to allow ASTUnit to create a preprocessor object *before* loading the AST file. No actual functionality change. llvm-svn: 138983
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Remove unused member of Builtin::Info.Eli Friedman2011-07-051-15/+7
| | | | llvm-svn: 134443
* Test commit.Richard Smith2011-02-201-1/+0
| | | | llvm-svn: 126063
* In C++, if the user redeclares a builtin function with a type that isDouglas Gregor2010-12-211-0/+4
| | | | | | | | | | | | | | | inconsistent with the type that the builtin *should* have, forget about the builtin altogether: we don't want subsequence analyses, CodeGen, etc., to think that we have a proper builtin function. C is protected from errors here because it allows one to use a library builtin without having a declaration, and detects inconsistent (re-)declarations of builtins during declaration merging. C++ was unprotected, and therefore would crash. Fixes PR8839. llvm-svn: 122351
* Such function decls,as objc's objc_msgSend, builtins in Fariborz Jahanian2010-11-301-7/+12
| | | | | | | | | a specific language. We are adding such language info. by extensing Builtins.def and via a language flag added to LIBBUILTIN/BUILTIN and check for that when deciding a name is builtin or not. Implements //rdar://8689273. llvm-svn: 120429
* Add builtin definition for scanf, including extending the builtin encoding toTed Kremenek2010-07-161-0/+20
| | | | | | | | | | represent builtins that have the "scanf" attribution (via the format attribute) just like we do with printf functions. Follow-up work is needed to add similar support for fscanf et al. This is to support format-string checking for scanf functions. llvm-svn: 108499
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-9/+9
| | | | llvm-svn: 81346
* follow-on to my patch: some targets (like sparc) do notChris Lattner2009-06-161-0/+2
| | | | | | | have target-specific builtins, and do not set the count. Just default to 0 for these targets. llvm-svn: 73510
* my refactoring of builtins changed target-specific builtins to only beChris Lattner2009-06-161-4/+5
| | | | | | | | | registered when PCH wasn't being used. We should always install (in BuiltinInfo) information about target-specific builtins, but we shouldn't register any builtin identifier infos. This fixes the build of apps that use PCH and target specific builtins together. llvm-svn: 73492
* Sink the BuiltinInfo object from ASTContext into theChris Lattner2009-06-141-6/+4
| | | | | | | | preprocessor and initialize it early in clang-cc. This ensures that __has_builtin works in all modes, not just when ASTContext is around. llvm-svn: 73319
* move the various builtins stuff from libast to libbasic. ThisChris Lattner2009-06-141-0/+94
fixes a layering violation in lib/Basic/Targets.cpp. llvm-svn: 73318
OpenPOWER on IntegriCloud