[OPENMP] Codegen for 'atomic capture'.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 23 Apr 2015 06:35:10 +0000 (06:35 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 23 Apr 2015 06:35:10 +0000 (06:35 +0000)
commit5e018f9e29a2b7e67e82dfa17f32662f18a9bdf7
tree1076e98ec3521274c55a0da81e8ca2f8542305da
parent96183f6b0659c036100ce4718d219ceb43a82edd
[OPENMP] Codegen for 'atomic capture'.

Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements:

v = x binop= expr;
v = x++;
v = ++x;
v = x--;
v = --x;
v = x = x binop expr;
v = x = expr binop x;
{v = x; x = binop= expr;}
{v = x; x++;}
{v = x; ++x;}
{v = x; x--;}
{v = x; --x;}
{x = x binop expr; v = x;}
{x binop= expr; v = x;}
{x++; v = x;}
{++x; v = x;}
{x--; v = x;}
{--x; v = x;}
{x = x binop expr; v = x;}
{x = expr binop x; v = x;}
{v = x; x = expr;}
If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted.
Otherwise compare-and-swap sequence is emitted.
Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'.

bb:
...
atomic load <x>
cont:
<expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ]
<desired> = <expected> binop <expr>
<res> = cmpxchg atomic &<x>, desired, expected
<new_failed> = <res>.field1;
br <res>field2, label %exit, label %cont
exit:
atomic store <old/new x>, <v>
...
Differential Revision: http://reviews.llvm.org/D9049

llvm-svn: 235573
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp [new file with mode: 0644]
clang/test/OpenMP/atomic_codegen.cpp
clang/test/OpenMP/atomic_messages.cpp