From patchwork Mon Jan 4 09:48:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 1422033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=FZV+oscN; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8W612VfNz9sRR for ; Mon, 4 Jan 2021 20:48:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B15D03850433; Mon, 4 Jan 2021 09:48:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 1A7B43858C27 for ; Mon, 4 Jan 2021 09:48:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1A7B43858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kito.cheng@sifive.com Received: by mail-pl1-x62b.google.com with SMTP id g3so14268853plp.2 for ; Mon, 04 Jan 2021 01:48:17 -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=fefFd9VzASfpKR1a5DaJWtGhlvK2zjRTvUwRDo+ytBE=; b=FZV+oscNHq4D0j87g8oXETK2mbmRy97kcItT/3RdsYGxpXX53nPTNKvFsUwNQGcref HAt1F8CA6iIp4SAIW1EZV0nAVSYRxJQ1EWmfaVt/C6+w1xK5ItZN7vsrTz+kw60vVTRW FUcJF61TI136/UbxvYPs5oEX497txilF9/bsAiCQJ1I8oSL6KcJ19oQGWbJAflNu7EyK 12uBoVKryeCZP8pnwqgQ17KVOYwAprpzrYMQuvpNcrl5dHoCa7luwxkxq4Cb3axEPZjk moZJRzOzmzFq73PWbP/vqNQxXsGOn0BOnx3pEol0NyFFLro82EHNXVAhw1flgtAMiwGl UTdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fefFd9VzASfpKR1a5DaJWtGhlvK2zjRTvUwRDo+ytBE=; b=pBmhjJHk588qBz0SJhACeNcObCTPr5mhqnV8sKC3xjEaBKjivT5vJwHKwhXAT3SyR7 XNofHnG7x7zI06x0Q5y2/tmnmZ/KHjp1L3H6L17i2tMv4arnkUMWTq6XFJL7k2P6eLN+ zFlapmW75h09NqSX5xUHAqXjOl7icNWDpHFaEZCSLaEmhRhnqxZN2i0ctXUYHUOEwugc kkX5MjOKcSDXDwPagIEKA56cL1UvR3sOHhhGF1e6SyLIUSyPgBV9pSHAnQcDqOPy6F0k 4eJesz+e2wJ8189Vqu0WmLbXoUCh3GTR+wWrUT7MDJ2mJVzccWlHfpl2YW5DpcyDHUZC Ztjw== X-Gm-Message-State: AOAM53261bX3diNF2qLJob5EcASnWY/0zKkLkWv/D3a6prjP34b5hnRW 0LnK9Fvi8a0QXrSQcOdit6xKEATGuGdiiNjJ X-Google-Smtp-Source: ABdhPJwKy0sRKxjd7TLifYuertEqBvjFXNA18xnMrMgV3E87Zo/vik1/pNuKnhgahLLT6GCBIkfbgQ== X-Received: by 2002:a17:902:228:b029:da:6be8:ee22 with SMTP id 37-20020a1709020228b02900da6be8ee22mr72199784plc.44.1609753695885; Mon, 04 Jan 2021 01:48:15 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id a1sm54665921pfo.56.2021.01.04.01.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 01:48:15 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com Subject: [PATCH 1/2] RISC-V: Move class riscv_subset_list and riscv_subset_t to riscv-protos.h Date: Mon, 4 Jan 2021 17:48:04 +0800 Message-Id: <20210104094805.2160-2-kito.cheng@sifive.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104094805.2160-1-kito.cheng@sifive.com> References: <20210104094805.2160-1-kito.cheng@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" Pre-work of new style of architecture extension test macros, we need the list used in `config/riscv/riscv-c.c`, so those struct/class declaration must move to header file rather than local C file. gcc/ChangeLog * common/config/riscv/riscv-common.c (RISCV_DONT_CARE_VERSION): Move to riscv-protos.h. (struct riscv_subset_t): Ditto. (class riscv_subset_list): Ditto. * config/riscv/riscv-protos.h (RISCV_DONT_CARE_VERSION): Move from riscv-common.c. (struct riscv_subset_t): Ditto. (class riscv_subset_list): Ditto. --- gcc/common/config/riscv/riscv-common.c | 66 ------------------------- gcc/config/riscv/riscv-protos.h | 67 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c index 5e3ddcf3f81..3a8bcbef006 100644 --- a/gcc/common/config/riscv/riscv-common.c +++ b/gcc/common/config/riscv/riscv-common.c @@ -31,22 +31,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-core.h" #include "config/riscv/riscv-protos.h" -#define RISCV_DONT_CARE_VERSION -1 - -/* Subset info. */ -struct riscv_subset_t -{ - riscv_subset_t (); - - std::string name; - int major_version; - int minor_version; - struct riscv_subset_t *next; - - bool explicit_version_p; - bool implied_p; -}; - /* Type for implied ISA info. */ struct riscv_implied_info_t { @@ -123,56 +107,6 @@ static const riscv_cpu_info riscv_cpu_tables[] = {NULL, NULL, NULL} }; -/* Subset list. */ -class riscv_subset_list -{ -private: - /* Original arch string. */ - const char *m_arch; - - /* Location of arch string, used for report error. */ - location_t m_loc; - - /* Head of subset info list. */ - riscv_subset_t *m_head; - - /* Tail of subset info list. */ - riscv_subset_t *m_tail; - - /* X-len of m_arch. */ - unsigned m_xlen; - - riscv_subset_list (const char *, location_t); - - const char *parsing_subset_version (const char *, const char *, unsigned *, - unsigned *, bool, bool *); - - const char *parse_std_ext (const char *); - - const char *parse_multiletter_ext (const char *, const char *, - const char *); - - void handle_implied_ext (riscv_subset_t *); - -public: - ~riscv_subset_list (); - - void add (const char *, int, int, bool, bool); - - void add (const char *, bool); - - riscv_subset_t *lookup (const char *, - int major_version = RISCV_DONT_CARE_VERSION, - int minor_version = RISCV_DONT_CARE_VERSION) const; - - std::string to_string (bool) const; - - unsigned xlen() const {return m_xlen;}; - - static riscv_subset_list *parse (const char *, location_t); - -}; - static const char *riscv_supported_std_ext (void); static riscv_subset_list *current_subset_list = NULL; diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 256dab1d0cf..1a258553d73 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -108,4 +108,71 @@ struct riscv_cpu_info { extern const riscv_cpu_info *riscv_find_cpu (const char *); +#define RISCV_DONT_CARE_VERSION -1 + +/* Subset info. */ +struct riscv_subset_t +{ + riscv_subset_t (); + + std::string name; + int major_version; + int minor_version; + struct riscv_subset_t *next; + + bool explicit_version_p; + bool implied_p; +}; + +/* Subset list. */ +class riscv_subset_list +{ +private: + /* Original arch string. */ + const char *m_arch; + + /* Location of arch string, used for report error. */ + location_t m_loc; + + /* Head of subset info list. */ + riscv_subset_t *m_head; + + /* Tail of subset info list. */ + riscv_subset_t *m_tail; + + /* X-len of m_arch. */ + unsigned m_xlen; + + riscv_subset_list (const char *, location_t); + + const char *parsing_subset_version (const char *, const char *, unsigned *, + unsigned *, bool, bool *); + + const char *parse_std_ext (const char *); + + const char *parse_multiletter_ext (const char *, const char *, + const char *); + + void handle_implied_ext (riscv_subset_t *); + +public: + ~riscv_subset_list (); + + void add (const char *, int, int, bool, bool); + + void add (const char *, bool); + + riscv_subset_t *lookup (const char *, + int major_version = RISCV_DONT_CARE_VERSION, + int minor_version = RISCV_DONT_CARE_VERSION) const; + + std::string to_string (bool) const; + + unsigned xlen () const {return m_xlen;}; + + static riscv_subset_list *parse (const char *, location_t); + + int match_score (riscv_subset_list *) const; +}; + #endif /* ! GCC_RISCV_PROTOS_H */