On Thu, Mar 03, 2011 at 05:54:32PM +0100, Jakub Jelinek wrote: > This patch is a WIP patch for OpenMP 3.1 atomics, so far for C FE only. > It handles parsing (I created 3 new tree codes for atomic read, > atomic capture of the old and of the new value), gimplification and > omp expansion thereof, but currently both atomic read and atomic write > are implemented always pretty expensively using __sync_val_compare_and_swap. > > I think we probably want to implement them as volatile read or write > (or perhaps just non-volatile read with some barriers around?), but probably > need some target hook to tell us what loads/stores aren't actually atomic > (say on old alpha char/short/int loads and stores aren't atomic).
I've now committed the patch as is to gomp-3_1-branch, so that I can continue working on C++ and Fortran 3.1 atomics parsing. Comments/suggestions about the omp-low.c implementation of atomic reads and writes are welcome. Here is ChangeLog for the committed bits. 2011-04-21 Jakub Jelinek <ja...@redhat.com> * c-parser.c (c_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics. Adjust c_finish_omp_atomic caller. * tree.def (OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD, OMP_ATOMIC_CAPTURE_NEW): New. * gimple.h (GF_OMP_ATOMIC_NEED_VALUE): New. (gimple_omp_atomic_need_value_p, gimple_omp_atomic_set_need_value): New inlines. * gimplify.c (gimplify_omp_atomic, gimplify_expr): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. * omp-low.c (expand_omp_atomic_load, expand_omp_atomic_store): New functions. (expand_omp_atomic_fetch_op): Handle cases where old or new value is needed afterwards. (expand_omp_atomic): Call expand_omp_atomic_load resp. expand_omp_atomic_store. * tree-pretty-print.c (dump_generic_node): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. * c-common.h (c_finish_omp_atomic): Adjust prototype. * c-omp.c (c_finish_omp_atomic): Add OPCODE, V and LHS1 arguments. Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW in addition to OMP_ATOMIC. * semantics.c (finish_omp_atomic): Adjust c_finish_omp_atomic caller. * testsuite/libgomp.c/atomic-11.c: New test. * testsuite/libgomp.c/atomic-12.c: New test. Jakub