From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 631B93857027 for ; Fri, 25 Feb 2022 09:37:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 631B93857027 Received: by mail-ed1-x52d.google.com with SMTP id g20so6557151edw.6 for ; Fri, 25 Feb 2022 01:37:32 -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=gkuIUprUYdy/ZdMG6Ezz8RuKQJC7MTmOnuqh3EmwPrw=; b=XMxm44+/aghc4ZMNDGedfRe95RNe6f64b1djmeMx4ML8r73c9Ow9SdxBixwb1u23GM vVZtZaO7iYIttWxoigdfLjZLFL5cggZOVsAqZT7ADUnRmiq3jW6nyz6mnbw/+ZT2+V1E lYxDvqbnBpgA0BZIHPCEzHQ66sd8o5wPZ80qSuAAI7kR4FG4iH/4KKmzpQaeR7WCTPYP /3lZoiCgkq/h9mIlhF0yHvTXQYg/ROXIFCEbqjd7m5yykhJfyZQdsB4r1Ikujxyw6Xdh HH6RXyiVrHaennxd0+aRWN8VsKOGmJHgxLvclgDO/yhcjLoISLR0mNGR3QvAxOrRfQZg CxHg== X-Gm-Message-State: AOAM533zR3xZPXBKXq4aHgbkd8Uj4g6rm/H/v7UgEYnPUXOSIdAKWbsu UJwBAHg4Hg/8gQKO8rvwGCYkMH/Zcry0lSmE8Tq96UkQRGY= X-Google-Smtp-Source: ABdhPJyYuVqyQ8T0obbmoro3/lN4Q7zHTR3V6HIvk6QRF+9Rsy3puib5n+2mZ54i+WANf01prYC+PJFxp0qLjSFfD6M= X-Received: by 2002:aa7:c7c4:0:b0:407:52cc:3b32 with SMTP id o4-20020aa7c7c4000000b0040752cc3b32mr6213144eds.397.1645781851077; Fri, 25 Feb 2022 01:37:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kito Cheng Date: Fri, 25 Feb 2022 17:37:19 +0800 Message-ID: Subject: Re: [PATCH 2/3] RISC-V: Stricter underscore handling for ISA To: Nelson Chu , Andrew Waterman Cc: Tsukasa OI , Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2022 09:37:34 -0000 Just for reference: For RISC-V GCC, you can use any number of underscores as you can, so -march=rv64i___m____a_____c_ is valid input for GCC. For RISC-V LLVM, you can use only one underscore and have trailing underscore, e.g. -march=rv64i_mac_ On Fri, Feb 25, 2022 at 5:23 PM Nelson Chu wrote: > > On Wed, Feb 23, 2022 at 9:49 AM Tsukasa OI via Binutils > wrote: > > > > Double underscores and trailing underscore in an ISA string are invalid. > > The ISA spec does say that "Extensions with the Z prefix must be > separated from other multi-letter extensions by an underscore". But I > am not sure if we need the stricter underscore checking for now. The > discussion [1] said that we can set the ISA string in any order, so I > think the checks will be more and more user friendly. I know that > these are two different questions, and I don't have a strong opinion. > Maybe see if anyone else has any suggestions. > > Thanks > Nelson > > [1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/14 > > > bfd/ChangeLog: > > > > * elfxx-riscv.c (riscv_parse_std_ext): Make handling for > > underscores in ISA string more strict. > > (riscv_parse_prefixed_ext): Likewise. > > --- > > bfd/elfxx-riscv.c | 25 ++++++++++++++++++++++++- > > 1 file changed, 24 insertions(+), 1 deletion(-) > > > > diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c > > index 329dcaed304..ee4b442ba89 100644 > > --- a/bfd/elfxx-riscv.c > > +++ b/bfd/elfxx-riscv.c > > @@ -1650,6 +1650,8 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > > const char *arch, > > const char *p) > > { > > + unsigned char underscores = 0; > > + > > /* First letter must start with i, e or g. */ > > if (*p != 'e' && *p != 'i' && *p != 'g') > > { > > @@ -1669,8 +1671,15 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > > if (*p == '_') > > { > > p++; > > + if (++underscores == 2) > > + { > > + rps->error_handler > > + (_("%s: double underscores"), arch); > > + return NULL; > > + } > > continue; > > } > > + underscores = 0; > > > > bool implicit = false; > > int major = RISCV_UNKNOWN_VERSION; > > @@ -1709,7 +1718,7 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps, > > riscv_parse_add_subset (rps, subset, major, minor, implicit); > > } > > > > - return p; > > + return p - underscores; > > } > > > > /* Parsing function for prefixed extensions. > > @@ -1731,14 +1740,22 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps, > > int minor_version; > > const char *last_name; > > enum riscv_prefix_ext_class class; > > + unsigned char underscores = 0; > > > > while (*p) > > { > > if (*p == '_') > > { > > p++; > > + if (++underscores == 2) > > + { > > + rps->error_handler > > + (_("%s: double underscores"), arch); > > + return NULL; > > + } > > continue; > > } > > + underscores = 0; > > > > class = riscv_get_prefix_class (p); > > if (class == RV_ISA_CLASS_UNKNOWN) > > @@ -1843,6 +1860,12 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps, > > } > > } > > > > + if (underscores) > > + { > > + rps->error_handler > > + (_("%s: trailing underscore"), arch); > > + return NULL; > > + } > > return p; > > } > > > > -- > > 2.32.0 > >