From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by sourceware.org (Postfix) with ESMTPS id 81D333972C0B for ; Tue, 19 May 2020 09:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 81D333972C0B 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-il1-x143.google.com with SMTP id o67so8048110ila.0 for ; Tue, 19 May 2020 02:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=z4uciZeOsXSoSpfsMc5VLTf6woCw1K0GRNcbjhb9iAI=; b=NxIoVgLBjlJcm70BVtx+MPaPknwMpOGqEf4GptVJOwW7nFp1EOFuEruGJR7Wmh5fOq 8dBBPWgPLwyP0MOuq2pu/2ReRbFyL4N7kbQOFXzoHXdcr4+m6FU2ZytJW01QNpdcZ89z 5I3RyhALZ1Q6KaMCB2gcgMCyBu/DKnu4QD6cjrzLkduS7kxMk4T45jWJVSBV1NEZI13c yKfTlTPa/5eI0N4pFSBGWjdD/cyjancVRs2IDQBaJmnmtFnPKNNciMfXb01mXb62VDXC XeLr52K47Km32FYJgNw1u6nm3mpK4qVHckuIi/KXfgHZM9dfcP9eURTd8lTLOI4eaHuG 9Rhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=z4uciZeOsXSoSpfsMc5VLTf6woCw1K0GRNcbjhb9iAI=; b=uW9L7RZUoRLNI/WoGOfMJcMETtT/bIviLcE1x/TIb8nfzYFX5DLX7o36EScBrCxqck xWDPCIMF/fJweDrtF5nLPqjx8gOzuYDtz2PwdMl2iJeb5+0wKJ3ShF4Qm1JOF7GjBPU1 fNyuc9sFlYaNIE1jDCgwzQQ2ZM6TNsM7oh9QHRuM62FcoB6AflNKnyhqOk2KnzrL5PMJ JeabvorAuy+Mtcicfo+ja/GDTx7ptp1QJ6PiKCFxiodVWIoKCAhXt/xT+P10skNf7z4L 6qM45xPQa6uWuvSCc3oAv2FXqncMMta1JliBtfCue2k/HQPuUB0QehKmhQ0EF625vt0N 8zdg== X-Gm-Message-State: AOAM531FEgGvqOKlags0jWbBW2CN3N2uRIHIIP6lyuy5vxryuQbctQU8 AQoFHwA/Llm6rgBfPVo9ACw35/+92JL3sjNrAhrsCw== X-Google-Smtp-Source: ABdhPJw8MFbCFPmGscUoXWJHlDhlrrLTwtXQl2GMRLHOCmUFBmY9tXJc1ePlV+Q0SBGqmg0G6tEp+0L81znHGYymNQU= X-Received: by 2002:a92:9f4b:: with SMTP id u72mr19103076ili.273.1589879304925; Tue, 19 May 2020 02:08:24 -0700 (PDT) MIME-Version: 1.0 References: <1588733747-18787-1-git-send-email-nelson.chu@sifive.com> <1588733747-18787-7-git-send-email-nelson.chu@sifive.com> In-Reply-To: <1588733747-18787-7-git-send-email-nelson.chu@sifive.com> From: Nelson Chu Date: Tue, 19 May 2020 17:08:13 +0800 Message-ID: Subject: Re: [PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version. To: Binutils , gdb-patches@sourceware.org Cc: Palmer Dabbelt , Kito Cheng , Jim Wilson , Andrew Waterman , Andrew Burgess , Alex Bradbury , Maxim Blinov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.3 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: 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: Tue, 19 May 2020 09:08:27 -0000 PING :) On Wed, May 6, 2020 at 10:55 AM Nelson Chu wrote: > > Support new configure option --with-priv-spec to choose the privilege spe= c > version if we don't set the --mpriv-spec option. > > * --with-priv-spec =3D [1.9|1.9.1|1.10|1.11] > The syntax is same as -mpriv-spec option. Assembler will check this sett= ing > if -mpriv-spec option isn=E2=80=99t set. > > gas/ > * config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure o= ption > setting. You can set it by configure option --with-priv-spec. > (riscv_set_default_priv_spec): New function used to set the defau= lt > 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 t= he > 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=3D1.11, s= ince > 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 prop= erties > 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[] =3D DEFAULT_ARCH; > static const char *default_arch_with_ext =3D DEFAULT_RISCV_ARCH_WITH_EXT= ; > static enum riscv_isa_spec_class default_isa_spec =3D ISA_SPEC_CLASS_NON= E; > @@ -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 addre= ss > + 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 =3D 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 spe= c > + according to DEFAULT_PRIV_SPEC. */ > if (default_priv_spec =3D=3D PRIV_SPEC_CLASS_NONE) > - default_priv_spec =3D 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 =3D=3D 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=3D[1.9|1.9.1|1.10|1.11]. > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default con= figuration of --with-priv-spec" >&5 > +$as_echo_n "checking for default configuration of --with-priv-spec... " = >&6; } > + if test "x${with_priv_spec}" !=3D 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=3D[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}" !=3D 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=3Drv32if > +#as: -march=3Drv32if -mpriv-spec=3D1.11 > #objdump: --dwarf=3Dframes > > > 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=3Drv32if > +#as: -march=3Drv32if -mpriv-spec=3D1.11 > #objdump: -dr > > .*:[ ]+file format .* > -- > 2.7.4 >