From patchwork Wed Sep 6 22:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 137600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2607551vqo; Wed, 6 Sep 2023 15:33:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOA0iiHL1uYk4ErrhcNJ3IVVFgdps/KhjsOHwMTRKzY2+m3OWWdHuw5Tsvd2eHRwLfoPMV X-Received: by 2002:a5d:56cf:0:b0:319:7c0f:d920 with SMTP id m15-20020a5d56cf000000b003197c0fd920mr3445055wrw.57.1694039626411; Wed, 06 Sep 2023 15:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694039626; cv=none; d=google.com; s=arc-20160816; b=NB88vHHLsTbjhpWTR/aa33lyspnLwyV2s9Zo828hmJ2c56BDWq6foCifxQyYVfdE+j VgAitfuVyGmS6DPCMhhuHaozkH15OMk/6vPlp3+cfzoCsUTdZto7xMQ5TF11teyADUzj C/YvcG7GnHM3iHpvmRYv8/6f9fPlF3wXFv8hFCnT3dAjOoj0/VYXlzZmX54/Nt/WCqs6 G7L0BNDGNqrxrV3mzIg2TwFEfBxE1mSPDw05W0VfxO/HMFK8lYomCNJJ5xBqell1pxPt YwDE6JGwMv1hjP2ACKdkPdXtrsVM8JcTaU0WmC+5ptqHtQw3UsILQ8FZWZcpXMRUeXiR if6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=ZU4lGYIgk8YkjdubxtlyXRwRp02MP5C6b5w8M+rHRCE=; fh=8G0fvw9kezX2+yjwifXgHvTII1omy92vRpR1R+rFCOA=; b=Xsgd6q99dfCsDSmf+dnyYSv2lwcn5T9L9gHX89b5NhLWc4oFf51nlUjelNhDxGGE+z SoV8O4qKZlt/sC30vF9QGWtC6Dr5siwsl3sWSVJEKL3S51qu4Gr6iNfUXkwe21wrkASI 9imIrw1HA91DvNW7NUD5t4NpFuQvkEjBuquooFDAJtPuhb5OrTHnoxkIiLlT47+OL25P 39WmvfvKP2gSox8azohOzmFBDbRVBvTdZEMWAOVF+jYFlfkyqExfYzgzMlJxBxjTdcfm OMkzEhqaywNgB3uKDbLVrmrmWzGA1KQXZAebdni+ZkPlYvvQlqNdMFB/exwt/pwrw+Pk eaeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=LlCcgpSe; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c15-20020aa7c98f000000b0052c235ca6e6si9601496edt.666.2023.09.06.15.33.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 15:33:46 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=LlCcgpSe; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17D9C3858000 for ; Wed, 6 Sep 2023 22:33:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17D9C3858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694039625; bh=ZU4lGYIgk8YkjdubxtlyXRwRp02MP5C6b5w8M+rHRCE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LlCcgpSeZuTrjJU7jHBlS3mymCxknWgjvWMmZ9wbglCiM5DdDIsnUDX7ZIzOJE8y5 KACBqpZnms/Gh9D2iTzhdq4JvsOA/frfvM3WhGIq2aBwxSYKcOF61Se8h7wkuUja/L FjkLx8Rk4oBgy3IFYGW7FFZ+Fn2lqlab86pMq5tE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 23AB13858C66 for ; Wed, 6 Sep 2023 22:33:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23AB13858C66 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-26f6b2c8e80so255823a91.1 for ; Wed, 06 Sep 2023 15:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694039579; x=1694644379; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZU4lGYIgk8YkjdubxtlyXRwRp02MP5C6b5w8M+rHRCE=; b=VXQDrPZdJv3fDwHAJhtnNLvB8MV2ljX+/NALDbn3OgbxNUxB40pCaXx1l8FvfWA8Qw m6qaKLNWPezmrH1iswMy7WmW08+O6OcfpolFz0Wf2HbNFj9+0TrFA1VdsRxVs/k5ToaP 6XWj2iqBwzeFVCAkiaNAeLjAoZ795EBEh3Cx6mlkDUNSndUKzwsg1vQCwYXCregDmeXg 1j/OzTYLrEoG73A9OFEC2KHs07gGyNEa1mg7LpMGqUuKmszsuRoa3aAxEeJegopLT6w5 Y1DjH950zZor2/CrAgkmdNrLJxJH+LS1uwP2YcO+pzyK0/d4u6cQvqCFIC50iVfANc98 lz5g== X-Gm-Message-State: AOJu0YzOZ7N48pSbLTNGZh4i2WUevm2oiw8k2FFWema1ULa15jTuQ1JI T/58fMJuXM62v/yShghRW3zVIBwCkJamt9v2+sS5hJjU66IDwLGV5hE= X-Received: by 2002:a17:90a:7c07:b0:26d:124e:571a with SMTP id v7-20020a17090a7c0700b0026d124e571amr17208201pjf.26.1694039579542; Wed, 06 Sep 2023 15:32:59 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 6 Sep 2023 15:32:47 -0700 Message-ID: Subject: godump.cc patch committed: Handle _BitInt To: gcc-patches X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: , X-Patchwork-Original-From: Ian Lance Taylor via Gcc-patches From: Ian Lance Taylor Reply-To: Ian Lance Taylor Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776329295138063890 X-GMAIL-MSGID: 1776329295138063890 This patch to godump.cc adds support for BITINT_TYPE. Bootstrapped and ran godump and Go tests on x86_64-pc-linux-gnu. Committed to mainline. Ian gcc/ PR go/111310 * godump.cc (go_format_type): Handle BITINT_TYPE. gcc/testsuite/ PR go/111310 * gcc.misc-tests/godump-1.c: Add _BitInt test cases. diff --git a/gcc/godump.cc b/gcc/godump.cc index 0893d5fbc97..bdd2d108d76 100644 --- a/gcc/godump.cc +++ b/gcc/godump.cc @@ -760,6 +760,25 @@ go_format_type (class godump_container *container, tree type, } break; + case BITINT_TYPE: + { + const char *s; + char buf[100]; + + s = go_get_uinttype_for_precision (TYPE_PRECISION (type), + TYPE_UNSIGNED (type)); + if (s == NULL) + { + snprintf (buf, sizeof buf, "INVALID-bitint-%u%s", + TYPE_PRECISION (type), + TYPE_UNSIGNED (type) ? "u" : ""); + s = buf; + ret = false; + } + obstack_grow (ob, s, strlen(s)); + } + break; + case REAL_TYPE: { const char *s; diff --git a/gcc/testsuite/gcc.misc-tests/godump-1.c b/gcc/testsuite/gcc.misc-tests/godump-1.c index 95dabdc0e4c..f359a657827 100644 --- a/gcc/testsuite/gcc.misc-tests/godump-1.c +++ b/gcc/testsuite/gcc.misc-tests/godump-1.c @@ -234,6 +234,17 @@ const char cc_v1; cc_t cc_v2; /* { dg-final { scan-file godump-1.out "(?n)^var _cc_v2 _cc_t$" } } */ +_BitInt(32) b32_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b32_v int32$" } } */ + +_BitInt(64) b64_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b64_v int64$" } } */ + +unsigned _BitInt(32) b32u_v; +/* { dg-final { scan-file godump-1.out "(?n)^var _b32u_v uint32$" } } */ + +_BitInt(33) b33_v; +/* { dg-final { scan-file godump-1.out "(?n)^// var _b33_v INVALID-bitint-33$" } } */ /*** pointer and array types ***/ typedef void *vp_t;