00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GCC_TREE_SSA_OPERANDS_H
00022 #define GCC_TREE_SSA_OPERANDS_H
00023
00024
00025
00026
00027
00028 typedef struct def_operand_ptr GTY(())
00029 {
00030 tree * GTY((skip(""))) def;
00031 } def_operand_p;
00032
00033
00034 typedef struct use_operand_ptr GTY(())
00035 {
00036 tree * GTY((skip(""))) use;
00037 } use_operand_p;
00038
00039 extern def_operand_p NULL_DEF_OPERAND_P;
00040 extern use_operand_p NULL_USE_OPERAND_P;
00041
00042
00043 typedef struct def_optype_d GTY(())
00044 {
00045 unsigned num_defs;
00046 struct def_operand_ptr GTY((length("%h.num_defs"))) defs[1];
00047 } def_optype_t;
00048
00049 typedef def_optype_t *def_optype;
00050
00051 /* This represents the USE operands of a stmt. */
00052 typedef struct use_optype_d GTY(())
00053 {
00054 unsigned num_uses;
00055 struct use_operand_ptr GTY((length("%h.num_uses"))) uses[1];
00056 } use_optype_t;
00057
00058 typedef use_optype_t *use_optype;
00059
00060 /* Operand type which stores a def and a use tree. */
00061 typedef struct v_def_use_operand_type GTY(())
00062 {
00063 tree def;
00064 tree use;
00065 } v_def_use_operand_type_t;
00066
00067 /* This represents the MAY_DEFS for a stmt. */
00068 typedef struct v_may_def_optype_d GTY(())
00069 {
00070 unsigned num_v_may_defs;
00071 struct v_def_use_operand_type GTY((length ("%h.num_v_may_defs")))
00072 v_may_defs[1];
00073 } v_may_def_optype_t;
00074
00075 typedef v_may_def_optype_t *v_may_def_optype;
00076
00077 /* This represents the VUSEs for a stmt. */
00078 typedef struct vuse_optype_d GTY(())
00079 {
00080 unsigned num_vuses;
00081 tree GTY((length ("%h.num_vuses"))) vuses[1];
00082 } vuse_optype_t;
00083
00084 typedef vuse_optype_t *vuse_optype;
00085
00086 /* This represents the V_MUST_DEFS for a stmt. */
00087 typedef struct v_must_def_optype_d GTY(())
00088 {
00089 unsigned num_v_must_defs;
00090 v_def_use_operand_type_t GTY((length("%h.num_v_must_defs"))) v_must_defs[1];
00091 } v_must_def_optype_t;
00092
00093 typedef v_must_def_optype_t *v_must_def_optype;
00094
00095 /* This represents the operand cache fora stmt. */
00096 typedef struct stmt_operands_d GTY(())
00097 {
00098 /* Statement operands. */
00099 struct def_optype_d * GTY (()) def_ops;
00100 struct use_optype_d * GTY (()) use_ops;
00101
00102 /* Virtual operands (V_MAY_DEF, VUSE, and V_MUST_DEF). */
00103 struct v_may_def_optype_d * GTY (()) v_may_def_ops;
00104 struct vuse_optype_d * GTY (()) vuse_ops;
00105 struct v_must_def_optype_d * GTY (()) v_must_def_ops;
00106 } stmt_operands_t;
00107
00108 typedef stmt_operands_t *stmt_operands_p;
00109
00110 #define USE_FROM_PTR(OP) get_use_from_ptr (OP)
00111 #define DEF_FROM_PTR(OP) get_def_from_ptr (OP)
00112 #define SET_USE(OP, V) ((*((OP).use)) = (V))
00113 #define SET_DEF(OP, V) ((*((OP).def)) = (V))
00114
00115
00116 #define USE_OPS(ANN) get_use_ops (ANN)
00117 #define STMT_USE_OPS(STMT) get_use_ops (stmt_ann (STMT))
00118 #define NUM_USES(OPS) ((OPS) ? (OPS)->num_uses : 0)
00119 #define USE_OP_PTR(OPS, I) get_use_op_ptr ((OPS), (I))
00120 #define USE_OP(OPS, I) (USE_FROM_PTR (USE_OP_PTR ((OPS), (I))))
00121 #define SET_USE_OP(OPS, I, V) (SET_USE (USE_OP_PTR ((OPS), (I)), (V)))
00122
00123
00124
00125 #define DEF_OPS(ANN) get_def_ops (ANN)
00126 #define STMT_DEF_OPS(STMT) get_def_ops (stmt_ann (STMT))
00127 #define NUM_DEFS(OPS) ((OPS) ? (OPS)->num_defs : 0)
00128 #define DEF_OP_PTR(OPS, I) get_def_op_ptr ((OPS), (I))
00129 #define DEF_OP(OPS, I) (DEF_FROM_PTR (DEF_OP_PTR ((OPS), (I))))
00130 #define SET_DEF_OP(OPS, I, V) (SET_DEF (DEF_OP_PTR ((OPS), (I)), (V)))
00131
00132
00133
00134 #define V_MAY_DEF_OPS(ANN) get_v_may_def_ops (ANN)
00135 #define STMT_V_MAY_DEF_OPS(STMT) get_v_may_def_ops (stmt_ann(STMT))
00136 #define NUM_V_MAY_DEFS(OPS) ((OPS) ? (OPS)->num_v_may_defs : 0)
00137 #define V_MAY_DEF_RESULT_PTR(OPS, I) get_v_may_def_result_ptr ((OPS), (I))
00138 #define V_MAY_DEF_RESULT(OPS, I) \
00139 (DEF_FROM_PTR (V_MAY_DEF_RESULT_PTR ((OPS), (I))))
00140 #define SET_V_MAY_DEF_RESULT(OPS, I, V) \
00141 (SET_DEF (V_MAY_DEF_RESULT_PTR ((OPS), (I)), (V)))
00142 #define V_MAY_DEF_OP_PTR(OPS, I) get_v_may_def_op_ptr ((OPS), (I))
00143 #define V_MAY_DEF_OP(OPS, I) \
00144 (USE_FROM_PTR (V_MAY_DEF_OP_PTR ((OPS), (I))))
00145 #define SET_V_MAY_DEF_OP(OPS, I, V) \
00146 (SET_USE (V_MAY_DEF_OP_PTR ((OPS), (I)), (V)))
00147
00148
00149 #define VUSE_OPS(ANN) get_vuse_ops (ANN)
00150 #define STMT_VUSE_OPS(STMT) get_vuse_ops (stmt_ann(STMT))
00151 #define NUM_VUSES(OPS) ((OPS) ? (OPS)->num_vuses : 0)
00152 #define VUSE_OP_PTR(OPS, I) get_vuse_op_ptr ((OPS), (I))
00153 #define VUSE_OP(OPS, I) (USE_FROM_PTR (VUSE_OP_PTR ((OPS), (I))))
00154 #define SET_VUSE_OP(OPS, I, V) (SET_USE (VUSE_OP_PTR ((OPS), (I)), (V)))
00155
00156
00157 #define V_MUST_DEF_OPS(ANN) get_v_must_def_ops (ANN)
00158 #define STMT_V_MUST_DEF_OPS(STMT) get_v_must_def_ops (stmt_ann (STMT))
00159 #define NUM_V_MUST_DEFS(OPS) ((OPS) ? (OPS)->num_v_must_defs : 0)
00160 #define V_MUST_DEF_RESULT_PTR(OPS, I) get_v_must_def_result_ptr ((OPS), (I))
00161 #define V_MUST_DEF_RESULT(OPS, I) \
00162 (DEF_FROM_PTR (V_MUST_DEF_RESULT_PTR ((OPS), (I))))
00163 #define SET_V_MUST_DEF_RESULT(OPS, I, V) \
00164 (SET_DEF (V_MUST_DEF_RESULT_PTR ((OPS), (I)), (V)))
00165 #define V_MUST_DEF_KILL_PTR(OPS, I) get_v_must_def_kill_ptr ((OPS), (I))
00166 #define V_MUST_DEF_KILL(OPS, I) (USE_FROM_PTR (V_MUST_DEF_KILL_PTR ((OPS), (I))))
00167 #define SET_V_MUST_DEF_KILL(OPS, I, V) (SET_USE (V_MUST_DEF_KILL_PTR ((OPS), (I)), (V)))
00168
00169 #define PHI_RESULT_PTR(PHI) get_phi_result_ptr (PHI)
00170 #define PHI_RESULT(PHI) DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
00171 #define SET_PHI_RESULT(PHI, V) SET_DEF (PHI_RESULT_PTR (PHI), (V))
00172
00173 #define PHI_ARG_DEF_PTR(PHI, I) get_phi_arg_def_ptr ((PHI), (I))
00174 #define PHI_ARG_DEF(PHI, I) USE_FROM_PTR (PHI_ARG_DEF_PTR ((PHI), (I)))
00175 #define SET_PHI_ARG_DEF(PHI, I, V) \
00176 SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
00177 #define PHI_ARG_DEF_FROM_EDGE(PHI, E) \
00178 PHI_ARG_DEF ((PHI), (E)->dest_idx)
00179 #define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E) \
00180 PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
00181
00182
00183 extern void init_ssa_operands (void);
00184 extern void fini_ssa_operands (void);
00185 extern void get_stmt_operands (tree);
00186 extern void copy_virtual_operands (tree, tree);
00187 extern void create_ssa_artficial_load_stmt (stmt_operands_p, tree);
00188
00189 extern bool ssa_call_clobbered_cache_valid;
00190 extern bool ssa_ro_call_cache_valid;
00191
00192 /* This structure is used in the operand iterator loops. It contains the
00193 items required to determine which operand is retrieved next. During
00194 optimization, this structure is scalarized, and any unused fields are
00195 optimized away, resulting in little overhead. */
00196
00197 typedef struct ssa_operand_iterator_d
00198 {
00199 int num_use;
00200 int num_def;
00201 int num_vuse;
00202 int num_v_mayu;
00203 int num_v_mayd;
00204 int num_v_mustu;
00205 int num_v_mustd;
00206 int use_i;
00207 int def_i;
00208 int vuse_i;
00209 int v_mayu_i;
00210 int v_mayd_i;
00211 int v_mustu_i;
00212 int v_mustd_i;
00213 stmt_operands_p ops;
00214 bool done;
00215 } ssa_op_iter;
00216
00217 /* These flags are used to determine which operands are returned during
00218 execution of the loop. */
00219 #define SSA_OP_USE 0x01 /* Real USE operands. */
00220 #define SSA_OP_DEF 0x02 /* Real DEF operands. */
00221 #define SSA_OP_VUSE 0x04 /* VUSE operands. */
00222 #define SSA_OP_VMAYUSE 0x08 /* USE portion of V_MAY_DEFS. */
00223 #define SSA_OP_VMAYDEF 0x10 /* DEF portion of V_MAY_DEFS. */
00224 #define SSA_OP_VMUSTDEF 0x20 /* V_MUST_DEF definitions. */
00225 #define SSA_OP_VMUSTDEFKILL 0x40 /* V_MUST_DEF kills. */
00226
00227 /* These are commonly grouped operand flags. */
00228 #define SSA_OP_VIRTUAL_USES (SSA_OP_VUSE | SSA_OP_VMAYUSE)
00229 #define SSA_OP_VIRTUAL_DEFS (SSA_OP_VMAYDEF | SSA_OP_VMUSTDEF)
00230 #define SSA_OP_VIRTUAL_KILLS (SSA_OP_VMUSTDEFKILL)
00231 #define SSA_OP_ALL_VIRTUALS (SSA_OP_VIRTUAL_USES | SSA_OP_VIRTUAL_KILLS | SSA_OP_VIRTUAL_DEFS)
00232 #define SSA_OP_ALL_USES (SSA_OP_VIRTUAL_USES | SSA_OP_USE)
00233 #define SSA_OP_ALL_DEFS (SSA_OP_VIRTUAL_DEFS | SSA_OP_DEF)
00234 #define SSA_OP_ALL_KILLS (SSA_OP_VIRTUAL_KILLS)
00235 #define SSA_OP_ALL_OPERANDS (SSA_OP_ALL_USES | SSA_OP_ALL_DEFS | SSA_OP_ALL_KILLS)
00236
00237 /* This macro executes a loop over the operands of STMT specified in FLAG,
00238 returning each operand as a 'tree' in the variable TREEVAR. ITER is an
00239 ssa_op_iter structure used to control the loop. */
00240 #define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS) \
00241 for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS); \
00242 !op_iter_done (&(ITER)); \
00243 TREEVAR = op_iter_next_tree (&(ITER)))
00244
00245 /* This macro executes a loop over the operands of STMT specified in FLAG,
00246 returning each operand as a 'use_operand_p' in the variable USEVAR.
00247 ITER is an ssa_op_iter structure used to control the loop. */
00248 #define FOR_EACH_SSA_USE_OPERAND(USEVAR, STMT, ITER, FLAGS) \
00249 for (USEVAR = op_iter_init_use (&(ITER), STMT, FLAGS); \
00250 !op_iter_done (&(ITER)); \
00251 USEVAR = op_iter_next_use (&(ITER)))
00252
00253 /* This macro executes a loop over the operands of STMT specified in FLAG,
00254 returning each operand as a 'def_operand_p' in the variable DEFVAR.
00255 ITER is an ssa_op_iter structure used to control the loop. */
00256 #define FOR_EACH_SSA_DEF_OPERAND(DEFVAR, STMT, ITER, FLAGS) \
00257 for (DEFVAR = op_iter_init_def (&(ITER), STMT, FLAGS); \
00258 !op_iter_done (&(ITER)); \
00259 DEFVAR = op_iter_next_def (&(ITER)))
00260
00261 /* This macro executes a loop over the V_MAY_DEF operands of STMT. The def
00262 and use for each V_MAY_DEF is returned in DEFVAR and USEVAR.
00263 ITER is an ssa_op_iter structure used to control the loop. */
00264 #define FOR_EACH_SSA_MAYDEF_OPERAND(DEFVAR, USEVAR, STMT, ITER) \
00265 for (op_iter_init_maydef (&(ITER), STMT, &(USEVAR), &(DEFVAR)); \
00266 !op_iter_done (&(ITER)); \
00267 op_iter_next_maydef (&(USEVAR), &(DEFVAR), &(ITER)))
00268
00269 /* This macro executes a loop over the V_MUST_DEF operands of STMT. The def
00270 and kill for each V_MUST_DEF is returned in DEFVAR and KILLVAR.
00271 ITER is an ssa_op_iter structure used to control the loop. */
00272 #define FOR_EACH_SSA_MUSTDEF_OPERAND(DEFVAR, KILLVAR, STMT, ITER) \
00273 for (op_iter_init_mustdef (&(ITER), STMT, &(KILLVAR), &(DEFVAR)); \
00274 !op_iter_done (&(ITER)); \
00275 op_iter_next_mustdef (&(KILLVAR), &(DEFVAR), &(ITER)))
00276
00277 #endif /* GCC_TREE_SSA_OPERANDS_H */