From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 9EF7138654A2 for ; Wed, 26 Oct 2022 08:15:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9EF7138654A2 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-x336.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso911007wma.1 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=xwfVoj69e+TZdvr/xAFpREToz/vVL1CcWKOEnfn/bZ7mNzHbn3TDlAILnlVtlG9vNE 0nSPivO5J2A3aKHjHkcha4V+8bXlzkWiJFTihEP+N1TienV6BAAfF5ozFHRmBV47fhJu qt63BZRC8fMv5v+mSLv1jM+gYlMwAcFVHG00UPK4cWI9qpfJZD5X38GQlnls8tPsxSgp 4Myh1vK+2QLTvkPpiyMhHjvZdoOFxz/JlQhH5gxoJ6woqfvf80bq+bNea0nrfM++zmh9 a1Da6fg4c5OHHSEf5IotDwhU/SqbSE63V8oE8eHoFup2eWUNiN7+ZHJMwGKEbp+uiN/G NwpA== X-Gm-Message-State: ACrzQf3+zdJB2zhk9/1t7K5n5DdB2yao36oNrfASUCAudCaFe2InIU3R buEhOYP5j/2EZSYBnr8b/HG1FRZyiLk5JmIoyQ== X-Google-Smtp-Source: AMsMyM6S0/0TuBRl4PUIMqnW3dgW3x3ZmNmCnHMY6b9xuio6Ypfcgc2XOdWUX4wMKEXjPtz3210Rbw== 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 Cc: gcc-rust@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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.2 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 List-Id: 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) -- 2.37.2