This is the mail archive of the
mailing list for the GCC project.
Re: How can I generate a new function at compile time?
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Benedikt Huber <benedikt dot huber at theobroma-systems dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 30 Apr 2014 14:28:30 +0200
- Subject: Re: How can I generate a new function at compile time?
- Authentication-results: sourceware.org; auth=none
- References: <2C1DB30D-9984-48C5-A7DF-19FF419C6E0F at theobroma-systems dot com> <CAFiYyc21CDRRAn44fzKsfH=C+G5NB-_94X4CBjHZPf7Hsno1mg at mail dot gmail dot com> <DDB19999-77F0-4991-AA65-555111EC1531 at theobroma-systems dot com>
On Wed, Apr 30, 2014 at 2:16 PM, Benedikt Huber
> Thank you for the hint. I managed to extract the basic blocks to a helper function and put
> a call to this helper function at the place of the removed basic blocks in the original function.
> All this is done with help of move_sese_region_to_fn.
> The helper function is created similar to create_omp_child_function.
> I had a successful compilation run when I moved the pass just after pass_build_cgraph_edges.
> The problems I am still facing is with passing of parameters.
> I imagine that variables used in the helper function which are defined in the original function
> should become in-out parameters to the helper function.
> For that I wanted to use DECL_ARGUMENTS and the arguments to gimple_build_call or gimple_build_call_vec.
> However, how do I find the undefined variables in the helper function and how do I find out to
> which variables in the original function they belong. In particular, how do I get the names and order
> in the argument list right?
> Do you know of some equally useful examples?
> To me it seems that what is done in omp-low.c (expand_omp_taskreg or expand_omp_target) is not
> exactly what I need.
But it's very similar. Other than you need to figure out what variables
are used in the region yourself. The autopar code (tree-parloops.c)
may have more what you have in mind (though the code is very old
and I consider it ugly as hell). It also uses the omp lowering
infrastructure to do the actual outlining.
> Thank you again and best regards,