From patchwork Thu Jan 7 09:55:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 1423212 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=8.43.85.97; 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=fEXcOFeD; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (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 4DBM7Y07Swz9sRR for ; Thu, 7 Jan 2021 20:56:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3A21396DC27; Thu, 7 Jan 2021 09:55:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 1D6E2395206E for ; Thu, 7 Jan 2021 09:55:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D6E2395206E 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-x633.google.com with SMTP id r4so3206968pls.11 for ; Thu, 07 Jan 2021 01:55:55 -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=JZefTj37AH57fz95IkLSJBGQFyNk0Ege2FIAJwijF+g=; b=fEXcOFeDKa9ZSwM2ApxXFxtcFCNekgLri7Lvoru6XbUYur6U9vQgMDrwHKZQ/uaTgK 3A+ufztcGjeLpt9KYek1ZkZAvzt0IjCafF6Z5lj8M3mwvmokgngst8G6QwaZ8delBo3m PJ9xbuV0vyEJY4GGJTqcQb+Rml7zqTugWYSVrG5jdABUM1Kfj/FuAGiVblm72HX3FWKM S6huycXOwQYnoCWuWzIdCwbeDW2sKNXugXaKnm8cwxJ8prepfnB8iuFIx+8rNNWKdoBw aiJj667Q0IeU78/F2o030Ejo7vCoCqvamVLc5dHfW4a61AuSzrqHXF2nX+aXmM9GWfgX 4zyA== 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=JZefTj37AH57fz95IkLSJBGQFyNk0Ege2FIAJwijF+g=; b=tFuzL5OFUFilAYU4P8msV9p4SldaM/jZUBuqOmyppBP7kp7cosFqbOlsZGUU+9XeKq 6OYj92m3/k/N1p9zXkLttlzP0JO6fCl8+bRKa2gsJ0ihlbO8W8eH8n6wVfcToyVCy17F /Gr2r0Ns2E/c4jD6H+SpkFeLJCmZf3kxn2nbPpA5JZUX63MICtfZaLafCkv6L+mgZ1vy zvJzmGbNW5y6FMl92Ka4UVUCVw6eVtvUF4n3iTzqnEmkUUFZW9u+EKM6oncGFqavkhZ8 Prf8sxSadvqAcf/kLurL43kALL/Vpkz+3qSPV9TSdb9MNK4JPzhvC/usWnjWNP5KLp6J RCfA== X-Gm-Message-State: AOAM5330uF6hM9rvhSkEBCzcMhW7DMqyYMB3Wo7S17cwtlMcox+SnxXL DfABwfCZwpPmh8rmCNKnDkY2CBmW+JZAkEKF X-Google-Smtp-Source: ABdhPJyiB06bMGnEudgHKqreqkE/mhlFt/4ciUruHB6JA2o11AvW7I3Om6ijB9FhooJsjVYf+M3Dxw== X-Received: by 2002:a17:903:2288:b029:dd:5a71:67a9 with SMTP id b8-20020a1709032288b02900dd5a7167a9mr2704576plh.57.1610013353798; Thu, 07 Jan 2021 01:55:53 -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 19sm5105212pfn.133.2021.01.07.01.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 01:55:53 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com Subject: [PATCH v2 1/2] RISC-V: Move class riscv_subset_list and riscv_subset_t to riscv-protos.h Date: Thu, 7 Jan 2021 17:55:43 +0800 Message-Id: <20210107095544.20845-2-kito.cheng@sifive.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107095544.20845-1-kito.cheng@sifive.com> References: <20210107095544.20845-1-kito.cheng@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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-subset.h. (struct riscv_subset_t): Ditto. (class riscv_subset_list): Ditto. * config/riscv/riscv-subset.h (RISCV_DONT_CARE_VERSION): Move from riscv-common.c. (struct riscv_subset_t): Ditto. (class riscv_subset_list): Ditto. * config/riscv/t-riscv ($(common_out_file)): Add file dependency. --- gcc/common/config/riscv/riscv-common.c | 67 +------------------ gcc/config/riscv/riscv-subset.h | 90 ++++++++++++++++++++++++++ gcc/config/riscv/t-riscv | 4 +- 3 files changed, 94 insertions(+), 67 deletions(-) create mode 100644 gcc/config/riscv/riscv-subset.h diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c index 7b75114421d..934c716a2e8 100644 --- a/gcc/common/config/riscv/riscv-common.c +++ b/gcc/common/config/riscv/riscv-common.c @@ -30,22 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #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; -}; +#include "config/riscv/riscv-subset.h" /* Type for implied ISA info. */ struct riscv_implied_info_t @@ -123,56 +108,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-subset.h b/gcc/config/riscv/riscv-subset.h new file mode 100644 index 00000000000..ae7401ac0c4 --- /dev/null +++ b/gcc/config/riscv/riscv-subset.h @@ -0,0 +1,90 @@ +/* Definition of data structure of RISC-V subset for GNU compiler. + Copyright (C) 2011-2021 Free Software Foundation, Inc. + Contributed by Andrew Waterman (andrew@sifive.com). + Based on MIPS target for GNU compiler. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_RISCV_SUBSET_H +#define GCC_RISCV_SUBSET_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; +}; + +/* 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); +}; + +#endif /* ! GCC_RISCV_SUBSET_H */ diff --git a/gcc/config/riscv/t-riscv b/gcc/config/riscv/t-riscv index 702767c1736..1215ea8b734 100644 --- a/gcc/config/riscv/t-riscv +++ b/gcc/config/riscv/t-riscv @@ -25,4 +25,6 @@ riscv-shorten-memrefs.o: $(srcdir)/config/riscv/riscv-shorten-memrefs.c PASSES_EXTRA += $(srcdir)/config/riscv/riscv-passes.def -$(common_out_file): $(srcdir)/config/riscv/riscv-cores.def +$(common_out_file): $(srcdir)/config/riscv/riscv-cores.def \ + $(srcdir)/config/riscv/riscv-protos.h \ + $(srcdir)/config/riscv/riscv-subset.h