diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-10-22 17:09:22 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-10-22 17:09:22 +0200 |
commit | c26d7df103197e52dcd6edbb9a7f58eafdd6c715 (patch) | |
tree | 612b26bcbe24f27385ef93fa3bda30b2f90f4276 /gcc/fortran/trans-openmp.c | |
parent | b69c00612db1ccf7de77b0072c6b1b47090318f3 (diff) | |
download | gcc-c26d7df103197e52dcd6edbb9a7f58eafdd6c715.zip gcc-c26d7df103197e52dcd6edbb9a7f58eafdd6c715.tar.gz gcc-c26d7df103197e52dcd6edbb9a7f58eafdd6c715.tar.bz2 |
OpenMP: Fortran - support omp flush's memorder clauses
gcc/fortran/ChangeLog:
* gfortran.h (enum gfc_omp_memorder): Add.
(gfc_omp_clauses): Use it.
* openmp.c (gfc_match_omp_flush): Match memorder clauses.
* trans-openmp.c (gfc_trans_omp_flush): Handle them.
(gfc_trans_omp_directive): Update call.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/flush-1.f90: New test.
* gfortran.dg/gomp/flush-2.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r-- | gcc/fortran/trans-openmp.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 378088a..bd7e13d 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -38,6 +38,8 @@ along with GCC; see the file COPYING3. If not see #include "gomp-constants.h" #include "omp-general.h" #include "omp-low.h" +#include "memmodel.h" /* For MEMMODEL_ enums. */ + #undef GCC_DIAG_STYLE #define GCC_DIAG_STYLE __gcc_tdiag__ #include "diagnostic-core.h" @@ -4785,10 +4787,30 @@ gfc_trans_oacc_combined_directive (gfc_code *code) } static tree -gfc_trans_omp_flush (void) +gfc_trans_omp_flush (gfc_code *code) { - tree decl = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); - return build_call_expr_loc (input_location, decl, 0); + tree call; + if (!code->ext.omp_clauses + || code->ext.omp_clauses->memorder == OMP_MEMORDER_LAST) + { + call = builtin_decl_explicit (BUILT_IN_SYNC_SYNCHRONIZE); + call = build_call_expr_loc (input_location, call, 0); + } + else + { + enum memmodel mo = MEMMODEL_LAST; + switch (code->ext.omp_clauses->memorder) + { + case OMP_MEMORDER_ACQ_REL: mo = MEMMODEL_ACQ_REL; break; + case OMP_MEMORDER_RELEASE: mo = MEMMODEL_RELEASE; break; + case OMP_MEMORDER_ACQUIRE: mo = MEMMODEL_ACQUIRE; break; + default: gcc_unreachable (); break; + } + call = builtin_decl_explicit (BUILT_IN_ATOMIC_THREAD_FENCE); + call = build_call_expr_loc (input_location, call, 1, + build_int_cst (integer_type_node, mo)); + } + return call; } static tree @@ -6033,7 +6055,7 @@ gfc_trans_omp_directive (gfc_code *code) case EXEC_OMP_DO_SIMD: return gfc_trans_omp_do_simd (code, NULL, NULL, NULL_TREE); case EXEC_OMP_FLUSH: - return gfc_trans_omp_flush (); + return gfc_trans_omp_flush (code); case EXEC_OMP_MASTER: return gfc_trans_omp_master (code); case EXEC_OMP_ORDERED: |