1*38fd1498Szrj /* Gimple simplify definitions.
2*38fd1498Szrj
3*38fd1498Szrj Copyright (C) 2011-2018 Free Software Foundation, Inc.
4*38fd1498Szrj Contributed by Richard Guenther <rguenther@suse.de>
5*38fd1498Szrj
6*38fd1498Szrj This file is part of GCC.
7*38fd1498Szrj
8*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
9*38fd1498Szrj the terms of the GNU General Public License as published by the Free
10*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
11*38fd1498Szrj version.
12*38fd1498Szrj
13*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16*38fd1498Szrj for more details.
17*38fd1498Szrj
18*38fd1498Szrj You should have received a copy of the GNU General Public License
19*38fd1498Szrj along with GCC; see the file COPYING3. If not see
20*38fd1498Szrj <http://www.gnu.org/licenses/>. */
21*38fd1498Szrj
22*38fd1498Szrj #ifndef GCC_GIMPLE_MATCH_H
23*38fd1498Szrj #define GCC_GIMPLE_MATCH_H
24*38fd1498Szrj
25*38fd1498Szrj
26*38fd1498Szrj /* Helper to transparently allow tree codes and builtin function codes
27*38fd1498Szrj exist in one storage entity. */
28*38fd1498Szrj class code_helper
29*38fd1498Szrj {
30*38fd1498Szrj public:
code_helper()31*38fd1498Szrj code_helper () {}
code_helper(tree_code code)32*38fd1498Szrj code_helper (tree_code code) : rep ((int) code) {}
code_helper(combined_fn fn)33*38fd1498Szrj code_helper (combined_fn fn) : rep (-(int) fn) {}
tree_code()34*38fd1498Szrj operator tree_code () const { return (tree_code) rep; }
combined_fn()35*38fd1498Szrj operator combined_fn () const { return (combined_fn) -rep; }
is_tree_code()36*38fd1498Szrj bool is_tree_code () const { return rep > 0; }
is_fn_code()37*38fd1498Szrj bool is_fn_code () const { return rep < 0; }
get_rep()38*38fd1498Szrj int get_rep () const { return rep; }
39*38fd1498Szrj private:
40*38fd1498Szrj int rep;
41*38fd1498Szrj };
42*38fd1498Szrj
43*38fd1498Szrj /* Return whether OPS[0] with CODE is a non-expression result and
44*38fd1498Szrj a gimple value. */
45*38fd1498Szrj
46*38fd1498Szrj inline bool
gimple_simplified_result_is_gimple_val(code_helper code,tree * ops)47*38fd1498Szrj gimple_simplified_result_is_gimple_val (code_helper code, tree *ops)
48*38fd1498Szrj {
49*38fd1498Szrj return (code.is_tree_code ()
50*38fd1498Szrj && (TREE_CODE_LENGTH ((tree_code) code) == 0
51*38fd1498Szrj || ((tree_code) code) == ADDR_EXPR)
52*38fd1498Szrj && is_gimple_val (ops[0]));
53*38fd1498Szrj }
54*38fd1498Szrj
55*38fd1498Szrj extern tree (*mprts_hook) (code_helper, tree, tree *);
56*38fd1498Szrj
57*38fd1498Szrj bool gimple_simplify (gimple *, code_helper *, tree *, gimple_seq *,
58*38fd1498Szrj tree (*)(tree), tree (*)(tree));
59*38fd1498Szrj bool gimple_resimplify1 (gimple_seq *, code_helper *, tree, tree *,
60*38fd1498Szrj tree (*)(tree));
61*38fd1498Szrj bool gimple_resimplify2 (gimple_seq *, code_helper *, tree, tree *,
62*38fd1498Szrj tree (*)(tree));
63*38fd1498Szrj bool gimple_resimplify3 (gimple_seq *, code_helper *, tree, tree *,
64*38fd1498Szrj tree (*)(tree));
65*38fd1498Szrj tree maybe_push_res_to_seq (code_helper, tree, tree *,
66*38fd1498Szrj gimple_seq *, tree res = NULL_TREE);
67*38fd1498Szrj void maybe_build_generic_op (enum tree_code, tree, tree *);
68*38fd1498Szrj
69*38fd1498Szrj
70*38fd1498Szrj #endif /* GCC_GIMPLE_MATCH_H */
71