xref: /dflybsd-src/contrib/gcc-8.0/gcc/tree-ssa-operands.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj /* SSA operand management for trees.
2*38fd1498Szrj    Copyright (C) 2003-2018 Free Software Foundation, Inc.
3*38fd1498Szrj 
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj 
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj 
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj 
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3.  If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>.  */
19*38fd1498Szrj 
20*38fd1498Szrj #ifndef GCC_TREE_SSA_OPERANDS_H
21*38fd1498Szrj #define GCC_TREE_SSA_OPERANDS_H
22*38fd1498Szrj 
23*38fd1498Szrj /* Interface to SSA operands.  */
24*38fd1498Szrj 
25*38fd1498Szrj 
26*38fd1498Szrj /* This represents a pointer to a DEF operand.  */
27*38fd1498Szrj typedef tree *def_operand_p;
28*38fd1498Szrj 
29*38fd1498Szrj /* This represents a pointer to a USE operand.  */
30*38fd1498Szrj typedef ssa_use_operand_t *use_operand_p;
31*38fd1498Szrj 
32*38fd1498Szrj /* NULL operand types.  */
33*38fd1498Szrj #define NULL_USE_OPERAND_P 		((use_operand_p)NULL)
34*38fd1498Szrj #define NULL_DEF_OPERAND_P 		((def_operand_p)NULL)
35*38fd1498Szrj 
36*38fd1498Szrj /* This represents the USE operands of a stmt.  */
37*38fd1498Szrj struct use_optype_d
38*38fd1498Szrj {
39*38fd1498Szrj   struct use_optype_d *next;
40*38fd1498Szrj   struct ssa_use_operand_t use_ptr;
41*38fd1498Szrj };
42*38fd1498Szrj typedef struct use_optype_d *use_optype_p;
43*38fd1498Szrj 
44*38fd1498Szrj /* This structure represents a variable sized buffer which is allocated by the
45*38fd1498Szrj    operand memory manager.  Operands are suballocated out of this block.  The
46*38fd1498Szrj    MEM array varies in size.  */
47*38fd1498Szrj 
48*38fd1498Szrj struct GTY((chain_next("%h.next"))) ssa_operand_memory_d {
49*38fd1498Szrj   struct ssa_operand_memory_d *next;
50*38fd1498Szrj   char mem[1];
51*38fd1498Szrj };
52*38fd1498Szrj 
53*38fd1498Szrj /* Per-function operand caches.  */
54*38fd1498Szrj struct GTY(()) ssa_operands {
55*38fd1498Szrj    struct ssa_operand_memory_d *operand_memory;
56*38fd1498Szrj    unsigned operand_memory_index;
57*38fd1498Szrj    /* Current size of the operand memory buffer.  */
58*38fd1498Szrj    unsigned int ssa_operand_mem_size;
59*38fd1498Szrj 
60*38fd1498Szrj    bool ops_active;
61*38fd1498Szrj 
62*38fd1498Szrj    struct use_optype_d * GTY ((skip (""))) free_uses;
63*38fd1498Szrj };
64*38fd1498Szrj 
65*38fd1498Szrj #define USE_FROM_PTR(PTR)	get_use_from_ptr (PTR)
66*38fd1498Szrj #define DEF_FROM_PTR(PTR)	get_def_from_ptr (PTR)
67*38fd1498Szrj #define SET_USE(USE, V)		set_ssa_use_from_ptr (USE, V)
68*38fd1498Szrj #define SET_DEF(DEF, V)		((*(DEF)) = (V))
69*38fd1498Szrj 
70*38fd1498Szrj #define USE_STMT(USE)		(USE)->loc.stmt
71*38fd1498Szrj 
72*38fd1498Szrj #define USE_OP_PTR(OP)		(&((OP)->use_ptr))
73*38fd1498Szrj #define USE_OP(OP)		(USE_FROM_PTR (USE_OP_PTR (OP)))
74*38fd1498Szrj 
75*38fd1498Szrj #define PHI_RESULT_PTR(PHI)	gimple_phi_result_ptr (PHI)
76*38fd1498Szrj #define PHI_RESULT(PHI)		DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
77*38fd1498Szrj #define SET_PHI_RESULT(PHI, V)	SET_DEF (PHI_RESULT_PTR (PHI), (V))
78*38fd1498Szrj /*
79*38fd1498Szrj #define PHI_ARG_DEF(PHI, I)	USE_FROM_PTR (PHI_ARG_DEF_PTR ((PHI), (I)))
80*38fd1498Szrj */
81*38fd1498Szrj #define PHI_ARG_DEF_PTR(PHI, I)	gimple_phi_arg_imm_use_ptr ((PHI), (I))
82*38fd1498Szrj #define PHI_ARG_DEF(PHI, I)	gimple_phi_arg_def ((PHI), (I))
83*38fd1498Szrj #define SET_PHI_ARG_DEF(PHI, I, V)					\
84*38fd1498Szrj 				SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
85*38fd1498Szrj #define PHI_ARG_DEF_FROM_EDGE(PHI, E)					\
86*38fd1498Szrj 				PHI_ARG_DEF ((PHI), (E)->dest_idx)
87*38fd1498Szrj #define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E)				\
88*38fd1498Szrj 				PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
89*38fd1498Szrj #define PHI_ARG_INDEX_FROM_USE(USE)   phi_arg_index_from_use (USE)
90*38fd1498Szrj 
91*38fd1498Szrj 
92*38fd1498Szrj extern bool ssa_operands_active (struct function *);
93*38fd1498Szrj extern void init_ssa_operands (struct function *fn);
94*38fd1498Szrj extern void fini_ssa_operands (struct function *);
95*38fd1498Szrj extern bool verify_ssa_operands (struct function *, gimple *stmt);
96*38fd1498Szrj extern void free_stmt_operands (struct function *, gimple *);
97*38fd1498Szrj extern void update_stmt_operands (struct function *, gimple *);
98*38fd1498Szrj extern void swap_ssa_operands (gimple *, tree *, tree *);
99*38fd1498Szrj extern bool verify_imm_links (FILE *f, tree var);
100*38fd1498Szrj 
101*38fd1498Szrj extern void dump_immediate_uses_for (FILE *file, tree var);
102*38fd1498Szrj extern void dump_immediate_uses (FILE *file);
103*38fd1498Szrj extern void debug_immediate_uses (void);
104*38fd1498Szrj extern void debug_immediate_uses_for (tree var);
105*38fd1498Szrj 
106*38fd1498Szrj extern void unlink_stmt_vdef (gimple *);
107*38fd1498Szrj 
108*38fd1498Szrj /* Return the tree pointed-to by USE.  */
109*38fd1498Szrj static inline tree
get_use_from_ptr(use_operand_p use)110*38fd1498Szrj get_use_from_ptr (use_operand_p use)
111*38fd1498Szrj {
112*38fd1498Szrj   return *(use->use);
113*38fd1498Szrj }
114*38fd1498Szrj 
115*38fd1498Szrj /* Return the tree pointed-to by DEF.  */
116*38fd1498Szrj static inline tree
get_def_from_ptr(def_operand_p def)117*38fd1498Szrj get_def_from_ptr (def_operand_p def)
118*38fd1498Szrj {
119*38fd1498Szrj   return *def;
120*38fd1498Szrj }
121*38fd1498Szrj 
122*38fd1498Szrj #endif  /* GCC_TREE_SSA_OPERANDS_H  */
123