]> granicus.if.org Git - clang/commit
[OpenCL] Add to_{global|local|private} builtin functions.
authorYaxun Liu <Yaxun.Liu@amd.com>
Fri, 20 May 2016 19:54:38 +0000 (19:54 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Fri, 20 May 2016 19:54:38 +0000 (19:54 +0000)
commit5c2e21d12f6ff7d763c7aa057b6ed36b1081ce57
tree43bac0073eec5203688c5f1cac54e495ff1cd7db
parent4cf7242721a0349b4f025f5ca3e60d9dc4c89494
[OpenCL] Add to_{global|local|private} builtin functions.

OpenCL builtin functions to_{global|local|private} accepts argument of pointer type to arbitrary pointee type, and return a pointer to the same pointee type in different addr space, i.e.

global gentype *to_global(gentype *p);
It is not desirable to declare it as

global void *to_global(void *);
in opencl header file since it misses diagnostics.

This patch implements these builtin functions as Clang builtin functions. In the builtin def file they are defined to have signature void*(void*). When handling call expressions, their declarations are re-written to have correct parameter type and return type corresponding to the call argument.

In codegen call to addr void *to_addr(void*) is generated with addrcasts or bitcasts to facilitate implementation in builtin library.

Differential Revision: http://reviews.llvm.org/D19932

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270261 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/Builtins.def
include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CGBuiltin.cpp
lib/Sema/SemaChecking.cpp
test/CodeGenOpenCL/to_addr_builtin.cl [new file with mode: 0644]
test/SemaOpenCL/to_addr_builtin.cl [new file with mode: 0644]