summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorXiuli Pan <xiulipan@outlook.com>2016-02-26 03:13:03 +0000
committerXiuli Pan <xiulipan@outlook.com>2016-02-26 03:13:03 +0000
commit11e13f60ea8dc595c34da1024121214544b673cb (patch)
treeefded82997a8ba6888d55fb0e8b798beb7c56a0e /clang/include
parent2a610381bcb7289425b693fb84ccec9d0cc94c8d (diff)
downloadbcm5719-llvm-11e13f60ea8dc595c34da1024121214544b673cb.tar.gz
bcm5719-llvm-11e13f60ea8dc595c34da1024121214544b673cb.zip
[OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr
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
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Basic/Attr.td4
-rw-r--r--clang/include/clang/Basic/AttrDocs.td26
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td8
3 files changed, 36 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index c7f559d9b3a..b77a5337192 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -664,7 +664,7 @@ def OpenCLUnrollHint : InheritableAttr {
// This attribute is both a type attribute, and a declaration attribute (for
// parameter variables).
-def OpenCLImageAccess : Attr {
+def OpenCLAccess : Attr {
let Spellings = [Keyword<"__read_only">, Keyword<"read_only">,
Keyword<"__write_only">, Keyword<"write_only">,
Keyword<"__read_write">, Keyword<"read_write">];
@@ -675,7 +675,7 @@ def OpenCLImageAccess : Attr {
Keyword<"read_write">]>,
Accessor<"isWriteOnly", [Keyword<"__write_only">,
Keyword<"write_only">]>];
- let Documentation = [Undocumented];
+ let Documentation = [OpenCLAccessDocs];
}
def OpenCLPrivateAddressSpace : TypeAttr {
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 5ed44de420c..f1a6ae2b1cc 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1581,6 +1581,32 @@ s6.11.5 for details.
}];
}
+def OpenCLAccessDocs : Documentation {
+ let Category = DocCatStmt;
+ let Content = [{
+The access qualifiers must be used with image object arguments or pipe arguments
+to declare if they are being read or written by a kernel or function.
+
+The read_only/__read_only, write_only/__write_only and read_write/__read_write
+names are reserved for use as access qualifiers and shall not be used otherwise.
+
+ .. code-block:: c
+ kernel void
+ foo (read_only image2d_t imageA,
+ write_only image2d_t imageB)
+ {
+ ...
+ }
+
+In the above example imageA is a read-only 2D image object, and imageB is a
+write-only 2D image object.
+
+The read_write (or __read_write) qualifier can not be used with pipe.
+
+More details can be found in the OpenCL C language Spec v2.0, Section 6.6.
+ }];
+}
+
def DocOpenCLAddressSpaces : DocumentationCategory<"OpenCL Address Spaces"> {
let Content = [{
The address space qualifier may be used to specify the region of memory that is
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 70a841711ab..7f5ecca9b6a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7735,6 +7735,14 @@ def err_opencl_builtin_pipe_invalid_arg : Error<
def err_opencl_builtin_pipe_invalid_access_modifier : Error<
"invalid pipe access modifier (expecting %0)">;
+// OpenCL access qualifier
+def err_opencl_invalid_access_qualifier : Error<
+ "access qualifier can only be used for pipe and image type">;
+def err_opencl_invalid_read_write : Error<
+ "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL2.0 version}2">;
+def err_opencl_multiple_access_qualifiers : Error<
+ "multiple access qualifiers">;
+
// OpenCL Section 6.8.g
def err_opencl_unknown_type_specifier : Error<
"OpenCL does not support the '%0' %select{type qualifier|storage class specifier}1">;
OpenPOWER on IntegriCloud