diff options
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r-- | gcc/gimple.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h index 3cde3cd..f7fdefc 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -4692,6 +4692,44 @@ gimple_phi_arg_has_location (const gphi *phi, size_t i) return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION; } +/* Return the number of arguments that can be accessed by gimple_arg. */ + +static inline unsigned +gimple_num_args (const gimple *gs) +{ + if (auto phi = dyn_cast<const gphi *> (gs)) + return gimple_phi_num_args (phi); + if (auto call = dyn_cast<const gcall *> (gs)) + return gimple_call_num_args (call); + return gimple_num_ops (as_a <const gassign *> (gs)) - 1; +} + +/* GS must be an assignment, a call, or a PHI. + If it's an assignment, return rhs operand I. + If it's a call, return function argument I. + If it's a PHI, return the value of PHI argument I. */ + +static inline tree +gimple_arg (const gimple *gs, unsigned int i) +{ + if (auto phi = dyn_cast<const gphi *> (gs)) + return gimple_phi_arg_def (phi, i); + if (auto call = dyn_cast<const gcall *> (gs)) + return gimple_call_arg (call, i); + return gimple_op (as_a <const gassign *> (gs), i + 1); +} + +/* Return a pointer to gimple_arg (GS, I). */ + +static inline tree * +gimple_arg_ptr (gimple *gs, unsigned int i) +{ + if (auto phi = dyn_cast<gphi *> (gs)) + return gimple_phi_arg_def_ptr (phi, i); + if (auto call = dyn_cast<gcall *> (gs)) + return gimple_call_arg_ptr (call, i); + return gimple_op_ptr (as_a <gassign *> (gs), i + 1); +} /* Return the region number for GIMPLE_RESX RESX_STMT. */ |