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