From patchwork Mon Jul 3 14:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1802823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=u02Zi9Cz; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QvpT50pXHz20ZF for ; Tue, 4 Jul 2023 00:38:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE818385840B for ; Mon, 3 Jul 2023 14:38:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE818385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688395127; bh=j6wv3btwqaD79kOnT2K+ivGRyceen9t0+i/Jv0JjoRo=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=u02Zi9CzCMIysWA0poIT+lTlgxk6dfngklsBdT3zov2TdnvtLb5IZcOzoJgCMPRLI d7FMP1MLyb2PqROQM9p1wFjybcHxbGRSXX7LK7pyieSfAMeatlLxQOjdUpSjy/wQEn 9bvs9mak6Uw2qA3KDzRj1c3iiNz/pz/VYA3zN1lE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 94F5B3858C52 for ; Mon, 3 Jul 2023 14:38:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94F5B3858C52 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-51d7f350758so5900651a12.3 for ; Mon, 03 Jul 2023 07:38:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688395103; x=1690987103; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=j6wv3btwqaD79kOnT2K+ivGRyceen9t0+i/Jv0JjoRo=; b=abutRn9JcuZsdLUVX/CogFWkUIeUEfGy0XSYsnMRQFaBSv9+kYKo5+QaHb5UMEYKQH jwiwVRj3Kg1VgNQ/c646hW6mbH5vOMCxaS/PiKqTyOCkZt7FIiOKa+XFr69qgpfIJpsD iWPW7JPl2FSIzxy7ykpNX3JoAs7yJpCan88nOTddtNmufBksHFFdGHiYba+zj8QjGZut 6QWEnuzHYlkJ/h01/KzljiGEBHaISU2Setvw/Ww2ei3Zf8zWVtoNHulY2ifOhZLlmZ/0 LQLaw5r9ReTjTy8/4z4CB6dCnjg9D5KcZ+Cmy5pmO+yHy4w0BF79acSY84ZF7oFjnkzi YW9A== X-Gm-Message-State: ABy/qLYE606doqIh+MLEsLYp8GGGqAhDKKubB2n5XLb6/ooGmEPlLaO7 mJN/x4MJnjKVXjeWDhvd+pr4+caUTBfDjXLoiIakzpEMKIHhcg== X-Google-Smtp-Source: APBJJlHTHwQcEODWo7ecsAzc0kgMirU8RHnw7fK4uFIdKBmKErZaAHynVCCyTQzwlAicqgOF17b3amG5oFYIhtV4MWQ= X-Received: by 2002:a50:ec98:0:b0:51d:d01c:a2c4 with SMTP id e24-20020a50ec98000000b0051dd01ca2c4mr8305609edr.7.1688395102871; Mon, 03 Jul 2023 07:38:22 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 3 Jul 2023 16:38:11 +0200 Message-ID: Subject: [committed] tree+ggc: Change return type of predicate functions from int to bool To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Also change internal variable from int to bool. gcc/ChangeLog: * tree.h (tree_int_cst_equal): Change return type from int to bool. (operand_equal_for_phi_arg_p): Ditto. (tree_map_base_marked_p): Ditto. * tree.cc (contains_placeholder_p): Update function body for bool return type. (type_cache_hasher::equal): Ditto. (tree_map_base_hash): Change return type from int to void and adjust function body accordingly. (tree_int_cst_equal): Ditto. (operand_equal_for_phi_arg_p): Ditto. (get_narrower): Change "first" variable to bool. (cl_option_hasher::equal): Update function body for bool return type. * ggc.h (ggc_set_mark): Change return type from int to bool. (ggc_marked_p): Ditto. * ggc-page.cc (gt_ggc_mx): Change return type from int to void and adjust function body accordingly. (ggc_set_mark): Ditto. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/ggc-page.cc b/gcc/ggc-page.cc index c25218d7415..2f0b72e1b22 100644 --- a/gcc/ggc-page.cc +++ b/gcc/ggc-page.cc @@ -1538,7 +1538,7 @@ gt_ggc_mx (unsigned char& x ATTRIBUTE_UNUSED) P must have been allocated by the GC allocator; it mustn't point to static objects, stack variables, or memory allocated with malloc. */ -int +bool ggc_set_mark (const void *p) { page_entry *entry; @@ -1558,7 +1558,7 @@ ggc_set_mark (const void *p) /* If the bit was previously set, skip it. */ if (entry->in_use_p[word] & mask) - return 1; + return true; /* Otherwise set it, and decrement the free object count. */ entry->in_use_p[word] |= mask; @@ -1567,14 +1567,14 @@ ggc_set_mark (const void *p) if (GGC_DEBUG_LEVEL >= 4) fprintf (G.debug_file, "Marking %p\n", p); - return 0; + return false; } -/* Return 1 if P has been marked, zero otherwise. +/* Return true if P has been marked, zero otherwise. P must have been allocated by the GC allocator; it mustn't point to static objects, stack variables, or memory allocated with malloc. */ -int +bool ggc_marked_p (const void *p) { page_entry *entry; diff --git a/gcc/ggc.h b/gcc/ggc.h index 78eab7eaba6..34108e2f006 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -90,15 +90,15 @@ extern const struct ggc_root_tab * const gt_pch_scalar_rtab[]; /* Actually set the mark on a particular region of memory, but don't follow pointers. This function is called by ggc_mark_*. It - returns zero if the object was not previously marked; nonzero if + returns false if the object was not previously marked; true if the object was already marked, or if, for any other reason, pointers in this data structure should not be traversed. */ -extern int ggc_set_mark (const void *); +extern bool ggc_set_mark (const void *); -/* Return 1 if P has been marked, zero otherwise. +/* Return true if P has been marked, zero otherwise. P must have been allocated by the GC allocator; it mustn't point to static objects, stack variables, or memory allocated with malloc. */ -extern int ggc_marked_p (const void *); +extern bool ggc_marked_p (const void *); /* PCH and GGC handling for strings, mostly trivial. */ extern void gt_pch_n_S (const void *); diff --git a/gcc/tree.cc b/gcc/tree.cc index 58288efa2e2..bd500ec72a5 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -2839,7 +2839,7 @@ grow_tree_vec (tree v, int len MEM_STAT_DECL) return v; } -/* Return 1 if EXPR is the constant zero, whether it is integral, float or +/* Return true if EXPR is the constant zero, whether it is integral, float or fixed, and scalar, complex or vector. */ bool @@ -2850,7 +2850,7 @@ zerop (const_tree expr) || fixed_zerop (expr)); } -/* Return 1 if EXPR is the integer constant zero or a complex constant +/* Return true if EXPR is the integer constant zero or a complex constant of zero, or a location wrapper for such a constant. */ bool @@ -2874,7 +2874,7 @@ integer_zerop (const_tree expr) } } -/* Return 1 if EXPR is the integer constant one or the corresponding +/* Return true if EXPR is the integer constant one or the corresponding complex constant, or a location wrapper for such a constant. */ bool @@ -2898,9 +2898,9 @@ integer_onep (const_tree expr) } } -/* Return 1 if EXPR is the integer constant one. For complex and vector, - return 1 if every piece is the integer constant one. - Also return 1 for location wrappers for such a constant. */ +/* Return true if EXPR is the integer constant one. For complex and vector, + return true if every piece is the integer constant one. + Also return true for location wrappers for such a constant. */ bool integer_each_onep (const_tree expr) @@ -2914,8 +2914,8 @@ integer_each_onep (const_tree expr) return integer_onep (expr); } -/* Return 1 if EXPR is an integer containing all 1's in as much precision as - it contains, or a complex or vector whose subparts are such integers, +/* Return true if EXPR is an integer containing all 1's in as much precision + as it contains, or a complex or vector whose subparts are such integers, or a location wrapper for such a constant. */ bool @@ -2940,8 +2940,8 @@ integer_all_onesp (const_tree expr) == wi::to_wide (expr)); } -/* Return 1 if EXPR is the integer constant minus one, or a location wrapper - for such a constant. */ +/* Return true if EXPR is the integer constant minus one, or a location + wrapper for such a constant. */ bool integer_minus_onep (const_tree expr) @@ -2955,8 +2955,8 @@ integer_minus_onep (const_tree expr) return integer_all_onesp (expr); } -/* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only - one bit on), or a location wrapper for such a constant. */ +/* Return true if EXPR is an integer constant that is a power of 2 (i.e., has + only one bit on), or a location wrapper for such a constant. */ bool integer_pow2p (const_tree expr) @@ -2974,7 +2974,7 @@ integer_pow2p (const_tree expr) return wi::popcount (wi::to_wide (expr)) == 1; } -/* Return 1 if EXPR is an integer constant other than zero or a +/* Return true if EXPR is an integer constant other than zero or a complex constant other than zero, or a location wrapper for such a constant. */ @@ -2990,10 +2990,10 @@ integer_nonzerop (const_tree expr) || integer_nonzerop (TREE_IMAGPART (expr))))); } -/* Return 1 if EXPR is the integer constant one. For vector, - return 1 if every piece is the integer constant minus one +/* Return true if EXPR is the integer constant one. For vector, + return true if every piece is the integer constant minus one (representing the value TRUE). - Also return 1 for location wrappers for such a constant. */ + Also return true for location wrappers for such a constant. */ bool integer_truep (const_tree expr) @@ -3005,7 +3005,7 @@ integer_truep (const_tree expr) return integer_onep (expr); } -/* Return 1 if EXPR is the fixed-point constant zero, or a location wrapper +/* Return true if EXPR is the fixed-point constant zero, or a location wrapper for such a constant. */ bool @@ -3152,9 +3152,9 @@ tree_ctz (const_tree expr) } } -/* Return 1 if EXPR is the real constant zero. Trailing zeroes matter for - decimal float constants, so don't return 1 for them. - Also return 1 for location wrappers around such a constant. */ +/* Return true if EXPR is the real constant zero. Trailing zeroes matter for + decimal float constants, so don't return true for them. + Also return true for location wrappers around such a constant. */ bool real_zerop (const_tree expr) @@ -3184,10 +3184,10 @@ real_zerop (const_tree expr) } } -/* Return 1 if EXPR is the real constant one in real or complex form. +/* Return true if EXPR is the real constant one in real or complex form. Trailing zeroes matter for decimal float constants, so don't return - 1 for them. - Also return 1 for location wrappers around such a constant. */ + true for them. + Also return true for location wrappers around such a constant. */ bool real_onep (const_tree expr) @@ -3211,9 +3211,9 @@ real_onep (const_tree expr) } } -/* Return 1 if EXPR is the real constant minus one. Trailing zeroes - matter for decimal float constants, so don't return 1 for them. - Also return 1 for location wrappers around such a constant. */ +/* Return true if EXPR is the real constant minus one. Trailing zeroes + matter for decimal float constants, so don't return true for them. + Also return true for location wrappers around such a constant. */ bool real_minus_onep (const_tree expr) @@ -3266,7 +3266,7 @@ real_maybe_zerop (const_tree expr) } } -/* Nonzero if EXP is a constant or a cast of a constant. */ +/* True if EXP is a constant or a cast of a constant. */ bool really_constant_p (const_tree exp) @@ -3381,7 +3381,7 @@ chain_index (int idx, tree chain) return chain; } -/* Return nonzero if ELEM is part of the chain CHAIN. */ +/* Return true if ELEM is part of the chain CHAIN. */ bool chain_member (const_tree elem, const_tree chain) @@ -4099,11 +4099,11 @@ contains_placeholder_p (const_tree exp) enum tree_code code; if (!exp) - return 0; + return false; code = TREE_CODE (exp); if (code == PLACEHOLDER_EXPR) - return 1; + return true; switch (TREE_CODE_CLASS (code)) { @@ -4138,7 +4138,7 @@ contains_placeholder_p (const_tree exp) case SAVE_EXPR: /* The save_expr function never wraps anything containing a PLACEHOLDER_EXPR. */ - return 0; + return false; default: break; @@ -4152,7 +4152,7 @@ contains_placeholder_p (const_tree exp) return (CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0)) || CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 1))); default: - return 0; + return false; } case tcc_vl_exp: @@ -4164,17 +4164,17 @@ contains_placeholder_p (const_tree exp) const_call_expr_arg_iterator iter; FOR_EACH_CONST_CALL_EXPR_ARG (arg, iter, exp) if (CONTAINS_PLACEHOLDER_P (arg)) - return 1; - return 0; + return true; + return false; } default: - return 0; + return false; } default: - return 0; + return false; } - return 0; + return false; } /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR @@ -5792,7 +5792,7 @@ tree_map_base_hash (const void *item) purposes. We simply return true if the from tree is marked, so that this structure goes away when the from tree goes away. */ -int +bool tree_map_base_marked_p (const void *p) { return ggc_marked_p (((const struct tree_map_base *) p)->from); @@ -6088,7 +6088,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) TYPE_ATTRIBUTES (b->type)) || (TREE_CODE (a->type) != COMPLEX_TYPE && TYPE_NAME (a->type) != TYPE_NAME (b->type))) - return 0; + return false; /* Be careful about comparing arrays before and after the element type has been completed; don't compare TYPE_ALIGN unless both types are @@ -6096,7 +6096,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) if (COMPLETE_TYPE_P (a->type) && COMPLETE_TYPE_P (b->type) && (TYPE_ALIGN (a->type) != TYPE_ALIGN (b->type) || TYPE_MODE (a->type) != TYPE_MODE (b->type))) - return 0; + return false; switch (TREE_CODE (a->type)) { @@ -6106,7 +6106,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) case POINTER_TYPE: case REFERENCE_TYPE: case NULLPTR_TYPE: - return 1; + return true; case VECTOR_TYPE: return known_eq (TYPE_VECTOR_SUBPARTS (a->type), @@ -6120,7 +6120,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) && TREE_CODE (TYPE_VALUES (b->type)) == TREE_LIST && type_list_equal (TYPE_VALUES (a->type), TYPE_VALUES (b->type)))) - return 0; + return false; /* fall through */ @@ -6152,7 +6152,7 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) && type_list_equal (TYPE_ARG_TYPES (a->type), TYPE_ARG_TYPES (b->type))))) break; - return 0; + return false; case ARRAY_TYPE: /* Don't compare TYPE_TYPELESS_STORAGE flag on aggregates, where the flag should be inherited from the element type @@ -6187,16 +6187,16 @@ type_cache_hasher::equal (type_hash *a, type_hash *b) && type_list_equal (TYPE_ARG_TYPES (a->type), TYPE_ARG_TYPES (b->type)))) break; - return 0; + return false; default: - return 0; + return false; } if (lang_hooks.types.type_hash_eq != NULL) return lang_hooks.types.type_hash_eq (a->type, b->type); - return 1; + return true; } /* Given TYPE, and HASHCODE its hash code, return the canonical @@ -6355,17 +6355,17 @@ type_argument_type (const_tree fntype, unsigned argno) return NULL_TREE; } -/* Nonzero if integer constants T1 and T2 +/* True if integer constants T1 and T2 represent the same constant value. */ -int +bool tree_int_cst_equal (const_tree t1, const_tree t2) { if (t1 == t2) - return 1; + return true; if (t1 == 0 || t2 == 0) - return 0; + return false; STRIP_ANY_LOCATION_WRAPPER (t1); STRIP_ANY_LOCATION_WRAPPER (t2); @@ -6373,9 +6373,9 @@ tree_int_cst_equal (const_tree t1, const_tree t2) if (TREE_CODE (t1) == INTEGER_CST && TREE_CODE (t2) == INTEGER_CST && wi::to_widest (t1) == wi::to_widest (t2)) - return 1; + return true; - return 0; + return false; } /* Return true if T is an INTEGER_CST whose numerical value (extended @@ -7978,7 +7978,7 @@ tree get_narrower (tree op, int *unsignedp_ptr) { int uns = 0; - int first = 1; + bool first = true; tree win = op; bool integral_p = INTEGRAL_TYPE_P (TREE_TYPE (op)); @@ -8026,7 +8026,7 @@ get_narrower (tree op, int *unsignedp_ptr) if a zero extension has been stripped, only zero-extensions. */ else if (uns != TYPE_UNSIGNED (TREE_TYPE (op))) break; - first = 0; + first = false; } else /* bitschange == 0 */ { @@ -8034,7 +8034,7 @@ get_narrower (tree op, int *unsignedp_ptr) preserve the unsignedness. */ if (first) uns = TYPE_UNSIGNED (TREE_TYPE (op)); - first = 0; + first = false; op = TREE_OPERAND (op, 0); /* Keep trying to narrow, but don't assign op to win if it would turn an integral type into something else. */ @@ -11194,19 +11194,19 @@ lower_bound_in_type (tree outer, tree inner) } } -/* Return nonzero if two operands that are suitable for PHI nodes are +/* Return true if two operands that are suitable for PHI nodes are necessarily equal. Specifically, both ARG0 and ARG1 must be either SSA_NAME or invariant. Note that this is strictly an optimization. That is, callers of this function can directly call operand_equal_p and get the same result, only slower. */ -int +bool operand_equal_for_phi_arg_p (const_tree arg0, const_tree arg1) { if (arg0 == arg1) - return 1; + return true; if (TREE_CODE (arg0) == SSA_NAME || TREE_CODE (arg1) == SSA_NAME) - return 0; + return false; return operand_equal_p (arg0, arg1, 0); } @@ -11825,7 +11825,7 @@ cl_option_hasher::equal (tree x, tree y) const_tree const yt = y; if (TREE_CODE (xt) != TREE_CODE (yt)) - return 0; + return false; if (TREE_CODE (xt) == OPTIMIZATION_NODE) return cl_optimization_option_eq (TREE_OPTIMIZATION (xt), diff --git a/gcc/tree.h b/gcc/tree.h index f11c758afb9..213a097ab55 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4810,7 +4810,7 @@ extern bool vec_member (const_tree, vec *); extern tree chain_index (int, tree); /* Arguments may be null. */ -extern int tree_int_cst_equal (const_tree, const_tree); +extern bool tree_int_cst_equal (const_tree, const_tree); /* The following predicates are safe to call with a null argument. */ extern bool tree_fits_shwi_p (const_tree) ATTRIBUTE_PURE; @@ -5418,7 +5418,7 @@ extern bool operation_can_overflow (enum tree_code); extern bool operation_no_trapping_overflow (tree, enum tree_code); extern tree upper_bound_in_type (tree, tree); extern tree lower_bound_in_type (tree, tree); -extern int operand_equal_for_phi_arg_p (const_tree, const_tree); +extern bool operand_equal_for_phi_arg_p (const_tree, const_tree); extern tree create_artificial_label (location_t); extern const char *get_name (tree); extern bool stdarg_p (const_tree); @@ -5662,7 +5662,7 @@ extern tree component_ref_size (tree, special_array_member * = NULL); extern int tree_map_base_eq (const void *, const void *); extern unsigned int tree_map_base_hash (const void *); -extern int tree_map_base_marked_p (const void *); +extern bool tree_map_base_marked_p (const void *); extern void DEBUG_FUNCTION verify_type (const_tree t); extern bool gimple_canonical_types_compatible_p (const_tree, const_tree, bool trust_type_canonical = true);