From patchwork Wed Jun 30 08:46:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1498802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: 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=HCDhM9Oy; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GFFND0FNYz9sW6 for ; Wed, 30 Jun 2021 18:47:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACA0B3835800 for ; Wed, 30 Jun 2021 08:47:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACA0B3835800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1625042856; bh=9g7hG83LpfXrpBJkLGsH2opsBqf3BBvHaLXJuC3T+zY=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HCDhM9OyzCSJMCg0Bzu4wPyAYrYi43am99ZKczOOOavbvVNKr8eEl169JuUb1riTW A19VE8UBJxb6JtrJRjYdIg6eXsXNLTRsiT/DMACAm/TyzBAOOh2ZQ7LQ2Ez3Tzr5kq ApQXm4yoJgMAEZlpVc1mLVGtcLHiugeVovB3r/k0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id BBAE93858D35 for ; Wed, 30 Jun 2021 08:46:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BBAE93858D35 Received: by mail-qk1-x72d.google.com with SMTP id q16so1651249qke.10 for ; Wed, 30 Jun 2021 01:46:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9g7hG83LpfXrpBJkLGsH2opsBqf3BBvHaLXJuC3T+zY=; b=YieZOlndFQ+yOGGqOSQ15/+5C/FpNBkrB8nj3OQ4wQK5jUjnON7nbYU3J4TMAXUU+A NZLNShGIUm0f3QbP7vD6RcVtCsmKfASH28LWtZPW5TzQCFQvoCUz55Lo4xcPXO5qHxe9 MuyO2wMQm/YQA7L02Nu5goOGUZIDXTGuDDzhngMFH+vntXAOoc92D10NpxxpUezR2aJ1 q6Aqv04rTauGK5uWv2JXNIB1lgYygjp85TyD7SXAsAWhaRYlL6XzT8KbVz0HeSBwUZmZ 2lp9VvL4oK+KInwECKa5Ge9cangXQEAkkH+IXHVtIsklyYDJILn+H2lLrH5WAuspLpOP Rc6g== X-Gm-Message-State: AOAM531B8TqpzomVWrXD7bcAkpZracQr5Bxn9KAa6BextW4vO/SF8ykL cQkPdGyBql+wppGiwtcWmWWlmpaAKT4QCUYgmOtd1Cy+Faq+6w== X-Google-Smtp-Source: ABdhPJymFGgE3UUxy2sh7PKS3xmrv3GIqk5v9xa8nvLjORXstpiToMannVVc0nAn7irrGKXDpCIpa17oCkwPcqXitjk= X-Received: by 2002:ae9:dd06:: with SMTP id r6mr35941775qkf.74.1625042811214; Wed, 30 Jun 2021 01:46:51 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 30 Jun 2021 10:46:50 +0200 Message-ID: Subject: [RFC PATCH] Change the type of predicates to bool. To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-9.1 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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" This RFC patch changes the type of predicates to bool. However, some of the targets (e.g. x86) use indirect functions to call the predicates, so without the local change, the build fails. Putting the patch through CI bots should weed out the problems, but I have no infrastructure to do it myself. 2021-06-30 Uroš Bizjak gcc/ * genpreds.c (write_predicate_subfunction): Change the type of written subfunction to bool. (write_one_predicate_function): Change the type of written function to bool. (write_tm_preds_h): Ditto. * recog.h (*insn_operand_predicate_fn): Change the type to bool. * recog.c (general_operand): Change the type to bool. (address_operand): Ditto. (register_operand): Ditto. (pmode_register_operand): Ditto. (scratch_operand): Ditto. (immediate_operand): Ditto. (const_int_operand): Ditto. (const_scalar_int_operand): Ditto. (const_double_operand): Ditto. (nonimmediate_operand): Ditto. (nonmemory_operand): Ditto. (push_operand): Ditto. (pop_operand): Ditto. (memory_operand): Ditto. (indirect_operand): Ditto. (ordered_comparison_operator): Ditto. (comparison_operator): Ditto. * config/i386/i386-expand.c (ix86_expand_sse_cmp): Change the type of indirect predicate function to bool. Patch was bootstrapped on x86_64-linux-gnu. Comments welcome. Uros. diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index e9763eb5b3e..76d6afd6d9d 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -3571,7 +3571,7 @@ ix86_expand_sse_cmp (rtx dest, enum rtx_code code, rtx cmp_op0, rtx cmp_op1, cmp_op0 = force_reg (cmp_ops_mode, cmp_op0); - int (*op1_predicate)(rtx, machine_mode) + bool (*op1_predicate)(rtx, machine_mode) = VECTOR_MODE_P (cmp_ops_mode) ? vector_operand : nonimmediate_operand; if (!op1_predicate (cmp_op1, cmp_ops_mode)) diff --git a/gcc/genpreds.c b/gcc/genpreds.c index 63fac0c7d34..9d9715f3d2f 100644 --- a/gcc/genpreds.c +++ b/gcc/genpreds.c @@ -110,7 +110,7 @@ process_define_predicate (md_rtx_info *info) becomes - static inline int basereg_operand_1(rtx op, machine_mode mode) + static inline bool basereg_operand_1(rtx op, machine_mode mode) { if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); @@ -151,7 +151,7 @@ write_predicate_subfunction (struct pred_data *p) p->exp = and_exp; - printf ("static inline int\n" + printf ("static inline bool\n" "%s_1 (rtx op ATTRIBUTE_UNUSED, machine_mode mode ATTRIBUTE_UNUSED)\n", p->name); rtx_reader_ptr->print_md_ptr_loc (p->c_block); @@ -651,7 +651,7 @@ write_one_predicate_function (struct pred_data *p) /* A normal predicate can legitimately not look at machine_mode if it accepts only CONST_INTs and/or CONST_WIDE_INT and/or CONST_DOUBLEs. */ - printf ("int\n%s (rtx op, machine_mode mode ATTRIBUTE_UNUSED)\n{\n", + printf ("bool\n%s (rtx op, machine_mode mode ATTRIBUTE_UNUSED)\n{\n", p->name); write_predicate_stmts (p->exp); fputs ("}\n\n", stdout); @@ -1416,7 +1416,7 @@ write_tm_preds_h (void) #ifdef HAVE_MACHINE_MODES"); FOR_ALL_PREDICATES (p) - printf ("extern int %s (rtx, machine_mode);\n", p->name); + printf ("extern bool %s (rtx, machine_mode);\n", p->name); puts ("#endif /* HAVE_MACHINE_MODES */\n"); diff --git a/gcc/recog.c b/gcc/recog.c index eb617f11163..9d880433e6f 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -1393,7 +1393,7 @@ valid_insn_p (rtx_insn *insn) return true; } -/* Return 1 if OP is a valid general operand for machine mode MODE. +/* Return true if OP is a valid general operand for machine mode MODE. This is either a register reference, a memory reference, or a constant. In the case of a memory reference, the address is checked for general validity for the target machine. @@ -1407,7 +1407,7 @@ valid_insn_p (rtx_insn *insn) The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool general_operand (rtx op, machine_mode mode) { enum rtx_code code = GET_CODE (op); @@ -1515,13 +1515,13 @@ general_operand (rtx op, machine_mode mode) return 0; } -/* Return 1 if OP is a valid memory address for a memory reference +/* Return true if OP is a valid memory address for a memory reference of mode MODE. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool address_operand (rtx op, machine_mode mode) { /* Wrong mode for an address expr. */ @@ -1532,13 +1532,13 @@ address_operand (rtx op, machine_mode mode) return memory_address_p (mode, op); } -/* Return 1 if OP is a register reference of mode MODE. +/* Return true if OP is a register reference of mode MODE. If MODE is VOIDmode, accept a register in any mode. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool register_operand (rtx op, machine_mode mode) { if (GET_CODE (op) == SUBREG) @@ -1559,18 +1559,18 @@ register_operand (rtx op, machine_mode mode) return general_operand (op, mode); } -/* Return 1 for a register in Pmode; ignore the tested mode. */ +/* Return true for a register in Pmode; ignore the tested mode. */ -int +bool pmode_register_operand (rtx op, machine_mode mode ATTRIBUTE_UNUSED) { return register_operand (op, Pmode); } -/* Return 1 if OP should match a MATCH_SCRATCH, i.e., if it is a SCRATCH +/* Return true if OP should match a MATCH_SCRATCH, i.e., if it is a SCRATCH or a hard register. */ -int +bool scratch_operand (rtx op, machine_mode mode) { if (GET_MODE (op) != mode && mode != VOIDmode) @@ -1583,12 +1583,12 @@ scratch_operand (rtx op, machine_mode mode) && REGNO_REG_CLASS (REGNO (op)) != NO_REGS)))); } -/* Return 1 if OP is a valid immediate operand for mode MODE. +/* Return true if OP is a valid immediate operand for mode MODE. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool immediate_operand (rtx op, machine_mode mode) { /* Don't accept CONST_INT or anything similar @@ -1612,9 +1612,9 @@ immediate_operand (rtx op, machine_mode mode) : mode, op)); } -/* Returns 1 if OP is an operand that is a CONST_INT of mode MODE. */ +/* Return true if OP is an operand that is a CONST_INT of mode MODE. */ -int +bool const_int_operand (rtx op, machine_mode mode) { if (!CONST_INT_P (op)) @@ -1628,9 +1628,9 @@ const_int_operand (rtx op, machine_mode mode) } #if TARGET_SUPPORTS_WIDE_INT -/* Returns 1 if OP is an operand that is a CONST_INT or CONST_WIDE_INT +/* Return true if OP is an operand that is a CONST_INT or CONST_WIDE_INT of mode MODE. */ -int +bool const_scalar_int_operand (rtx op, machine_mode mode) { if (!CONST_SCALAR_INT_P (op)) @@ -1661,20 +1661,20 @@ const_scalar_int_operand (rtx op, machine_mode mode) return 1; } -/* Returns 1 if OP is an operand that is a constant integer or constant +/* Return true if OP is an operand that is a constant integer or constant floating-point number of MODE. */ -int +bool const_double_operand (rtx op, machine_mode mode) { return (GET_CODE (op) == CONST_DOUBLE) && (GET_MODE (op) == mode || mode == VOIDmode); } #else -/* Returns 1 if OP is an operand that is a constant integer or constant +/* Return true if OP is an operand that is a constant integer or constant floating-point number of MODE. */ -int +bool const_double_operand (rtx op, machine_mode mode) { /* Don't accept CONST_INT or anything similar @@ -1689,18 +1689,19 @@ const_double_operand (rtx op, machine_mode mode) || GET_MODE (op) == VOIDmode)); } #endif -/* Return 1 if OP is a general operand that is not an immediate +/* Return true if OP is a general operand that is not an immediate operand of mode MODE. */ -int +bool nonimmediate_operand (rtx op, machine_mode mode) { return (general_operand (op, mode) && ! CONSTANT_P (op)); } -/* Return 1 if OP is a register reference or immediate value of mode MODE. */ +/* Return true if OP is a register reference or + immediate value of mode MODE. */ -int +bool nonmemory_operand (rtx op, machine_mode mode) { if (CONSTANT_P (op)) @@ -1708,13 +1709,13 @@ nonmemory_operand (rtx op, machine_mode mode) return register_operand (op, mode); } -/* Return 1 if OP is a valid operand that stands for pushing a +/* Return true if OP is a valid operand that stands for pushing a value of mode MODE onto the stack. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool push_operand (rtx op, machine_mode mode) { if (!MEM_P (op)) @@ -1752,13 +1753,13 @@ push_operand (rtx op, machine_mode mode) return XEXP (op, 0) == stack_pointer_rtx; } -/* Return 1 if OP is a valid operand that stands for popping a +/* Return true if OP is a valid operand that stands for popping a value of mode MODE off the stack. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool pop_operand (rtx op, machine_mode mode) { if (!MEM_P (op)) @@ -1794,13 +1795,13 @@ memory_address_addr_space_p (machine_mode mode ATTRIBUTE_UNUSED, #endif } -/* Return 1 if OP is a valid memory reference with mode MODE, +/* Return true if OP is a valid memory reference with mode MODE, including a valid address. The main use of this function is as a predicate in match_operand expressions in the machine description. */ -int +bool memory_operand (rtx op, machine_mode mode) { rtx inner; @@ -1820,10 +1821,10 @@ memory_operand (rtx op, machine_mode mode) return (MEM_P (inner) && general_operand (op, mode)); } -/* Return 1 if OP is a valid indirect memory reference with mode MODE; +/* Return true if OP is a valid indirect memory reference with mode MODE; that is, a memory reference whose address is a general_operand. */ -int +bool indirect_operand (rtx op, machine_mode mode) { /* Before reload, a SUBREG isn't in memory (see memory_operand, above). */ @@ -1848,10 +1849,10 @@ indirect_operand (rtx op, machine_mode mode) && general_operand (XEXP (op, 0), Pmode)); } -/* Return 1 if this is an ordered comparison operator (not including +/* Return true if this is an ordered comparison operator (not including ORDERED and UNORDERED). */ -int +bool ordered_comparison_operator (rtx op, machine_mode mode) { if (mode != VOIDmode && GET_MODE (op) != mode) @@ -1874,10 +1875,10 @@ ordered_comparison_operator (rtx op, machine_mode mode) } } -/* Return 1 if this is a comparison operator. This allows the use of +/* Return true if this is a comparison operator. This allows the use of MATCH_OPERATOR to recognize all the branch insns. */ -int +bool comparison_operator (rtx op, machine_mode mode) { return ((mode == VOIDmode || GET_MODE (op) == mode) diff --git a/gcc/recog.h b/gcc/recog.h index e96e66e99f2..653d0b08184 100644 --- a/gcc/recog.h +++ b/gcc/recog.h @@ -393,7 +393,7 @@ which_op_alt () /* A table defined in insn-output.c that give information about each insn-code value. */ -typedef int (*insn_operand_predicate_fn) (rtx, machine_mode); +typedef bool (*insn_operand_predicate_fn) (rtx, machine_mode); typedef const char * (*insn_output_fn) (rtx *, rtx_insn *); struct insn_gen_fn