On 09/14/09 11:52:11, Richard Guenther wrote:
> > What approach would you recommend for the
> > implementation of UPC tree re-writes that will
> > support calls to the runtime (that are inlined,
> > if applicable)?
> 
> Without reading all the details of your mail I suggest that you
> perform a custom walk over the function bodies right before
> the frontend calls cgraph_finalize_compilation_unit () that
> performs the necessary lowering (and function creation) to
> GENERIC.  The C++ frontend already does this during its
> genericize phase to transform frontend specific trees to
> middle-end GENERIC trees.

I tried the custom tree walk approach, but decided that it
will require some of the infrastructure already present in
the gimplify pass (e. g., the creation of temp. variables),
and that it is more expedient to utilize the current
language dependent gimplify hook, but to move it earlier
in the processing of the function body.

To that end, I defined a language dependent genericize hook:

   /* Determine if a tree is a function parameter pack.  */
   bool (*function_parameter_pack_p) (const_tree);

+  /* Genericize before finalization (called from finish_function()).
+     Perform lowering of function bodies from language dependent form
+     to language independent (GENERIC) form.  */
+  void (*genericize) (tree);
+

which is called from finish_function (instead of calling c_genericize):

       if (!decl_function_context (fndecl))
         {
           invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
-          c_genericize (fndecl);
+          /* Lower to GENERIC form before finalization. */
+          lang_hooks.genericize (fndecl);

The UPC genericize hook is implemented as:

/* Convert the tree representation of FNDECL from UPC frontend trees
   to GENERIC.  */
void
upc_genericize (tree fndecl)
{
  /* Take care of C-specific actions first.
     Normally, we'd do this after the language-specific
     actions, but c_genericize is only a dumping pass
     now, and should be renamed.  */
  c_genericize (fndecl);
  /* Perform a full gimplify pass, because the UPC lowering rewrites
     are implemented using the gimplify framework.  */
  gimplify_function_tree (fndecl);
}

Although this may not be the best fit with the current
framework, it lets us re-use the gimplify pass
that we have been using with previous GCC 4.x
implementations.  At some point, we'll need to develop
a ground-up tree-walk rewrite pass.

Reply via email to