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]

Re: [tree-ssa][RFC] An interface to fold(tree)


Jeff Law wrote:
> I'd rather have an interface like
>
> fold_tree (code, type, arg0, arg1, arg2, arg3)
> {
>   most of the code currently in fold ()
> }
>
> [ Or however many arguments the largest tree code has :-0 ]
>
>
> fold then becomes
>
> fold (tree exp)
> {
>   code = TREE_CODE (exp);
>   type = TREE_TYPE (exp);
>
>   for (i = 0; i < noperands; i++)
>    op[i] = TREE_OPERAND (exp, i);
>
>   return fold_tree (code, type, op[0], op[1], op[2], op[3]);
> }
>
> Thoughts?

Just to agree with Jeff, I much prefer this approach.

Instead of having a single fold_tree with an arbitrary number of
arguments, some of which may be NULL_TREE,  I'd suggest pushing
the role model of "simplify_rtx" even further,  and have several
"baby-folds": fold_unary, fold_binary, fold_ternary, etc...

Not unlike Jeff's non_destructive_fold_unary, etc.. on tree-ssa.

I also like the simplify_rtx model of returning NULL_TREE if no
simplification can be made.  The last line of the pseudo-code
above then becomes:

  temp = fold_tree (code, type, op[0], op[1], op[2], op[3]);
  return temp ? temp : exp;

and we save generating a few more temporary trees.

Roger
--


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