8f595e9b4f
1. Remove the -mriscv-isa-version and --with-riscv-isa-version options. We can still use -march to choose the version for each extensions, so there is no need to add these. 2. Change the arguments of options from [1p9|1p9p1|...] to [1.9|1.9.1|...]. Unlike the architecture string has specified by spec, ther is no need to do the same thing for options. 3. Spilt the patches to reduce the burdens of review. [PATCH 3/7] RISC-V: Support new GAS options and configure options to set ISA versions to [PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions [PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default. [PATCH 4/7] RISC-V: Support version checking for CSR according to privilege version. to [PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version. [PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version. 4. Use enum class rather than string to compare the choosen ISA spec in opcodes/riscv-opc.c. The behavior is same as comparing the choosen privilege spec. include * opcode/riscv.h: Include "bfd.h" to support bfd_boolean. (enum riscv_isa_spec_class): New enum class. All supported ISA spec belong to one of the class (struct riscv_ext_version): New structure holds version information for the specific ISA. * opcode/riscv-opc.h (DECLARE_CSR): There are two version information, define_version and abort_version. The define_version means which privilege spec is started to define the CSR, and the abort_version means which privilege spec is started to abort the CSR. If the CSR is valid for the newest spec, then the abort_version should be PRIV_SPEC_CLASS_DRAFT. (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR. * opcode/riscv.h (enum riscv_priv_spec_class): New enum class. Define the current supported privilege spec versions. (struct riscv_csr_extra): Add new fields to store more information about the CSR. We use these information to find the suitable CSR address when user choosing a specific privilege spec. binutils * dwarf.c: Updated since DECLARE_CSR is changed. opcodes * riscv-opc.c (riscv_ext_version_table): The table used to store all information about the supported spec and the corresponding ISA versions. Currently, only Zicsr is supported to verify the correctness of Z sub extension settings. Others will be supported in the future patches. (struct isa_spec_t, isa_specs): List for all supported ISA spec classes and the corresponding strings. (riscv_get_isa_spec_class): New function. Get the corresponding ISA spec class by giving a ISA spec string. * riscv-opc.c (struct priv_spec_t): New structure. (struct priv_spec_t priv_specs): List for all supported privilege spec classes and the corresponding strings. (riscv_get_priv_spec_class): New function. Get the corresponding privilege spec class by giving a spec string. (riscv_get_priv_spec_name): New function. Get the corresponding privilege spec string by giving a CSR version class. * riscv-dis.c: Updated since DECLARE_CSR is changed. * riscv-dis.c: Add new disassembler option -Mpriv-spec to dump the CSR according to the chosen version. Build a hash table riscv_csr_hash to store the valid CSR for the chosen pirv verison. Dump the direct CSR address rather than it's name if it is invalid. (parse_riscv_dis_option_without_args): New function. Parse the options without arguments. (parse_riscv_dis_option): Call parse_riscv_dis_option_without_args to parse the options without arguments first, and then handle the options with arguments. Add the new option -Mpriv-spec, which has argument. * riscv-dis.c (print_riscv_disassembler_options): Add description about the new OBJDUMP option. ld * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated priv attributes according to the -mpriv-spec option. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise. bfd * elfxx-riscv.h (riscv_parse_subset_t): Add new callback function get_default_version. It is used to find the default version for the specific extension. * elfxx-riscv.c (riscv_parsing_subset_version): Remove the parameters default_major_version and default_minor_version. Add new bfd_boolean parameter *use_default_version. Set it to TRUE if we need to call the callback rps->get_default_version to find the default version. (riscv_parse_std_ext): Call rps->get_default_version if we fail to find the default version in riscv_parsing_subset_version, and then call riscv_add_subset to add the subset into subset list. (riscv_parse_prefixed_ext): Likewise. (riscv_std_z_ext_strtab): Support Zicsr extensions. * elfnn-riscv.c (riscv_merge_std_ext): Use strcasecmp to compare the strings rather than characters. riscv_merge_arch_attr_info): The callback function get_default_version is only needed for assembler, so set it to NULL int the linker. * elfxx-riscv.c (riscv_estimate_digit): Remove the static. * elfxx-riscv.h: Updated. gas * testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated. * config/tc-riscv.c (default_arch_with_ext, default_isa_spec): Static variables which are used to set the ISA extensions. You can use -march (or ELF build attributes) and -misa-spec to set them, respectively. (ext_version_hash): The hash table used to handle the extensions with versions. (init_ext_version_hash): Initialize the ext_version_hash according to riscv_ext_version_table. (riscv_get_default_ext_version): The callback function of riscv_parse_subset_t. According to the choosed ISA spec, get the default version for the specific extension. (riscv_set_arch): Set the callback function. (enum options, struct option md_longopts): Add new option -misa-spec. (md_parse_option): Do not call riscv_set_arch for -march. We will call it later in riscv_after_parse_args. Call riscv_get_isa_spec_class to set default_isa_spec class. (riscv_after_parse_args): Call init_ext_version_hash to initialize the ext_version_hash, and then call riscv_set_arch to set the architecture with versions according to default_arch_with_ext. * testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for x extensions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-09.d: New testcase. For i-ext, we already set it's version to 2p1 by march, so no need to use the default 2p2 version. For m-ext, we do not set the version by -march and ELF arch attribute, so set the default 2p0 to it. For zicsr, it is not defined in ISA spec 2p2, so set 0p0 to it. * testsuite/gas/riscv/attribute-10.d: New testcase. The version of zicsr is 2p0 according to ISA spec 20191213. * 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. * config/tc-riscv.c (default_priv_spec): Static variable which is used to check if the CSR is valid for the chosen privilege spec. You can use -mpriv-spec to set it. (enum reg_class): We now get the CSR address from csr_extra_hash rather than reg_names_hash. Therefore, move RCLASS_CSR behind RCLASS_MAX. (riscv_init_csr_hashes): Only need to initialize one hash table csr_extra_hash. (riscv_csr_class_check): Change the return type to void. Don't check the ISA dependency if -mcsr-check isn't set. (riscv_csr_version_check): New function. Check and find the CSR address from csr_extra_hash, according to default_priv_spec. Report warning for the invalid CSR if -mcsr-check is set. (reg_csr_lookup_internal): Updated. (reg_lookup_internal): Likewise. (md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed. (enum options, struct option md_longopts): Add new GAS option -mpriv-spec. (md_parse_option): Call riscv_set_default_priv_version to set default_priv_spec. (riscv_after_parse_args): If -mpriv-spec isn't set, then set the default privilege spec to the newest one. (enum riscv_csr_class, struct riscv_csr_extra): Move them to include/opcode/riscv.h. * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want to check the ISA dependency for CSR, so fix the spec version by adding -mpriv-spec=1.11. * testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise. There are some version warnings for the test case. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case. Check whether the CSR is valid when privilege version 1.9 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case. Check whether the CSR is valid when privilege version 1.9.1 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case. Check whether the CSR is valid when privilege version 1.10 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case. Check whether the CSR is valid when privilege version 1.11 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise. * 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. * config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to explicit_attr. Set it to TRUE if any ELF attribute is found. (riscv_set_default_priv_spec): Try to set the default_priv_spec if the priv attributes are set. (md_assemble): Set the default_priv_spec according to the priv attributes when we start to assemble instruction. (riscv_write_out_attrs): Rename riscv_write_out_arch_attr to riscv_write_out_attrs. Update the arch and priv attributes. If we don't set the corresponding ELF attributes, then try to output the default ones. (riscv_set_public_attributes): If any ELF attribute or -march-attr options is set (explicit_attr is TRUE), then call riscv_write_out_attrs to update the arch and priv attributes. (s_riscv_attribute): Make sure all arch and priv attributes are set before any instruction. * testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any ELF attribute or -march-attr is set. If the priv attributes are not set, then try to update them by the default setting (-mpriv-spec or --with-priv-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-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * testsuite/gas/riscv/attribute-08.d: Likewise. * testsuite/gas/riscv/attribute-09.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/attribute-unknown.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. Also, the priv spec set by priv attributes must be supported. * testsuite/gas/riscv/attribute-05.s: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise. Updated priv attributes according to the -mpriv-spec option. * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise. * testsuite/gas/riscv/priv-reg.d: Removed. * testsuite/gas/riscv/priv-reg-version-1p9.d: New test case. Dump the CSR according to the priv spec 1.9. * testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case. Dump the CSR according to the priv spec 1.9.1. * testsuite/gas/riscv/priv-reg-version-1p10.d: New test case. Dump the CSR according to the priv spec 1.10. * testsuite/gas/riscv/priv-reg-version-1p11.d: New test case. Dump the CSR according to the priv spec 1.11. * config/tc-riscv.c (md_show_usage): Add descriptions about the new GAS options. * doc/c-riscv.texi: Likewise. |
||
---|---|---|
.. | ||
po | ||
.gitignore | ||
aarch64-asm-2.c | ||
aarch64-asm.c | ||
aarch64-asm.h | ||
aarch64-dis-2.c | ||
aarch64-dis.c | ||
aarch64-dis.h | ||
aarch64-gen.c | ||
aarch64-opc-2.c | ||
aarch64-opc.c | ||
aarch64-opc.h | ||
aarch64-tbl.h | ||
aclocal.m4 | ||
alpha-dis.c | ||
alpha-opc.c | ||
arc-dis.c | ||
arc-dis.h | ||
arc-ext-tbl.h | ||
arc-ext.c | ||
arc-ext.h | ||
arc-fxi.h | ||
arc-nps400-tbl.h | ||
arc-opc.c | ||
arc-regs.h | ||
arc-tbl.h | ||
arm-dis.c | ||
avr-dis.c | ||
bfin-dis.c | ||
bpf-asm.c | ||
bpf-desc.c | ||
bpf-desc.h | ||
bpf-dis.c | ||
bpf-ibld.c | ||
bpf-opc.c | ||
bpf-opc.h | ||
cgen-asm.c | ||
cgen-asm.in | ||
cgen-bitset.c | ||
cgen-dis.c | ||
cgen-dis.in | ||
cgen-ibld.in | ||
cgen-opc.c | ||
cgen.sh | ||
ChangeLog | ||
ChangeLog-0001 | ||
ChangeLog-0203 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog-2018 | ||
ChangeLog-2019 | ||
ChangeLog-9297 | ||
ChangeLog-9899 | ||
config.in | ||
configure | ||
configure.ac | ||
configure.com | ||
cr16-dis.c | ||
cr16-opc.c | ||
cris-dis.c | ||
cris-opc.c | ||
crx-dis.c | ||
crx-opc.c | ||
csky-dis.c | ||
csky-opc.h | ||
d10v-dis.c | ||
d10v-opc.c | ||
d30v-dis.c | ||
d30v-opc.c | ||
dep-in.sed | ||
dis-buf.c | ||
dis-init.c | ||
disassemble.c | ||
disassemble.h | ||
dlx-dis.c | ||
epiphany-asm.c | ||
epiphany-desc.c | ||
epiphany-desc.h | ||
epiphany-dis.c | ||
epiphany-ibld.c | ||
epiphany-opc.c | ||
epiphany-opc.h | ||
fr30-asm.c | ||
fr30-desc.c | ||
fr30-desc.h | ||
fr30-dis.c | ||
fr30-ibld.c | ||
fr30-opc.c | ||
fr30-opc.h | ||
frv-asm.c | ||
frv-desc.c | ||
frv-desc.h | ||
frv-dis.c | ||
frv-ibld.c | ||
frv-opc.c | ||
frv-opc.h | ||
ft32-dis.c | ||
ft32-opc.c | ||
h8300-dis.c | ||
hppa-dis.c | ||
i386-dis-evex-len.h | ||
i386-dis-evex-mod.h | ||
i386-dis-evex-prefix.h | ||
i386-dis-evex-reg.h | ||
i386-dis-evex-w.h | ||
i386-dis-evex.h | ||
i386-dis.c | ||
i386-gen.c | ||
i386-init.h | ||
i386-opc.c | ||
i386-opc.h | ||
i386-opc.tbl | ||
i386-reg.tbl | ||
i386-tbl.h | ||
ia64-asmtab.c | ||
ia64-asmtab.h | ||
ia64-dis.c | ||
ia64-gen.c | ||
ia64-ic.tbl | ||
ia64-opc-a.c | ||
ia64-opc-b.c | ||
ia64-opc-d.c | ||
ia64-opc-f.c | ||
ia64-opc-i.c | ||
ia64-opc-m.c | ||
ia64-opc-x.c | ||
ia64-opc.c | ||
ia64-opc.h | ||
ia64-raw.tbl | ||
ia64-war.tbl | ||
ia64-waw.tbl | ||
ip2k-asm.c | ||
ip2k-desc.c | ||
ip2k-desc.h | ||
ip2k-dis.c | ||
ip2k-ibld.c | ||
ip2k-opc.c | ||
ip2k-opc.h | ||
iq2000-asm.c | ||
iq2000-desc.c | ||
iq2000-desc.h | ||
iq2000-dis.c | ||
iq2000-ibld.c | ||
iq2000-opc.c | ||
iq2000-opc.h | ||
lm32-asm.c | ||
lm32-desc.c | ||
lm32-desc.h | ||
lm32-dis.c | ||
lm32-ibld.c | ||
lm32-opc.c | ||
lm32-opc.h | ||
lm32-opinst.c | ||
m32c-asm.c | ||
m32c-desc.c | ||
m32c-desc.h | ||
m32c-dis.c | ||
m32c-ibld.c | ||
m32c-opc.c | ||
m32c-opc.h | ||
m32r-asm.c | ||
m32r-desc.c | ||
m32r-desc.h | ||
m32r-dis.c | ||
m32r-ibld.c | ||
m32r-opc.c | ||
m32r-opc.h | ||
m32r-opinst.c | ||
m68hc11-dis.c | ||
m68hc11-opc.c | ||
m68k-dis.c | ||
m68k-opc.c | ||
m10200-dis.c | ||
m10200-opc.c | ||
m10300-dis.c | ||
m10300-opc.c | ||
MAINTAINERS | ||
Makefile.am | ||
Makefile.in | ||
makefile.vms | ||
mcore-dis.c | ||
mcore-opc.h | ||
mep-asm.c | ||
mep-desc.c | ||
mep-desc.h | ||
mep-dis.c | ||
mep-ibld.c | ||
mep-opc.c | ||
mep-opc.h | ||
metag-dis.c | ||
microblaze-dis.c | ||
microblaze-dis.h | ||
microblaze-opc.h | ||
microblaze-opcm.h | ||
micromips-opc.c | ||
mips16-opc.c | ||
mips-dis.c | ||
mips-formats.h | ||
mips-opc.c | ||
mmix-dis.c | ||
mmix-opc.c | ||
moxie-dis.c | ||
moxie-opc.c | ||
msp430-decode.c | ||
msp430-decode.opc | ||
msp430-dis.c | ||
mt-asm.c | ||
mt-desc.c | ||
mt-desc.h | ||
mt-dis.c | ||
mt-ibld.c | ||
mt-opc.c | ||
mt-opc.h | ||
nds32-asm.c | ||
nds32-asm.h | ||
nds32-dis.c | ||
nds32-opc.h | ||
nfp-dis.c | ||
nios2-dis.c | ||
nios2-opc.c | ||
ns32k-dis.c | ||
opc2c.c | ||
opintl.h | ||
or1k-asm.c | ||
or1k-desc.c | ||
or1k-desc.h | ||
or1k-dis.c | ||
or1k-ibld.c | ||
or1k-opc.c | ||
or1k-opc.h | ||
or1k-opinst.c | ||
pdp11-dis.c | ||
pdp11-opc.c | ||
pj-dis.c | ||
pj-opc.c | ||
ppc-dis.c | ||
ppc-opc.c | ||
pru-dis.c | ||
pru-opc.c | ||
riscv-dis.c | ||
riscv-opc.c | ||
rl78-decode.c | ||
rl78-decode.opc | ||
rl78-dis.c | ||
rx-decode.c | ||
rx-decode.opc | ||
rx-dis.c | ||
s12z-dis.c | ||
s12z-opc.c | ||
s12z-opc.h | ||
s390-dis.c | ||
s390-mkopc.c | ||
s390-opc.c | ||
s390-opc.txt | ||
score7-dis.c | ||
score-dis.c | ||
score-opc.h | ||
sh-dis.c | ||
sh-opc.h | ||
sparc-dis.c | ||
sparc-opc.c | ||
spu-dis.c | ||
spu-opc.c | ||
stamp-h.in | ||
sysdep.h | ||
tic4x-dis.c | ||
tic6x-dis.c | ||
tic30-dis.c | ||
tic54x-dis.c | ||
tic54x-opc.c | ||
tilegx-dis.c | ||
tilegx-opc.c | ||
tilepro-dis.c | ||
tilepro-opc.c | ||
v850-dis.c | ||
v850-opc.c | ||
vax-dis.c | ||
visium-dis.c | ||
visium-opc.c | ||
wasm32-dis.c | ||
xc16x-asm.c | ||
xc16x-desc.c | ||
xc16x-desc.h | ||
xc16x-dis.c | ||
xc16x-ibld.c | ||
xc16x-opc.c | ||
xc16x-opc.h | ||
xgate-dis.c | ||
xgate-opc.c | ||
xstormy16-asm.c | ||
xstormy16-desc.c | ||
xstormy16-desc.h | ||
xstormy16-dis.c | ||
xstormy16-ibld.c | ||
xstormy16-opc.c | ||
xstormy16-opc.h | ||
xtensa-dis.c | ||
z8k-dis.c | ||
z8k-opc.h | ||
z8kgen.c | ||
z80-dis.c |