[cfe-commits] [PATCH] OpenCL: introduce support for function scope __local variables

Peter Collingbourne peter at pcc.me.uk
Wed Jul 27 19:06:02 PDT 2011


On Wed, Jul 27, 2011 at 02:26:30PM -0700, John McCall wrote:
> --- a/include/clang/Basic/Specifiers.h
> +++ b/include/clang/Basic/Specifiers.h
> @@ -146,6 +146,7 @@ namespace clang {
>      SC_PrivateExtern,
>  
>      // These are only legal on variables.
> +    SC_WorkGroupLocal,
> 
> Is there a similar concept in CUDA?  If not, please put "OpenCL" in
> the name somewhere.

CUDA has __shared__, but it is orthogonal to the storage classes.
Renamed.

> 
> +++ b/lib/AST/Decl.cpp
> @@ -1126,6 +1126,7 @@ const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
>    case SC_PrivateExtern: return "__private_extern__"; break;
>    case SC_Register:      return "register"; break;
>    case SC_Static:        return "static"; break;
> +  case SC_WorkGroupLocal:return "work-group-local"; break;
> 
> This should return the source-code spelling, i.e. "__local".

Well, "__local" is not the storage class specifier for the
work-group-local storage class.  In fact, it does not even have a
specifier as such.  "__local" is a type attribute whose presence (on
the top-level type) causes a variable to receive the work-group-local
storage class.  The distinction is shown below:

typedef __local int li;
li i; // is work-group-local

__local int *lip; // is not work-group-local (not top-level __local)

Because using this "storage class specifier" in source code would be a
mistake, I deliberately chose a spelling that would not lex to a single
token, but that would still be useful for AST dumper tools.

Thanks,
-- 
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-OpenCL-introduce-support-for-function-scope-__local-.patch
Type: text/x-diff
Size: 13844 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110728/c6d0a6d8/attachment.patch>


More information about the cfe-commits mailing list