GCC Middle and Back End API Reference
tree-phinodes.h
Go to the documentation of this file.
1/* Header file for PHI node routines
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_TREE_PHINODES_H
21#define GCC_TREE_PHINODES_H
22
23extern void phinodes_print_statistics (void);
26extern void add_phi_arg (gphi *, tree, edge, location_t);
27extern void remove_phi_args (edge);
28extern void remove_phi_node (gimple_stmt_iterator *, bool);
29extern void remove_phi_nodes (basic_block);
32
33inline use_operand_p
35{
36 return &gimple_phi_arg (gs, i)->imm_use;
37}
38
39inline use_operand_p
41{
42 gcc_checking_assert (e->dest == gimple_bb (gs));
43 return &gimple_phi_arg (gs, e->dest_idx)->imm_use;
44}
45
46/* Return the phi argument which contains the specified use. */
47
48inline int
50{
51 struct phi_arg_d *element, *root;
52 size_t index;
53 gimple *phi;
54
55 /* Since the use is the first thing in a PHI argument element, we can
56 calculate its index based on casting it to an argument, and performing
57 pointer arithmetic. */
58
59 phi = USE_STMT (use);
60
61 element = (struct phi_arg_d *)use;
62 root = gimple_phi_arg (phi, 0);
63 index = element - root;
64
65 /* Make sure the calculation doesn't have any leftover bytes. If it does,
66 then imm_use is likely not the first element in phi_arg_d. */
67 gcc_checking_assert ((((char *)element - (char *)root)
68 % sizeof (struct phi_arg_d)) == 0
69 && index < gimple_phi_capacity (phi));
70
71 return index;
72}
73
74#endif /* GCC_TREE_PHINODES_H */
class edge_def * edge
Definition coretypes.h:352
const class edge_def * const_edge
Definition coretypes.h:353
union tree_node * tree
Definition coretypes.h:97
basic_block gimple_bb(const gimple *g)
Definition gimple.h:1861
unsigned gimple_phi_capacity(const gimple *gs)
Definition gimple.h:4540
struct phi_arg_d * gimple_phi_arg(gphi *gs, unsigned index)
Definition gimple.h:4604
i
Definition poly-int.h:776
Definition basic-block.h:117
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition gimple.h:461
Definition tree-core.h:1681
Definition loop-invariant.cc:78
#define gcc_checking_assert(EXPR)
Definition system.h:821
void remove_phi_node(gimple_stmt_iterator *, bool)
Definition tree-phinodes.cc:445
void reserve_phi_args_for_new_edge(basic_block)
Definition tree-phinodes.cc:283
use_operand_p gimple_phi_arg_imm_use_ptr(gimple *gs, int i)
Definition tree-phinodes.h:34
void phinodes_print_statistics(void)
Definition tree-phinodes.cc:81
int phi_arg_index_from_use(use_operand_p use)
Definition tree-phinodes.h:49
tree degenerate_phi_result(gphi *)
Definition tree-phinodes.cc:478
void add_phi_arg(gphi *, tree, edge, location_t)
Definition tree-phinodes.cc:362
gphi * create_phi_node(tree, basic_block)
Definition tree-phinodes.cc:346
use_operand_p gimple_phi_arg_imm_use_ptr_from_edge(gimple *gs, const_edge e)
Definition tree-phinodes.h:40
void set_phi_nodes(basic_block, gimple_seq)
Definition tree-phinodes.cc:513
void remove_phi_nodes(basic_block)
Definition tree-phinodes.cc:464
void remove_phi_args(edge)
Definition tree-phinodes.cc:429
#define USE_STMT(USE)
Definition tree-ssa-operands.h:70