public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Add ADDR_EXPR_CODE_P
@ 2022-05-05 12:07 Matthew Malcomson
0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:08dafc1f06db0e5b61ced9ab4801a00263cbbf8d
commit 08dafc1f06db0e5b61ced9ab4801a00263cbbf8d
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Mon Apr 11 17:52:00 2022 +0100
Add ADDR_EXPR_CODE_P
Mechanically replace checks of the form:
code == ADDR_EXPR
with:
ADDR_EXPR_CODE_P (code)
similarly to how CONVERT_EXPR_CODE_P handles CONVERT_EXPR and
NOP_EXPR.
Diff:
---
gcc/analyzer/sm-malloc.cc | 2 +-
gcc/builtins.c | 2 +-
gcc/c-family/c-pretty-print.c | 3 ++-
gcc/c/c-fold.c | 2 +-
gcc/c/c-typeck.c | 2 +-
gcc/calls.c | 2 +-
gcc/config/aarch64/aarch64.c | 2 +-
gcc/config/arm/arm.c | 2 +-
gcc/config/ia64/ia64.c | 2 +-
gcc/cp/parser.c | 4 ++--
gcc/cp/typeck.c | 8 ++++----
gcc/expr.c | 2 +-
gcc/genmatch.c | 10 ++++++++--
gcc/gimple-match.h | 2 +-
gcc/gimple-pretty-print.c | 2 +-
gcc/gimple-ssa-isolate-paths.c | 2 +-
gcc/gimple-ssa-sprintf.c | 2 +-
gcc/gimple.c | 2 +-
gcc/ipa-fnsummary.c | 2 +-
gcc/stor-layout.c | 2 +-
gcc/tree-data-ref.c | 2 +-
gcc/tree-ssa-forwprop.c | 4 ++--
gcc/tree-ssa-loop-ivopts.c | 2 +-
gcc/tree-ssa-loop-niter.c | 4 ++--
gcc/tree-ssa-phiopt.c | 2 +-
gcc/tree-ssa-sccvn.c | 20 ++++++++++----------
gcc/tree-ssa-strlen.c | 2 +-
gcc/tree-ssa-uninit.c | 2 +-
gcc/tree-stdarg.c | 6 +++---
gcc/tree.c | 2 +-
gcc/tree.h | 7 +++++++
31 files changed, 62 insertions(+), 48 deletions(-)
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index ba6d41cf8ee..d6b726bd582 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -778,7 +778,7 @@ malloc_state_machine::on_stmt (sm_context *sm_ctxt,
if (const gassign *assign_stmt = dyn_cast <const gassign *> (stmt))
{
enum tree_code op = gimple_assign_rhs_code (assign_stmt);
- if (op == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (op))
{
tree lhs = gimple_assign_lhs (assign_stmt);
if (lhs)
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 9d58a4909a6..56d22eaaaba 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4192,7 +4192,7 @@ compute_objsize (tree ptr, int ostype, access_ref *pref,
pref->offrng[0] += orng[0];
pref->offrng[1] += orng[1];
}
- else if (code != ADDR_EXPR)
+ else if (!ADDR_EXPR_CODE_P (code))
return false;
return compute_objsize (ptr, ostype, pref, visited, rvals);
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index ddc29c67464..94aa4bff891 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1765,7 +1765,8 @@ c_pretty_printer::unary_expression (tree e)
case TRUTH_NOT_EXPR:
case CONJ_EXPR:
/* String literal are used by address. */
- if (code == ADDR_EXPR && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
+ if (ADDR_EXPR_CODE_P (code)
+ && TREE_CODE (TREE_OPERAND (e, 0)) != STRING_CST)
pp_ampersand (this);
else if (code == INDIRECT_REF)
{
diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c
index bd21d247051..a022a64c563 100644
--- a/gcc/c/c-fold.c
+++ b/gcc/c/c-fold.c
@@ -479,7 +479,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
/* ??? Cope with user tricks that amount to offsetof. The middle-end is
not prepared to deal with them if they occur in initializers. */
if (op0 != orig_op0
- && code == ADDR_EXPR
+ && ADDR_EXPR_CODE_P (code)
&& (op1 = get_base_address (op0)) != NULL_TREE
&& INDIRECT_REF_P (op1)
&& TREE_CONSTANT (TREE_OPERAND (op1, 0)))
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 30a082b3144..74f7245e5b5 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -4408,7 +4408,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg,
if (int_operands)
arg = remove_c_maybe_const_expr (arg);
- if (code != ADDR_EXPR)
+ if (!ADDR_EXPR_CODE_P (code))
arg = require_complete_type (location, arg);
if (TREE_CODE (TREE_TYPE (arg)) == INTCAP_TYPE)
diff --git a/gcc/calls.c b/gcc/calls.c
index 6c38afee29b..87af7720c60 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -1522,7 +1522,7 @@ get_attr_nonstring_decl (tree expr, tree *ref)
if (is_gimple_assign (def))
{
tree_code code = gimple_assign_rhs_code (def);
- if (code == ADDR_EXPR
+ if (ADDR_EXPR_CODE_P (code)
|| code == COMPONENT_REF
|| code == VAR_DECL)
decl = gimple_assign_rhs1 (def);
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f2a72a0ca2f..c42eca5c0e9 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -24691,7 +24691,7 @@ static const char *
aarch64_invalid_unary_op (int op, const_tree type)
{
/* Reject all single-operand operations on BFmode except for &. */
- if (element_mode (type) == BFmode && op != ADDR_EXPR)
+ if (element_mode (type) == BFmode && !ADDR_EXPR_CODE_P (tree_code (op)))
return N_("operation not permitted on type %<bfloat16_t%>");
/* Operation allowed. */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index dd78141519e..15268d03761 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -33262,7 +33262,7 @@ static const char *
arm_invalid_unary_op (int op, const_tree type)
{
/* Reject all single-operand operations on BFmode except for &. */
- if (element_mode (type) == BFmode && op != ADDR_EXPR)
+ if (element_mode (type) == BFmode && !ADDR_EXPR_CODE_P (op))
return N_("operation not permitted on type %<bfloat16_t%>");
/* Operation allowed. */
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index ece71606165..b51b26276ac 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -11255,7 +11255,7 @@ ia64_invalid_unary_op (int op, const_tree type)
/* Reject operations on __fpreg other than unary + or &. */
if (TYPE_MODE (type) == RFmode
&& op != CONVERT_EXPR
- && op != ADDR_EXPR)
+ && !ADDR_EXPR_CODE_P (op))
return N_("invalid operation on %<__fpreg%>");
return NULL;
}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 525a0a27c19..bb30c927d90 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4021,7 +4021,7 @@ cp_parser_make_indirect_declarator (enum tree_code code, tree class_type,
else
return make_ptrmem_declarator (cv_qualifiers, class_type,
target, attributes);
- else if (code == ADDR_EXPR && class_type == NULL_TREE)
+ else if (ADDR_EXPR_CODE_P (code) && class_type == NULL_TREE)
return make_reference_declarator (cv_qualifiers, target,
false, attributes);
else if (code == NON_LVALUE_EXPR && class_type == NULL_TREE)
@@ -8555,7 +8555,7 @@ cp_parser_unary_expression (cp_parser *parser, cp_id_kind * pidk,
/* Parse the cast-expression. */
cast_expression
= cp_parser_cast_expression (parser,
- unary_operator == ADDR_EXPR,
+ ADDR_EXPR_CODE_P (unary_operator),
/*cast_p=*/false,
/*decltype*/false,
pidk);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 3c66e2e05da..0bd527737ae 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2397,7 +2397,7 @@ string_conv_p (const_tree totype, const_tree exp, int warn)
unary_complex_lvalue, but we needed it to deal with `a = (d == c) ? b : c'
expressions, where we're dealing with aggregates. But now it's again only
called from unary_complex_lvalue. The case (in particular) that led to
- this was with CODE == ADDR_EXPR, since it's not an lvalue when we'd
+ this was with ADDR_EXPR_CODE_P (CODE), since it's not an lvalue when we'd
get it there. */
static tree
@@ -6097,7 +6097,7 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg,
"operator &".) However, if the type is a template
specialization, we must complete the type at this point so that
an overloaded "operator &" will be available if required. */
- if (code == ADDR_EXPR
+ if (ADDR_EXPR_CODE_P (code)
&& TREE_CODE (xarg) != TEMPLATE_ID_EXPR
&& ((CLASS_TYPE_P (TREE_TYPE (xarg))
&& !COMPLETE_TYPE_P (complete_type (TREE_TYPE (xarg))))
@@ -6107,7 +6107,7 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg,
exp = build_new_op (loc, code, LOOKUP_NORMAL, xarg, NULL_TREE,
NULL_TREE, &overload, complain);
- if (!exp && code == ADDR_EXPR)
+ if (!exp && ADDR_EXPR_CODE_P (code))
{
if (is_overloaded_fn (xarg))
{
@@ -6955,7 +6955,7 @@ unary_complex_lvalue (enum tree_code code, tree arg)
|| TREE_CODE (arg) == PREDECREMENT_EXPR)
return unary_complex_lvalue (code, genericize_compound_lvalue (arg));
- if (code != ADDR_EXPR)
+ if (!ADDR_EXPR_CODE_P (code))
return NULL_TREE;
/* Handle (a = b) used as an "lvalue" for `&'. */
diff --git a/gcc/expr.c b/gcc/expr.c
index f9ecd700276..2ec3735e9de 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -12070,7 +12070,7 @@ constant_byte_string (tree arg, tree *ptr_offset, tree *mem_size, tree *decl,
tree rhs1 = gimple_assign_rhs1 (stmt);
tree_code code = gimple_assign_rhs_code (stmt);
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
return string_constant (rhs1, ptr_offset, mem_size, decl);
else if (code != POINTER_PLUS_EXPR)
return NULL_TREE;
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 107f6f2ec9e..1ab3063b7b9 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -30,7 +30,6 @@ along with GCC; see the file COPYING3. If not see
#include "hash-set.h"
#include "is-a.h"
-
/* Stubs for GGC referenced through instantiations triggered by hash-map. */
void *ggc_internal_cleared_alloc (size_t, void (*)(void *),
size_t, size_t MEM_STAT_DECL)
@@ -254,6 +253,13 @@ enum combined_fn {
#include "case-cfn-macros.h"
+/* Return true if CODE takes the address of an object. */
+static inline bool
+ADDR_EXPR_CODE_P (tree_code code)
+{
+ return code == ADDR_EXPR;
+}
+
/* Return true if CODE represents a commutative tree code. Otherwise
return false. */
bool
@@ -538,7 +544,7 @@ add_operator (enum tree_code code, const char *id,
&& !(code == SSA_NAME))
return;
/* Treat ADDR_EXPR as atom, thus don't allow matching its operand. */
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
nargs = 0;
operator_id *op = new operator_id (code, id, nargs, tcc);
id_base **slot = operators->find_slot_with_hash (op, op->hashval, INSERT);
diff --git a/gcc/gimple-match.h b/gcc/gimple-match.h
index 097898aed1e..9c2a49213bd 100644
--- a/gcc/gimple-match.h
+++ b/gcc/gimple-match.h
@@ -327,7 +327,7 @@ gimple_simplified_result_is_gimple_val (const gimple_match_op *op)
{
return (op->code.is_tree_code ()
&& (TREE_CODE_LENGTH ((tree_code) op->code) == 0
- || ((tree_code) op->code) == ADDR_EXPR)
+ || ADDR_EXPR_CODE_P (op->code))
&& is_gimple_val (op->ops[0]));
}
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index a01bf901657..90a9e52a71c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -387,7 +387,7 @@ dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
|| TREE_CODE_CLASS (rhs_code) == tcc_constant
|| TREE_CODE_CLASS (rhs_code) == tcc_reference
|| rhs_code == SSA_NAME
- || rhs_code == ADDR_EXPR
+ || ADDR_EXPR_CODE_P (rhs_code)
|| rhs_code == CONSTRUCTOR)
{
dump_generic_node (buffer, rhs, spc, flags, false);
diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c
index ed7bae3189a..f3ffd426ca6 100644
--- a/gcc/gimple-ssa-isolate-paths.c
+++ b/gcc/gimple-ssa-isolate-paths.c
@@ -477,7 +477,7 @@ is_addr_local (gimple *return_stmt, tree exp, locmap_t *plocmap,
ptr2 = gimple_assign_rhs2 (def_stmt);
nargs = 2;
}
- else if (code == ADDR_EXPR
+ else if (ADDR_EXPR_CODE_P (code)
|| code == NOP_EXPR
|| code == POINTER_PLUS_EXPR)
/* Leave NARGS at zero and let the recursive call set it. */
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 70b031fe7b9..7d5c1f0cf50 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2368,7 +2368,7 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff, HOST_WIDE_INT *off)
if (is_gimple_assign (def))
{
tree_code code = gimple_assign_rhs_code (def);
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
{
x = gimple_assign_rhs1 (def);
return get_origin_and_offset (x, fldoff, off);
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 0de9323e4c7..05920adcd92 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2271,7 +2271,7 @@ get_gimple_rhs_num_ops (enum tree_code code)
: ((SYM) == CONSTRUCTOR \
|| (SYM) == OBJ_TYPE_REF \
|| (SYM) == ASSERT_EXPR \
- || (SYM) == ADDR_EXPR \
+ || ADDR_EXPR_CODE_P (SYM) \
|| (SYM) == WITH_SIZE_EXPR \
|| (SYM) == SSA_NAME) ? GIMPLE_SINGLE_RHS \
: GIMPLE_INVALID_RHS),
diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index 2cfab40156e..cd56362c11e 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -1244,7 +1244,7 @@ eliminated_by_inlining_prob (ipa_func_body_info *fbi, gimple *stmt)
Assume that half of statements goes away. */
if (CONVERT_EXPR_CODE_P (rhs_code)
|| rhs_code == VIEW_CONVERT_EXPR
- || rhs_code == ADDR_EXPR
+ || ADDR_EXPR_CODE_P (rhs_code)
|| gimple_assign_rhs_class (stmt) == GIMPLE_SINGLE_RHS)
{
tree rhs = gimple_assign_rhs1 (stmt);
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 8a16add9dbc..07a036a186e 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -120,7 +120,7 @@ copy_self_referential_tree_r (tree *tp, int *walk_subtrees, void *data)
}
/* This is the pattern built in ada/make_aligning_type. */
- else if (code == ADDR_EXPR
+ else if (ADDR_EXPR_CODE_P (code)
&& TREE_CODE (TREE_OPERAND (*tp, 0)) == PLACEHOLDER_EXPR)
{
*walk_subtrees = 0;
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 06d807b65a9..23a7106c195 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -711,7 +711,7 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1,
|| subcode == PLUS_EXPR
|| subcode == MINUS_EXPR
|| subcode == MULT_EXPR
- || subcode == ADDR_EXPR
+ || ADDR_EXPR_CODE_P (subcode)
|| CONVERT_EXPR_CODE_P (subcode)))
{
use_cache = true;
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 0b83a966e1c..3f2a992a774 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -1219,7 +1219,7 @@ constant_pointer_difference (tree p1, tree p2)
off = size_binop (PLUS_EXPR, off, gimple_assign_rhs2 (stmt));
p = gimple_assign_rhs1 (stmt);
}
- else if (code == ADDR_EXPR || CONVERT_EXPR_CODE_P (code))
+ else if (ADDR_EXPR_CODE_P (code) || CONVERT_EXPR_CODE_P (code))
p = gimple_assign_rhs1 (stmt);
else
break;
@@ -2773,7 +2773,7 @@ pass_forwprop::execute (function *fun)
/* If this statement sets an SSA_NAME to an address,
try to propagate the address into the uses of the SSA_NAME. */
- if ((code == ADDR_EXPR
+ if ((ADDR_EXPR_CODE_P (code)
/* Handle pointer conversions on invariant addresses
as well, as this is valid gimple. */
|| (CONVERT_EXPR_CODE_P (code)
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 2f45777cca1..582d17c73cc 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1095,7 +1095,7 @@ determine_base_object_1 (tree *tp, int *walk_subtrees, void *wdata)
{
tree_code code = TREE_CODE (*tp);
tree obj = NULL_TREE;
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
{
tree base = get_base_address (TREE_OPERAND (*tp, 0));
if (!base)
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index c7f449456ca..48e1a1ed9c2 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2083,7 +2083,7 @@ expand_simple_operations (tree expr, tree stop, hash_map<tree, tree> &cache)
if (code == SSA_NAME)
return expand_simple_operations (e, stop, cache);
- else if (code == ADDR_EXPR)
+ else if (ADDR_EXPR_CODE_P (code))
{
poly_int64 offset;
tree base = get_addr_base_and_unit_offset (TREE_OPERAND (e, 0),
@@ -2899,7 +2899,7 @@ chain_of_csts_start (class loop *loop, tree x)
code = gimple_assign_rhs_code (stmt);
if (gimple_references_memory_p (stmt)
|| TREE_CODE_CLASS (code) == tcc_reference
- || (code == ADDR_EXPR
+ || (ADDR_EXPR_CODE_P (code)
&& !is_gimple_min_invariant (gimple_assign_rhs1 (stmt))))
return NULL;
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index b6209404346..dbe935527cb 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -872,7 +872,7 @@ static bool
jump_function_from_stmt (tree *arg, gimple *stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
{
/* For arg = &p->i transform it to p, if possible. */
tree rhs1 = gimple_assign_rhs1 (stmt);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 47581247833..6f6efd9aae3 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -554,7 +554,7 @@ vn_get_stmt_kind (gimple *stmt)
return VN_CONSTANT;
default:
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
return (is_gimple_min_invariant (rhs1)
? VN_CONSTANT : VN_REFERENCE);
else if (code == CONSTRUCTOR)
@@ -655,7 +655,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
{
if (vro->opcode == MEM_REF)
deref = true;
- else if (vro->opcode != ADDR_EXPR)
+ else if (!ADDR_EXPR_CODE_P (vro->opcode))
deref = false;
if (maybe_ne (vro->off, -1))
{
@@ -670,7 +670,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
hstate.add_poly_int (off);
off = -1;
if (deref
- && vro->opcode == ADDR_EXPR)
+ && ADDR_EXPR_CODE_P (vro->opcode))
{
if (vro->op0)
{
@@ -761,7 +761,7 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2)
}
if (maybe_ne (off1, off2))
return false;
- if (deref1 && vro1->opcode == ADDR_EXPR)
+ if (deref1 && ADDR_EXPR_CODE_P (vro1->opcode))
{
memset (&tem1, 0, sizeof (tem1));
tem1.op0 = TREE_OPERAND (vro1->op0, 0);
@@ -770,7 +770,7 @@ vn_reference_eq (const_vn_reference_t const vr1, const_vn_reference_t const vr2)
vro1 = &tem1;
deref1 = false;
}
- if (deref2 && vro2->opcode == ADDR_EXPR)
+ if (deref2 && ADDR_EXPR_CODE_P (vro2->opcode))
{
memset (&tem2, 0, sizeof (tem2));
tem2.op0 = TREE_OPERAND (vro2->op0, 0);
@@ -1267,7 +1267,7 @@ vn_reference_maybe_forwprop_address (vec<vn_reference_op_s> *ops,
return changed;
code = gimple_assign_rhs_code (def_stmt);
- if (code != ADDR_EXPR
+ if (!ADDR_EXPR_CODE_P (code)
&& code != POINTER_PLUS_EXPR)
return changed;
@@ -1276,7 +1276,7 @@ vn_reference_maybe_forwprop_address (vec<vn_reference_op_s> *ops,
/* The only thing we have to do is from &OBJ.foo.bar add the offset
from .foo.bar to the preceding MEM_REF offset and replace the
address with &OBJ. */
- if (code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (code))
{
tree addr, addr_base;
poly_int64 addr_offset;
@@ -1395,12 +1395,12 @@ fully_constant_vn_reference_p (vn_reference_t ref)
if (operands.length () > 2)
arg1 = &operands[2];
if (TREE_CODE_CLASS (arg0->opcode) == tcc_constant
- || (arg0->opcode == ADDR_EXPR
+ || (ADDR_EXPR_CODE_P (arg0->opcode)
&& is_gimple_min_invariant (arg0->op0)))
anyconst = true;
if (arg1
&& (TREE_CODE_CLASS (arg1->opcode) == tcc_constant
- || (arg1->opcode == ADDR_EXPR
+ || (ADDR_EXPR_CODE_P (arg1->opcode)
&& is_gimple_min_invariant (arg1->op0))))
anyconst = true;
if (anyconst)
@@ -1458,7 +1458,7 @@ fully_constant_vn_reference_p (vn_reference_t ref)
if (TREE_CODE_CLASS (base->opcode) == tcc_constant)
ctor = base->op0;
else if (base->opcode == MEM_REF
- && base[1].opcode == ADDR_EXPR
+ && ADDR_EXPR_CODE_P (base[1].opcode)
&& (TREE_CODE (TREE_OPERAND (base[1].op0, 0)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (base[1].op0, 0)) == CONST_DECL
|| TREE_CODE (TREE_OPERAND (base[1].op0, 0)) == STRING_CST))
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 6addfe57f4d..0e14fc1ccb5 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -415,7 +415,7 @@ get_stridx (tree exp, wide_int offrng[2] = NULL, const vr_values *rvals = NULL)
tree_code rhs_code = gimple_assign_rhs_code (def_stmt);
tree ptr, off;
- if (rhs_code == ADDR_EXPR)
+ if (ADDR_EXPR_CODE_P (rhs_code))
{
/* Handle indices/offsets into VLAs which are implemented
as pointers to arrays. */
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c
index 2f0ff724cde..e73cc6f4cf6 100644
--- a/gcc/tree-ssa-uninit.c
+++ b/gcc/tree-ssa-uninit.c
@@ -350,7 +350,7 @@ maybe_warn_operand (ao_ref &ref, gimple *stmt, tree lhs, tree rhs,
break;
tree_code code = gimple_assign_rhs_code (def_stmt);
- if (code != ADDR_EXPR && code != POINTER_PLUS_EXPR)
+ if (!ADDR_EXPR_CODE_P (code) && code != POINTER_PLUS_EXPR)
break;
base = gimple_assign_rhs1 (def_stmt);
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index f9cedd49f0b..53bf6c3d7ee 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -174,7 +174,7 @@ va_list_counter_bump (struct stdarg_info *si, tree counter, tree rhs,
continue;
}
- if (rhs_code == ADDR_EXPR
+ if (ADDR_EXPR_CODE_P (rhs_code)
&& TREE_CODE (TREE_OPERAND (rhs1, 0)) == MEM_REF
&& TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0)) == SSA_NAME
&& tree_fits_uhwi_p (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1)))
@@ -241,7 +241,7 @@ va_list_counter_bump (struct stdarg_info *si, tree counter, tree rhs,
continue;
}
- if (rhs_code == ADDR_EXPR
+ if (ADDR_EXPR_CODE_P (rhs_code)
&& TREE_CODE (TREE_OPERAND (rhs1, 0)) == MEM_REF
&& TREE_CODE (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0)) == SSA_NAME
&& tree_fits_uhwi_p (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1)))
@@ -626,7 +626,7 @@ check_all_va_list_escapes (struct stdarg_info *si)
DECL_UID (lhs) + num_ssa_names))
continue;
}
- else if (rhs_code == ADDR_EXPR
+ else if (ADDR_EXPR_CODE_P (rhs_code)
&& TREE_CODE (TREE_OPERAND (rhs, 0)) == MEM_REF
&& TREE_OPERAND (TREE_OPERAND (rhs, 0), 0) == use)
{
diff --git a/gcc/tree.c b/gcc/tree.c
index d47b13e6d8d..11dd9cc0276 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -4072,7 +4072,7 @@ find_placeholder_in_expr (tree exp, vec<tree> *refs)
case tcc_expression:
/* This is the pattern built in ada/make_aligning_type. */
- if (code == ADDR_EXPR
+ if (ADDR_EXPR_CODE_P (code)
&& TREE_CODE (TREE_OPERAND (exp, 0)) == PLACEHOLDER_EXPR)
{
push_without_duplicates (exp, refs);
diff --git a/gcc/tree.h b/gcc/tree.h
index e0d8204edfe..9c14bce5b1c 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -470,6 +470,13 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
used in hash tables which are saved to a PCH. */
#define TREE_HASH(NODE) ((size_t) (NODE) & 0777777)
+/* Return true if CODE takes the address of an object. */
+static inline bool
+ADDR_EXPR_CODE_P (tree_code code)
+{
+ return code == ADDR_EXPR;
+}
+
/* Tests if CODE is a conversion expr (NOP_EXPR or CONVERT_EXPR). */
#define CONVERT_EXPR_CODE_P(CODE) \
((CODE) == NOP_EXPR || (CODE) == CONVERT_EXPR)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-05 12:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:07 [gcc(refs/vendors/ARM/heads/morello)] Add ADDR_EXPR_CODE_P Matthew Malcomson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).