From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 82C133858D38 for ; Mon, 11 Dec 2023 16:15:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82C133858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 82C133858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702311353; cv=none; b=NfEp6LEQ/JHLKDrf1vjhfz5gELLiqbQdfyI4Lgtx5WcTlvejyIHMqQK9ANOXh684q+WstKj3E/d96byWy6qT3a1zpBHdfT8HUKp7PgqnltOT/rJ3XCJikONipkMvtahCrE//mGw7VzXhvQCQ8Bibv1A/T7IaEIalLU+KEjz1Voo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702311353; c=relaxed/simple; bh=PvjLOf0U0ap3I01pwYG817ADVDchIrrc6kM/LMWQ6Xg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=C1Gvv1107CKjWBl8tbN55wf0UomTh2BJ9LKIvq2QwyhTYL1bed0pW4rwH2EfdZnLUdUmmfr5BPME69wtJc+DS24XqLa1GWPp8byxFlZlVf/Fbjg+SAlDZ6OiLyTTLwQRuJLH0PjP9gqQVt8tDJVQBK63ARKpI2+oGxZIMqRX/g4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5c66bbb3d77so2637947a12.0 for ; Mon, 11 Dec 2023 08:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702311350; x=1702916150; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tqJKoMoYKcancIMS+IYWsPEGQ8LiMgMmJI9iTl2PG7M=; b=V+faF0usDoSngXNNZ1BBW/x2BZDul3lUz2WwayVGIOsjTp8L90EXwgmv+zrmsu9IXF K0D4V//PxveRSLtMMXQZlcs0SZ8wS1xl6uHICkfeN6/15MZlFo6jtYzSVvynQYja/26a BBN++qjBXtasYJVXxEeDK+oOz68LvX2aK+E3WxOj490TG6Nx7EMI0JawkQTddlRjj0N0 haetkMH4RV59BgknPrgEe5dPUbm4Kx5yB7dXkBdaIjKrZCPvm6LRCSEHb/UsHVhmu0U6 omdOOg84sTgzuWn4wFH6cPHiS422xABh41KfXd6/Bnp0TY0G1G/xo/nr0XKJ1sZ2Jkp1 ieGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702311350; x=1702916150; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tqJKoMoYKcancIMS+IYWsPEGQ8LiMgMmJI9iTl2PG7M=; b=XtkKWgtJZUl4rYQ8XyWwIYWrTah3xtdPy5ccn61VGWPMrMydWSqC/ZUkiGmgj/hO+u waZHtUTMzg/7G60NzzzjL+6DIvQQA34YMjFR+cqeh+NmDNZmeCBpsMAI5u4mtHqsnBAA GwSg0DgvGxbWMi2NotkaAirncvQ/CI4P9mL4YaCE+2Nv5qRKJM7qI/tCpKGWnNtKP5k9 fQvcy0SY9rtFHYnZYhn+dTNBB2fjr6CBfkV/28O7CUILPFTI2paSoE5iSJAdV8GvMIrg humKiaId3kuh/jd2l7eRNcohswFzDRECN1AI31RL/AlgteJj0ReTZb6xv3pfYTtDiE4X 081w== X-Gm-Message-State: AOJu0YysWBl5bbkXTZmZr9hyKamA08AIcIr+Vg2OskF7wuBaWeqzhLL1 E72oJ2QBKepQBVMFYCBCqtg= X-Google-Smtp-Source: AGHT+IFW4ix9QKQDO52tqjdn3WFhga3zhKiAUbTdajTLspQKO54q4nhvBlmY2leLV4xD7dcwqKtLiA== X-Received: by 2002:a05:6a21:350d:b0:18c:8db0:2a2c with SMTP id zc13-20020a056a21350d00b0018c8db02a2cmr3021257pzb.17.1702311350340; Mon, 11 Dec 2023 08:15:50 -0800 (PST) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id g4-20020a056a000b8400b006ce5bb61a60sm6434472pfj.35.2023.12.11.08.15.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Dec 2023 08:15:49 -0800 (PST) Message-ID: <28aeda17-e20b-4313-908c-2f4fd09018ef@gmail.com> Date: Mon, 11 Dec 2023 09:15:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] RISC-V: Support RISC-V Profiles in -march option. Content-Language: en-US To: Jiawei , gcc-patches@gcc.gnu.org Cc: kito.cheng@sifive.com, palmer@dabbelt.com, christoph.muellner@vrull.eu References: <20231120191447.2189928-1-jiawei@iscas.ac.cn> From: Jeff Law In-Reply-To: <20231120191447.2189928-1-jiawei@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,RCVD_IN_XBL,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 List-Id: On 11/20/23 12:14, Jiawei wrote: > Supports RISC-V profiles[1] in -march option. > > Default input set the profile is before other formal extensions. > > [1]https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc > > gcc/ChangeLog: > > * common/config/riscv/riscv-common.cc (struct riscv_profiles): > New struct. > (riscv_subset_list::parse_profiles): New function. > (riscv_subset_list::parse): New table. > * config/riscv/riscv-subset.h: New protype. > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/arch-29.c: New test. > * gcc.target/riscv/arch-30.c: New test. > * gcc.target/riscv/arch-31.c: New test. > > --- > gcc/common/config/riscv/riscv-common.cc | 58 +++++++++++++++++++++++- > gcc/config/riscv/riscv-subset.h | 2 + > gcc/testsuite/gcc.target/riscv/arch-29.c | 5 ++ > gcc/testsuite/gcc.target/riscv/arch-30.c | 5 ++ > gcc/testsuite/gcc.target/riscv/arch-31.c | 5 ++ > 6 files changed, 81 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/riscv/arch-29.c > create mode 100644 gcc/testsuite/gcc.target/riscv/arch-30.c > create mode 100644 gcc/testsuite/gcc.target/riscv/arch-31.c > > diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc > index 5111626157b..30617e619b1 100644 > --- a/gcc/common/config/riscv/riscv-common.cc > +++ b/gcc/common/config/riscv/riscv-common.cc > @@ -165,6 +165,12 @@ struct riscv_ext_version > int minor_version; > }; > > +struct riscv_profiles > +{ > + const char * profile_name; > + const char * profile_string; > +}; Just a formatting nit, no space between the '*' and the field name. > @@ -348,6 +354,28 @@ static const struct riscv_ext_version riscv_combine_info[] = > {NULL, ISA_SPEC_CLASS_NONE, 0, 0} > }; > > +static const riscv_profiles riscv_profiles_table[] = > +{ > + {"RVI20U64", "rv64i"}, > + {"RVI20U32", "rv32i"}, > + /*Currently we don't have zicntr,ziccif,ziccrse,ziccamoa, > + zicclsm,za128rs yet. */ It is actually useful to note the extensions not included? I don't think the profiles are supposed to change once ratified. > + {"RVA22U64", "rv64imafdc_zicsr_zihintpause_zba_zbb_zbs_" \ Note the trailing "_", was that intentional? None of the other entries have a trailing "_". > @@ -927,6 +955,31 @@ riscv_subset_list::parsing_subset_version (const char *ext, > return p; > } > > +const char * > +riscv_subset_list::parse_profiles (const char * p){ > + for (int i = 0; riscv_profiles_table[i].profile_name != NULL; ++i) { > + const char* match = strstr(p, riscv_profiles_table[i].profile_name); > + const char* plus_ext = strchr(p, '+'); > + /* Find profile at the begin. */ > + if (match != NULL && match == p) { > + /* If there's no '+' sign, return the profile_string directly. */ > + if(!plus_ext) > + return riscv_profiles_table[i].profile_string; > + /* If there's a '+' sign, concatenate profiles with other ext. */ > + else { > + size_t arch_len = strlen(riscv_profiles_table[i].profile_string) + > + strlen(plus_ext); > + static char* result = new char[arch_len + 2]; > + strcpy(result, riscv_profiles_table[i].profile_string); > + strcat(result, "_"); > + strcat(result, plus_ext + 1); /* skip the '+'. */ > + return result; > + } > + } > + } > + return p; > +} This needs a function comment. The open curly should always be on a line by itself which is going to require reindenting all this code. Comments go on separate lines rather than appending them to an existing line. I think the consensus in the Tuesday patchwork meeting was that while there are concerns about profiles, those concerns should prevent this patch from going forward. So if you could fix the formatting problem as well as the trailing "_" issue noted above and repost, it would be appreciated. Thanks, Jeff