From patchwork Tue Aug 13 16:39:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1972020 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WjxvZ65BHz1yYl for ; Wed, 14 Aug 2024 02:40:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7C2E385828E for ; Tue, 13 Aug 2024 16:40:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 32D3A3858289 for ; Tue, 13 Aug 2024 16:40:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32D3A3858289 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 32D3A3858289 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723567205; cv=none; b=HGLYKrsaPPOuLW7xLlqIRKCFUf8+Nre3k8VslYoeI27poJZi/12aftnmZuWeKXj/ZiGo9fphqOjLnazzdpCpYD/JyehGoSVgOF/pxFb02alP34vbLolPz7lfKEojdVVykn6aYeOwKOgDcn3FCifjQvuH/MI/M9BvEc3QGQnZPiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723567205; c=relaxed/simple; bh=TVpWlLXs4OHDnBQ7ETXuMViYqldK+P2XzQ8xBWiPnro=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=VCiD/zCMe09i18CVr2ZWz/0chTEMVaG95p1cAeo+ezrh73Zoi6AUvdLka/MKMrfg7yGr5cl0iT4dHT7TEdpEILduDjfRpgltK1xzZ75hE3tYNIAFgkeJQ0f6nER3jL8W9AypZhraMJlZeH7qtMciBeT8F3V8W2O5lpunoAPifrE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E2FBC12FC; Tue, 13 Aug 2024 09:40:28 -0700 (PDT) Received: from [10.57.67.195] (unknown [10.57.67.195]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 88EC13F6A8; Tue, 13 Aug 2024 09:40:02 -0700 (PDT) Message-ID: Date: Tue, 13 Aug 2024 17:39:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches@gcc.gnu.org, Richard.Sandiford@arm.com From: "Andre Vieira (lists)" Subject: rtl: Enable the use of rtx values with int and mode attributes X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, The 'code' part of a 'define_code_attr' refers to the type of the key, in other words, it uses a code_iterator to pick the value from their (key "value") pair list. Though it seems rtx_alloc_for_name requires a code_attribute to be used when the 'value' needs to be a type. In other words, no other type of attributes can be used to produce a rtx typed 'value'. This patch removes that restriction and allows the backend to use any kind of attribute as long as that attribute always produces a valid code typed 'value'. I also made some local, nonsense changes to test whether other attributes could be used regardless of type, for instance use an int attribute to produce modes: +(define_int_iterator TEST_ITERATOR [UNSPEC_CALLEE_ABI UNSPEC_ABS]) +(define_int_attr test_attr [(UNSPEC_CALLEE_ABI "DI") (UNSPEC_ABS "SI")]) +  (define_insn "*sibcall_insn"    [(call (mem:DI (match_operand:DI 0 "aarch64_call_insn_operand" "Ucs, Usf")) (match_operand 1 "")) -   (unspec:DI [(match_operand:DI 2 "const_int_operand")] UNSPEC_CALLEE_ABI) +   (unspec: [(match_operand: 2 "const_int_operand")] TEST_ITERATOR)     (return)] or a mode attribute to produce ints: +(define_mode_attr test_mode_attr [(HF "0") (SF "0") (DF "0")]) +  (define_split    [(set (match_operand:GPF_HF 0 "nonimmediate_operand")         (match_operand:GPF_HF 1 "const_double_operand"))]    "can_create_pseudo_p ()     && !aarch64_can_const_movi_rtx_p (operands[1], mode)     && !aarch64_float_const_representable_p (operands[1])     && !aarch64_float_const_zero_rtx_p (operands[1])     &&  aarch64_float_const_rtx_p (operands[1])" -  [(const_int 0)] +  [(const_int )] These all build fine.  Which makes me think this change would be consistent with other attributes. Bootstrapped and regression tested aarch64-linux-gnu and x86_64-linux-gnu. OK for trunk? gcc/ChangeLog:     * read-rtl.cc (rtx_reader::rtx_alloc_for_name): Allow all attribute     types to produce code 'values'.     (check_code_attribute): Rename ...     (check_attribute_codes): ... to this.  And change comments to refer to     any type of iterator. diff --git a/gcc/read-rtl.cc b/gcc/read-rtl.cc index 4f09e449c81fb3d05bc566e6b9fb1787f4b3e31b..a6d0d41535d5db41bd3110c03a970cb451ea0706 100644 --- a/gcc/read-rtl.cc +++ b/gcc/read-rtl.cc @@ -1423,21 +1423,21 @@ check_code_iterator (struct mapping *iterator) consistent format. Return a representative code. */ static rtx_code -check_code_attribute (mapping *attr) +check_attribute_codes (mapping *attr) { rtx_code bellwether = UNKNOWN; for (map_value *v = attr->values; v != 0; v = v->next) { rtx_code code = maybe_find_code (v->string); if (code == UNKNOWN) - fatal_with_file_and_line ("code attribute `%s' contains " + fatal_with_file_and_line ("attribute `%s' contains " "unrecognized rtx code `%s'", attr->name, v->string); if (bellwether == UNKNOWN) bellwether = code; else if (strcmp (GET_RTX_FORMAT (bellwether), GET_RTX_FORMAT (code)) != 0) - fatal_with_file_and_line ("code attribute `%s' combines " + fatal_with_file_and_line ("attribute `%s' combines " "`%s' and `%s', which have different " "rtx formats", attr->name, GET_RTX_NAME (bellwether), @@ -1604,7 +1604,7 @@ parse_reg_note_name (const char *string) fatal_with_file_and_line ("unrecognized REG_NOTE name: `%s'", string); } -/* Allocate an rtx for code NAME. If NAME is a code iterator or code +/* Allocate an rtx for code NAME. If NAME is a code iterator or an attribute, record its use for later and use one of its possible values as an interim rtx code. */ @@ -1629,11 +1629,15 @@ rtx_reader::rtx_alloc_for_name (const char *name) /* Find the attribute itself. */ mapping *m = (mapping *) htab_find (codes.attrs, &attr); if (!m) - fatal_with_file_and_line ("unknown code attribute `%s'", attr); + m = (mapping *) htab_find (ints.attrs, &attr); + if (!m) + m = (mapping *) htab_find (modes.attrs, &attr); + if (!m) + fatal_with_file_and_line ("unknown attribute `%s'", attr); /* Pick the first possible code for now, and record the attribute use for later. */ - rtx x = rtx_alloc (check_code_attribute (m)); + rtx x = rtx_alloc (check_attribute_codes (m)); record_attribute_use (&codes, get_current_location (), x, 0, deferred_name); return x;