From patchwork Tue Dec 6 10:13:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 61496 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19B13395B464 for ; Tue, 6 Dec 2022 10:11:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 02BB8395B072 for ; Tue, 6 Dec 2022 10:11:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02BB8395B072 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-x334.google.com with SMTP id n9-20020a05600c3b8900b003d0944dba41so7606268wms.4 for ; Tue, 06 Dec 2022 02:11:40 -0800 (PST) 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=PqZMeW5ZPtonQ1ws5AuIz0aOoi5wwBmAkIDoBL0wGY8=; b=RIVaIKPoUHUErWOIP2+pI+NuD3H1sLiDXIU8CZsMBW6YgmeyfOIzp4ggCqYETMe+rF /4rZgcN8fwHTAla6UU9RaNB0Vn4nUmE5PcZoq0EKMgdh1NiS4DTUiiA16BxO4O4MJvuJ C93gb0AB3uKD4UJWHjG4ZESTllusHxRsD4sPUhK3VekVxNAKSuHUdmlN2a+FlPFzC9cF +C0IXRY9BncJWIddxEhh+309FVW+YkaadA/S3c9GZg2BMlKbk8JvJxgMRGMCD/YxUzkj yYqtDo5Ch6x93ZCiXzp5u/oeVYfDZ3E0mRYdChJtVexNwYuIQ0QaGeqhTcuZp7twRctl 4rfQ== 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=PqZMeW5ZPtonQ1ws5AuIz0aOoi5wwBmAkIDoBL0wGY8=; b=6D3eCVANWm5AuzKYDVlmh35rG8CbLdtwKJwJ3t09PNxA24VftV+MCkrhIN07Kf7hHu i0di8rUXYUg7P4hBttmnE6zBRzj83/Ac2ISz5fYmRBAdVSZ5wGE75A1ECVkuEURsO4fa ni8dT1h1kEdYk56mksIVs7aMRJ0F0TeA/Xef3cCCc1Gv/hIdZI7h72Zww0JXDHzmv2dp 09O5fWVtkWtj2CfnKUSXui1nCk6NY4orSTu9Mlthn2dXvFGPkhY7DZnNkoAlP39FM8kt 4fjxrqjJiUeCWYGbpkW3TK7ILzavPs5lRPYDBP/9lUA6gCkkhC7Jt/kaa93Jq4qsDnno 2fXg== X-Gm-Message-State: ANoB5pmSygfhFoHO9CuPpvF1K3HigtlNyP02TF6YAMISFcJnj0x/3j98 8xq/S9vK4mZKSyKUj38cPwzd3Sw6RwJ75w0CSw== X-Google-Smtp-Source: AA0mqf73zIbDjm8Lj0uyw2JHzvbMs5E7P5qxSLZR2rWIWVmEBaD3qDDGC2i9MLNYZXTTmRTcKBK/NQ== X-Received: by 2002:a05:600c:3d10:b0:3cf:8a44:e1eb with SMTP id bh16-20020a05600c3d1000b003cf8a44e1ebmr54503216wmb.189.1670321499461; Tue, 06 Dec 2022 02:11:39 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.googlemail.com with ESMTPSA id r10-20020a05600c458a00b003cfd4a50d5asm27052699wmo.34.2022.12.06.02.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:11:39 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, jakub@redhat.com, Tom Tromey , Mark Wielaard , =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [PATCH Rust front-end v4 01/46] Use DW_ATE_UTF for the Rust 'char' type Date: Tue, 6 Dec 2022 11:13:33 +0100 Message-Id: <20221206101417.778807-2-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206101417.778807-1-arthur.cohen@embecosm.com> References: <20221206101417.778807-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-65.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=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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Tom Tromey The Rust 'char' type should use the DWARF DW_ATE_UTF encoding. Co-authored-by: Mark Wielaard Co-authored-by: Marc Poulhiès --- gcc/dwarf2out.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e3920c898f5..0d8dd4f1767 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -5600,6 +5600,17 @@ is_fortran (const_tree decl) return is_fortran (); } +/* Return TRUE if the language is Rust. + Note, returns FALSE for dwarf_version < 5 && dwarf_strict. */ + +static inline bool +is_rust () +{ + unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); + + return lang == DW_LANG_Rust; +} + /* Return TRUE if the language is Ada. */ static inline bool @@ -13231,7 +13242,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; @@ -25226,6 +25241,8 @@ gen_compile_unit_die (const char *filename) { if (strcmp (language_string, "GNU Go") == 0) language = DW_LANG_Go; + else if (strcmp (language_string, "GNU Rust") == 0) + language = DW_LANG_Rust; } } /* Use a degraded Fortran setting in strict DWARF2 so is_fortran works. */