Commit acd15a28 by Jakub Jelinek Committed by Jakub Jelinek

c-common.h (omp_clause_mask::operator !=): New method.

	* c-common.h (omp_clause_mask::operator !=): New method.
	* c-omp.c (c_omp_split_clauses): Use if ((mask & something) != 0)
	instead of if (mask & something) tests everywhere.

From-SVN: r203447
parent ddc757fe
2013-10-11 Jakub Jelinek <jakub@redhat.com> 2013-10-11 Jakub Jelinek <jakub@redhat.com>
* c-common.h (omp_clause_mask::operator !=): New method.
* c-omp.c (c_omp_split_clauses): Use if ((mask & something) != 0)
instead of if (mask & something) tests everywhere.
* c-cppbuiltin.c (c_cpp_builtins): Predefine _OPENMP to * c-cppbuiltin.c (c_cpp_builtins): Predefine _OPENMP to
201307 instead of 201107. 201307 instead of 201107.
* c-common.c (DEF_FUNCTION_TYPE_8): Define. * c-common.c (DEF_FUNCTION_TYPE_8): Define.
......
...@@ -1052,6 +1052,7 @@ struct omp_clause_mask ...@@ -1052,6 +1052,7 @@ struct omp_clause_mask
inline omp_clause_mask operator >> (int); inline omp_clause_mask operator >> (int);
inline omp_clause_mask operator << (int); inline omp_clause_mask operator << (int);
inline bool operator == (omp_clause_mask) const; inline bool operator == (omp_clause_mask) const;
inline bool operator != (omp_clause_mask) const;
unsigned HOST_WIDE_INT low, high; unsigned HOST_WIDE_INT low, high;
}; };
...@@ -1156,6 +1157,12 @@ omp_clause_mask::operator == (omp_clause_mask b) const ...@@ -1156,6 +1157,12 @@ omp_clause_mask::operator == (omp_clause_mask b) const
return low == b.low && high == b.high; return low == b.low && high == b.high;
} }
inline bool
omp_clause_mask::operator != (omp_clause_mask b) const
{
return low != b.low || high != b.high;
}
# define OMP_CLAUSE_MASK_1 omp_clause_mask (1) # define OMP_CLAUSE_MASK_1 omp_clause_mask (1)
#endif #endif
......
...@@ -631,7 +631,7 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -631,7 +631,7 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
cclauses[i] = NULL; cclauses[i] = NULL;
/* Add implicit nowait clause on /* Add implicit nowait clause on
#pragma omp parallel {for,for simd,sections}. */ #pragma omp parallel {for,for simd,sections}. */
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0)
switch (code) switch (code)
{ {
case OMP_FOR: case OMP_FOR:
...@@ -691,10 +691,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -691,10 +691,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_SIMD]; OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_SIMD];
cclauses[C_OMP_CLAUSE_SPLIT_SIMD] = c; cclauses[C_OMP_CLAUSE_SPLIT_SIMD] = c;
} }
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) != 0)
{ {
if (mask & (OMP_CLAUSE_MASK_1 if ((mask & (OMP_CLAUSE_MASK_1
<< PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
{ {
c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
OMP_CLAUSE_COLLAPSE); OMP_CLAUSE_COLLAPSE);
...@@ -729,19 +729,20 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -729,19 +729,20 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
target and simd. Put it on the outermost of those and target and simd. Put it on the outermost of those and
duplicate on parallel. */ duplicate on parallel. */
case OMP_CLAUSE_FIRSTPRIVATE: case OMP_CLAUSE_FIRSTPRIVATE:
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS))
!= 0)
{ {
if (mask & ((OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS) if ((mask & ((OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)
| (OMP_CLAUSE_MASK_1 | (OMP_CLAUSE_MASK_1
<< PRAGMA_OMP_CLAUSE_DIST_SCHEDULE))) << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE))) != 0)
{ {
c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
OMP_CLAUSE_FIRSTPRIVATE); OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses);
OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL]; OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL];
cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] = c; cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] = c;
if (mask & (OMP_CLAUSE_MASK_1 if ((mask & (OMP_CLAUSE_MASK_1
<< PRAGMA_OMP_CLAUSE_NUM_TEAMS)) << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) != 0)
s = C_OMP_CLAUSE_SPLIT_TEAMS; s = C_OMP_CLAUSE_SPLIT_TEAMS;
else else
s = C_OMP_CLAUSE_SPLIT_DISTRIBUTE; s = C_OMP_CLAUSE_SPLIT_DISTRIBUTE;
...@@ -751,14 +752,15 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -751,14 +752,15 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
#pragma omp parallel{, for{, simd}, sections}. */ #pragma omp parallel{, for{, simd}, sections}. */
s = C_OMP_CLAUSE_SPLIT_PARALLEL; s = C_OMP_CLAUSE_SPLIT_PARALLEL;
} }
else if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) else if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS))
!= 0)
{ {
/* This must be #pragma omp {,target }teams distribute. */ /* This must be #pragma omp {,target }teams distribute. */
gcc_assert (code == OMP_DISTRIBUTE); gcc_assert (code == OMP_DISTRIBUTE);
s = C_OMP_CLAUSE_SPLIT_TEAMS; s = C_OMP_CLAUSE_SPLIT_TEAMS;
} }
else if (mask & (OMP_CLAUSE_MASK_1 else if ((mask & (OMP_CLAUSE_MASK_1
<< PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
{ {
/* This must be #pragma omp distribute simd. */ /* This must be #pragma omp distribute simd. */
gcc_assert (code == OMP_SIMD); gcc_assert (code == OMP_SIMD);
...@@ -777,19 +779,21 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -777,19 +779,21 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
case OMP_CLAUSE_LASTPRIVATE: case OMP_CLAUSE_LASTPRIVATE:
if (code == OMP_FOR || code == OMP_SECTIONS) if (code == OMP_FOR || code == OMP_SECTIONS)
{ {
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS))
!= 0)
s = C_OMP_CLAUSE_SPLIT_PARALLEL; s = C_OMP_CLAUSE_SPLIT_PARALLEL;
else else
s = C_OMP_CLAUSE_SPLIT_FOR; s = C_OMP_CLAUSE_SPLIT_FOR;
break; break;
} }
gcc_assert (code == OMP_SIMD); gcc_assert (code == OMP_SIMD);
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) != 0)
{ {
c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
OMP_CLAUSE_LASTPRIVATE); OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses); OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (clauses);
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS))
!= 0)
s = C_OMP_CLAUSE_SPLIT_PARALLEL; s = C_OMP_CLAUSE_SPLIT_PARALLEL;
else else
s = C_OMP_CLAUSE_SPLIT_FOR; s = C_OMP_CLAUSE_SPLIT_FOR;
...@@ -806,7 +810,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -806,7 +810,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
s = C_OMP_CLAUSE_SPLIT_TEAMS; s = C_OMP_CLAUSE_SPLIT_TEAMS;
break; break;
} }
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS))
!= 0)
{ {
c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
OMP_CLAUSE_CODE (clauses)); OMP_CLAUSE_CODE (clauses));
...@@ -837,9 +842,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -837,9 +842,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_SIMD]; OMP_CLAUSE_CHAIN (c) = cclauses[C_OMP_CLAUSE_SPLIT_SIMD];
cclauses[C_OMP_CLAUSE_SPLIT_SIMD] = c; cclauses[C_OMP_CLAUSE_SPLIT_SIMD] = c;
} }
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)) != 0)
{ {
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS))
!= 0)
{ {
c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses), c = build_omp_clause (OMP_CLAUSE_LOCATION (clauses),
OMP_CLAUSE_REDUCTION); OMP_CLAUSE_REDUCTION);
...@@ -852,8 +858,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -852,8 +858,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] = c; cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] = c;
s = C_OMP_CLAUSE_SPLIT_TEAMS; s = C_OMP_CLAUSE_SPLIT_TEAMS;
} }
else if (mask & (OMP_CLAUSE_MASK_1 else if ((mask & (OMP_CLAUSE_MASK_1
<< PRAGMA_OMP_CLAUSE_NUM_THREADS)) << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0)
s = C_OMP_CLAUSE_SPLIT_PARALLEL; s = C_OMP_CLAUSE_SPLIT_PARALLEL;
else else
s = C_OMP_CLAUSE_SPLIT_FOR; s = C_OMP_CLAUSE_SPLIT_FOR;
...@@ -865,7 +871,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code, ...@@ -865,7 +871,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
break; break;
case OMP_CLAUSE_IF: case OMP_CLAUSE_IF:
/* FIXME: This is currently being discussed. */ /* FIXME: This is currently being discussed. */
if (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS))
!= 0)
s = C_OMP_CLAUSE_SPLIT_PARALLEL; s = C_OMP_CLAUSE_SPLIT_PARALLEL;
else else
s = C_OMP_CLAUSE_SPLIT_TARGET; s = C_OMP_CLAUSE_SPLIT_TARGET;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment