1 /* Header file for gimple decl, type and expressions.
2 Copyright (C) 2013 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_GIMPLE_EXPR_H
21 #define GCC_GIMPLE_EXPR_H
23 extern bool useless_type_conversion_p (tree
, tree
);
25 extern void gimple_set_body (tree
, gimple_seq
);
26 extern gimple_seq
gimple_body (tree
);
27 extern bool gimple_has_body_p (tree
);
28 extern const char *gimple_decl_printable_name (tree
, int);
29 extern tree
copy_var_decl (tree
, tree
, tree
);
30 extern bool gimple_can_coalesce_p (tree
, tree
);
32 extern void extract_ops_from_tree_1 (tree
, enum tree_code
*, tree
*, tree
*,
34 extern void gimple_cond_get_ops_from_tree (tree
, enum tree_code
*, tree
*,
36 extern bool is_gimple_lvalue (tree
);
37 extern bool is_gimple_condexpr (tree
);
38 extern bool is_gimple_address (const_tree
);
39 extern bool is_gimple_invariant_address (const_tree
);
40 extern bool is_gimple_ip_invariant_address (const_tree
);
41 extern bool is_gimple_min_invariant (const_tree
);
42 extern bool is_gimple_ip_invariant (const_tree
);
43 extern bool is_gimple_reg (tree
);
44 extern bool is_gimple_val (tree
);
45 extern bool is_gimple_asm_val (tree
);
46 extern bool is_gimple_min_lval (tree
);
47 extern bool is_gimple_call_addr (tree
);
48 extern bool is_gimple_mem_ref_addr (tree
);
50 /* Return true if a conversion from either type of TYPE1 and TYPE2
51 to the other is not required. Otherwise return false. */
54 types_compatible_p (tree type1
, tree type2
)
56 return (type1
== type2
57 || (useless_type_conversion_p (type1
, type2
)
58 && useless_type_conversion_p (type2
, type1
)));
61 /* Return true if TYPE is a suitable type for a scalar register variable. */
64 is_gimple_reg_type (tree type
)
66 return !AGGREGATE_TYPE_P (type
);
69 /* Return true if T is a variable. */
72 is_gimple_variable (tree t
)
74 return (TREE_CODE (t
) == VAR_DECL
75 || TREE_CODE (t
) == PARM_DECL
76 || TREE_CODE (t
) == RESULT_DECL
77 || TREE_CODE (t
) == SSA_NAME
);
80 /* Return true if T is a GIMPLE identifier (something with an address). */
85 return (is_gimple_variable (t
)
86 || TREE_CODE (t
) == FUNCTION_DECL
87 || TREE_CODE (t
) == LABEL_DECL
88 || TREE_CODE (t
) == CONST_DECL
89 /* Allow string constants, since they are addressable. */
90 || TREE_CODE (t
) == STRING_CST
);
93 /* Return true if OP, an SSA name or a DECL is a virtual operand. */
96 virtual_operand_p (tree op
)
98 if (TREE_CODE (op
) == SSA_NAME
)
100 op
= SSA_NAME_VAR (op
);
105 if (TREE_CODE (op
) == VAR_DECL
)
106 return VAR_DECL_IS_VIRTUAL_OPERAND (op
);
111 /* Return true if T is something whose address can be taken. */
114 is_gimple_addressable (tree t
)
116 return (is_gimple_id (t
) || handled_component_p (t
)
117 || TREE_CODE (t
) == MEM_REF
);
120 /* Return true if T is a valid gimple constant. */
123 is_gimple_constant (const_tree t
)
125 switch (TREE_CODE (t
))
140 /* A wrapper around extract_ops_from_tree_1, for callers which expect
141 to see only a maximum of two operands. */
144 extract_ops_from_tree (tree expr
, enum tree_code
*code
, tree
*op0
,
148 extract_ops_from_tree_1 (expr
, code
, op0
, op1
, &op2
);
149 gcc_assert (op2
== NULL_TREE
);
152 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
153 associated with the callee if known. Otherwise return NULL_TREE. */
156 gimple_call_addr_fndecl (const_tree fn
)
158 if (fn
&& TREE_CODE (fn
) == ADDR_EXPR
)
160 tree fndecl
= TREE_OPERAND (fn
, 0);
161 if (TREE_CODE (fndecl
) == MEM_REF
162 && TREE_CODE (TREE_OPERAND (fndecl
, 0)) == ADDR_EXPR
163 && integer_zerop (TREE_OPERAND (fndecl
, 1)))
164 fndecl
= TREE_OPERAND (TREE_OPERAND (fndecl
, 0), 0);
165 if (TREE_CODE (fndecl
) == FUNCTION_DECL
)
171 #endif /* GCC_GIMPLE_EXPR_H */