From: Nelson Chu <nelson.chu@sifive.com>
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 [thread overview]
Message-ID: <1588733747-18787-7-git-send-email-nelson.chu@sifive.com> (raw)
In-Reply-To: <1588733747-18787-1-git-send-email-nelson.chu@sifive.com>
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
next prev parent reply other threads:[~2020-05-06 2:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 2:55 [PATCH v2 0/9] RISC-V: Support version controling for ISA standard extensions and CSR Nelson Chu
2020-05-06 2:55 ` [PATCH v2 1/9] RISC-V: Remove the redundant gas test file Nelson Chu
2020-05-19 9:07 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 2/9] RISC-V: Forgot to update the priv-reg-fail-read-only-01 test case Nelson Chu
2020-05-19 9:07 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions Nelson Chu
2020-05-19 9:07 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default Nelson Chu
2020-05-19 9:07 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version Nelson Chu
2020-05-19 9:08 ` Nelson Chu
2020-05-06 2:55 ` Nelson Chu [this message]
2020-05-19 9:08 ` [PATCH v2 6/9] RISC-V: Support configure option to choose the " Nelson Chu
2020-05-06 2:55 ` [PATCH v2 7/9] RISC-V: Make privilege spec attributes workable Nelson Chu
2020-05-19 9:08 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 8/9] RISC-V: Disassembler dumps the CSR according to the chosen privilege spec Nelson Chu
2020-05-19 9:08 ` Nelson Chu
2020-05-06 2:55 ` [PATCH v2 9/9] RISC-V: Add documents and --help for the new GAS and OBJDUMP options Nelson Chu
2020-05-19 9:08 ` Nelson Chu
2020-05-19 9:07 ` [PATCH v2 0/9] RISC-V: Support version controling for ISA standard extensions and CSR Nelson Chu
2020-05-20 16:27 ` Nick Clifton
2020-05-21 2:38 ` Nelson Chu
2020-05-21 7:29 ` Nick Clifton
2020-05-21 9:11 ` Nelson Chu
2020-05-28 20:09 ` Jim Wilson
2020-05-29 1:02 ` Nelson Chu
2020-06-01 21:35 ` Jim Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1588733747-18787-7-git-send-email-nelson.chu@sifive.com \
--to=nelson.chu@sifive.com \
--cc=andrew.burgess@embecosm.com \
--cc=andrew@sifive.com \
--cc=asb@lowrisc.org \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=jimw@sifive.com \
--cc=kito.cheng@sifive.com \
--cc=maxim.blinov@embecosm.com \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).