1 /* Functions to analyze and validate GIMPLE trees.
2 Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 #ifndef _TREE_SIMPLE_H
23 #define _TREE_SIMPLE_H 1
26 #include "tree-iterator.h"
28 extern tree
create_tmp_var_raw (tree
, const char *);
29 extern tree
create_tmp_var_name (const char *);
30 extern tree
create_tmp_var (tree
, const char *);
31 extern tree
get_initialized_tmp_var (tree
, tree
*, tree
*);
32 extern tree
get_formal_tmp_var (tree
, tree
*);
33 extern void declare_tmp_vars (tree
, tree
);
35 extern void annotate_all_with_locus (tree
*, location_t
);
37 /* Validation of GIMPLE expressions. Note that these predicates only check
38 the basic form of the expression, they don't recurse to make sure that
39 underlying nodes are also of the right form. */
41 typedef bool (*gimple_predicate
)(tree
);
43 /* Returns true iff T is a valid GIMPLE statement. */
44 extern bool is_gimple_stmt (tree
);
46 /* Returns true iff TYPE is a valid type for a scalar register variable. */
47 extern bool is_gimple_reg_type (tree
);
48 /* Returns true iff T is a scalar register variable. */
49 extern bool is_gimple_reg (tree
);
50 /* Returns true if T is a GIMPLE temporary variable, false otherwise. */
51 extern bool is_gimple_formal_tmp_var (tree
);
52 /* Returns true if T is a GIMPLE temporary register variable. */
53 extern bool is_gimple_formal_tmp_reg (tree
);
54 /* Returns true iff T is any sort of variable. */
55 extern bool is_gimple_variable (tree
);
56 /* Returns true iff T is any sort of symbol. */
57 extern bool is_gimple_id (tree
);
58 /* Returns true iff T is a variable or an INDIRECT_REF (of a variable). */
59 extern bool is_gimple_min_lval (tree
);
60 /* Returns true iff T is something whose address can be taken. */
61 extern bool is_gimple_addressable (tree
);
62 /* Returns true iff T is any valid GIMPLE lvalue. */
63 extern bool is_gimple_lvalue (tree
);
65 /* Returns true iff T is a GIMPLE restricted function invariant. */
66 extern bool is_gimple_min_invariant (tree
);
67 /* Returns true iff T is a GIMPLE rvalue. */
68 extern bool is_gimple_val (tree
);
69 /* Returns true iff T is a GIMPLE asm statement input. */
70 extern bool is_gimple_asm_val (tree
);
71 /* Returns true iff T is a valid rhs for a MODIFY_EXPR where the LHS is a
72 GIMPLE temporary, a renamed user variable, or something else,
74 extern bool is_gimple_formal_tmp_rhs (tree
);
75 extern bool is_gimple_reg_rhs (tree
);
76 extern bool is_gimple_mem_rhs (tree
);
77 /* Returns the appropriate one of the above three predicates for the LHS
79 extern gimple_predicate
rhs_predicate_for (tree
);
81 /* Returns true iff T is a valid if-statement condition. */
82 extern bool is_gimple_condexpr (tree
);
84 /* Returns true iff T is a type conversion. */
85 extern bool is_gimple_cast (tree
);
86 /* Returns true iff T is a variable that does not need to live in memory. */
87 extern bool is_gimple_non_addressable (tree t
);
89 /* Returns true iff T is a valid call address expression. */
90 extern bool is_gimple_call_addr (tree
);
91 /* If T makes a function call, returns the CALL_EXPR operand. */
92 extern tree
get_call_expr_in (tree t
);
94 extern void recalculate_side_effects (tree
);
96 /* FIXME we should deduce this from the predicate. */
97 typedef enum fallback_t
{
102 fb_either
= fb_rvalue
| fb_lvalue
105 enum gimplify_status
{
106 GS_ERROR
= -2, /* Something Bad Seen. */
107 GS_UNHANDLED
= -1, /* A langhook result for "I dunno". */
108 GS_OK
= 0, /* We did something, maybe more to do. */
109 GS_ALL_DONE
= 1 /* The expression is fully gimplified. */
112 extern enum gimplify_status
gimplify_expr (tree
*, tree
*, tree
*,
113 bool (*) (tree
), fallback_t
);
114 extern void gimplify_type_sizes (tree
, tree
*);
115 extern void gimplify_one_sizepos (tree
*, tree
*);
116 extern void gimplify_stmt (tree
*);
117 extern void gimplify_to_stmt_list (tree
*);
118 extern void gimplify_body (tree
*, tree
, bool);
119 extern void push_gimplify_context (void);
120 extern void pop_gimplify_context (tree
);
121 extern void gimplify_and_add (tree
, tree
*);
123 /* Miscellaneous helpers. */
124 extern void gimple_add_tmp_var (tree
);
125 extern tree
gimple_current_bind_expr (void);
126 extern tree
voidify_wrapper_expr (tree
, tree
);
127 extern tree
gimple_build_eh_filter (tree
, tree
, tree
);
128 extern tree
build_and_jump (tree
*);
129 extern tree
alloc_stmt_list (void);
130 extern void free_stmt_list (tree
);
131 extern tree
force_labels_r (tree
*, int *, void *);
132 extern enum gimplify_status
gimplify_va_arg_expr (tree
*, tree
*, tree
*);
134 /* In tree-nested.c. */
135 extern void lower_nested_functions (tree
);
137 #endif /* _TREE_SIMPLE_H */