This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C/gomp PATCH] Convert OMP_CLAUSE_IF_EXPR to boolean_type_node


One aspect of the design of the GNU OpenMP implementation is that
the OMP_* primitives are expanded to their final forms with a gomp
lowering pass in the middle-end.  By implementing this lowering as a
tree-ssa pass it allows the same logic to to be reused by the C/C++
and fortran front-ends in a language independent way.  One minor
consequence of this is that the tree representations used internally
to represent gomp directives/primitives should ideally also be
front-end independent.

The following patch tweaks the gomp-specific bits of the C front-end
to convert the conditions of parallel if clauses to boolean_type_node
for storing in OMP_CLAUSE_IF nodes (which matches the C++ and fortran
front-ends).  The current scheme of maintaining the conditional in
the native "truevalue" type, creates a dependency of the gimplifier
on the front-end's "convert" function, which implements int->bool
conversions differently from the middle-end.  The simple act of
performing this conversion early, isolates front-end semantics from
the GENERIC/GIMPLE representation, as is done with other tree nodes.

Hopefully this makes sense?

The following patch has been tested on i686-pc-linux-gnu with a
full "make bootstrap", all default languages, and regression
tested with a top-level "make -k check" with no new failures.
This change allows all uses of "convert" in gimplify.c to be
replaced with calls to fold_convert.  Given that the front-end
"convert" functions can potentially issue diagnostic error/warning
messages, this is a doubly good thing.

Ok for mainline?  Unfortunately, there's currently no official
gomp maintainer, so it'd be nice to hear from the gomp developers
even if they can't approve this change themselves.



2006-03-28  Roger Sayle  <roger@eyesopen.com>

	* c-parser.c (c_parser_omp_clause_if): Ensure that the conditional
	OMP_CLAUSE_IF_EXPR of an OMP_CLAUSE_IF has been suitably converted
	to a boolean_type_node.


Index: c-parser.c
===================================================================
*** c-parser.c	(revision 112438)
--- c-parser.c	(working copy)
*************** c_parser_omp_clause_if (c_parser *parser
*** 6790,6796 ****
        check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if");

        c = build_omp_clause (OMP_CLAUSE_IF);
!       OMP_CLAUSE_IF_EXPR (c) = t;
        OMP_CLAUSE_CHAIN (c) = list;
        list = c;
      }
--- 6790,6796 ----
        check_no_duplicate_clause (list, OMP_CLAUSE_IF, "if");

        c = build_omp_clause (OMP_CLAUSE_IF);
!       OMP_CLAUSE_IF_EXPR (c) = convert (boolean_type_node, t);
        OMP_CLAUSE_CHAIN (c) = list;
        list = c;
      }


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]