xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/tree-phinodes.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /* Header file for PHI node routines
2    Copyright (C) 2013-2015 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10 
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along 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 
23 extern void phinodes_print_statistics (void);
24 extern void release_phi_node (gimple);
25 extern void reserve_phi_args_for_new_edge (basic_block);
26 extern void add_phi_node_to_bb (gphi *phi, basic_block bb);
27 extern gphi *create_phi_node (tree, basic_block);
28 extern void add_phi_arg (gphi *, tree, edge, source_location);
29 extern void remove_phi_args (edge);
30 extern void remove_phi_node (gimple_stmt_iterator *, bool);
31 extern void remove_phi_nodes (basic_block);
32 extern tree degenerate_phi_result (gphi *);
33 extern void set_phi_nodes (basic_block, gimple_seq);
34 
35 static inline use_operand_p
36 gimple_phi_arg_imm_use_ptr (gimple gs, int i)
37 {
38   return &gimple_phi_arg (gs, i)->imm_use;
39 }
40 
41 /* Return the phi argument which contains the specified use.  */
42 
43 static inline int
44 phi_arg_index_from_use (use_operand_p use)
45 {
46   struct phi_arg_d *element, *root;
47   size_t index;
48   gimple phi;
49 
50   /* Since the use is the first thing in a PHI argument element, we can
51      calculate its index based on casting it to an argument, and performing
52      pointer arithmetic.  */
53 
54   phi = USE_STMT (use);
55 
56   element = (struct phi_arg_d *)use;
57   root = gimple_phi_arg (phi, 0);
58   index = element - root;
59 
60   /* Make sure the calculation doesn't have any leftover bytes.  If it does,
61      then imm_use is likely not the first element in phi_arg_d.  */
62   gcc_checking_assert ((((char *)element - (char *)root)
63 			% sizeof (struct phi_arg_d)) == 0
64 		       && index < gimple_phi_capacity (phi));
65 
66  return index;
67 }
68 
69 #endif /* GCC_TREE_PHINODES_H */
70