From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by sourceware.org (Postfix) with ESMTPS id 35916396ECCD for ; Tue, 19 May 2020 09:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 35916396ECCD 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-x144.google.com with SMTP id l20so12665557ilj.10 for ; Tue, 19 May 2020 02:08:08 -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; bh=o7LfJIBRb6q/crJZK3j5qdUixW9yHvvFR/1VVAkjZw8=; b=gzj4fxs2le/LRh/DUMCwrGoylilMV6WPA8qD6gAG3YI9XtXOZMw7vhmh1ZBWHHFsSY l/7vqldaayj35CLkrx1fD3GVylA5skmHwgVq+pXDT2/+SkrR28TGs3fMYU24x8kJxeZP C9+2v1YcHMGquzvvDbb4SSi2E2QgaQHv+Bdgbrh9oY2tRkOkbpjlIwoXPoR7KUHS5nOz Gyv8/EV37TiRCac9Ws2JgQO9IJ5hhquXDmGNfKsGdBM2jpUEBgUy6LkLPiLqyTi38zQ4 3Iq6L7jvgyRLTRYBiuDv91aS5wIl9g+ucchm1zzPY8lji7W47RjPs03FtDURLaLZN/NF wnPw== 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; bh=o7LfJIBRb6q/crJZK3j5qdUixW9yHvvFR/1VVAkjZw8=; b=k3i+rNZ8LpsahP0pLYWfz30mMs5qqmvsv9C8dMtpg1krC1QYyiDLXWFSLTKvo0bxWS tuWIh7lemKWxQP70CikxKJYXctWOSP7tI66eQEBJHgF24bt4aGkxmAhMoqGdUxKhBfNZ tAso+xEwySs61D8qdpHNSnLxVNiViHt/J9dj+uPCBhAcFx8kKcofbUZu1NBYEv/0+wcL kDv9bqRz49KzLXN6T4MqBbbHYqwkurJs/hUD9dtnn8MxGkD70TR9yKq8Jz922VeDlNgC JXniLHBz29oVegRsAjIcnQXrq6iwD+tI+sabP/5qr1pe+Yaqv7dl7OQmcQnKmtng/YLe hEag== X-Gm-Message-State: AOAM531TG2NSoB+kD7P9n9zKkLtCuvL9ORXfp5RO/Ss8+192/bw4Ubxi vaGbuIRaKX3osFVuHgWkxSs1yGFfjVkbjeYiuLPNZw== X-Google-Smtp-Source: ABdhPJzimB/l4t74G5uTBB2OWz9iTe3FdDHKZFRpf0NbO2K8t99P6u4r87gZIiqkdzsVu1K5WcdkvPq5yHYMPTQlI1Y= X-Received: by 2002:a92:2801:: with SMTP id l1mr14111061ilf.132.1589879287558; Tue, 19 May 2020 02:08:07 -0700 (PDT) MIME-Version: 1.0 References: <1588733747-18787-1-git-send-email-nelson.chu@sifive.com> <1588733747-18787-5-git-send-email-nelson.chu@sifive.com> In-Reply-To: <1588733747-18787-5-git-send-email-nelson.chu@sifive.com> From: Nelson Chu Date: Tue, 19 May 2020 17:07:56 +0800 Message-ID: Subject: Re: [PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default. 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" X-Spam-Status: No, score=-10.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:14 -0000 PING :) On Wed, May 6, 2020 at 10:55 AM Nelson Chu wrote: > > Support new configure options --with-arch and --with-isa-spec to set > ISA versions if we do not set the -march and -misa-spec options. > > * --with-arch = > The syntax of is same as -march option. Assembler will > check this if -march option and ELF arch attributes are not set. > > * --with-isa-spec = [2.2|20190608|20191213] > The syntax is same as -misa-spec option. Assembler will check this if > -misa-spec option is not set. > > The Priority of these options, > > * ELF arch attributes > Assembler options > Default configure options > * For GAS options, -march > -misa-spec > * For configure options, --with-arch > --with-isa-spec > > gas/ > * config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT, > DEFAULT_RISCV_ISA_SPEC): Default configure option settings. > You can set them by configure options --with-arch and > --with-isa-spec, respectively. > (riscv_set_default_isa_spec): New function used to set the > default ISA spec. > (md_parse_option): Call riscv_set_default_isa_spec rather than > call riscv_get_isa_spec_class directly. > (riscv_after_parse_args): If the -isa-spec is not set, then we > set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by > calling riscv_set_default_isa_spec. > > * testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since > the --with-isa-spec may be set to different ISA spec. > * testsuite/gas/riscv/attribute-02.d: Likewise. > * testsuite/gas/riscv/attribute-03.d: Likewise. > * testsuite/gas/riscv/attribute-04.d: Likewise. > * testsuite/gas/riscv/attribute-05.d: Likewise. > * testsuite/gas/riscv/attribute-06.d: Likewise. > * testsuite/gas/riscv/attribute-07.d: Likewise. > > * configure.ac: Add configure options, --with-arch and > --with-isa-spec. > * configure: Regenerated. > * config.in: Regenerated. > --- > gas/config.in | 6 ++++ > gas/config/tc-riscv.c | 58 ++++++++++++++++++++++++++-------- > gas/configure | 39 ++++++++++++++++++++++- > gas/configure.ac | 25 ++++++++++++++- > gas/testsuite/gas/riscv/attribute-01.d | 2 +- > gas/testsuite/gas/riscv/attribute-02.d | 2 +- > gas/testsuite/gas/riscv/attribute-03.d | 2 +- > gas/testsuite/gas/riscv/attribute-04.d | 2 +- > gas/testsuite/gas/riscv/attribute-05.d | 2 +- > gas/testsuite/gas/riscv/attribute-06.d | 2 +- > gas/testsuite/gas/riscv/attribute-07.d | 2 +- > 11 files changed, 119 insertions(+), 23 deletions(-) > > diff --git a/gas/config.in b/gas/config.in > index 8724eb1..e20d3c3 100644 > --- a/gas/config.in > +++ b/gas/config.in > @@ -53,9 +53,15 @@ > /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */ > #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC > > +/* Define default value for RISC-V -march. */ > +#undef DEFAULT_RISCV_ARCH_WITH_EXT > + > /* Define to 1 if you want to generate RISC-V arch attribute by default. */ > #undef DEFAULT_RISCV_ATTR > > +/* Define default value for RISC-V -misa-spec. */ > +#undef DEFAULT_RISCV_ISA_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 5ef257e..3b6c429 100644 > --- a/gas/config/tc-riscv.c > +++ b/gas/config/tc-riscv.c > @@ -63,8 +63,24 @@ struct riscv_cl_insn > #define DEFAULT_RISCV_ATTR 0 > #endif > > +/* Let riscv_after_parse_args set the default value according to xlen. */ > + > +#ifndef DEFAULT_RISCV_ARCH_WITH_EXT > +#define DEFAULT_RISCV_ARCH_WITH_EXT NULL > +#endif > + > +/* The default ISA spec is set to 2.2 rather than the lastest version. > + The reason is that compiler generates the ISA string with fixed 2p0 > + verisons only for the RISCV ELF architecture attributes, but not for > + the -march option. Therefore, we should update the compiler or linker > + to resolve this problem. */ > + > +#ifndef DEFAULT_RISCV_ISA_SPEC > +#define DEFAULT_RISCV_ISA_SPEC "2.2" > +#endif > + > static const char default_arch[] = DEFAULT_ARCH; > -static const char *default_arch_with_ext = NULL; > +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; > > static unsigned xlen = 0; /* width of an x-register */ > @@ -76,6 +92,24 @@ static bfd_boolean rve_abi = FALSE; > > static unsigned elf_flags = 0; > > +/* Set the default_isa_spec. Return 0 if the input spec string isn't > + supported. Otherwise, return 1. */ > + > +static int > +riscv_set_default_isa_spec (const char *s) > +{ > + enum riscv_isa_spec_class class; > + if (!riscv_get_isa_spec_class (s, &class)) > + { > + as_bad ("Unknown default ISA spec `%s' set by " > + "-misa-spec or --with-isa-spec", s); > + return 0; > + } > + else > + default_isa_spec = class; > + return 1; > +} > + > /* This is the set of options which the .option pseudo-op may modify. */ > > struct riscv_set_options > @@ -2522,12 +2556,7 @@ md_parse_option (int c, const char *arg) > break; > > case OPTION_MISA_SPEC: > - if (!riscv_get_isa_spec_class (arg, &default_isa_spec)) > - { > - as_bad ("Unknown default ISA spec `%s' set by -misa-spec", arg); > - return 0; > - } > - break; > + return riscv_set_default_isa_spec (arg); > > default: > return 0; > @@ -2539,6 +2568,10 @@ md_parse_option (int c, const char *arg) > void > riscv_after_parse_args (void) > { > + /* The --with-arch is optional for now, so we have to set the xlen > + according to the default_arch, which is set by the --targte, first. > + Then, we use the xlen to set the default_arch_with_ext if the > + -march and --with-arch are not set. */ > if (xlen == 0) > { > if (strcmp (default_arch, "riscv32") == 0) > @@ -2554,15 +2587,12 @@ riscv_after_parse_args (void) > /* Initialize the hash table for extensions with default version. */ > ext_version_hash = init_ext_version_hash (riscv_ext_version_table); > > - /* The default ISA spec is set to 2.2 rather than the lastest version. > - The reason is that compiler generates the ISA string with fixed 2p0 > - verisons only for the RISCV ELF architecture attributes, but not for > - the -march option. Therefore, we should update the compiler or linker > - to resolve this problem. */ > + /* If the -misa-spec isn't set, then we set the default ISA spec according > + to DEFAULT_RISCV_ISA_SPEC. */ > if (default_isa_spec == ISA_SPEC_CLASS_NONE) > - default_isa_spec = ISA_SPEC_CLASS_2P2; > + riscv_set_default_isa_spec (DEFAULT_RISCV_ISA_SPEC); > > - /* Set the architecture according to -march. */ > + /* Set the architecture according to -march or or --with-arch. */ > riscv_set_arch (default_arch_with_ext); > > /* Add the RVC extension, regardless of -march, to support .option rvc. */ > diff --git a/gas/configure b/gas/configure > index 1515787..cc21e0a 100755 > --- a/gas/configure > +++ b/gas/configure > @@ -13009,7 +13009,7 @@ $as_echo "#define NDS32_DEFAULT_ZOL_EXT 1" >>confdefs.h > $as_echo "$enable_zol_ext" >&6; } > ;; > > - aarch64 | i386 | riscv | s390 | sparc) > + aarch64 | i386 | s390 | sparc) > if test $this_target = $target ; then > > cat >>confdefs.h <<_ACEOF > @@ -13019,6 +13019,43 @@ _ACEOF > fi > ;; > > + riscv) > + # --target=riscv[32|64]-*-*. */ > + if test $this_target = $target ; then > + > +cat >>confdefs.h <<_ACEOF > +#define DEFAULT_ARCH "${arch}" > +_ACEOF > + > + fi > + > + # --with-arch=. The syntax of is same as Gas option -march. > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-arch" >&5 > +$as_echo_n "checking for default configuration of --with-arch... " >&6; } > + if test "x${with_arch}" != x; then > + > +cat >>confdefs.h <<_ACEOF > +#define DEFAULT_RISCV_ARCH_WITH_EXT "$with_arch" > +_ACEOF > + > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_arch" >&5 > +$as_echo "$with_arch" >&6; } > + > + # --with-isa-spec=[2.2|20190608|20191213]. > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-isa-spec" >&5 > +$as_echo_n "checking for default configuration of --with-isa-spec... " >&6; } > + if test "x${with_isa_spec}" != x; then > + > +cat >>confdefs.h <<_ACEOF > +#define DEFAULT_RISCV_ISA_SPEC "$with_isa_spec" > +_ACEOF > + > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_isa_spec" >&5 > +$as_echo "$with_isa_spec" >&6; } > + ;; > + > rl78) > f=rl78-parse.o > case " $extra_objects " in > diff --git a/gas/configure.ac b/gas/configure.ac > index 6f32e55..8a5f5c5 100644 > --- a/gas/configure.ac > +++ b/gas/configure.ac > @@ -569,12 +569,35 @@ changequote([,])dnl > AC_MSG_RESULT($enable_zol_ext) > ;; > > - aarch64 | i386 | riscv | s390 | sparc) > + aarch64 | i386 | s390 | sparc) > if test $this_target = $target ; then > AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.]) > fi > ;; > > + riscv) > + # --target=riscv[32|64]-*-*. */ > + if test $this_target = $target ; then > + AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.]) > + fi > + > + # --with-arch=. The syntax of is same as Gas option -march. > + AC_MSG_CHECKING(for default configuration of --with-arch) > + if test "x${with_arch}" != x; then > + AC_DEFINE_UNQUOTED(DEFAULT_RISCV_ARCH_WITH_EXT, "$with_arch", > + [Define default value for RISC-V -march.]) > + fi > + AC_MSG_RESULT($with_arch) > + > + # --with-isa-spec=[2.2|20190608|20191213]. > + AC_MSG_CHECKING(for default configuration of --with-isa-spec) > + if test "x${with_isa_spec}" != x; then > + AC_DEFINE_UNQUOTED(DEFAULT_RISCV_ISA_SPEC, "$with_isa_spec", > + [Define default value for RISC-V -misa-spec.]) > + fi > + AC_MSG_RESULT($with_isa_spec) > + ;; > + > rl78) > f=rl78-parse.o > case " $extra_objects " in > diff --git a/gas/testsuite/gas/riscv/attribute-01.d b/gas/testsuite/gas/riscv/attribute-01.d > index e22773e..2e19e09 100644 > --- a/gas/testsuite/gas/riscv/attribute-01.d > +++ b/gas/testsuite/gas/riscv/attribute-01.d > @@ -1,4 +1,4 @@ > -#as: -march=rv32g -march-attr > +#as: -march=rv32g -march-attr -misa-spec=2.2 > #readelf: -A > #source: empty.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-02.d b/gas/testsuite/gas/riscv/attribute-02.d > index e1e8ce3..ae0195e 100644 > --- a/gas/testsuite/gas/riscv/attribute-02.d > +++ b/gas/testsuite/gas/riscv/attribute-02.d > @@ -1,4 +1,4 @@ > -#as: -march=rv32gxargle -march-attr > +#as: -march=rv32gxargle -march-attr -misa-spec=2.2 > #readelf: -A > #source: empty.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-03.d b/gas/testsuite/gas/riscv/attribute-03.d > index fa38bf3..9916ff6 100644 > --- a/gas/testsuite/gas/riscv/attribute-03.d > +++ b/gas/testsuite/gas/riscv/attribute-03.d > @@ -1,4 +1,4 @@ > -#as: -march=rv32gxargle_xfoo -march-attr > +#as: -march=rv32gxargle_xfoo -march-attr -misa-spec=2.2 > #readelf: -A > #source: empty.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-04.d b/gas/testsuite/gas/riscv/attribute-04.d > index c97bf03..408464d 100644 > --- a/gas/testsuite/gas/riscv/attribute-04.d > +++ b/gas/testsuite/gas/riscv/attribute-04.d > @@ -1,4 +1,4 @@ > -#as: -march-attr > +#as: -march-attr -misa-spec=2.2 > #readelf: -A > #source: attribute-04.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-05.d b/gas/testsuite/gas/riscv/attribute-05.d > index f9b65f2..ad24834 100644 > --- a/gas/testsuite/gas/riscv/attribute-05.d > +++ b/gas/testsuite/gas/riscv/attribute-05.d > @@ -1,4 +1,4 @@ > -#as: -march-attr > +#as: -march-attr -misa-spec=2.2 > #readelf: -A > #source: attribute-05.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-06.d b/gas/testsuite/gas/riscv/attribute-06.d > index 1abeb47..a2dd9fb 100644 > --- a/gas/testsuite/gas/riscv/attribute-06.d > +++ b/gas/testsuite/gas/riscv/attribute-06.d > @@ -1,4 +1,4 @@ > -#as: -march=rv32g2p0 -march-attr > +#as: -march=rv32g2p0 -march-attr -misa-spec=2.2 > #readelf: -A > #source: attribute-06.s > Attribute Section: riscv > diff --git a/gas/testsuite/gas/riscv/attribute-07.d b/gas/testsuite/gas/riscv/attribute-07.d > index dfd7e6b..342a537 100644 > --- a/gas/testsuite/gas/riscv/attribute-07.d > +++ b/gas/testsuite/gas/riscv/attribute-07.d > @@ -1,4 +1,4 @@ > -#as: -march=rv64g2p0 -march-attr > +#as: -march=rv64g2p0 -march-attr -misa-spec=2.2 > #readelf: -A > #source: attribute-07.s > Attribute Section: riscv > -- > 2.7.4 >