From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by sourceware.org (Postfix) with ESMTPS id 555C03894E7C for ; Wed, 6 May 2020 02:55:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 555C03894E7C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nelson.chu@sifive.com Received: by mail-pj1-x1043.google.com with SMTP id a32so151137pje.5 for ; Tue, 05 May 2020 19:55:59 -0700 (PDT) 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=XKis86XVxytY9cshQIo7sQT6MKb9eNZGA/t2QrM61Ws=; b=S8KZfSg6OEo/9lgUvOziYi0ewMMu7I074i60QLAQUDM/4Y9F5IDQNqUgbuExuQEsPX PB/amnsRBTTKlh2hxU53hn/CGDPczY9Cf+Ti3G3Hnqn76evYhovXcjwBGDiAJrdlq4lc DGcomvWjH1WQC33nl3NhXQZipvRt3EWKVzuirKfKVVNqt+gfqoU1ILx/nHnk3A3agRId JfUq2tGM2qY6ZuOSef4M0RpgM+H6HsNhBXRxPYwpNdTxHbPbkM5Bb5PhUPAYZWRO+vNa PxMHDdHKW/bLHD0MoAqAkbQx53dFpxzADOf/qIOzy7E3QQ3DYnw9M9svGe1JgFGIIGJ8 JQVw== 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=XKis86XVxytY9cshQIo7sQT6MKb9eNZGA/t2QrM61Ws=; b=mlcZqRGJM7l2dt87ZE68qUJiwuryRjEqGA6Hv6fKiwrXeNBq98wPw2idXIkI2nPDKi QWwVbBY1tJrkTKg54SVH1vE/55WQhUpJjILJPsUcnHpb82yBkOQMoEcvgyDR9xVO2rW8 v9Q3Sqv+bCZCzNDIxPavUckjs9Un7ymNqXFuLGuSAuDQHFODNH4OPslKhuDMRkLOENs7 hu/mbG/pa2UaN/qWJ8/FtUw+jlLeZhQpoO4ttccmFKDVYP509GwgTGm0I4caR6GaUNgZ NAPBbtlR4FPF/pnZU0cOin+9wLSuIb8ufSD2GbibftcA+c/X0a+zcvrEIE9Qgn4vxfeC xF+A== X-Gm-Message-State: AGi0PuazbVMshRBHOiqmRfvNgDOW9Y0cz0U2l6WmgcUUGyqV+tuk9HAL H4n7YDhBXNpq1QYXPpWnr6NmdQ== X-Google-Smtp-Source: APiQypL6UVWpfw9irEs0LusiSA6hOXkaRpCYJsAF9uRka33JIQ/Qc7DV6y4dHO+XfQB7Wfqjp9Ulzw== X-Received: by 2002:a17:90a:bf08:: with SMTP id c8mr6792577pjs.20.1588733758339; Tue, 05 May 2020 19:55:58 -0700 (PDT) Received: from gamma05.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id 141sm222996pfz.171.2020.05.05.19.55.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 19:55:57 -0700 (PDT) From: Nelson Chu To: binutils@sourceware.org, gdb-patches@sourceware.org Cc: palmer@dabbelt.com, kito.cheng@sifive.com, jimw@sifive.com, andrew@sifive.com, andrew.burgess@embecosm.com, asb@lowrisc.org, maxim.blinov@embecosm.com, nelson.chu@sifive.com Subject: [PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version. Date: Tue, 5 May 2020 19:55:44 -0700 Message-Id: <1588733747-18787-7-git-send-email-nelson.chu@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588733747-18787-1-git-send-email-nelson.chu@sifive.com> References: <1588733747-18787-1-git-send-email-nelson.chu@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2020 02:56:02 -0000 Support new configure option --with-priv-spec to choose the privilege spec version if we don't set the --mpriv-spec option. * --with-priv-spec = [1.9|1.9.1|1.10|1.11] The syntax is same as -mpriv-spec option. Assembler will check this setting if -mpriv-spec option isn’t set. gas/ * config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option setting. You can set it by configure option --with-priv-spec. (riscv_set_default_priv_spec): New function used to set the default privilege spec. (md_parse_option): Call riscv_set_default_priv_spec rather than call riscv_get_priv_spec_class directly. (riscv_after_parse_args): If -mpriv-spec isn't set, then we set the default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by calling riscv_set_default_priv_spec. * testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since the --with-priv-spec may be set to different privilege spec. * testsuite/gas/riscv/priv-reg.d: Likewise. * configure.ac: Add configure option --with-priv-spec. * configure: Regenerated. * config.in: Regenerated. --- gas/config.in | 3 +++ gas/config/tc-riscv.c | 36 ++++++++++++++++++++++++-------- gas/configure | 13 ++++++++++++ gas/configure.ac | 8 +++++++ gas/testsuite/gas/riscv/csr-dw-regnums.d | 2 +- gas/testsuite/gas/riscv/priv-reg.d | 2 +- 6 files changed, 53 insertions(+), 11 deletions(-) diff --git a/gas/config.in b/gas/config.in index e20d3c3..bd12504 100644 --- a/gas/config.in +++ b/gas/config.in @@ -62,6 +62,9 @@ /* Define default value for RISC-V -misa-spec. */ #undef DEFAULT_RISCV_ISA_SPEC +/* Define default value for RISC-V -mpriv-spec */ +#undef DEFAULT_RISCV_PRIV_SPEC + /* Define to 1 if you want to generate GNU x86 used ISA and feature properties by default. */ #undef DEFAULT_X86_USED_NOTE diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 743e4bb..6fd1dcf 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -79,6 +79,10 @@ struct riscv_cl_insn #define DEFAULT_RISCV_ISA_SPEC "2.2" #endif +#ifndef DEFAULT_RISCV_PRIV_SPEC +#define DEFAULT_RISCV_PRIV_SPEC "1.11" +#endif + static const char default_arch[] = DEFAULT_ARCH; static const char *default_arch_with_ext = DEFAULT_RISCV_ARCH_WITH_EXT; static enum riscv_isa_spec_class default_isa_spec = ISA_SPEC_CLASS_NONE; @@ -111,6 +115,25 @@ riscv_set_default_isa_spec (const char *s) return 1; } +/* Set the default_priv_spec, assembler will find the suitable CSR address + according to default_priv_spec. Return 0 if the input priv name isn't + supported. Otherwise, return 1. */ + +static int +riscv_set_default_priv_spec (const char *s) +{ + enum riscv_priv_spec_class class; + if (!riscv_get_priv_spec_class (s, &class)) + { + as_bad (_("Unknown default privilege spec `%s' set by " + "-mpriv-spec or --with-priv-spec"), s); + return 0; + } + else + default_priv_spec = class; + return 1; +} + /* This is the set of options which the .option pseudo-op may modify. */ struct riscv_set_options @@ -2626,13 +2649,7 @@ md_parse_option (int c, const char *arg) return riscv_set_default_isa_spec (arg); case OPTION_MPRIV_SPEC: - if (!riscv_get_priv_spec_class (arg, &default_priv_spec)) - { - as_bad ("Unknown default privilege spec `%s' set by " - "-mpriv-spec", arg); - return 0; - } - break; + return riscv_set_default_priv_spec (arg); default: return 0; @@ -2681,9 +2698,10 @@ riscv_after_parse_args (void) if (riscv_subset_supports ("e")) riscv_set_rve (TRUE); - /* Set the default privilege spec to the newest one. */ + /* If the -mpriv-spec isn't set, then we set the default privilege spec + according to DEFAULT_PRIV_SPEC. */ if (default_priv_spec == PRIV_SPEC_CLASS_NONE) - default_priv_spec = PRIV_SPEC_CLASS_1P11; + riscv_set_default_priv_spec (DEFAULT_RISCV_PRIV_SPEC); /* Infer ABI from ISA if not specified on command line. */ if (abi_xlen == 0) diff --git a/gas/configure b/gas/configure index cc21e0a..72e33d9 100755 --- a/gas/configure +++ b/gas/configure @@ -13054,6 +13054,19 @@ _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_isa_spec" >&5 $as_echo "$with_isa_spec" >&6; } + + # --with-priv-spec=[1.9|1.9.1|1.10|1.11]. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-priv-spec" >&5 +$as_echo_n "checking for default configuration of --with-priv-spec... " >&6; } + if test "x${with_priv_spec}" != x; then + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_RISCV_PRIV_SPEC "$with_priv_spec" +_ACEOF + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_priv_spec" >&5 +$as_echo "$with_priv_spec" >&6; } ;; rl78) diff --git a/gas/configure.ac b/gas/configure.ac index 8a5f5c5..82122e8 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -596,6 +596,14 @@ changequote([,])dnl [Define default value for RISC-V -misa-spec.]) fi AC_MSG_RESULT($with_isa_spec) + + # --with-priv-spec=[1.9|1.9.1|1.10|1.11]. + AC_MSG_CHECKING(for default configuration of --with-priv-spec) + if test "x${with_priv_spec}" != x; then + AC_DEFINE_UNQUOTED(DEFAULT_RISCV_PRIV_SPEC, "$with_priv_spec", + [Define default value for RISC-V -mpriv-spec]) + fi + AC_MSG_RESULT($with_priv_spec) ;; rl78) diff --git a/gas/testsuite/gas/riscv/csr-dw-regnums.d b/gas/testsuite/gas/riscv/csr-dw-regnums.d index df9642f..c03d459 100644 --- a/gas/testsuite/gas/riscv/csr-dw-regnums.d +++ b/gas/testsuite/gas/riscv/csr-dw-regnums.d @@ -1,4 +1,4 @@ -#as: -march=rv32if +#as: -march=rv32if -mpriv-spec=1.11 #objdump: --dwarf=frames diff --git a/gas/testsuite/gas/riscv/priv-reg.d b/gas/testsuite/gas/riscv/priv-reg.d index 8fc41d2..a0c3cd7 100644 --- a/gas/testsuite/gas/riscv/priv-reg.d +++ b/gas/testsuite/gas/riscv/priv-reg.d @@ -1,4 +1,4 @@ -#as: -march=rv32if +#as: -march=rv32if -mpriv-spec=1.11 #objdump: -dr .*:[ ]+file format .* -- 2.7.4