]>
Commit | Line | Data |
---|---|---|
46a19abf | 1 | /* Header file for gimple decl, type and expressions. |
f1717362 | 2 | Copyright (C) 2013-2016 Free Software Foundation, Inc. |
46a19abf | 3 | |
4 | This file is part of GCC. | |
5 | ||
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 | |
9 | version. | |
10 | ||
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 | |
14 | for more details. | |
15 | ||
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/>. */ | |
19 | ||
20 | #ifndef GCC_GIMPLE_EXPR_H | |
21 | #define GCC_GIMPLE_EXPR_H | |
22 | ||
23 | extern bool useless_type_conversion_p (tree, tree); | |
24 | ||
a8783bee | 25 | |
46a19abf | 26 | extern void gimple_set_body (tree, gimple_seq); |
27 | extern gimple_seq gimple_body (tree); | |
28 | extern bool gimple_has_body_p (tree); | |
29 | extern const char *gimple_decl_printable_name (tree, int); | |
30 | extern tree copy_var_decl (tree, tree, tree); | |
a8783bee | 31 | extern tree create_tmp_var_name (const char *); |
f9e245b2 | 32 | extern tree create_tmp_var_raw (tree, const char * = NULL); |
33 | extern tree create_tmp_var (tree, const char * = NULL); | |
34 | extern tree create_tmp_reg (tree, const char * = NULL); | |
98107def | 35 | extern tree create_tmp_reg_fn (struct function *, tree, const char *); |
a8783bee | 36 | |
46a19abf | 37 | |
38 | extern void extract_ops_from_tree_1 (tree, enum tree_code *, tree *, tree *, | |
39 | tree *); | |
40 | extern void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *, | |
41 | tree *); | |
42 | extern bool is_gimple_lvalue (tree); | |
43 | extern bool is_gimple_condexpr (tree); | |
44 | extern bool is_gimple_address (const_tree); | |
45 | extern bool is_gimple_invariant_address (const_tree); | |
46 | extern bool is_gimple_ip_invariant_address (const_tree); | |
47 | extern bool is_gimple_min_invariant (const_tree); | |
48 | extern bool is_gimple_ip_invariant (const_tree); | |
49 | extern bool is_gimple_reg (tree); | |
50 | extern bool is_gimple_val (tree); | |
51 | extern bool is_gimple_asm_val (tree); | |
52 | extern bool is_gimple_min_lval (tree); | |
53 | extern bool is_gimple_call_addr (tree); | |
54 | extern bool is_gimple_mem_ref_addr (tree); | |
ea804f86 | 55 | extern void flush_mark_addressable_queue (void); |
a8783bee | 56 | extern void mark_addressable (tree); |
57 | extern bool is_gimple_reg_rhs (tree); | |
46a19abf | 58 | |
59 | /* Return true if a conversion from either type of TYPE1 and TYPE2 | |
60 | to the other is not required. Otherwise return false. */ | |
61 | ||
62 | static inline bool | |
63 | types_compatible_p (tree type1, tree type2) | |
64 | { | |
65 | return (type1 == type2 | |
66 | || (useless_type_conversion_p (type1, type2) | |
67 | && useless_type_conversion_p (type2, type1))); | |
68 | } | |
69 | ||
70 | /* Return true if TYPE is a suitable type for a scalar register variable. */ | |
71 | ||
72 | static inline bool | |
73 | is_gimple_reg_type (tree type) | |
74 | { | |
75 | return !AGGREGATE_TYPE_P (type); | |
76 | } | |
77 | ||
78 | /* Return true if T is a variable. */ | |
79 | ||
80 | static inline bool | |
81 | is_gimple_variable (tree t) | |
82 | { | |
83 | return (TREE_CODE (t) == VAR_DECL | |
84 | || TREE_CODE (t) == PARM_DECL | |
85 | || TREE_CODE (t) == RESULT_DECL | |
86 | || TREE_CODE (t) == SSA_NAME); | |
87 | } | |
88 | ||
89 | /* Return true if T is a GIMPLE identifier (something with an address). */ | |
90 | ||
91 | static inline bool | |
92 | is_gimple_id (tree t) | |
93 | { | |
94 | return (is_gimple_variable (t) | |
95 | || TREE_CODE (t) == FUNCTION_DECL | |
96 | || TREE_CODE (t) == LABEL_DECL | |
97 | || TREE_CODE (t) == CONST_DECL | |
98 | /* Allow string constants, since they are addressable. */ | |
99 | || TREE_CODE (t) == STRING_CST); | |
100 | } | |
101 | ||
102 | /* Return true if OP, an SSA name or a DECL is a virtual operand. */ | |
103 | ||
104 | static inline bool | |
105 | virtual_operand_p (tree op) | |
106 | { | |
107 | if (TREE_CODE (op) == SSA_NAME) | |
108 | { | |
109 | op = SSA_NAME_VAR (op); | |
110 | if (!op) | |
111 | return false; | |
112 | } | |
113 | ||
114 | if (TREE_CODE (op) == VAR_DECL) | |
115 | return VAR_DECL_IS_VIRTUAL_OPERAND (op); | |
116 | ||
117 | return false; | |
118 | } | |
119 | ||
120 | /* Return true if T is something whose address can be taken. */ | |
121 | ||
122 | static inline bool | |
123 | is_gimple_addressable (tree t) | |
124 | { | |
125 | return (is_gimple_id (t) || handled_component_p (t) | |
126 | || TREE_CODE (t) == MEM_REF); | |
127 | } | |
128 | ||
129 | /* Return true if T is a valid gimple constant. */ | |
130 | ||
131 | static inline bool | |
132 | is_gimple_constant (const_tree t) | |
133 | { | |
134 | switch (TREE_CODE (t)) | |
135 | { | |
136 | case INTEGER_CST: | |
137 | case REAL_CST: | |
138 | case FIXED_CST: | |
46a19abf | 139 | case COMPLEX_CST: |
140 | case VECTOR_CST: | |
1fa87479 | 141 | case STRING_CST: |
46a19abf | 142 | return true; |
143 | ||
144 | default: | |
145 | return false; | |
146 | } | |
147 | } | |
148 | ||
149 | /* A wrapper around extract_ops_from_tree_1, for callers which expect | |
150 | to see only a maximum of two operands. */ | |
151 | ||
152 | static inline void | |
153 | extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0, | |
154 | tree *op1) | |
155 | { | |
156 | tree op2; | |
157 | extract_ops_from_tree_1 (expr, code, op0, op1, &op2); | |
158 | gcc_assert (op2 == NULL_TREE); | |
159 | } | |
160 | ||
161 | /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL | |
162 | associated with the callee if known. Otherwise return NULL_TREE. */ | |
163 | ||
164 | static inline tree | |
165 | gimple_call_addr_fndecl (const_tree fn) | |
166 | { | |
167 | if (fn && TREE_CODE (fn) == ADDR_EXPR) | |
168 | { | |
169 | tree fndecl = TREE_OPERAND (fn, 0); | |
170 | if (TREE_CODE (fndecl) == MEM_REF | |
171 | && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR | |
172 | && integer_zerop (TREE_OPERAND (fndecl, 1))) | |
173 | fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0); | |
174 | if (TREE_CODE (fndecl) == FUNCTION_DECL) | |
175 | return fndecl; | |
176 | } | |
177 | return NULL_TREE; | |
178 | } | |
179 | ||
180 | #endif /* GCC_GIMPLE_EXPR_H */ |