From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 6ACE43858414 for ; Fri, 25 Feb 2022 11:26:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6ACE43858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-x22b.google.com with SMTP id j24so6972526oii.11 for ; Fri, 25 Feb 2022 03:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w2LWpZSrq46NL34x3xfLEn7YMYVZqe/YR1peogHa9ig=; b=Me15OdfGZLwQiLZE1LyeTiIRy+N0mZx+gRyJm4HrY185trcDxH6MXdTKhyfhx/qvJC NrQMRQ5HwMmjkWx35LWsnXvQzK7OyV9Rcp4v7pW/i4hH/nzH3EJM+aHvlJqioBv7TMt8 1HN1aVOd7g3srIZ1+K3QsxemVxB2j0zZ+aMlKpcL/BuMFyeQ41yvoRUT00NCQwO7Uc5J SWoF7EtGq/mwfMqJoBOWL7o4yZQTP3YvydRDvvbXEZ/VDHdyExrpajfVPbjus0RKHXMe 90fO0N8gUh2fyfOLWeKSwzZ9zg8TDQxTqkN0Izw8nkEfldIAgxutRquuTRDgiSM9ksW+ CtWQ== 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=w2LWpZSrq46NL34x3xfLEn7YMYVZqe/YR1peogHa9ig=; b=ndND4xHiG4ifkPBi9tQWl/qgzCaJ2N8jtbTnVK/09jslwL9yNIv0U9P5LaDWRzGYWC m1lTwN0/r/rC0el9zsUSrAmmjPAS7U+QJTBWjEuc7VdskT2JDCW2UPKHWhnBVDbroeIo r9U/uq1LCX1F97U9PEY1bBOut4k/9m98jvaXUAgWz5bbI4XrYqyj+8rTzYu5L2OZDr5D befEACeSmDbxaTQ+/CHUAaAVX8ZQFgQcbo/yo8oIAjLS0jIR2e2seNdDleWoQcGMBnrm 9pZ19fqs6inrwMzlr9YC+eowJna/MmcHL4Q7ufmPGXTogmInnFZaG0jmOQDQqqbPQe6Z bC+g== X-Gm-Message-State: AOAM533ddJ0rpSR+XGl4M1LxA/ysU4ZMUAsW7OrxgzYO7uKn+HwtOmZM cYMwkIdjQoOrqo4BWWHrm1XcgXSZfu83ew== X-Google-Smtp-Source: ABdhPJwd18BzRMvMauDF2qaChc1PesDuGJ2um7ehzFuG5ZOogMP2ojZi97VUdJnAlrVCLIPFI88WwQ== X-Received: by 2002:a05:6808:190d:b0:2d5:bd9:dbf6 with SMTP id bf13-20020a056808190d00b002d50bd9dbf6mr1192692oib.48.1645788376526; Fri, 25 Feb 2022 03:26:16 -0800 (PST) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com. [209.85.161.52]) by smtp.gmail.com with ESMTPSA id gk11-20020a0568703c0b00b000d068c784ffsm1056396oab.31.2022.02.25.03.26.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Feb 2022 03:26:15 -0800 (PST) Received: by mail-oo1-f52.google.com with SMTP id w10-20020a4ae08a000000b0031bdf7a6d76so5726728oos.10 for ; Fri, 25 Feb 2022 03:26:15 -0800 (PST) X-Received: by 2002:a4a:88e9:0:b0:319:19d0:24c2 with SMTP id q38-20020a4a88e9000000b0031919d024c2mr2489471ooh.35.1645788375581; Fri, 25 Feb 2022 03:26:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Waterman Date: Fri, 25 Feb 2022 03:26:04 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] RISC-V: Stricter underscore handling for ISA To: Kito Cheng Cc: Nelson Chu , Tsukasa OI , Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-10.3 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, 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 11:26:19 -0000 Although the spec isn't written as a formal grammar, my interpretation of the text is that excess underscores are acceptable. The basis for my claim is that "underscores [...] may be used [...] to improve readability", implying they can sometimes be inserted where they aren't required. Sounds like GCC agrees with my thinking. I don't have an opinion on the trailing underscore. On Fri, Feb 25, 2022 at 1:37 AM Kito Cheng wrote: > > 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 > > >