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 */ From patchwork Mon Jan 4 09:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kito Cheng X-Patchwork-Id: 1422034 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=JIumCno5; 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 4D8W670KMYz9sRR for ; Mon, 4 Jan 2021 20:48:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C9E9387087C; Mon, 4 Jan 2021 09:48:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 15C5D387087C for ; Mon, 4 Jan 2021 09:48:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 15C5D387087C 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-x630.google.com with SMTP id be12so14267474plb.4 for ; Mon, 04 Jan 2021 01:48:20 -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=j2W9oSDM6G7yFq1dFe/2moxrG32tRwpHhRin0rKTmAE=; b=JIumCno5SdJAjuZ7Gw6TgsHQsUa8PlBgeo5dapNBcJKt2uttTkxR2pjOYpGqpSbxjA J/X4wzYlImW27sOovHJWsMj08B7i/otQJeIKtT/MUXHsi5DkWklr4F4x0l5eJAaca/br zmHA9b0OpVRPPeHWmTe6vhNrJkX7TyB4R4rn/cLOjpaC6SgIjiPySFl3jeLaDURhTZXO g2dUVAxU/IsKCk05ql3Qkx/CdCNJCF0cyTOV0WblSmtgPFfPzG91W6KfiDFpnEclRkzi QTGobsYxPCmbZgl5gruoNP8xaQuHeI4VYZ1NMMTs8dTLZik5kIZD6rx0tbyZxXNkcRp+ nOWw== 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=j2W9oSDM6G7yFq1dFe/2moxrG32tRwpHhRin0rKTmAE=; b=UibZ58WdedV9vHogB0pQNcN4bNfKIXqrYvqxE+Tty2xfMEZ6Db9JXAGPKyfojkdusx 0w5QSdsDlaMWQnErW6Hbz9OeFVF2S8L8UyPmLjow3qhBxSYekL5CinHxmBGvU1Bzm2jV dlTVzXDXH7yEkqWJxZJVTk71wnFHWPYJp9lm5Uf6638wo5jIh5XrUp9AoxSBmoulA+PB b1YQU6EknPY5wDKv8k84C0ohgfYoQOBc9lMQ20LgvTAhrOt/gq2qKbtIfw3BzHZTzxQx OmWbRhuoUCZnZWuP53F+m+41TnUy+QKsTG3hSHP939tF9CsChDV1AkoRNDW69UCFbBXs Q87w== X-Gm-Message-State: AOAM533fXXUaeBpwbdbDA4l0K+u40FYi941+XUfFB4QlSYcER2yybZGI nprG9ddC9zq8ngOoNbtX1VkEoto2qyY4QIgL X-Google-Smtp-Source: ABdhPJy/z6J5Jblx6TZhDtqQ9Jzq7ASxtHHU5rvDkYn17KIANGIRtOrizyLFrtfKeOwsevfAv/gGcA== X-Received: by 2002:a17:90a:398d:: with SMTP id z13mr29119872pjb.1.1609753698792; Mon, 04 Jan 2021 01:48:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jan 2021 01:48:18 -0800 (PST) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com Subject: [PATCH 2/2] RISC-V: Implement new style of architecture extension test macros. Date: Mon, 4 Jan 2021 17:48:05 +0800 Message-Id: <20210104094805.2160-3-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" - This patch introduce new set of architecture extension test macros which is accept on riscv-c-api-doc recently. - https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md#architecture-extension-test-macro - We will also mark deprecated for legacy architecture extension test macros in GCC 11, but still support that for 1 or 2 release cycles. gcc/ChangeLog: * common/config/riscv/riscv-common.c (riscv_current_subset_list): New. * config/riscv/riscv-c.c (riscv-protos.h): New. (riscv_cpu_cpp_builtins): Add new style architecture extension test macros. * config/riscv/riscv-protos.h (string): (riscv_subset_list::begin): New. (riscv_subset_list::end): New. (riscv_current_subset_list): New. gcc/testsuite/ChangeLog: * gcc.target/riscv/predef-10.c: New. * gcc.target/riscv/predef-11.c: New. * gcc.target/riscv/predef-12.c: New. * gcc.target/riscv/predef-13.c: New. --- gcc/common/config/riscv/riscv-common.c | 5 +++ gcc/config/riscv/riscv-c.c | 31 ++++++++++++++++ gcc/config/riscv/riscv-protos.h | 7 ++++ gcc/testsuite/gcc.target/riscv/predef-10.c | 43 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/predef-11.c | 43 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/predef-12.c | 43 ++++++++++++++++++++++ gcc/testsuite/gcc.target/riscv/predef-13.c | 43 ++++++++++++++++++++++ 7 files changed, 215 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/predef-10.c create mode 100644 gcc/testsuite/gcc.target/riscv/predef-11.c create mode 100644 gcc/testsuite/gcc.target/riscv/predef-12.c create mode 100644 gcc/testsuite/gcc.target/riscv/predef-13.c diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c index 3a8bcbef006..c859440c477 100644 --- a/gcc/common/config/riscv/riscv-common.c +++ b/gcc/common/config/riscv/riscv-common.c @@ -111,6 +111,11 @@ static const char *riscv_supported_std_ext (void); static riscv_subset_list *current_subset_list = NULL; +const riscv_subset_list *riscv_current_subset_list () +{ + return current_subset_list; +} + riscv_subset_t::riscv_subset_t () : name (), major_version (0), minor_version (0), next (NULL), explicit_version_p (false), implied_p (false) diff --git a/gcc/config/riscv/riscv-c.c b/gcc/config/riscv/riscv-c.c index c600badb313..e8c5f375374 100644 --- a/gcc/config/riscv/riscv-c.c +++ b/gcc/config/riscv/riscv-c.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "c-family/c-common.h" #include "cpplib.h" +#include "riscv-protos.h" #define builtin_define(TXT) cpp_define (pfile, TXT) @@ -101,4 +102,34 @@ riscv_cpu_cpp_builtins (cpp_reader *pfile) break; } + + /* Define architecture extension test macros. */ + builtin_define_with_int_value ("__riscv_arch_test", 1); + + const riscv_subset_list *subset_list = riscv_current_subset_list (); + size_t max_ext_len = 0; + + /* Figure out the max length of extension name for reserving buffer. */ + for (const riscv_subset_t *subset = subset_list->begin (); + subset != subset_list->end (); + subset = subset->next) + max_ext_len = MAX (max_ext_len, subset->name.length ()); + + char *buf = (char *)alloca (max_ext_len + 10 /* For __riscv_ and '\0'. */); + + for (const riscv_subset_t *subset = subset_list->begin (); + subset != subset_list->end (); + subset = subset->next) + { + int version_value = (subset->major_version * 1000000) + + (subset->minor_version * 1000); + /* Special rule for zicsr and zifencei, it's used for ISA spec 2.2 or + earlier. */ + if ((subset->name == "zicsr" || subset->name == "zifencei") + && version_value == 0) + version_value = 2000000; + + sprintf (buf, "__riscv_%s", subset->name.c_str ()); + builtin_define_with_int_value (buf, version_value); + } } diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 1a258553d73..bbd38ff0170 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -22,6 +22,8 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_RISCV_PROTOS_H #define GCC_RISCV_PROTOS_H +#include + /* Symbol types we understand. The order of this list must match that of the unspec enum in riscv.md, subsequent to UNSPEC_ADDRESS_FIRST. */ enum riscv_symbol_type { @@ -173,6 +175,11 @@ public: static riscv_subset_list *parse (const char *, location_t); int match_score (riscv_subset_list *) const; + + const riscv_subset_t *begin () const {return m_head;}; + const riscv_subset_t *end () const {return NULL;}; }; +extern const riscv_subset_list *riscv_current_subset_list (void); + #endif /* ! GCC_RISCV_PROTOS_H */ diff --git a/gcc/testsuite/gcc.target/riscv/predef-10.c b/gcc/testsuite/gcc.target/riscv/predef-10.c new file mode 100644 index 00000000000..7c447bfb08d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-10.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32i2p0 -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 32 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000)) +#error "__riscv_i" +#endif + +#if defined(__riscv_c) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if defined(__riscv_a) +#error "__riscv_a" +#endif + +#if defined(__riscv_m) +#error "__riscv_m" +#endif + +#if defined(__riscv_f) +#error "__riscv_f" +#endif + +#if defined(__riscv_d) +#error "__riscv_d" +#endif + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/predef-11.c b/gcc/testsuite/gcc.target/riscv/predef-11.c new file mode 100644 index 00000000000..80f48113dfa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-11.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64gc -mabi=lp64 -mcmodel=medlow -misa-spec=2.2" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 64 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000)) +#error "__riscv_i" +#endif + +#if !defined(__riscv_c) || (__riscv_c != (2 * 1000 * 1000)) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if !defined(__riscv_a) || (__riscv_a != (2 * 1000 * 1000)) +#error "__riscv_a" +#endif + +#if !defined(__riscv_m) || (__riscv_m != (2 * 1000 * 1000)) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) || (__riscv_f != (2 * 1000 * 1000)) +#error "__riscv_f" +#endif + +#if !defined(__riscv_d) || (__riscv_d != (2 * 1000 * 1000)) +#error "__riscv_d" +#endif + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/predef-12.c b/gcc/testsuite/gcc.target/riscv/predef-12.c new file mode 100644 index 00000000000..dd35dbde925 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-12.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64gc -mabi=lp64 -mcmodel=medlow -misa-spec=20191213" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 64 +#error "__riscv_xlen" +#endif + +#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_i" +#endif + +#if !defined(__riscv_c) || (__riscv_c != (2 * 1000 * 1000)) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if !defined(__riscv_a) || (__riscv_a != (2 * 1000 * 1000 + 1 * 1000)) +#error "__riscv_a" +#endif + +#if !defined(__riscv_m) || (__riscv_m != (2 * 1000 * 1000)) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) || (__riscv_f != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_f" +#endif + +#if !defined(__riscv_d) || (__riscv_d != (2 * 1000 * 1000 + 2 * 1000)) +#error "__riscv_d" +#endif + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/predef-13.c b/gcc/testsuite/gcc.target/riscv/predef-13.c new file mode 100644 index 00000000000..95cf0012408 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-13.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32e -mabi=ilp32e -mcmodel=medlow -misa-spec=2.2" } */ + +int main () { + +#ifndef __riscv_arch_test +#error "__riscv_arch_test" +#endif + +#if __riscv_xlen != 32 +#error "__riscv_xlen" +#endif + +#if defined(__riscv_i) +#error "__riscv_i" +#endif + +#if defined(__riscv_c) +#error "__riscv_c" +#endif + +#if !defined(__riscv_e) || (__riscv_e != (1 * 1000 * 1000 + 9 * 1000)) +#error "__riscv_e" +#endif + +#if defined(__riscv_a) +#error "__riscv_a" +#endif + +#if defined(__riscv_m) +#error "__riscv_m" +#endif + +#if defined(__riscv_f) +#error "__riscv_f" +#endif + +#if defined(__riscv_d) +#error "__riscv_d" +#endif + + return 0; +}