[PATCH] [OPENMP] Codegen for 'atomic update' construct.

Alexey Bataev a.bataev at hotmail.com
Mon Mar 23 03:49:02 PDT 2015


Hi rjmccall, hfinkel, fraggamuffin, ejstotzer,

Adds atomic update codegen for the following forms of expressions:
```
x binop= expr;
x++;
++x;
x--;
--x;
x = x binop expr;
x = expr binop x;
```
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:
```
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:
...
```

http://reviews.llvm.org/D8536

Files:
  include/clang/AST/StmtOpenMP.h
  lib/AST/Stmt.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/atomic_codegen.cpp
  test/OpenMP/atomic_update_codegen.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8536.22451.patch
Type: text/x-patch
Size: 103304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150323/5c71a377/attachment.bin>


More information about the cfe-commits mailing list