annotate gcc/gimple-expr.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Header file for gimple decl, type and expressions.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2013-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #ifndef GCC_GIMPLE_EXPR_H
kono
parents:
diff changeset
21 #define GCC_GIMPLE_EXPR_H
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 extern bool useless_type_conversion_p (tree, tree);
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 extern void gimple_set_body (tree, gimple_seq);
kono
parents:
diff changeset
27 extern gimple_seq gimple_body (tree);
kono
parents:
diff changeset
28 extern bool gimple_has_body_p (tree);
kono
parents:
diff changeset
29 extern const char *gimple_decl_printable_name (tree, int);
kono
parents:
diff changeset
30 extern tree copy_var_decl (tree, tree, tree);
kono
parents:
diff changeset
31 extern tree create_tmp_var_name (const char *);
kono
parents:
diff changeset
32 extern tree create_tmp_var_raw (tree, const char * = NULL);
kono
parents:
diff changeset
33 extern tree create_tmp_var (tree, const char * = NULL);
kono
parents:
diff changeset
34 extern tree create_tmp_reg (tree, const char * = NULL);
kono
parents:
diff changeset
35 extern tree create_tmp_reg_fn (struct function *, tree, const char *);
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 extern void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *,
kono
parents:
diff changeset
39 tree *);
kono
parents:
diff changeset
40 extern void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *,
kono
parents:
diff changeset
41 tree *);
kono
parents:
diff changeset
42 extern bool is_gimple_lvalue (tree);
kono
parents:
diff changeset
43 extern bool is_gimple_condexpr (tree);
kono
parents:
diff changeset
44 extern bool is_gimple_address (const_tree);
kono
parents:
diff changeset
45 extern bool is_gimple_invariant_address (const_tree);
kono
parents:
diff changeset
46 extern bool is_gimple_ip_invariant_address (const_tree);
kono
parents:
diff changeset
47 extern bool is_gimple_min_invariant (const_tree);
kono
parents:
diff changeset
48 extern bool is_gimple_ip_invariant (const_tree);
kono
parents:
diff changeset
49 extern bool is_gimple_reg (tree);
kono
parents:
diff changeset
50 extern bool is_gimple_val (tree);
kono
parents:
diff changeset
51 extern bool is_gimple_asm_val (tree);
kono
parents:
diff changeset
52 extern bool is_gimple_min_lval (tree);
kono
parents:
diff changeset
53 extern bool is_gimple_call_addr (tree);
kono
parents:
diff changeset
54 extern bool is_gimple_mem_ref_addr (tree);
kono
parents:
diff changeset
55 extern void flush_mark_addressable_queue (void);
kono
parents:
diff changeset
56 extern void mark_addressable (tree);
kono
parents:
diff changeset
57 extern bool is_gimple_reg_rhs (tree);
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 /* Return true if a conversion from either type of TYPE1 and TYPE2
kono
parents:
diff changeset
60 to the other is not required. Otherwise return false. */
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 static inline bool
kono
parents:
diff changeset
63 types_compatible_p (tree type1, tree type2)
kono
parents:
diff changeset
64 {
kono
parents:
diff changeset
65 return (type1 == type2
kono
parents:
diff changeset
66 || (useless_type_conversion_p (type1, type2)
kono
parents:
diff changeset
67 && useless_type_conversion_p (type2, type1)));
kono
parents:
diff changeset
68 }
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* Return true if TYPE is a suitable type for a scalar register variable. */
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 static inline bool
kono
parents:
diff changeset
73 is_gimple_reg_type (tree type)
kono
parents:
diff changeset
74 {
kono
parents:
diff changeset
75 return !AGGREGATE_TYPE_P (type);
kono
parents:
diff changeset
76 }
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 /* Return true if T is a variable. */
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 static inline bool
kono
parents:
diff changeset
81 is_gimple_variable (tree t)
kono
parents:
diff changeset
82 {
kono
parents:
diff changeset
83 return (TREE_CODE (t) == VAR_DECL
kono
parents:
diff changeset
84 || TREE_CODE (t) == PARM_DECL
kono
parents:
diff changeset
85 || TREE_CODE (t) == RESULT_DECL
kono
parents:
diff changeset
86 || TREE_CODE (t) == SSA_NAME);
kono
parents:
diff changeset
87 }
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* Return true if T is a GIMPLE identifier (something with an address). */
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 static inline bool
kono
parents:
diff changeset
92 is_gimple_id (tree t)
kono
parents:
diff changeset
93 {
kono
parents:
diff changeset
94 return (is_gimple_variable (t)
kono
parents:
diff changeset
95 || TREE_CODE (t) == FUNCTION_DECL
kono
parents:
diff changeset
96 || TREE_CODE (t) == LABEL_DECL
kono
parents:
diff changeset
97 || TREE_CODE (t) == CONST_DECL
kono
parents:
diff changeset
98 /* Allow string constants, since they are addressable. */
kono
parents:
diff changeset
99 || TREE_CODE (t) == STRING_CST);
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Return true if OP, an SSA name or a DECL is a virtual operand. */
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 static inline bool
kono
parents:
diff changeset
105 virtual_operand_p (tree op)
kono
parents:
diff changeset
106 {
kono
parents:
diff changeset
107 if (TREE_CODE (op) == SSA_NAME)
kono
parents:
diff changeset
108 return SSA_NAME_IS_VIRTUAL_OPERAND (op);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 if (TREE_CODE (op) == VAR_DECL)
kono
parents:
diff changeset
111 return VAR_DECL_IS_VIRTUAL_OPERAND (op);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 return false;
kono
parents:
diff changeset
114 }
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 /* Return true if T is something whose address can be taken. */
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 static inline bool
kono
parents:
diff changeset
119 is_gimple_addressable (tree t)
kono
parents:
diff changeset
120 {
kono
parents:
diff changeset
121 return (is_gimple_id (t) || handled_component_p (t)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 || TREE_CODE (t) == TARGET_MEM_REF
111
kono
parents:
diff changeset
123 || TREE_CODE (t) == MEM_REF);
kono
parents:
diff changeset
124 }
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 /* Return true if T is a valid gimple constant. */
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 static inline bool
kono
parents:
diff changeset
129 is_gimple_constant (const_tree t)
kono
parents:
diff changeset
130 {
kono
parents:
diff changeset
131 switch (TREE_CODE (t))
kono
parents:
diff changeset
132 {
kono
parents:
diff changeset
133 case INTEGER_CST:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
134 case POLY_INT_CST:
111
kono
parents:
diff changeset
135 case REAL_CST:
kono
parents:
diff changeset
136 case FIXED_CST:
kono
parents:
diff changeset
137 case COMPLEX_CST:
kono
parents:
diff changeset
138 case VECTOR_CST:
kono
parents:
diff changeset
139 case STRING_CST:
kono
parents:
diff changeset
140 return true;
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 default:
kono
parents:
diff changeset
143 return false;
kono
parents:
diff changeset
144 }
kono
parents:
diff changeset
145 }
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 /* A wrapper around extract_ops_from_tree with 3 ops, for callers which
kono
parents:
diff changeset
148 expect to see only a maximum of two operands. */
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 static inline void
kono
parents:
diff changeset
151 extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
kono
parents:
diff changeset
152 tree *op1)
kono
parents:
diff changeset
153 {
kono
parents:
diff changeset
154 tree op2;
kono
parents:
diff changeset
155 extract_ops_from_tree (expr, code, op0, op1, &op2);
kono
parents:
diff changeset
156 gcc_assert (op2 == NULL_TREE);
kono
parents:
diff changeset
157 }
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 /* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
kono
parents:
diff changeset
160 associated with the callee if known. Otherwise return NULL_TREE. */
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 static inline tree
kono
parents:
diff changeset
163 gimple_call_addr_fndecl (const_tree fn)
kono
parents:
diff changeset
164 {
kono
parents:
diff changeset
165 if (fn && TREE_CODE (fn) == ADDR_EXPR)
kono
parents:
diff changeset
166 {
kono
parents:
diff changeset
167 tree fndecl = TREE_OPERAND (fn, 0);
kono
parents:
diff changeset
168 if (TREE_CODE (fndecl) == MEM_REF
kono
parents:
diff changeset
169 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
kono
parents:
diff changeset
170 && integer_zerop (TREE_OPERAND (fndecl, 1)))
kono
parents:
diff changeset
171 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
kono
parents:
diff changeset
172 if (TREE_CODE (fndecl) == FUNCTION_DECL)
kono
parents:
diff changeset
173 return fndecl;
kono
parents:
diff changeset
174 }
kono
parents:
diff changeset
175 return NULL_TREE;
kono
parents:
diff changeset
176 }
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 #endif /* GCC_GIMPLE_EXPR_H */