]> granicus.if.org Git - clang/commit
[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)
commit98cb5a7c84db57cfe01069eaa890f83b0124e8e4
tree6af14c6924cfeb5719a20bf687a8a2381f7b3fb5
parent24003c1df297a7aabc667f616e8d7e1481a305c0
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235573 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGStmtOpenMP.cpp
lib/CodeGen/CodeGenFunction.h
lib/Sema/SemaOpenMP.cpp
test/OpenMP/atomic_capture_codegen.cpp [new file with mode: 0644]
test/OpenMP/atomic_codegen.cpp
test/OpenMP/atomic_messages.cpp