@@ -434,7 +434,7 @@ has_mem_ref_been_instrumented (const asan_mem_ref *ref, tree len)
otherwise. */
static bool
-get_mem_ref_of_assignment (const gimple assignment,
+get_mem_ref_of_assignment (const_gimple_assign assignment,
asan_mem_ref *ref,
bool *ref_is_store)
{
@@ -802,7 +802,8 @@ has_stmt_been_instrumented_p (gimple stmt)
asan_mem_ref r;
asan_mem_ref_init (&r, NULL, 1);
- if (get_mem_ref_of_assignment (stmt, &r, &r_is_store))
+ if (get_mem_ref_of_assignment (stmt->as_a_gimple_assign (), &r,
+ &r_is_store))
return has_mem_ref_been_instrumented (&r);
}
else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
@@ -77,6 +77,10 @@ struct gimple_statement_switch;
typedef struct gimple_statement_switch *gimple_switch;
typedef const struct gimple_statement_switch *const_gimple_switch;
+struct gimple_statement_assign;
+typedef struct gimple_statement_assign *gimple_assign;
+typedef const struct gimple_statement_assign *const_gimple_assign;
+
struct gimple_statement_bind;
typedef struct gimple_statement_bind *gimple_bind;
typedef const struct gimple_statement_bind *const_gimple_bind;
@@ -461,6 +461,8 @@ def build_pretty_printer():
'gimple_statement_cond *',
'gimple_switch', 'const_gimple_switch',
'gimple_statement_switch *',
+ 'gimple_assign', 'const_gimple_assign',
+ 'gimple_statement_assign *',
'gimple_bind', 'const_gimple_bind',
'gimple_statement_bind *'],
@@ -51,7 +51,7 @@ get_expr_type (enum tree_code code, tree op)
the expression code for the RHS. OP1 is the first operand and VAL
is an integer value to be used as the second operand. */
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, int val, tree lhs)
{
tree op2 = build_int_cst (TREE_TYPE (op1), val);
@@ -60,7 +60,7 @@ build_assign (enum tree_code code, tree op1, int val, tree lhs)
return gimple_build_assign_with_ops (code, lhs, op1, op2);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple g, int val, tree lhs )
{
return build_assign (code, gimple_assign_lhs (g), val, lhs);
@@ -75,7 +75,7 @@ build_assign (enum tree_code code, gimple g, int val, tree lhs )
in normal form depending on the type of builder invoking this
function. */
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
{
if (lhs == NULL_TREE)
@@ -83,19 +83,19 @@ build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
return gimple_build_assign_with_ops (code, lhs, op1, op2);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple op1, tree op2, tree lhs)
{
return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, tree op1, gimple op2, tree lhs)
{
return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
}
-gimple
+gimple_assign
build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
{
return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
@@ -106,7 +106,7 @@ build_assign (enum tree_code code, gimple op1, gimple op2, tree lhs)
/* Create and return a type cast assignment. This creates a NOP_EXPR
that converts OP to TO_TYPE. */
-gimple
+gimple_assign
build_type_cast (tree to_type, tree op, tree lhs)
{
if (lhs == NULL_TREE)
@@ -114,7 +114,7 @@ build_type_cast (tree to_type, tree op, tree lhs)
return gimple_build_assign_with_ops (NOP_EXPR, lhs, op, NULL_TREE);
}
-gimple
+gimple_assign
build_type_cast (tree to_type, gimple op, tree lhs)
{
return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
@@ -21,13 +21,13 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_GIMPLE_BUILDER_H
#define GCC_GIMPLE_BUILDER_H
-gimple build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
-gimple build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, tree, tree lhs = NULL_TREE);
-gimple build_type_cast (tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, int, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, tree, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, tree, gimple, tree lhs = NULL_TREE);
+gimple_assign build_assign (enum tree_code, gimple, gimple, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, tree, tree lhs = NULL_TREE);
+gimple_assign build_type_cast (tree, gimple, tree lhs = NULL_TREE);
#endif /* GCC_GIMPLE_BUILDER_H */
@@ -261,7 +261,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_unary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
enum tree_code rhs_code = gimple_assign_rhs_code (gs);
tree lhs = gimple_assign_lhs (gs);
@@ -345,7 +345,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_binary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
const char *p;
enum tree_code code = gimple_assign_rhs_code (gs);
@@ -401,7 +401,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */
static void
-dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_ternary_rhs (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
const char *p;
enum tree_code code = gimple_assign_rhs_code (gs);
@@ -486,7 +486,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
pp_gimple_stmt_1. */
static void
-dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
+dump_gimple_assign (pretty_printer *buffer, gimple_assign gs, int spc, int flags)
{
if (flags & TDF_RAW)
{
@@ -2095,7 +2095,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
break;
case GIMPLE_ASSIGN:
- dump_gimple_assign (buffer, gs, spc, flags);
+ dump_gimple_assign (buffer, gs->as_a_gimple_assign (), spc, flags);
break;
case GIMPLE_BIND:
@@ -377,7 +377,7 @@ gimple_build_call_from_tree (tree t)
LHS of the assignment.
RHS of the assignment which can be unary or binary. */
-gimple
+gimple_assign
gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
{
enum tree_code subcode;
@@ -393,19 +393,19 @@ gimple_build_assign_stat (tree lhs, tree rhs MEM_STAT_DECL)
OP1 and OP2. If OP2 is NULL then SUBCODE must be of class
GIMPLE_UNARY_RHS or GIMPLE_SINGLE_RHS. */
-gimple
+gimple_assign
gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
tree op2, tree op3 MEM_STAT_DECL)
{
unsigned num_ops;
- gimple p;
+ gimple_assign p;
/* Need 1 operand for LHS and 1 or 2 for the RHS (depending on the
code). */
num_ops = get_gimple_rhs_num_ops (subcode) + 1;
p = gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
- PASS_MEM_STAT);
+ PASS_MEM_STAT)->as_a_gimple_assign ();
gimple_assign_set_lhs (p, lhs);
gimple_assign_set_rhs1 (p, op1);
if (op2)
@@ -423,7 +423,7 @@ gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
return p;
}
-gimple
+gimple_assign
gimple_build_assign_with_ops (enum tree_code subcode, tree lhs, tree op1,
tree op2 MEM_STAT_DECL)
{
@@ -226,6 +226,12 @@ public:
return as_a <gimple_statement_switch> (this);
}
+ inline gimple_assign
+ as_a_gimple_assign ()
+ {
+ return as_a <gimple_statement_assign> (this);
+ }
+
inline gimple_bind
as_a_gimple_bind ()
{
@@ -252,6 +258,12 @@ public:
return dyn_cast <gimple_statement_switch> (this);
}
+ inline gimple_assign
+ dyn_cast_gimple_assign ()
+ {
+ return dyn_cast <gimple_statement_assign> (this);
+ }
+
inline gimple_bind
dyn_cast_gimple_bind ()
{
@@ -843,6 +855,16 @@ struct GTY((tag("GSS_WITH_OPS")))
/* no additional fields; this uses the layout for GSS_WITH_OPS. */
};
+/* A statement with the invariant that
+ stmt->code == GIMPLE_ASSIGN
+ i.e. an assignment statement. */
+
+struct GTY((tag("GSS_WITH_MEM_OPS")))
+ gimple_statement_assign : public gimple_statement_with_memory_ops
+{
+ /* no additional fields; this uses the layout for GSS_WITH_MEM_OPS. */
+};
+
template <>
template <>
inline bool
@@ -854,6 +876,14 @@ is_a_helper <gimple_statement_asm>::test (gimple gs)
template <>
template <>
inline bool
+is_a_helper <gimple_statement_assign>::test (gimple gs)
+{
+ return gs->code == GIMPLE_ASSIGN;
+}
+
+template <>
+template <>
+inline bool
is_a_helper <gimple_statement_bind>::test (gimple gs)
{
return gs->code == GIMPLE_BIND;
@@ -1264,12 +1294,13 @@ gimple gimple_build_call_valist (tree, unsigned, va_list);
gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
gimple gimple_build_call_from_tree (tree);
-gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
+gimple_assign gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
#define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
- tree, tree, tree CXX_MEM_STAT_INFO);
-gimple gimple_build_assign_with_ops (enum tree_code, tree,
- tree, tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+ tree, tree,
+ tree CXX_MEM_STAT_INFO);
+gimple_assign gimple_build_assign_with_ops (enum tree_code, tree,
+ tree, tree CXX_MEM_STAT_INFO);
gimple_cond gimple_build_cond (enum tree_code, tree, tree, tree, tree);
gimple_cond gimple_build_cond_from_tree (tree, tree, tree);
void gimple_cond_set_condition_from_tree (gimple_cond, tree);
@@ -3389,7 +3389,7 @@ verify_gimple_comparison (tree type, tree op0, tree op1)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_unary (gimple stmt)
+verify_gimple_assign_unary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3543,7 +3543,7 @@ verify_gimple_assign_unary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_binary (gimple stmt)
+verify_gimple_assign_binary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3817,7 +3817,7 @@ verify_gimple_assign_binary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_ternary (gimple stmt)
+verify_gimple_assign_ternary (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -3960,7 +3960,7 @@ verify_gimple_assign_ternary (gimple stmt)
Returns true if anything is wrong. */
static bool
-verify_gimple_assign_single (gimple stmt)
+verify_gimple_assign_single (gimple_assign stmt)
{
enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree lhs = gimple_assign_lhs (stmt);
@@ -4162,7 +4162,7 @@ verify_gimple_assign_single (gimple stmt)
is a problem, otherwise false. */
static bool
-verify_gimple_assign (gimple stmt)
+verify_gimple_assign (gimple_assign stmt)
{
switch (gimple_assign_rhs_class (stmt))
{
@@ -4401,7 +4401,7 @@ verify_gimple_stmt (gimple stmt)
switch (gimple_code (stmt))
{
case GIMPLE_ASSIGN:
- return verify_gimple_assign (stmt);
+ return verify_gimple_assign (stmt->as_a_gimple_assign ());
case GIMPLE_LABEL:
return verify_gimple_label (stmt);
@@ -3271,7 +3271,7 @@ simplify_binary_expression (gimple stmt)
simplified. */
static tree
-simplify_unary_expression (gimple stmt)
+simplify_unary_expression (gimple_assign stmt)
{
tree result = NULL_TREE;
tree orig_op0, op0 = gimple_assign_rhs1 (stmt);
@@ -3334,7 +3334,7 @@ simplify_unary_expression (gimple stmt)
/* Try to simplify RHS using equivalences and constant folding. */
static tree
-try_to_simplify (gimple stmt)
+try_to_simplify (gimple_assign stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
tree tem;
@@ -3422,7 +3422,7 @@ visit_use (tree use)
changed = visit_copy (lhs, rhs1);
goto done;
}
- simplified = try_to_simplify (stmt);
+ simplified = try_to_simplify (stmt->as_a_gimple_assign ());
if (simplified)
{
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -267,7 +267,7 @@ independent_of_stmt_p (tree expr, gimple at, gimple_stmt_iterator gsi)
additive factor for the real return value. */
static bool
-process_assignment (gimple stmt, gimple_stmt_iterator call, tree *m,
+process_assignment (gimple_assign stmt, gimple_stmt_iterator call, tree *m,
tree *a, tree *ass_var)
{
tree op0, op1 = NULL_TREE, non_ass_var = NULL_TREE;
@@ -549,7 +549,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
return;
/* This is a gimple assign. */
- if (! process_assignment (stmt, gsi, &tmp_m, &tmp_a, &ass_var))
+ if (! process_assignment (stmt->as_a_gimple_assign (), gsi, &tmp_m,
+ &tmp_a, &ass_var))
return;
if (tmp_a)
@@ -837,7 +837,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0,
static void
expand_vector_condition (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree type = gimple_expr_type (stmt);
tree a = gimple_assign_rhs1 (stmt);
tree a1 = a;
@@ -900,7 +900,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi)
static tree
expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type,
- gimple assign, enum tree_code code)
+ gimple_assign assign, enum tree_code code)
{
enum machine_mode compute_mode = TYPE_MODE (compute_type);
@@ -1005,7 +1005,7 @@ expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
static void
optimize_vector_constructor (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
tree type = TREE_TYPE (rhs);
@@ -1220,7 +1220,7 @@ vector_element (gimple_stmt_iterator *gsi, tree vect, tree idx, tree *ptmpvec)
static void
lower_vec_perm (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
+ gimple_assign stmt = gsi_stmt (*gsi)->as_a_gimple_assign ();
tree mask = gimple_assign_rhs3 (stmt);
tree vec0 = gimple_assign_rhs1 (stmt);
tree vec1 = gimple_assign_rhs2 (stmt);
@@ -1340,7 +1340,6 @@ lower_vec_perm (gimple_stmt_iterator *gsi)
static void
expand_vector_operations_1 (gimple_stmt_iterator *gsi)
{
- gimple stmt = gsi_stmt (*gsi);
tree lhs, rhs1, rhs2 = NULL, type, compute_type;
enum tree_code code;
enum machine_mode compute_mode;
@@ -1348,7 +1347,9 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
enum gimple_rhs_class rhs_class;
tree new_rhs;
- if (gimple_code (stmt) != GIMPLE_ASSIGN)
+ /* Only consider code == GIMPLE_ASSIGN. */
+ gimple_assign stmt = gsi_stmt (*gsi)->dyn_cast_gimple_assign ();
+ if (!stmt)
return;
code = gimple_assign_rhs_code (stmt);
@@ -3507,7 +3507,7 @@ extract_range_from_unary_expr (value_range_t *vr, enum tree_code code,
the ranges of each of its operands and the expression code. */
static void
-extract_range_from_cond_expr (value_range_t *vr, gimple stmt)
+extract_range_from_cond_expr (value_range_t *vr, gimple_assign stmt)
{
tree op0, op1;
value_range_t vr0 = VR_INITIALIZER;
@@ -3814,7 +3814,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
in *VR. */
static void
-extract_range_from_assignment (value_range_t *vr, gimple stmt)
+extract_range_from_assignment (value_range_t *vr, gimple_assign stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
@@ -6800,7 +6800,7 @@ vrp_visit_assignment_or_call (gimple stmt, tree *output_p)
else if (code == GIMPLE_CALL)
extract_range_basic (&new_vr, stmt);
else
- extract_range_from_assignment (&new_vr, stmt);
+ extract_range_from_assignment (&new_vr, stmt->as_a_gimple_assign ());
if (update_value_range (lhs, &new_vr))
{
@@ -9561,16 +9561,16 @@ simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
gimple_cond_lhs (stmt),
gimple_cond_rhs (stmt), within_stmt);
- if (gimple_code (stmt) == GIMPLE_ASSIGN)
+ if (gimple_assign assign_stmt = stmt->dyn_cast_gimple_assign ())
{
value_range_t new_vr = VR_INITIALIZER;
- tree lhs = gimple_assign_lhs (stmt);
+ tree lhs = gimple_assign_lhs (assign_stmt);
if (TREE_CODE (lhs) == SSA_NAME
&& (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
|| POINTER_TYPE_P (TREE_TYPE (lhs))))
{
- extract_range_from_assignment (&new_vr, stmt);
+ extract_range_from_assignment (&new_vr, assign_stmt);
if (range_int_cst_singleton_p (&new_vr))
return new_vr.min;
}