summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaOpenCL
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenCL] Output OpenCL version in diagnostics.Anastasia Stulova2016-05-122-2/+2
| | | | | | | | | | | | | | Diagnostics should note version dependent issues by giving a hint about current version being compiled for. This patch changes diagnostics of static storage class specifier and generic type qualifier to specify OpenCL version as well as converts other diagnostics to match the style. Patch by Vedran Miletic! Review: http://reviews.llvm.org/D19780 llvm-svn: 269305
* [OpenCL] Fix pipe type dump.Xiuli Pan2016-05-032-2/+2
| | | | | | | | | | | | | | Summary: Fix the dump of PipeType. Now we will have "pipe int" and element type. Reviewers: yaxunl, Anastasia Subscribers: cfe-commits, bader Differential Revision: http://reviews.llvm.org/D19524 llvm-svn: 268364
* Block: Fix a crash when we have type attributes or qualifiers with omittedManman Ren2016-04-181-9/+8
| | | | | | | | | | | | return type. Emit a warning instead of crashing in IR generation. rdar://22762981 Differential Revision: http://reviews.llvm.org/D18567 llvm-svn: 266648
* PR19957: [OpenCL] Incorrectly accepts implicit address space conversion with ↵Yaxun Liu2016-04-121-0/+66
| | | | | | | | | | | | ternary operator. Generates addrspacecast instead of bitcast for ternary operator when necessary, and diagnose ternary operator with incompatible second and third operands. https://llvm.org/bugs/show_bug.cgi?id=19957 Differential Revision: http://reviews.llvm.org/D17412 llvm-svn: 266111
* [OpenCL] Complete image types support.Alexey Bader2016-04-084-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 llvm-svn: 265783
* [OpenCL] Added nosvm attribute for OpenCL v2.0.Anastasia Stulova2016-03-311-0/+17
| | | | | | | | | | | | | It is not widely used and removed from OpenCL v2.1. This change modifies Clang to parse the attribute for OpenCL but ignores it afterwards. Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D17861 llvm-svn: 265006
* [OpenCL] Fix pipe builtin bugsXiuli Pan2016-03-301-10/+20
| | | | | | | | | | | | | | | Summary: 1. Diag should be output if types are not the same. 2. Should compare using canonical type. 3. Refine the diag to be more clear. Reviewers: yaxunl, Anastasia Subscribers: MatsPetersson, pekka.jaaskelainen, cfe-commits Differential Revision: http://reviews.llvm.org/D17955 llvm-svn: 264825
* [OpenCL] Refine pipe builtin supportXiuli Pan2016-03-041-20/+20
| | | | | | | | | | | | | | 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 llvm-svn: 262692
* [OpenCL] Improve diagnostics of address spaces for variables in functionAnastasia Stulova2016-03-032-3/+10
| | | | | | | | | - Prevent local variables to be declared in global AS - Diagnose AS of local variables with an extern storage class as if they would be in a program scope Review: http://reviews.llvm.org/D17345 llvm-svn: 262641
* [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0Anastasia Stulova2016-03-034-15/+52
| | | | | | | | | | | | | | Applying the following restrictions for block types in OpenCL (v2.0 s6.12.5): - __block storage class is disallowed - every block declaration must be const qualified and initialized - a block can't be used as a return type of a function - a blocks can't be used to declare a structure or union field - extern speficier is disallowed Corrected image and sampler types diagnostics with struct and unions. Review: http://reviews.llvm.org/D16928 llvm-svn: 262616
* AMDGPU: Add builtins for recently added intrinsicsMatt Arsenault2016-02-271-0/+6
| | | | llvm-svn: 262126
* [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttrXiuli Pan2016-02-263-4/+16
| | | | | | | | | | | | | | | Summary: OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading, Add semacheck for OpenCL access qualifier as well as test caees. Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D16040 llvm-svn: 261961
* [OpenCL] Add Sema checks for typesXiuli Pan2016-02-253-0/+14
| | | | | | | | | | | | | | Summary: Add Sema checks for opencl type: image, pipe.... This patch is partitioned from http://reviews.llvm.org/D16047 Reviewers: Anastasia, yaxunl Subscribers: pekka.jaaskelainen, cfe-commits Differential Revision: http://reviews.llvm.org/D17437 llvm-svn: 261818
* [OpenCL] Add Sema checks for OpenCL 2.0 blockXiuli Pan2016-02-241-0/+20
| | | | | | | | | | | | | | Summary: Add Sema checks for opencl 2.0 new features: Block. This patch is partitioned from http://reviews.llvm.org/D16047 Reviewers: Anastasia Subscribers: pekka.jaaskelainen, cfe-commits Differential Revision: http://reviews.llvm.org/D17436 llvm-svn: 261719
* [OpenCL] Generate metadata for opencl_unroll_hint attributeAnastasia Stulova2016-02-191-0/+30
| | | | | | | | | | | | | | | Add support for opencl_unroll_hint attribute from OpenCL v2.0 s6.11.5. Reusing most of metadata generation from CGLoopInfo helper class. The code is based on Khronos OpenCL compiler: https://github.com/KhronosGroup/SPIR/tree/spirv-1.0 Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16686 llvm-svn: 261350
* [OpenCL] Added half type literal with suffix h.Anastasia Stulova2016-02-171-0/+6
| | | | | | | | | | | | | OpenCL Extension v1.2 s9.5 allows half precision floating point type literals with suffices h or H when cl_khr_fp16 is enabled. Example: half x = 1.0h; Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16865 llvm-svn: 261084
* [OpenCL] Disable C99 standard lib functionsAnastasia Stulova2016-02-121-1/+12
| | | | | | | | | | | | | | The library functions defined in the C99 standard headers are not available (OpenCL v1.2 s6.9.f). This change stops treating OpenCL builtin functions as standard C lib functions to eliminate warning messages about printf format string. Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16812 llvm-svn: 260671
* [OpenCL] Adding reserved operator logical xor for OpenCLAnastasia Stulova2016-02-031-0/+4
| | | | | | | | | | | | | | | | | | This patch adds the reserved operator ^^ when compiling for OpenCL (spec v1.1 s6.3.g), which results in a more meaningful error message. Patch by Neil Hickey! Review: http://reviews.llvm.org/D13280 M test/SemaOpenCL/unsupported.cl M include/clang/Basic/TokenKinds.def M include/clang/Basic/DiagnosticParseKinds.td M lib/Basic/OperatorPrecedence.cpp M lib/Lex/Lexer.cpp M lib/Parse/ParseExpr.cpp llvm-svn: 259651
* [OpenCL] Eliminate warning when declaring OpenCL builtin functions.Anastasia Stulova2016-02-021-0/+3
| | | | | | | | | | | | | | OpenCL builtin functions are usually declared in header files. Currently clang emits warning for OpenCL builtin functions which have the same name as standard C library functions. This commit eliminates such warnings by not adding the C standard includes following the restriction from OpenCL v1.2 s6.9.f. Patch by Liu Yaxun (Sam)! Review: http://reviews.llvm.org/D16692 llvm-svn: 259491
* [Sema] Make extended vectors of `bool` an error.George Burgess IV2016-01-281-0/+3
| | | | | | | | | | | | | | In OpenCL, `bool` vectors are a reserved type, and are therefore illegal. Outside of OpenCL, if we try to make an extended vector of N `bool`s, Clang will lower it to an `[N x i1]`. LLVM has no ABI for bitvectors, so lots of operations on such vectors are thoroughly broken. As a result, this patch makes them illegal in everything else, as well. :) Differential Revision: http://reviews.llvm.org/D15721 llvm-svn: 259011
* Recommit: R258773 [OpenCL] Pipe builtin functionsXiuli Pan2016-01-261-0/+55
| | | | | | | | | | | | | | | | | 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-55/+0
| | | | | | | 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-0/+55
| | | | | | | | | | | | | | | | 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
* [OpenCL] Pipe type supportXiuli Pan2016-01-092-0/+11
| | | | | | | | | | | | | | | Summary: Support for OpenCL 2.0 pipe type. This is a bug-fix version for bader's patch reviews.llvm.org/D14441 Reviewers: pekka.jaaskelainen, Anastasia Subscribers: bader, Anastasia, cfe-commits Differential Revision: http://reviews.llvm.org/D15603 llvm-svn: 257254
* [OpenCL] Disallow taking an address of a function.Anastasia Stulova2016-01-052-1/+4
| | | | | | | | | | | | An undecorated function designator implies taking the address of a function, which is illegal in OpenCL. Implementing a check for this earlier to allow the error to be reported even in the presence of other more obvious errors. Patch by Neil Hickey! http://reviews.llvm.org/D15691 llvm-svn: 256838
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-0/+29
| | | | | | | | | | | address space unless address space is explicitly specified. Correct the behavior of NULL constant detection - generic AS void pointer should be accepted as a valid NULL constant. http://reviews.llvm.org/D15293 llvm-svn: 255346
* Reverting r255337 as it seems to kill bots. Needs investigation.Anastasia Stulova2015-12-111-29/+0
| | | | llvm-svn: 255339
* [OpenCL 2.0] In OpenCL v2.0 s6.5 all pointers are implicitly in genericAnastasia Stulova2015-12-111-0/+29
| | | | | | | | | | | address space unless address space is explicitly specified. Correct the behavior of NULL constant detection - generic AS void pointer should be accepted as a valid NULL constant. http://reviews.llvm.org/D15293 llvm-svn: 255337
* [OpenCL 2.0] Apply default address space (AS).Anastasia Stulova2015-11-231-2/+2
| | | | | | | | | | | | If AS of a variable/parameter declaration is not set by the source, OpenCL v2.0 s6.5 defines explicit rules for default ASes: - The AS of global and local static variables defaults to global; - All pointers point to generic AS. http://reviews.llvm.org/D13168 llvm-svn: 253863
* [OpenCL] Add test for program scope variable restrictions in OpenCL v2.0Anastasia Stulova2015-10-211-0/+15
| | | | | | http://reviews.llvm.org/D13105 llvm-svn: 250892
* [OpenCL 2.0] Enable program scope variables, Section 6.5.1.Anastasia Stulova2015-09-301-6/+21
| | | | | | | | | | | | | | | | | | - Remove virtual SC_OpenCLWorkGroupLocal storage type specifier as it conflicts with static local variables now and prevents diagnosing static local address space variables correctly. - Allow static local and global variables (OpenCL2.0 s6.8 and s6.5.1). - Improve diagnostics of allowed ASes for variables in different scopes: (i) Global or static local variables have to be in global or constant ASes (OpenCL1.2 s6.5, OpenCL2.0 s6.5.1); (ii) Non-kernel function variables can't be declared in local or constant ASes (OpenCL1.1 s6.5.2 and s6.5.3). http://reviews.llvm.org/D13105 llvm-svn: 248906
* [OpenCL] Improve diagnostics detecting implicit vector conversion.Alexey Bader2015-08-301-2/+2
| | | | | | | | Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12470 llvm-svn: 246393
* [Sema] Be consistent about diagnostic wording: always use "cannot".Davide Italiano2015-08-151-3/+3
| | | | | | Discussed with Richard Smith. llvm-svn: 245162
* Restores r228382, which was reverted in r228406.Sameer Sahasrabuddhe2015-02-251-16/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The original commit failed to handle "shift assign" (<<=), which broke the test mentioned in r228406. This is now fixed and the test added to the lit tests under SemaOpenCL. *** Original commit message from r228382 *** OpenCL: handle shift operator with vector operands Introduce a number of checks: 1. If LHS is a scalar, then RHS cannot be a vector. 2. Operands must be of integer type. 3. If both are vectors, then the number of elements must match. Relax the requirement for "usual arithmetic conversions": When LHS is a vector, a scalar RHS can simply be expanded into a vector; OpenCL does not require that its rank be lower than the LHS. For example, the following code is not an error even if the implicit type of the constant literal is "int". char2 foo(char2 v) { return v << 1; } Consolidate existing tests under CodeGenOpenCL, and add more tests under SemaOpenCL. llvm-svn: 230464
* Revert "OpenCL: handle shift operator with vector operands"Tom Stellard2015-02-061-53/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r228382. This breaks the following case: Reported by Jeroen Ketema: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150202/122961.html typedef __attribute__((ext_vector_type(3))) char char3; void foo() { char3 v = {1,1,1}; char3 w = {1,2,3}; w <<= v; } If I compile with: clang -x cl file.c Then an error is produced: file.c:10:5: error: expression is not assignable w <<= v; ~ ^ 1 error generated. llvm-svn: 228406
* OpenCL: handle shift operator with vector operandsSameer Sahasrabuddhe2015-02-061-16/+53
| | | | | | | | | | | | | | | | | | | | Introduce a number of checks: 1. If LHS is a scalar, then RHS cannot be a vector. 2. Operands must be of integer type. 3. If both are vectors, then the number of elements must match. Relax the requirement for "usual arithmetic conversions": When LHS is a vector, a scalar RHS can simply be expanded into a vector; OpenCL does not require that its rank be lower than the LHS. For example, the following code is not an error even if the implicit type of the constant literal is "int". char2 foo(char2 v) { return v << 1; } Consolidate existing tests under CodeGenOpenCL, and add more tests under SemaOpenCL. llvm-svn: 228382
* OpenCL: handle ternary operator when the condition is a vectorSameer Sahasrabuddhe2015-02-041-3/+129
| | | | | | | | | | When the condition is a vector, OpenCL specifies additional requirements on the operand types, and also the operations required to determine the result type of the operator. This is a combination of OpenCL v1.1 s6.3.i and s6.11.6, and the semantics remain unchanged in later versions of OpenCL. llvm-svn: 228118
* Fix OpenCL 1.2 double as an optional core feature behaviourFraser Cormack2015-01-303-0/+59
| | | | | | | | | | | | | | | | | | | | In OpenCL 1.2, using double no longer requires using the pragma cl_khr_fp64, instead a kernel is allowed to use double, but must first have queried clGetDeviceInfo's CL_DEVICE_DOUBLE_FP_CONFIG. Page 197, section 6.1.1 of the OpenCL 1.2 specification has a footnote 23 describing this behaviour. I've also added test cases such that the pragma must be used if targeting OpenCL 1.0 or 1.1, but is ignored in 1.2 and 2.0. Patch by Neil Henning! Reviewers: Pekka Jääskeläinen Differential Revision: http://reviews.llvm.org/D7245 llvm-svn: 227565
* Workaround attribute ordering issue with kernel only attributesMatt Arsenault2014-12-051-0/+6
| | | | | | | | | | | Placing the attribute after the kernel keyword would incorrectly reject the attribute, so use the smae workaround that other kernel only attributes use. Also add a FIXME because there are two different phrasings now for the same error, althoug amdgpu_num_[sv]gpr uses a consistent one. llvm-svn: 223490
* Add attributes for AMDGPU register limits.Matt Arsenault2014-12-041-0/+34
| | | | | | | This is a performance hint that can be applied to kernels to attempt to limit the number of used registers. llvm-svn: 223384
* [OpenCL] Implemented restrictions for pointer conversions specified in ↵Anastasia Stulova2014-11-261-0/+227
| | | | | | | | | | | | OpenCL v2.0. OpenCL v2.0 s6.5.5 restricts conversion of pointers to different address spaces: - the named address spaces (__global, __local, and __private) => __generic - implicitly converted; - __generic => named - with an explicit cast; - named <=> named - disallowed; - __constant <=> any other - disallowed. llvm-svn: 222834
* OpenCL: Emit global variables in the constant addr space as constant globalsTom Stellard2014-10-162-2/+5
| | | | llvm-svn: 219929
* OpenCL: Add -ffake-address-space-map to a testTom Stellard2014-10-161-2/+2
| | | | | | The ensures there is an explicit address space id in the output. llvm-svn: 219928
* [OpenCL] Reject reqd_work_group_size(X, Y, Z) where X, Y or Z == 0.Joey Gouly2014-05-191-0/+4
| | | | | | Patch by Pedro Ferreira! llvm-svn: 209127
* Parameter/argument terminology fixesAlp Toker2014-05-111-1/+1
| | | | llvm-svn: 208499
* Print detailed vector type information on diagnostics.Benjamin Kramer2014-04-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | We never aka vector types because our attributed syntax for it is less comprehensible than the typedefs. This leaves the user in the dark when the typedef isn't named that well. Example: v2s v; v4f w; w = v; The naming in this cases isn't even that bad, but the error we give is useless without looking up the actual typedefs. t.c:6:5: error: assigning to 'v4f' from incompatible type 'v2s' Now: t.c:6:5: error: assigning to 'v4f' (vector of 4 'float' values) from incompatible type 'v2s' (vector of 2 'int' values) We do this for all diagnostics that print a vector type. llvm-svn: 207267
* Disallow driver use in more Sema testsAlp Toker2014-04-191-0/+4
| | | | | | | There are now only a handful of Sema tests remaining that use %clang in SemaCXX, SemaObjC and SemaTemplate. llvm-svn: 206688
* Allow address space qualifiers on OpenCL array parametersFraser Cormack2014-04-152-0/+8
| | | | llvm-svn: 206275
* Enforce the restriction that a parameter to a kernel functionDavid Tweed2014-03-271-0/+2
| | | | | | | | | cannot be a pointer to the private address space (as clarified in the OpenCL 1.2 specification). Patch by Fraser Cormack! llvm-svn: 204941
* OpenCL: fix for the restriction on pointers to functions.Pekka Jaaskelainen2014-02-201-0/+16
| | | | | | Patch from Anastasia Stulova! llvm-svn: 201788
OpenPOWER on IntegriCloud