From patchwork Fri Dec 3 15:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 48467 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18CAA3858018 for ; Fri, 3 Dec 2021 15:51:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 0485A385842C for ; Fri, 3 Dec 2021 15:51:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0485A385842C 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-pf1-x433.google.com with SMTP id 8so3292887pfo.4 for ; Fri, 03 Dec 2021 07:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VtovMHQFPv3+u991EymxPsyh8OUzsLj2Ai8d80mH6lU=; b=VoT+6uoygAEhL5lE3ZS99lP0Kp8Kzf7I1GHELzc+DHU8aKhiCRzHeMdYZxmPYGdHIE 0VgOYNik4tgMmsoybjG1u4GdRuu9fY+BMgdEIZEN2yX09GDG/n0uRog2p2DQNy6P3c/y Xz4Rx9jh+89poAyCl9cPG1o2MQDmoQNdhGKWJMmPU4zuzfzHMK/aCVweP0KfwU7UOA+F xhMEat4aUVbeF2ZsKmETdBZbxG7BovKu/fQ9gFfhfGHd14W9/xYvCENPejzZIGdav4Ju G4wkKHIAuubJ1nROrMQztX4TmSO9a0IHyngoLS6A4dg4c15M5vpk1MZjY20TwIjNtip9 23Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VtovMHQFPv3+u991EymxPsyh8OUzsLj2Ai8d80mH6lU=; b=jLrA2p+AQOudihyAnxNMVMpdttYCOwhhOI2T/Kw5pfoHoctw1SZEotpCe1RAIW5Zqv fkITTNWpZ43TYnXdnOQZwCAYV7EHtpuYGRFnsBnn+1sYG7/6xMYHCeHU9dkscpVvEZAu Ft+s/Z7fy4AbRHtyjQq/JELN0lvPI973K/BqFFB2Sh2Qzzfg20pC9g3Lp0vOjqrD26Z3 Jl5pyP//MA1+tAVvmaUIyDFtSh1Lo5/38/mHshd4TLQDJkygo63UcgOU7TKCU6xVCoNd Yj9KToEm5mYZAg76I8V7I+t6yGBuTQhmwxMn/XEhhu6spaYxupj2907yiiW/EY2fig6Y /fiA== X-Gm-Message-State: AOAM5326oRWeFD/8YSzeKcdSfG5bOma9Bp2C18s/j/uMkuXlxVW3may5 7vM69bB5coI2nppw8KDDCMiLkJ2TrBfmnw== X-Google-Smtp-Source: ABdhPJztN0nQHs9THAgYEo/QUKlKOO86bN7G1OQCxS81dyRkbNfaw74VDdhyLg+kmUKDvQ7Mh/Fi/A== X-Received: by 2002:a63:4a5a:: with SMTP id j26mr5098238pgl.570.1638546674724; Fri, 03 Dec 2021 07:51:14 -0800 (PST) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id n1sm3598326pfj.193.2021.12.03.07.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 07:51:14 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com, palmer@dabbelt.com, andrew@sifive.com Subject: [PATCH 1/2] RISC-V: Allow extension name contain digit Date: Fri, 3 Dec 2021 23:50:53 +0800 Message-Id: <20211203155054.52834-2-kito.cheng@sifive.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211203155054.52834-1-kito.cheng@sifive.com> References: <20211203155054.52834-1-kito.cheng@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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.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: , Cc: Kito Cheng Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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) {