From patchwork Wed Aug 24 11:59:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: herron.philip@googlemail.com X-Patchwork-Id: 56977 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 E6FDF3851143 for ; Wed, 24 Aug 2022 12:00:32 +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-Google-Smtp-Source: AA6agR6UZ60ikAvqjliVx6dur45qqv6QIJlDKUO7GPs9TqCEAJWj+45eJu/GqpbRimoeDhMyCe/mSQ== 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: philip.herron@embecosm.com Cc: gcc-rust@gcc.gnu.org, Tom Tromey 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. --- 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)