]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-phinodes.h
[Ada] Improved support for aspect alignment in CCG
[thirdparty/gcc.git] / gcc / tree-phinodes.h
CommitLineData
80560f95 1/* Header file for PHI node routines
8d9254fc 2 Copyright (C) 2013-2020 Free Software Foundation, Inc.
80560f95
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_TREE_PHINODES_H
21#define GCC_TREE_PHINODES_H
22
23extern void phinodes_print_statistics (void);
80560f95 24extern void reserve_phi_args_for_new_edge (basic_block);
538dd0b7
DM
25extern void add_phi_node_to_bb (gphi *phi, basic_block bb);
26extern gphi *create_phi_node (tree, basic_block);
620e594b 27extern void add_phi_arg (gphi *, tree, edge, location_t);
80560f95
AM
28extern void remove_phi_args (edge);
29extern void remove_phi_node (gimple_stmt_iterator *, bool);
30extern void remove_phi_nodes (basic_block);
538dd0b7 31extern tree degenerate_phi_result (gphi *);
5be5c238 32extern void set_phi_nodes (basic_block, gimple_seq);
80560f95
AM
33
34static inline use_operand_p
355fe088 35gimple_phi_arg_imm_use_ptr (gimple *gs, int i)
80560f95
AM
36{
37 return &gimple_phi_arg (gs, i)->imm_use;
38}
39
40/* Return the phi argument which contains the specified use. */
41
42static inline int
43phi_arg_index_from_use (use_operand_p use)
44{
45 struct phi_arg_d *element, *root;
46 size_t index;
355fe088 47 gimple *phi;
80560f95
AM
48
49 /* Since the use is the first thing in a PHI argument element, we can
50 calculate its index based on casting it to an argument, and performing
51 pointer arithmetic. */
52
53 phi = USE_STMT (use);
54
55 element = (struct phi_arg_d *)use;
56 root = gimple_phi_arg (phi, 0);
57 index = element - root;
58
59 /* Make sure the calculation doesn't have any leftover bytes. If it does,
60 then imm_use is likely not the first element in phi_arg_d. */
61 gcc_checking_assert ((((char *)element - (char *)root)
62 % sizeof (struct phi_arg_d)) == 0
63 && index < gimple_phi_capacity (phi));
64
65 return index;
66}
67
68#endif /* GCC_TREE_PHINODES_H */