From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by sourceware.org (Postfix) with ESMTPS id 24A333858408 for ; Thu, 6 Jan 2022 16:57:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 24A333858408 Received: by mail-vk1-xa2c.google.com with SMTP id h5so2066425vkp.5 for ; Thu, 06 Jan 2022 08:57:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Um5qzjOWeMugjgGzzJiaISZKrvkhzigxElEZacO29is=; b=0RJQJdhViw18ThYQ0My2awy+qT32sio1a9XYmvhxFIqK4Wgg77V5g/Cjp5jhmdeBCa fcNAM07QQh8p1p8L9qwSjlieE4QBRbGX/pjqBLM82OVEK9OvAaQSvlJjRkhd+2BvVtqc dtzzZ0pJokXptUQMhKu/0wLQNxP+BCxf1B8Qh+EfFHN30a9IC543hTlxO8rwzgW/W0CT nlOKhiMGHg65rh++so90J3YRkP18zGd3VB4coaDxS03upfZH65Rney0GeYTuZL3Pe/Ao v6AfwpLqAW/XfYCiPvpjaNupxAFwwMV7o1rI9KEIM22rQx62iOBPyQ3Af6CaERY6HAX6 ffSQ== X-Gm-Message-State: AOAM530NlJwM48MJD55XYlx4ygghi2hzMNqpTvPTNjCJYXDkLt4sqbAb EYlBsX+MLxOocWelgg6iWvBb64S0QWY6hOrUO3U= X-Google-Smtp-Source: ABdhPJxXUtcvzzxyu/O8OhYdiCeiA3zr4IJ4iTUMBEvBjEAQyavDNuTQeuiV+Fk/PPy9PDgTYYyw8TeQ27k1vbc8rVA= X-Received: by 2002:a05:6122:506:: with SMTP id x6mr21324602vko.23.1641488259481; Thu, 06 Jan 2022 08:57:39 -0800 (PST) MIME-Version: 1.0 References: <20211203155054.52834-1-kito.cheng@sifive.com> <20211203155054.52834-2-kito.cheng@sifive.com> In-Reply-To: <20211203155054.52834-2-kito.cheng@sifive.com> From: Kito Cheng Date: Fri, 7 Jan 2022 00:57:28 +0800 Message-ID: Subject: Re: [PATCH 1/2] RISC-V: Allow extension name contain digit To: Kito Cheng Cc: GCC Patches , Jim Wilson , Palmer Dabbelt , Andrew Waterman Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.9 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Thu, 06 Jan 2022 16:57:41 -0000 Committed On Fri, Dec 3, 2021 at 11:51 PM Kito Cheng wrote: > > RISC-V spec only allow alphabetical name for extension before, however > vector extension add several extension named with digits, so we try to > extend the naming rule. > > Ref: > https://github.com/riscv/riscv-isa-manual/pull/718 > > gcc/ChangeLog: > > * common/config/riscv/riscv-common.c > (riscv_subset_list::parse_multiletter_ext): Allow ext. name has > digit. > --- > gcc/common/config/riscv/riscv-common.c | 42 +++++++++++++++++++++++--- > 1 file changed, 38 insertions(+), 4 deletions(-) > > diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c > index b8dd0aeac3e..31b1c833965 100644 > --- a/gcc/common/config/riscv/riscv-common.c > +++ b/gcc/common/config/riscv/riscv-common.c > @@ -760,24 +760,58 @@ riscv_subset_list::parse_multiletter_ext (const char *p, > bool explicit_version_p = false; > char *ext; > char backup; > + size_t len; > + size_t end_of_version_pos, i; > + bool found_any_number = false; > + bool found_minor_version = false; > > - while (*++q != '\0' && *q != '_' && !ISDIGIT (*q)) > + /* Parse until end of this extension including version number. */ > + while (*++q != '\0' && *q != '_') > ; > > backup = *q; > *q = '\0'; > - ext = xstrdup (subset); > + len = q - subset; > *q = backup; > > + end_of_version_pos = len; > + /* Find the begin of version string. */ > + for (i = len -1; i > 0; --i) > + { > + if (ISDIGIT (subset[i])) > + { > + found_any_number = true; > + continue; > + } > + /* Might be version seperator, but need to check one more char, > + we only allow p, so we could stop parsing if found > + any more `p`. */ > + if (subset[i] == 'p' && > + !found_minor_version && > + found_any_number && ISDIGIT (subset[i-1])) > + { > + found_minor_version = true; > + continue; > + } > + > + end_of_version_pos = i + 1; > + break; > + } > + > + backup = subset[end_of_version_pos]; > + subset[end_of_version_pos] = '\0'; > + ext = xstrdup (subset); > + subset[end_of_version_pos] = backup; > + > end_of_version > - = parsing_subset_version (ext, q, &major_version, &minor_version, > + = parsing_subset_version (ext, subset + end_of_version_pos, &major_version, &minor_version, > /* std_ext_p= */ false, &explicit_version_p); > free (ext); > > if (end_of_version == NULL) > return NULL; > > - *q = '\0'; > + subset[end_of_version_pos] = '\0'; > > if (strlen (subset) == 1) > { > -- > 2.34.0 >