GCC Middle and Back End API Reference
gimple-expr.h
Go to the documentation of this file.
1/* Header file for gimple decl, type and expressions.
2 Copyright (C) 2013-2024 Free Software Foundation, Inc.
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
24
25
26extern void gimple_set_body (tree, gimple_seq);
28extern bool gimple_has_body_p (tree);
29extern const char *gimple_decl_printable_name (tree, int);
31extern tree create_tmp_var_name (const char *);
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);
35extern tree create_tmp_reg_fn (struct function *, tree, const char *);
36
37
38extern void extract_ops_from_tree (tree, enum tree_code *, tree *, tree *,
39 tree *);
40extern void gimple_cond_get_ops_from_tree (tree, enum tree_code *, tree *,
41 tree *);
42extern bool is_gimple_lvalue (tree);
44extern bool is_gimple_address (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);
55extern void flush_mark_addressable_queue (void);
56extern void mark_addressable (tree);
57extern bool is_gimple_reg_rhs (tree);
59
60/* Return true if a conversion from either type of TYPE1 and TYPE2
61 to the other is not required. Otherwise return false. */
62
63inline bool
65{
66 return (type1 == type2
68 && useless_type_conversion_p (type2, type1)));
69}
70
71/* Return true if TYPE is a suitable type for a scalar register variable. */
72
73inline bool
78
79/* Return true if T is a variable. */
80
81inline bool
83{
84 return (VAR_P (t)
85 || TREE_CODE (t) == PARM_DECL
86 || TREE_CODE (t) == RESULT_DECL
87 || TREE_CODE (t) == SSA_NAME);
88}
89
90/* Return true if T is a GIMPLE identifier (something with an address). */
91
92inline bool
94{
95 return (is_gimple_variable (t)
96 || TREE_CODE (t) == FUNCTION_DECL
97 || TREE_CODE (t) == LABEL_DECL
98 || TREE_CODE (t) == CONST_DECL
99 /* Allow string constants, since they are addressable. */
100 || TREE_CODE (t) == STRING_CST);
101}
102
103/* Return true if OP, an SSA name or a DECL is a virtual operand. */
104
105inline bool
107{
108 if (TREE_CODE (op) == SSA_NAME)
109 return SSA_NAME_IS_VIRTUAL_OPERAND (op);
110
111 if (VAR_P (op))
112 return VAR_DECL_IS_VIRTUAL_OPERAND (op);
113
114 return false;
115}
116
117/* Return true if T is something whose address can be taken. */
118
119inline bool
121{
122 return (is_gimple_id (t) || handled_component_p (t)
123 || TREE_CODE (t) == TARGET_MEM_REF
124 || TREE_CODE (t) == MEM_REF);
125}
126
127/* Return true if T is a valid gimple constant. */
128
129inline bool
131{
132 switch (TREE_CODE (t))
133 {
134 case INTEGER_CST:
135 case POLY_INT_CST:
136 case REAL_CST:
137 case FIXED_CST:
138 case COMPLEX_CST:
139 case VECTOR_CST:
140 case STRING_CST:
141 return true;
142
143 default:
144 return false;
145 }
146}
147
148/* A wrapper around extract_ops_from_tree with 3 ops, for callers which
149 expect to see only a maximum of two operands. */
150
151inline void
153 tree *op1)
154{
155 tree op2;
156 extract_ops_from_tree (expr, code, op0, op1, &op2);
157 gcc_assert (op2 == NULL_TREE);
158}
159
160/* Given a valid GIMPLE_CALL function address return the FUNCTION_DECL
161 associated with the callee if known. Otherwise return NULL_TREE. */
162
163inline tree
165{
166 if (fn && TREE_CODE (fn) == ADDR_EXPR)
167 {
168 tree fndecl = TREE_OPERAND (fn, 0);
169 if (TREE_CODE (fndecl) == MEM_REF
170 && TREE_CODE (TREE_OPERAND (fndecl, 0)) == ADDR_EXPR
171 && integer_zerop (TREE_OPERAND (fndecl, 1)))
172 fndecl = TREE_OPERAND (TREE_OPERAND (fndecl, 0), 0);
173 if (TREE_CODE (fndecl) == FUNCTION_DECL)
174 return fndecl;
175 }
176 return NULL_TREE;
177}
178
179#endif /* GCC_GIMPLE_EXPR_H */
Definition genmatch.cc:845
const union tree_node * const_tree
Definition coretypes.h:98
union tree_node * tree
Definition coretypes.h:97
tree_code
Definition genmatch.cc:347
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
bool types_compatible_p(tree type1, tree type2)
Definition gimple-expr.h:64
bool is_gimple_variable(tree t)
Definition gimple-expr.h:82
tree canonicalize_cond_expr_cond(tree)
Definition gimple-expr.cc:636
bool is_gimple_id(tree t)
Definition gimple-expr.h:93
bool is_gimple_condexpr_for_cond(tree)
Definition gimple-expr.cc:626
bool is_gimple_mem_ref_addr(tree)
Definition gimple-expr.cc:883
bool is_gimple_asm_val(tree)
Definition gimple-expr.cc:854
void extract_ops_from_tree(tree, enum tree_code *, tree *, tree *, tree *)
Definition gimple-expr.cc:527
void gimple_set_body(tree, gimple_seq)
Definition gimple-expr.cc:305
bool is_gimple_call_addr(tree)
Definition gimple-expr.cc:875
tree create_tmp_var_name(const char *)
Definition gimple-expr.cc:424
bool is_gimple_invariant_address(const_tree)
Definition gimple-expr.cc:719
bool is_gimple_reg(tree)
Definition gimple-expr.cc:794
tree create_tmp_reg_fn(struct function *, tree, const char *)
Definition gimple-expr.cc:510
bool useless_type_conversion_p(tree, tree)
Definition gimple-expr.cc:68
bool is_gimple_min_lval(tree)
Definition gimple-expr.cc:865
const char * gimple_decl_printable_name(tree, int)
Definition gimple-expr.cc:344
bool is_gimple_address(const_tree)
Definition gimple-expr.cc:678
bool is_gimple_constant(const_tree t)
Definition gimple-expr.h:130
bool is_gimple_ip_invariant_address(const_tree)
Definition gimple-expr.cc:745
bool is_gimple_val(tree)
Definition gimple-expr.cc:840
bool is_gimple_ip_invariant(const_tree)
Definition gimple-expr.cc:783
bool is_gimple_reg_type(tree type)
Definition gimple-expr.h:74
bool is_gimple_addressable(tree t)
Definition gimple-expr.h:120
tree create_tmp_var_raw(tree, const char *=NULL)
Definition gimple-expr.cc:446
bool gimple_has_body_p(tree)
Definition gimple-expr.cc:335
bool is_gimple_min_invariant(const_tree)
Definition gimple-expr.cc:771
tree create_tmp_reg(tree, const char *=NULL)
Definition gimple-expr.cc:500
bool virtual_operand_p(tree op)
Definition gimple-expr.h:106
void gimple_cond_get_ops_from_tree(tree, enum tree_code *, tree *, tree *)
Definition gimple-expr.cc:569
void mark_addressable(tree)
Definition gimple-expr.cc:947
bool is_gimple_lvalue(tree)
Definition gimple-expr.cc:599
tree copy_var_decl(tree, tree, tree)
Definition gimple-expr.cc:376
void flush_mark_addressable_queue(void)
Definition gimple-expr.cc:932
bool is_gimple_reg_rhs(tree)
Definition gimple-expr.cc:980
tree gimple_call_addr_fndecl(const_tree fn)
Definition gimple-expr.h:164
gimple_seq gimple_body(tree)
Definition gimple-expr.cc:326
Definition function.h:249
Definition gimple.h:225
Definition gengtype.h:252
#define NULL
Definition system.h:50
#define gcc_assert(EXPR)
Definition system.h:821
#define create_tmp_var
Definition tree-nested.cc:242
bool integer_zerop(const_tree expr)
Definition tree.cc:2852
#define TREE_OPERAND(NODE, I)
Definition tree.h:1285
#define AGGREGATE_TYPE_P(TYPE)
Definition tree.h:693
#define VAR_DECL_IS_VIRTUAL_OPERAND(NODE)
Definition tree.h:3303
#define TREE_CODE(NODE)
Definition tree.h:324
bool handled_component_p(const_tree t)
Definition tree.h:5348
#define VAR_P(NODE)
Definition tree.h:235
#define SSA_NAME_IS_VIRTUAL_OPERAND(NODE)
Definition tree.h:2064
#define NULL_TREE
Definition tree.h:317