From patchwork Wed Oct 26 08:17:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 11104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp124873wru; Wed, 26 Oct 2022 01:17:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59ZOlq5N6kasFVJuowYNayj9X47mGIoSFNeAhBKqNF5DAE31S9afiOc4T2iQRzahJSXzBR X-Received: by 2002:a17:907:3205:b0:770:8554:c4ee with SMTP id xg5-20020a170907320500b007708554c4eemr36836844ejb.39.1666772223311; Wed, 26 Oct 2022 01:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666772223; cv=none; d=google.com; s=arc-20160816; b=Pa1NJTftOBE0nhYXhafFFV1/oiBHdC94mYNMH1soFXWJi0fG9UC+EM7NsZhCcg4gav rZ9/SFci9SCfCbtR8Y65Q2AjKUnxDNHIgH4Q1nDlbNvX8sYoMv6Y9lxKfv5ueKBcABR0 SQKZ330eolOHlS7Bt+B+DnZUQ2SlPlOJHXPjhZHS77zRDRmM0VxN+qIyEAoQA08zpwD+ Ilfk5Ogu5ZJACMnNcT02JkcpptaLLGrWquU6CvfdnwbIzurSbVaDJT14G8upJWIXi+Mr Eo6i6VZiQAiJJfxGnRlUpJe9LDZ6F46YSaL1visQan1n7LmNDJfXU0Q23kwi2CZL4mOC B+Yw== 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=Sj9/a2uvUPnEC61ylQPs2dyn5BI46BdrwcRR18kIofQ=; b=z/CquQrQFCLGrb6ARxeQuYKysD9WbbFzZlxyNkfVqtDFyvDwc+lGFuI/0u8ZacRjB3 ysDsuUxScwvJck16yejcUiB9GzTOxoT8wPo4PMt/aN8ZcvdDD/TN6C72X2E2u4qBS920 q7ccGERWqfu8NYYtvtBs/4118tkd/HZfmvtf8GV3tkDuedmxNFuc+9pGlHQ+h18rvKAm h42PIXzI6w6XfIPWNMgAwV0r+R2ySIcnnnRX0z0+2C3XSHpkolffaLH5dzTDRSYoNcx/ dmGVdl9D6isf4Yiwg1/ZrESKxdlRS6bLAh769MYDb8usMfIYr/qGOZ0OMCov808o8tER s5yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=QIQcGfYX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hv12-20020a17090760cc00b0077951929340si4253813ejc.271.2022.10.26.01.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 01:17:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=QIQcGfYX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 38B4A384B835 for ; Wed, 26 Oct 2022 08:16:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id E562C384BC30 for ; Wed, 26 Oct 2022 08:15:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E562C384BC30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x32c.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so904330wmr.2 for ; Wed, 26 Oct 2022 01:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Sj9/a2uvUPnEC61ylQPs2dyn5BI46BdrwcRR18kIofQ=; b=QIQcGfYXfkE4so6ODScwKOmraJlCCbftzI3zpnjQdpYSJQJRzPP6iJ5Naeh2G8Tri5 CNUYKfJLJNWtygfNEL+LEC9E+htgsk0zrYjdxTPdNcjMs7xawKyZykkH/15o/1zSEfio leOvRi90aPPxCLgSITlgepeAflPFEqE5Po5qD7m7gwck/eDqpZu/obm3SfSyNNNFobdE j75CEJV7KD5hgx0Sfz9c0t5KYqhc/5OuIYEKGVy5pgcXHAVqV1m8q+sBpYoME9IAhhZM CiaqnrRjvPnC6y7gn97exb1kMUwNoSZcaxXRhCrvw8M/+krLUJW4zv5q+hv0SPMB20q3 IyhA== 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:subject:date:message-id:reply-to; bh=Sj9/a2uvUPnEC61ylQPs2dyn5BI46BdrwcRR18kIofQ=; b=AOzc9Gps9byX9KAaKR+IpLtptiJanPCVG/fJ90mlxCApox1X7GqxM+evfSTKLtnRUg YB5SmbpYpcznKal56N/js1qNbrub8gGwbEAs/lor9tQdAGKQY01YLuyXMbSz5bI+yDCn /Z9dFPqJ/vwoEc5vYxdSCChhMg0IFMfnu6Ca2J0MrkksWin1L+E2ewAYLC86rEC9EJK1 zLynbep4r1eeg8LbVkO0wR2KY/SnLy6FOsEAJThZfiA6oBtxgBX2iaYLdQrHRjmuU/M1 cwR1p3E4H8yALi3bb6o+LPTRDtd0RtdkYbg0ILj81wAEEz1a2hMGxJqi0GMuzC+mbJO1 mB0Q== X-Gm-Message-State: ACrzQf3cs7sdyiQQNg6vWE0BC0NxCmohCcAix2jdesrs/1d/NCgEEIVB 1UnF3u40RlgGYFEQjnjligVFv/ZofrmYH6v+0g== X-Received: by 2002:a05:600c:4113:b0:3c6:f5d7:aa8d with SMTP id j19-20020a05600c411300b003c6f5d7aa8dmr1535667wmi.167.1666772128334; Wed, 26 Oct 2022 01:15:28 -0700 (PDT) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.googlemail.com with ESMTPSA id q16-20020a05600c46d000b003c6f426467fsm1134310wmo.40.2022.10.26.01.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 01:15:27 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Subject: [PATCH Rust front-end v3 01/46] Use DW_ATE_UTF for the Rust 'char' type Date: Wed, 26 Oct 2022 10:17:26 +0200 Message-Id: <20221026081811.602573-2-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221026081811.602573-1-arthur.cohen@embecosm.com> References: <20221026081811.602573-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Cc: gcc-rust@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747737350760097249?= X-GMAIL-MSGID: =?utf-8?q?1747737350760097249?= From: Tom Tromey The Rust 'char' type should use the DWARF DW_ATE_UTF encoding. --- 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)