This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help with new builtin
- To: lucier at math dot purdue dot edu
- Subject: Re: Help with new builtin
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Mon, 29 Jan 2001 23:51:33 -0500 (EST)
- Cc: feeley at iro dot umontreal dot ca, gcc at gcc dot gnu dot org
> From: Brad Lucier <lucier@math.purdue.edu>
>
> I would like to patch my copy of gcc to add a builtin that can be
> exploited by CPar, a parallel version of C developed by Marc Feeley
> and his students at the University of Montreal. CPar can be compiled
> without this builtin, but supporting it leads to much smaller
> task-switching times.
>
> The builtin was originally patched into gcc-2.7.2.3; after looking at
> the source and the info files, I realize that although it looks easy
> to provide a new patch for the current development compiler, I have no
> clue how to do it. Rather than try to mimic other code that I don't
> know the purpose of, I'm asking if some kind soul can show me the few
> lines of code that will meet how things are done in the current
> compiler.
>
> Brad Lucier
I've spent some time working on builtins recently. The code has moved
around a lot since 2.7.x, but its actually pretty close in form. I
think you can easily port it over with a couple of pointers to where
the new code lives. If you have more questions after these hints,
feel free to ask specifics.
> The old patches follow:
>
> diff -c gcc-2.7.2.3.before/c-decl.c gcc-2.7.2.3.after/c-decl.c
> *** gcc-2.7.2.3.before/c-decl.c Fri Oct 27 05:44:43 1995
> --- gcc-2.7.2.3.after/c-decl.c Sat Feb 19 17:06:11 2000
> ***************
> *** 3097,3102 ****
> --- 3097,3111 ----
> sizetype,
> endlink)),
> BUILT_IN_ALLOCA, "alloca");
> +
> + builtin_function ("_cparMoveSP",
> + build_function_type (ptr_type_node,
> + tree_cons (NULL_TREE,
> + sizetype,
> + endlink)),
> + BUILT_IN_CPAR_MOVESP, NULL_PTR);
This stuff has moved to c-common.c:c_common_nodes_and_builtins().
There's one extra parameter to builtin_function, just pass it
BUILT_IN_NORMAL and insert it as the second to last arg, and it should
work.
> diff -c gcc-2.7.2.3.before/expr.c gcc-2.7.2.3.after/expr.c
> *** gcc-2.7.2.3.before/expr.c Sat Jun 29 12:26:15 1996
> --- gcc-2.7.2.3.after/expr.c Sat Feb 19 17:06:32 2000
> ***************
> *** 7656,7661 ****
> --- 7656,7667 ----
> return tem;
> }
>
> + case BUILT_IN_CPAR_MOVESP:
> +
> + op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode,
> 1);
> + adjust_stack(op0);
> + return target;
This stuff has moved to builtins.c:expand_builtin(). And the guts are
usually made into a static function. Though in this case it doesn't
seem necessary. I don't know if op0 is still in scope here.
> diff -c gcc-2.7.2.3.before/tree.h gcc-2.7.2.3.after/tree.h
> *** gcc-2.7.2.3.before/tree.h Mon Sep 25 17:49:40 1995
> --- gcc-2.7.2.3.after/tree.h Sat Feb 19 17:06:06 2000
> ***************
> *** 105,110 ****
> --- 105,111 ----
> BUILT_IN_VEC_DELETE,
>
> /* Upper bound on non-language-specific builtins. */
> + BUILT_IN_CPAR_MOVESP,
> END_BUILTINS
This has moved to builtins.def.
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions