]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-expr.h
Add support for reductions in fully-masked loops
[thirdparty/gcc.git] / gcc / gimple-expr.h
CommitLineData
2a0603f1 1/* Header file for gimple decl, type and expressions.
85ec4feb 2 Copyright (C) 2013-2018 Free Software Foundation, Inc.
2a0603f1
AM
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16You should have received a copy of the GNU General Public License
17along 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
23extern bool useless_type_conversion_p (tree, tree);
24
45b0be94 25
2a0603f1
AM
26extern void gimple_set_body (tree, gimple_seq);
27extern gimple_seq gimple_body (tree);
28extern bool gimple_has_body_p (tree);
29extern const char *gimple_decl_printable_name (tree, int);
30extern tree copy_var_decl (tree, tree, tree);
45b0be94 31extern tree create_tmp_var_name (const char *);
b731b390
JJ
32extern tree create_tmp_var_raw (tree, const char * = NULL);
33extern tree create_tmp_var (tree, const char * = NULL);
34extern tree create_tmp_reg (tree, const char * = NULL);
45b62594 35extern tree create_tmp_reg_fn (struct function *, tree, const char *);
45b0be94 36
2a0603f1 37
d1e2bb2d
JJ
38extern void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *,
39 tree *);
2a0603f1
AM
40extern void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *,
41 tree *);
42extern bool is_gimple_lvalue (tree);
43extern bool is_gimple_condexpr (tree);
44extern bool is_gimple_address (const_tree);
45extern bool is_gimple_invariant_address (const_tree);
46extern bool is_gimple_ip_invariant_address (const_tree);
47extern bool is_gimple_min_invariant (const_tree);
48extern bool is_gimple_ip_invariant (const_tree);
49extern bool is_gimple_reg (tree);
50extern bool is_gimple_val (tree);
51extern bool is_gimple_asm_val (tree);
52extern bool is_gimple_min_lval (tree);
53extern bool is_gimple_call_addr (tree);
54extern bool is_gimple_mem_ref_addr (tree);
1b223a9f 55extern void flush_mark_addressable_queue (void);
45b0be94
AM
56extern void mark_addressable (tree);
57extern bool is_gimple_reg_rhs (tree);
2a0603f1
AM
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
62static inline bool
63types_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
72static inline bool
73is_gimple_reg_type (tree type)
74{
75 return !AGGREGATE_TYPE_P (type);
76}
77
78/* Return true if T is a variable. */
79
80static inline bool
81is_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
91static inline bool
92is_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
104static inline bool
105virtual_operand_p (tree op)
106{
107 if (TREE_CODE (op) == SSA_NAME)
e7960be7 108 return SSA_NAME_IS_VIRTUAL_OPERAND (op);
2a0603f1
AM
109
110 if (TREE_CODE (op) == VAR_DECL)
111 return VAR_DECL_IS_VIRTUAL_OPERAND (op);
112
113 return false;
114}
115
116/* Return true if T is something whose address can be taken. */
117
118static inline bool
119is_gimple_addressable (tree t)
120{
121 return (is_gimple_id (t) || handled_component_p (t)
122 || TREE_CODE (t) == MEM_REF);
123}
124
125/* Return true if T is a valid gimple constant. */
126
127static inline bool
128is_gimple_constant (const_tree t)
129{
130 switch (TREE_CODE (t))
131 {
132 case INTEGER_CST:
36fd6408 133 case POLY_INT_CST:
2a0603f1
AM
134 case REAL_CST:
135 case FIXED_CST:
2a0603f1
AM
136 case COMPLEX_CST:
137 case VECTOR_CST:
681a3d86 138 case STRING_CST:
2a0603f1
AM
139 return true;
140
141 default:
142 return false;
143 }
144}
145
d1e2bb2d
JJ
146/* A wrapper around extract_ops_from_tree with 3 ops, for callers which
147 expect to see only a maximum of two operands. */
2a0603f1
AM
148
149static inline void
150extract_ops_from_tree (tree expr, enum tree_code *code, tree *op0,
151 tree *op1)
152{
153 tree op2;
d1e2bb2d 154 extract_ops_from_tree (expr, code, op0, op1, &op2);
2a0603f1
AM
155 gcc_assert (op2 == NULL_TREE);
156}
157
158/* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
159 associated with the callee if known. Otherwise return NULL_TREE. */
160
161static inline tree
162gimple_call_addr_fndecl (const_tree fn)
163{
164 if (fn && TREE_CODE (fn) == ADDR_EXPR)
165 {
166 tree fndecl = TREE_OPERAND (fn, 0);
167 if (TREE_CODE (fndecl) == MEM_REF
168 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
169 && integer_zerop (TREE_OPERAND (fndecl, 1)))
170 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
171 if (TREE_CODE (fndecl) == FUNCTION_DECL)
172 return fndecl;
173 }
174 return NULL_TREE;
175}
176
177#endif /* GCC_GIMPLE_EXPR_H */