From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 4A2023858C74 for ; Mon, 21 Feb 2022 14:47:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A2023858C74 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-pl1-x634.google.com with SMTP id 4so4449911pll.6 for ; Mon, 21 Feb 2022 06:47:48 -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:mime-version :content-transfer-encoding; bh=z3RNvXfE0NlsmayaUbEE4OnXpuDNaN5qGetG6/PVUj4=; b=C1TtD7dzSS0S7+wPp4anZYXCvebj7HCitKG/yCxYfbpXg37IpZET0ek0Gkm9YaoGmL cbKXQWho+Y+ATfUO0dQRbHW4ABDPeesNnLEMT1G3zUb25IZON7BTspzYb2Gt0lUHHlLl X/lOrkbI/4IqXXR1y94vUJJTxGGnlq8NVpoZ91ERxswro/PAcLU078/2rEf3M9FsLVyT Mb6VRINsBSaqbWw43lsGaDpUkNq/RQvanqR6DOaamyl5Lkv0FeBq5mT07x4teZ+MaJsW P0TEMEWiJK4AbwhQdh6NY65eqdeTi8tWMh7acxmA7INqOpUbPrMFg1zK+HwHAL7O1y+o kAIw== 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:mime-version :content-transfer-encoding; bh=z3RNvXfE0NlsmayaUbEE4OnXpuDNaN5qGetG6/PVUj4=; b=5DMJBNVSOsnUV6VBH6oJtfAufQsArF8de09FCdnAnTU+k3o1lrnPonAnBFRYDQq/qa wgLWoT154xEQByh7xNDC5CrvhQF2lE7lMgXhlGZgmPbhf9sou21itch9cYTdUD8ojVR4 srWzz5+Otgn4fj921hDeoIY+7OFjUcUdPrS7M06mhBd7xYPGoGT8WNajkz6oiYQpyhk6 oTALpP5HWJzEUVKzZM6X2kUyIPeZkYugqrAnp5gY5C6cbfyxWl4vqDF0Ypv5LylNPlTq 1Ty7zGQna/U0gDdYazQQ/pMOJcOh9SPEu5DYpZs2FJxIIa1gCBN8QBBLBeC98wTgB7V5 pQjA== X-Gm-Message-State: AOAM533Pe6C/HM5OemclK70LV+QxBsgl84aa03Iq2Y/EgQub1UYxanP2 c53PD5c+usjcS3PldJB5clplNZlT8HQS6g== X-Google-Smtp-Source: ABdhPJyUVr+5jT1ZE/dM+n+8jIkyLU39y2vwAtGwW4BeRH/PBayYpnSQMGbM9/cAgVih4q4KQMS6mg== X-Received: by 2002:a17:902:d4ce:b0:14f:cd14:4fe7 with SMTP id o14-20020a170902d4ce00b0014fcd144fe7mr2379946plg.165.1645454866993; Mon, 21 Feb 2022 06:47:46 -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 s7sm12627580pfb.197.2022.02.21.06.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 06:47:46 -0800 (PST) From: Kito Cheng To: binutils@sourceware.org, kito.cheng@gmail.com, jim.wilson.gcc@gmail.com, research_trasio@irq.a4lg.com, jbeulich@suse.com, philipp.tomsich@vrull.eu, palmer@dabbelt.com, nelson.chu@sifive.com, cmuellner@ventanamicro.com, jiawei@iscas.ac.cn Cc: Kito Cheng Subject: [PATCH] RISC-V: Maintain a string to hold the canonical order Date: Mon, 21 Feb 2022 22:47:40 +0800 Message-Id: <20220221144740.19913-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.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: Mon, 21 Feb 2022 14:47:50 -0000 Using dummy entry in riscv_supported_std_ext cause confusing and wrongly support `b` and `k` extensions. bfd/ * elfxx-riscv.c (riscv_supported_std_ext): Drop unsupported extensions. (riscv_ext_canonical_order): New. (riscv_init_ext_order): Use riscv_ext_canonical_order rather than riscv_supported_std_ext to compute canonical order. --- bfd/elfxx-riscv.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 9f52bb545ac..17633e6fae2 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1163,17 +1163,10 @@ static struct riscv_supported_ext riscv_supported_std_ext[] = {"q", ISA_SPEC_CLASS_20191213, 2, 2, 0 }, {"q", ISA_SPEC_CLASS_20190608, 2, 2, 0 }, {"q", ISA_SPEC_CLASS_2P2, 2, 0, 0 }, - {"l", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, {"c", ISA_SPEC_CLASS_20191213, 2, 0, 0 }, {"c", ISA_SPEC_CLASS_20190608, 2, 0, 0 }, {"c", ISA_SPEC_CLASS_2P2, 2, 0, 0 }, - {"b", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, - {"k", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, - {"j", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, - {"t", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, - {"p", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, {"v", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, - {"n", ISA_SPEC_CLASS_NONE, RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION, 0 }, {NULL, 0, 0, 0, 0} }; @@ -1341,6 +1334,9 @@ riscv_recognized_prefixed_ext (const char *ext) return false; } +/* Canonical order for single letter extensions. */ +static const char riscv_ext_canonical_order[] = "eigmafdqlcbjktpvn"; + /* Array is used to compare the orders of standard extensions quickly. */ static int riscv_ext_order[26] = {0}; @@ -1356,16 +1352,10 @@ riscv_init_ext_order (void) /* The orders of all standard extensions are positive. */ int order = 1; - int i = 0; - while (riscv_supported_std_ext[i].name != NULL) - { - const char *ext = riscv_supported_std_ext[i].name; - riscv_ext_order[(*ext - 'a')] = order++; - i++; - while (riscv_supported_std_ext[i].name - && strcmp (ext, riscv_supported_std_ext[i].name) == 0) - i++; - } + for (const char *ext = &riscv_ext_canonical_order[0]; + *ext != NULL; + ++ext) + riscv_ext_order[(*ext - 'a')] = order++; /* Some of the prefixed keyword are not single letter, so we set their prefixed orders in the riscv_compare_subsets directly, -- 2.34.0