Message ID | 20220824115956.737931-2-philip.herron@embecosm.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1381677wro; Wed, 24 Aug 2022 05:01:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5odmkibPe/Az/TVQfdbOPNHBG0Ry/1ph6pVzr7RS66mGOQO5wW2gLHjiwtI4B46I6Cjz/z X-Received: by 2002:a05:6402:5150:b0:447:933d:ec65 with SMTP id n16-20020a056402515000b00447933dec65mr775150edd.80.1661342494291; Wed, 24 Aug 2022 05:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661342494; cv=none; d=google.com; s=arc-20160816; b=zDaSQRWx3+M8L0FTrg53YuG6BjZ7X6QcGQCt4oEwnUKTubOOcfiS2GRsN7KmlIQUTT H5Gur+bRRxNUdEoxTQXRrAPr4P1H15luuzf110SEiJwedUcdPHO5t2rQpN16JLmmoMeh R8dgoJiNTDusgMvhswYfqVpw1OONN12fyCJJm6GLuxE9INuoc8aiPUO/P4PPgxqhz7J7 V1AVCmVIchiKceKvrLtqCe7pWW5hyqVJjWrjEMDNfme2dtRJajbS+j9kW3JruB+HriLw vd/dywtwmBaR8ldJaE+lCrOSug8L1+q1WuocEBnUevp2urNTfeKZwd4c5ZYp69HYq1Rt jUkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature:dmarc-filter :delivered-to; bh=vW+oVBrKyKiiJASPTJ3TiwNitoa8EthpxoFCyHSWd/o=; b=HDWjmnHZpu0wRsDQiqkJfGWJcL8MJdQN4EQBmMzQbcSjVmc2eenlThtFvPApsU7afQ ICf9gklWQyr5NKmlZxFEgVSdSXdsbIDLrC+vYquNhLhrcEV2fF1vMY+XCYKe7NJkH5f1 tDd7/Hm5q8T49KsMJJ0Qf9006h7Yx1e3dV30hZ8N1pNt7IzdHrs3OZ/mOn3Te/6cb7eh d2rgiLh6xZB0iWunv5ILuYez0xwQhGLFYKqxHPpTflMUaCSY8T1gxonQT2/a1m+axxjF 4RsLDOpD9oL4+GEUpAvpY+IYL6NwRlD9pR7I/oKBus7sfvkJR2ulDTNnqs6uuYXOOtFO qpSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20210112 header.b=UQJmvI3K; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c12-20020a056402120c00b004466681e6a6si3352370edw.189.2022.08.24.05.01.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:01:34 -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=@googlemail.com header.s=20210112 header.b=UQJmvI3K; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B2BF3850866 for <ouuuleilei@gmail.com>; Wed, 24 Aug 2022 12:00:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id ECB8738515FE; Wed, 24 Aug 2022 12:00:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECB8738515FE Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-wr1-x42d.google.com with SMTP id d16so15193771wrr.3; Wed, 24 Aug 2022 05:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc; bh=vW+oVBrKyKiiJASPTJ3TiwNitoa8EthpxoFCyHSWd/o=; b=UQJmvI3KyD1FHqQGGgXTd3E760BXBudHrBqMy0xQOaObKcv9mKQgVsGcqPE7+6o8Iz ANy50eyUDeqxtUIGPtt6fwtmRCi1QJ0GdqT4gcwWC1oHeYlGBCSYRIOuaSyCnwuWLYt5 8TgWdEFpLnWrTuiH9EibyK3WmfMgHZUIK71lLu2lPEGymDj7Om/JC2trZfKC5mTut4bW R0xv7gc3QedYmmavolL8hjgV3Bf+UEQ2cOOtdU9ePn0QZccZPejOeTT5vQUvagx38Y+n w4uwIxkRq4BHS7J+vwFYPKBG3s0er3o+52QxbUM4YeMJpgAXy2XS/G9UcFTs7tMK8NKf 8uBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc; bh=vW+oVBrKyKiiJASPTJ3TiwNitoa8EthpxoFCyHSWd/o=; b=rUWE6ccsOl3sedL4b/ZsHDMjgDTdF6qKftU6VWtYSFa0Au/K6sWPLQxXlhxLry3dYt a+JidKqL7zMRye9CZ91a1zdjbJgOvpWoajGk42oFMM3fb6QNtWfM6SJbqmShw2krbcQm b0x2Y3OkirVzroPK+unw7QiQVSqO7nKBmhxUNqtwF/x+Ou44g9paxmzUjVw/37orrdon s/DpPRhPqiF1zzimZROMZa6OZAr8QVfV1Ci4XM4tt5qauPex3ETEcJIXVmZnzEIFgljl 7cINWktDxNIfCemZaQ/ItxR3/N4BTLdC5YUPTAFUAOklrrvISIH4Jqzr2EtNwDCbBJRB LMOw== X-Gm-Message-State: ACgBeo2mDN/ZCl9KyNyNmhR8CDIF+3X7kLzf4tQFXgvHP8tvUEeWexfr xt3JJBTij5/FasaQFj2VnZN21QLxQcQ= X-Received: by 2002:a05:6000:1e0f:b0:225:4052:3a68 with SMTP id bj15-20020a0560001e0f00b0022540523a68mr12089375wrb.707.1661342413389; Wed, 24 Aug 2022 05:00:13 -0700 (PDT) Received: from localhost.localdomain ([86.14.124.218]) by smtp.gmail.com with ESMTPSA id cc19-20020a5d5c13000000b0022571d43d32sm1697676wrb.21.2022.08.24.05.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 05:00:12 -0700 (PDT) From: herron.philip@googlemail.com X-Google-Original-From: philip.herron@embecosm.com To: gcc-patches@gcc.gnu.org Subject: [PATCH Rust front-end v2 01/37] Use DW_ATE_UTF for the Rust 'char' type Date: Wed, 24 Aug 2022 12:59:20 +0100 Message-Id: <20220824115956.737931-2-philip.herron@embecosm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220824115956.737931-1-philip.herron@embecosm.com> References: <20220824115956.737931-1-philip.herron@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: philip.herron@embecosm.com Cc: gcc-rust@gcc.gnu.org, Tom Tromey <tom@tromey.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742043867603559677?= X-GMAIL-MSGID: =?utf-8?q?1742043867603559677?= |
Series |
[Rust,front-end,v2,01/37] Use DW_ATE_UTF for the Rust 'char' type
|
|
Commit Message
herron.philip@googlemail.com
Aug. 24, 2022, 11:59 a.m. UTC
From: Tom Tromey <tom@tromey.com>
The Rust 'char' type should use the DWARF DW_ATE_UTF encoding.
---
gcc/dwarf2out.cc | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
Comments
On 8/24/22 04:59, herron.philip@googlemail.com wrote: > From: Tom Tromey <tom@tromey.com> > > The Rust 'char' type should use the DWARF DW_ATE_UTF encoding. The DWARF changes are OK. > --- > gcc/dwarf2out.cc | 23 ++++++++++++++++++++++- > 1 file changed, 22 insertions(+), 1 deletion(-) > > diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc > index e3920c898f5..a8bccbabca4 100644 > --- a/gcc/dwarf2out.cc > +++ b/gcc/dwarf2out.cc > @@ -5600,6 +5600,16 @@ is_fortran (const_tree decl) > return is_fortran (); > } > > +/* Return TRUE if the language is Rust. */ > + > +static inline bool > +is_rust () > +{ > + unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); > + > + return lang == DW_LANG_Rust || lang == DW_LANG_Rust_old; > +} > + > /* Return TRUE if the language is Ada. */ > > static inline bool > @@ -13231,7 +13241,11 @@ base_type_die (tree type, bool reverse) > } > if (TYPE_STRING_FLAG (type)) > { > - if (TYPE_UNSIGNED (type)) > + if ((dwarf_version >= 4 || !dwarf_strict) > + && is_rust () > + && int_size_in_bytes (type) == 4) > + encoding = DW_ATE_UTF; > + else if (TYPE_UNSIGNED (type)) > encoding = DW_ATE_unsigned_char; > else > encoding = DW_ATE_signed_char; > @@ -25201,6 +25215,13 @@ gen_compile_unit_die (const char *filename) > } > else if (strcmp (language_string, "GNU F77") == 0) > language = DW_LANG_Fortran77; > + else if (strcmp (language_string, "GNU Rust") == 0) > + { > + if (dwarf_version >= 5 || !dwarf_strict) > + language = DW_LANG_Rust; > + else > + language = DW_LANG_Rust_old; > + } > else if (dwarf_version >= 3 || !dwarf_strict) > { > if (strcmp (language_string, "GNU Ada") == 0)
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e3920c898f5..a8bccbabca4 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -5600,6 +5600,16 @@ is_fortran (const_tree decl) return is_fortran (); } +/* Return TRUE if the language is Rust. */ + +static inline bool +is_rust () +{ + unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); + + return lang == DW_LANG_Rust || lang == DW_LANG_Rust_old; +} + /* Return TRUE if the language is Ada. */ static inline bool @@ -13231,7 +13241,11 @@ base_type_die (tree type, bool reverse) } if (TYPE_STRING_FLAG (type)) { - if (TYPE_UNSIGNED (type)) + if ((dwarf_version >= 4 || !dwarf_strict) + && is_rust () + && int_size_in_bytes (type) == 4) + encoding = DW_ATE_UTF; + else if (TYPE_UNSIGNED (type)) encoding = DW_ATE_unsigned_char; else encoding = DW_ATE_signed_char; @@ -25201,6 +25215,13 @@ gen_compile_unit_die (const char *filename) } else if (strcmp (language_string, "GNU F77") == 0) language = DW_LANG_Fortran77; + else if (strcmp (language_string, "GNU Rust") == 0) + { + if (dwarf_version >= 5 || !dwarf_strict) + language = DW_LANG_Rust; + else + language = DW_LANG_Rust_old; + } else if (dwarf_version >= 3 || !dwarf_strict) { if (strcmp (language_string, "GNU Ada") == 0)