Add OpenCL 2.0 atomic builtin functions as Clang builtin
authorYaxun Liu <Yaxun.Liu@amd.com>
Fri, 4 Aug 2017 18:16:31 +0000 (18:16 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Fri, 4 Aug 2017 18:16:31 +0000 (18:16 +0000)
commit84162ace309f1c79bc374a1d0cc19c2c91a32ee8
treeeea6f42cbdc6920501911498c50e91a18bb547f4
parent7777ca006af0f49507cd2d005c957f5fff3a96df
Add OpenCL 2.0 atomic builtin functions as Clang builtin

OpenCL 2.0 atomic builtin functions have a scope argument which is ideally
represented as synchronization scope argument in LLVM atomic instructions.

Clang supports translating Clang atomic builtin functions to LLVM atomic
instructions. However it currently does not support synchronization scope
of LLVM atomic instructions. Without this, users have to use LLVM assembly
code to implement OpenCL atomic builtin functions.

This patch adds OpenCL 2.0 atomic builtin functions as Clang builtin
functions, which supports generating LLVM atomic instructions with
synchronization scope operand.

Currently only constant memory scope argument is supported. Support of
non-constant memory scope argument will be added later.

Differential Revision: https://reviews.llvm.org/D28691

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310082 91177308-0d34-0410-b5e6-96231b3b80d8
21 files changed:
docs/LanguageExtensions.rst
include/clang/AST/Expr.h
include/clang/Basic/Builtins.def
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/SyncScope.h [new file with mode: 0644]
lib/AST/ASTContext.cpp
lib/AST/Expr.cpp
lib/AST/StmtPrinter.cpp
lib/Basic/Targets/AMDGPU.cpp
lib/CodeGen/CGAtomic.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/TargetInfo.cpp
lib/CodeGen/TargetInfo.h
lib/Frontend/InitPreprocessor.cpp
lib/Headers/opencl-c.h
lib/Sema/SemaChecking.cpp
test/CodeGenOpenCL/atomic-ops-libcall.cl [new file with mode: 0644]
test/CodeGenOpenCL/atomic-ops.cl [new file with mode: 0644]
test/Preprocessor/init.c
test/Preprocessor/predefined-macros.c
test/SemaOpenCL/atomic-ops.cl [new file with mode: 0644]