This is the mail archive of the gcc@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]

Re: How can I generate a new function at compile time?


On Wed, Apr 30, 2014 at 2:16 PM, Benedikt Huber
<benedikt.huber@theobroma-systems.com> wrote:
> 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.

Richard.

> Thank you again and best regards,
> Benedikt


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