]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-phinodes.h
* tree-ssa.h: Don't include gimple-low.h, tree-ssa-address.h, sbitmap.h,
[thirdparty/gcc.git] / gcc / tree-phinodes.h
CommitLineData
8f6fa493 1/* Header file for PHI node routines
2 Copyright (C) 2013 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_TREE_PHINODES_H
21#define GCC_TREE_PHINODES_H
22
23extern void phinodes_print_statistics (void);
24extern void release_phi_node (gimple);
25extern void reserve_phi_args_for_new_edge (basic_block);
26extern void add_phi_node_to_bb (gimple phi, basic_block bb);
27extern gimple create_phi_node (tree, basic_block);
28extern void add_phi_arg (gimple, tree, edge, source_location);
29extern void remove_phi_args (edge);
30extern void remove_phi_node (gimple_stmt_iterator *, bool);
31extern void remove_phi_nodes (basic_block);
424a4a92 32extern tree degenerate_phi_result (gimple);
8f6fa493 33
34/* Set PHI nodes of a basic block BB to SEQ. */
35
36static inline void
37set_phi_nodes (basic_block bb, gimple_seq seq)
38{
39 gimple_stmt_iterator i;
40
41 gcc_checking_assert (!(bb->flags & BB_RTL));
42 bb->il.gimple.phi_nodes = seq;
43 if (seq)
44 for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
45 gimple_set_bb (gsi_stmt (i), bb);
46}
47
48
49static inline use_operand_p
50gimple_phi_arg_imm_use_ptr (gimple gs, int i)
51{
52 return &gimple_phi_arg (gs, i)->imm_use;
53}
54
55/* Return the phi argument which contains the specified use. */
56
57static inline int
58phi_arg_index_from_use (use_operand_p use)
59{
60 struct phi_arg_d *element, *root;
61 size_t index;
62 gimple phi;
63
64 /* Since the use is the first thing in a PHI argument element, we can
65 calculate its index based on casting it to an argument, and performing
66 pointer arithmetic. */
67
68 phi = USE_STMT (use);
69
70 element = (struct phi_arg_d *)use;
71 root = gimple_phi_arg (phi, 0);
72 index = element - root;
73
74 /* Make sure the calculation doesn't have any leftover bytes. If it does,
75 then imm_use is likely not the first element in phi_arg_d. */
76 gcc_checking_assert ((((char *)element - (char *)root)
77 % sizeof (struct phi_arg_d)) == 0
78 && index < gimple_phi_capacity (phi));
79
80 return index;
81}
82
83#endif /* GCC_TREE_PHINODES_H */