From patchwork Fri Jan 19 21:55:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoni Boucher X-Patchwork-Id: 189682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1302192dyb; Fri, 19 Jan 2024 13:56:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI+bY3ASAdcJsjEoiHv/rcjqigwwX/Y1xyLWdD781JMHd829s2l6Jd01qivewq4QN51aYN X-Received: by 2002:a05:620a:120c:b0:783:8d3e:db1a with SMTP id u12-20020a05620a120c00b007838d3edb1amr567789qkj.123.1705701417137; Fri, 19 Jan 2024 13:56:57 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1705701417; cv=pass; d=google.com; s=arc-20160816; b=hlPk5jKaHMNtsij6WXc+dL/gQq7V1fmiVBc8xjL1EOVMoQ8wXSZ7WF2qfaI+x2Q8ay /lCRYr8syCGOL4SoW5FmPgqEinPwNlaGXuZvAa9Y6v4sHWUH0qyjQlJF0hrpf/eclY1L snaFXcNjQUpavyEq2uIpCsC+oprT15XrA0eP48vnCJM/oPsBdr3mEYzOKvwRnOgJeuIl n7Zu4U1dF7FdtxkdsWLGl/jcZyyly8L4oLZ+v6TWRNAzaItwwK+0OuEpswGnZP4eR0H7 rD+s6n4/T5Xbu0NsBC2zuxZLaZtRIW4nRiSY+qbCYBamWGhNpATpzMrPtyGmovTd7em2 L/2Q== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id:mime-version :user-agent:autocrypt:date:to:from:subject:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=BJXB3qlJXjXA4kewZXb4QGTlrqvX4s+pxtP7NNAYDz0=; fh=czqxGZch5Vgice/quVb40eaDbwlGuL9Rbdl1KDXzwKY=; b=psVgaY0KLLmthyUQdsk5E9N28dPEZDcnqPPiOn7jsSi1OygwnKC9Pc92k86Z7K1zPk 3tjJtnIABWH3oe/f7w7oMn3rxWCp1wmplgLHQkhd/tZr5u9SX9adwO1T7K+zes7/Hg9Z tBYodMG+I7mhxkhNgMWZlBRYrAXo/5mns2xhj8fZlKbS04AafzEzorYr6qqaFfVsgl9v brIofgSkD9ZgZa6r23g5uUdz5cjmhTNIqr4t0ehBBHUie+qKs3cLPMBt+NqGmjJo3xC+ RQ0gAvsp1ufIi4QzAdZ9yp6OdHW08B3wpaByyutdB92vzswP/vgZmCSHbz+Igq+Pfh54 bQ8A== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b="C/KNjdjG"; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m20-20020a05620a291400b0078386bb4b8fsi172869qkp.689.2024.01.19.13.56.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 13:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b="C/KNjdjG"; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 410013858408 for ; Fri, 19 Jan 2024 21:56:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sender4-pp-o90.zoho.com (sender4-pp-o90.zoho.com [136.143.188.90]) by sourceware.org (Postfix) with ESMTPS id B4953385829D; Fri, 19 Jan 2024 21:55:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4953385829D Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=zoho.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zoho.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4953385829D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.188.90 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705701358; cv=pass; b=vjPC8QXiPTUZTvTyANkAF57NXsOA0Zi7CmBcVBRslnrdEnnt3f2S5bVjVCCWf7wnPFk/N8Gtt1eVyRNA21vFYXlPJD+4yrVXlKlS/FoFNLg+0gCj3ZHa0wJl/sIvGxmW86mP2HIwrQ3AZEQT9o/s2C1Af126YZp0AwtWgoFiFgU= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705701358; c=relaxed/simple; bh=F7Cqk3LaoHVUewU8jKVka6dKBc9GJy2142z8KBRxZOs=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=HpWBQvr6oVZ9UfgTSSJyYa1OqJQwfS0bPm4RprjVc3yAa/beZJNE4vzugLgfzIhKWGxPf9n2Uhv9Edvc+PwWVH59fxW/nFOmDM6vDVff9inZd9Qx9/lkUeMhofq+e4QrnYFtRld2R2Ldb3Vo6U33Q+jFSC46jJvC0bNqyrppM38= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1705701355; cv=none; d=zohomail.com; s=zohoarc; b=C28uJ17OR1rAnUO0QrT+a8iSIL93yshv0bglDW5npz+bqbISeCfiDSpJO416G1ItHQf7d6EaW8FBc+cG5+NeMU1OG1FcQtJQWpJGm56S5M97WIb7jN3zPWaowWfxHAwWnHo8I0JgaT6p+KnQ/1Glv13kdFgN/mHHBKcHGCLsP7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705701355; h=Content-Type:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=BJXB3qlJXjXA4kewZXb4QGTlrqvX4s+pxtP7NNAYDz0=; b=PiHIm5j+gD+uHh/Ed5p6nr/aTX+HZmDao7NqcIdmHot86WqO4Erhxz+aCMUWQA04hcc+o92PUxzRBjl+fOuaVZTh6rj32+w9yQVdLUVeZgqluvp1Fg7mSv3Z7W15KSMD/k69QfkdTbHF1+yXWM2Ri9N09sJq38lf7L351egpeOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1705701355; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Subject:Subject:From:From:To:To:Date:Date:Content-Type:MIME-Version:Feedback-ID:Message-Id:Reply-To:Cc; bh=BJXB3qlJXjXA4kewZXb4QGTlrqvX4s+pxtP7NNAYDz0=; b=C/KNjdjGpYaQRnqbk3AfKeb3CcvCwHgyI515a3S26aa1HesYHlcQlb++dKkyV+Mq tvNpmXR3z2oMO6UlJb1tLZVUWfVE4+Qp7PxTgrG7UXq+qyvcpQqZ2ZwZi7jryc8nWXy FVcKtX7+UlL9+/7cQDsMYERtV3CseyL1du4XIyHk= Received: from [192.168.1.172] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1705701354010226.5624004664977; Fri, 19 Jan 2024 13:55:54 -0800 (PST) Message-ID: Subject: [PATCH] libgccjit: Allow comparing array types From: Antoni Boucher To: "jit@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" Date: Fri, 19 Jan 2024 16:55:52 -0500 Autocrypt: addr=bouanto@zoho.com; prefer-encrypt=mutual; keydata=mQENBFOSMLQBCADO5aw6Ys8thMQUNzrwAnfJX2wbgWiz0pQ01DjYj22eeIpChkoZn6LWdt4dieq30u2rFi/yQzJ02foHwI2+aL9rU6xz/x4TwqyRJQGMOqklNc3R+pdXmH4WDQkQDWmLxvc07vu+zb8Tx5A6pMDh4J2ncCEhLEUcH39Yq/yg4eBnFwUX6N7kakvHrnScGNqhnSFCacoJeMJUAR+1G7VBSBd++jmnHLnx3mj7QkRZVECJUw2zqiv1yReCC6GU4SvqLjdqm5ZGeoWOqD/NHjBRoEeOVjzp6M/qOjjWRbkJVqmvgfcD8UytSSqqboR35YFT4L+rZt2ri3T12MJb3i5syCAXABEBAAG0IUFudG9uaSBCb3VjaGVyIDxib3VhbnRvQHpvaG8uY29tPokBVgQTAQgAQAIbIwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QM4FCRLMEZoACgkQRVeGAwR4zcFBQQf/afttJrA/puADQZhrDfkgr0MFvq6iB+GCy1b8BkXimk1TOXTPt87YLehSeijNu3JkYhl5eRc87BNfU9J87KfI/KIy6hZxqlDXk16FhW9bw/7wYEA0hpb3MUn7xLElXDT0ZHaD+KTe8Oun7qfzgx5RlL6r/WODf3CkSpO085R/rfeBqDEx9mVlhDWgq6Az3CZoD+3CqiCKVqmDuHTWz4kwrd9AM5eVcLvvLKnZIdoIp+G5Ao6BvaGlZyfenN1iOSjLy2NXNt4MnUt0lUYEP5KSIIRhHQ8xkUbj7eWUmaahkxhNb3fH3sAPwGnRZrPpb4rgYzNmSk63wWMh9M2xk+rLb7kBDQRTkjC0AQgAumZzsAV/UFWI+dpzebQfma36kKYZZFuseant5sq/HWP553XQ/U6ttJiKyN5MpCqtxvCAoRplf42YhlHuFqgf73WJxoJ6Y+sdyqoBSwlR+ gzAneAmsa8gmmY0wawH0Z2leazjKuS7mJjVEQZg0ZGsiCVRGeRnDqFGzDEzDc9ngWKSoTq0fKzlGy1X85OrtmUrvEbhSo6HP+FoeunHkIqrxu3w3vDoFEXxVQlKI6V3I4nCz5n6DB8WR3L7nsiiTnOiGirPw1ngvWFLW86kkA4FJpayc8Xl3va3SLY+2y4yuROboX2DVI4AC/Qeug/mDiBicPxkP6YfUartQRMe6obkEQARAQABiQE8BBgBCAAmAhsMFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QRsFCRLMEecACgkQRVeGAwR4zcE56ggAgTgrJInBKC+7552Dpccuo6Clh3wZfjlNLv9/6r5lKEbaNzaTrfhPiAP4WgnluIUmj8amOFLFJpj+BAVNOXpZ4D2R3o9ch8z7fot+fW4Yw+PKIxH4I2xEys8ndoEB3aiQwHjKcGIhkIU7uyMJFQr2aWjdTY0gmXw0YZueHOSLgo7uX4XKxB8fEO/yto/Tff2YBAAq+AtNwt+Gh5YS9rZw7rwUTWMi84yVOlc+zRE79E9NJkvdTwX7IJYo64VzIRNfgHsn7QNdVzuM1XIFHl+Glk6cIlI8s6BO7nEoCn3hTF104fQTAO3fEs+XXZOKXo2lk8faowEoPq5r58StrV0nyg== User-Agent: Evolution 3.50.3 MIME-Version: 1.0 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-1.1.0/204.902.92 Feedback-ID: rr080112286682a12add073ba4b8fac13d0000c68ab47881b03e798de105ebdf8d1bab14c941a114b3e3cb1cce:zu080112268aaffd418ab659d6616b3b110000870d1a222f2b05cc88ba7384d9a85281c7f1ca231858580c:rf0801123211690267c3cf6767e1d7b21000006c18d125db0f35df26267496406642a540183704456d1e881c49529d53d0d21a9f9a5b64:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-11.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788557569389177555 X-GMAIL-MSGID: 1788557569389177555 Hi. This patch allows comparing different instances of array types as equal. Thanks for the review. From ef4afd9de440f10502f3cc84b2112cf83cde2610 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 2 Jan 2024 16:04:10 -0500 Subject: [PATCH] libgccjit: Allow comparing array types gcc/jit/ChangeLog: * jit-common.h: Add array_type class. * jit-recording.h (type::dyn_cast_array_type, memento_of_get_aligned::dyn_cast_array_type, array_type::dyn_cast_array_type, array_type::is_same_type_as): New methods. gcc/testsuite/ChangeLog: * jit.dg/test-types.c: Add array type comparison to the test. --- gcc/jit/jit-common.h | 1 + gcc/jit/jit-recording.h | 17 +++++++++++++++++ gcc/testsuite/jit.dg/test-types.c | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/gcc/jit/jit-common.h b/gcc/jit/jit-common.h index 80c1618da96..57a667e6d12 100644 --- a/gcc/jit/jit-common.h +++ b/gcc/jit/jit-common.h @@ -118,6 +118,7 @@ namespace recording { class struct_; class union_; class vector_type; + class array_type; class field; class bitfield; class fields; diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 4a8082991fb..df33ce219fc 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -545,6 +545,7 @@ public: virtual function_type *as_a_function_type() { gcc_unreachable (); return NULL; } virtual struct_ *dyn_cast_struct () { return NULL; } virtual vector_type *dyn_cast_vector_type () { return NULL; } + virtual array_type *dyn_cast_array_type () { return NULL; } /* Is it typesafe to copy to this type from rtype? */ virtual bool accepts_writes_from (type *rtype) @@ -810,6 +811,11 @@ public: void replay_into (replayer *) final override; + array_type *dyn_cast_array_type () final override + { + return m_other_type->dyn_cast_array_type (); + } + private: string * make_debug_string () final override; void write_reproducer (reproducer &r) final override; @@ -868,6 +874,17 @@ class array_type : public type type *dereference () final override; + bool is_same_type_as (type *other) final override + { + array_type *other_array_type = other->dyn_cast_array_type (); + if (!other_array_type) + return false; + return m_num_elements == other_array_type->m_num_elements + && m_element_type->is_same_type_as (other_array_type->m_element_type); + } + + array_type *dyn_cast_array_type () final override { return this; } + bool is_int () const final override { return false; } bool is_float () const final override { return false; } bool is_bool () const final override { return false; } diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c index a01944e35fa..79f7ea21026 100644 --- a/gcc/testsuite/jit.dg/test-types.c +++ b/gcc/testsuite/jit.dg/test-types.c @@ -492,4 +492,9 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float)); CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double)); + + gcc_jit_type *int_type = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); + gcc_jit_type *array_type1 = gcc_jit_context_new_array_type (ctxt, NULL, int_type, 2); + gcc_jit_type *array_type2 = gcc_jit_context_new_array_type (ctxt, NULL, int_type, 2); + CHECK (gcc_jit_compatible_types (array_type1, array_type2)); } -- 2.43.0