1 /* Inline functions for tree-flow.h
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _TREE_FLOW_INLINE_H
22 #define _TREE_FLOW_INLINE_H 1
24 /* Inline functions for manipulating various data structures defined in
25 tree-flow.h. See tree-flow.h for documentation. */
27 /* Return true when gimple SSA form was built.
28 gimple_in_ssa_p is queried by gimplifier in various early stages before SSA
29 infrastructure is initialized. Check for presence of the datastructures
32 gimple_in_ssa_p (const struct function
*fun
)
34 return fun
&& fun
->gimple_df
&& fun
->gimple_df
->in_ssa_p
;
37 /* Artificial variable used for the virtual operand FUD chain. */
39 gimple_vop (const struct function
*fun
)
41 gcc_checking_assert (fun
&& fun
->gimple_df
);
42 return fun
->gimple_df
->vop
;
45 /* Get the number of the next statement uid to be allocated. */
46 static inline unsigned int
47 gimple_stmt_max_uid (struct function
*fn
)
49 return fn
->last_stmt_uid
;
52 /* Set the number of the next statement uid to be allocated. */
54 set_gimple_stmt_max_uid (struct function
*fn
, unsigned int maxid
)
56 fn
->last_stmt_uid
= maxid
;
59 /* Set the number of the next statement uid to be allocated. */
60 static inline unsigned int
61 inc_gimple_stmt_max_uid (struct function
*fn
)
63 return fn
->last_stmt_uid
++;
66 /* Return the line number for EXPR, or return -1 if we have no line
67 number information for it. */
69 get_lineno (const_gimple stmt
)
76 loc
= gimple_location (stmt
);
77 if (loc
== UNKNOWN_LOCATION
)
80 return LOCATION_LINE (loc
);
84 /* Return true if T (assumed to be a DECL) is a global variable.
85 A variable is considered global if its storage is not automatic. */
88 is_global_var (const_tree t
)
90 return (TREE_STATIC (t
) || DECL_EXTERNAL (t
));
94 /* Return true if VAR may be aliased. A variable is considered as
95 maybe aliased if it has its address taken by the local TU
96 or possibly by another TU and might be modified through a pointer. */
99 may_be_aliased (const_tree var
)
101 return (TREE_CODE (var
) != CONST_DECL
102 && !((TREE_STATIC (var
) || TREE_PUBLIC (var
) || DECL_EXTERNAL (var
))
103 && TREE_READONLY (var
)
104 && !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (var
)))
105 && (TREE_PUBLIC (var
)
106 || DECL_EXTERNAL (var
)
107 || TREE_ADDRESSABLE (var
)));
111 /* Returns the loop of the statement STMT. */
113 static inline struct loop
*
114 loop_containing_stmt (gimple stmt
)
116 basic_block bb
= gimple_bb (stmt
);
120 return bb
->loop_father
;
125 /* Return true if VAR cannot be modified by the program. */
128 unmodifiable_var_p (const_tree var
)
130 if (TREE_CODE (var
) == SSA_NAME
)
131 var
= SSA_NAME_VAR (var
);
133 return TREE_READONLY (var
) && (TREE_STATIC (var
) || DECL_EXTERNAL (var
));
136 /* Return true if REF, a handled component reference, has an ARRAY_REF
140 ref_contains_array_ref (const_tree ref
)
142 gcc_checking_assert (handled_component_p (ref
));
145 if (TREE_CODE (ref
) == ARRAY_REF
)
147 ref
= TREE_OPERAND (ref
, 0);
148 } while (handled_component_p (ref
));
153 /* Return true if REF has an VIEW_CONVERT_EXPR somewhere in it. */
156 contains_view_convert_expr_p (const_tree ref
)
158 while (handled_component_p (ref
))
160 if (TREE_CODE (ref
) == VIEW_CONVERT_EXPR
)
162 ref
= TREE_OPERAND (ref
, 0);
168 /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
169 overlap. SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
170 range is open-ended. Otherwise return false. */
173 ranges_overlap_p (unsigned HOST_WIDE_INT pos1
,
174 unsigned HOST_WIDE_INT size1
,
175 unsigned HOST_WIDE_INT pos2
,
176 unsigned HOST_WIDE_INT size2
)
179 && (size2
== (unsigned HOST_WIDE_INT
)-1
180 || pos1
< (pos2
+ size2
)))
183 && (size1
== (unsigned HOST_WIDE_INT
)-1
184 || pos2
< (pos1
+ size1
)))
190 /* Accessor to tree-ssa-operands.c caches. */
191 static inline struct ssa_operands
*
192 gimple_ssa_operands (const struct function
*fun
)
194 return &fun
->gimple_df
->ssa_operands
;
197 #endif /* _TREE_FLOW_INLINE_H */