mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-02 23:04:09 +08:00
RISC-V: Support to add implicit extensions for G.
G is a special case, consider the ISA spec github issue as follows, https://github.com/riscv/riscv-isa-manual/issues/575 My understand is that - i, m, a, f and d extensions are not g's implicit extensions, they are g's expansions. The zifencei is the implicit extension of g, and so is zicsr, since it is implicited by f (or i2p1). However, we add the g with the RISCV_UNKNOWN_VERSION to the subset list, and it will not output to the arch string, it is only used to check what implicit extensions are need to be added. bfd/ * elfxx-riscv.c (riscv_parse_add_subset): Allow to add g with RISCV_UNKNOWN_VERSION versions. (riscv_parse_std_ext): Add g to the subset list, we only use it to add the implicit extensions, but won't output it to arch string. (riscv_parse_add_implicit_subsets): Add implicit zicsr and zifencei for g extension. (riscv_arch_str1): Do not output g to the arch string. * elfxx-riscv.h (RISCV_UNKNOWN_VERSION): Moved to include/opcode/riscv.h. gas/ * testsuite/gas/riscv/attribute-10.d: Updated. * testsuite/gas/riscv/march-imply-g.d: New testcase for g. * testsuite/gas/riscv/march-imply-unsupported.d: The zicsr and zifencei are not supported in the ISA spec v2.2, so don't add and output them. include/ * opcode/riscv.h (RISCV_UNKNOWN_VERSION): added.
This commit is contained in:
parent
dfe9249667
commit
00d4d1b0a3
@ -1,3 +1,14 @@
|
|||||||
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
|
* elfxx-riscv.c (riscv_parse_add_subset): Allow to add g with
|
||||||
|
RISCV_UNKNOWN_VERSION versions.
|
||||||
|
(riscv_parse_std_ext): Add g to the subset list, we only use it
|
||||||
|
to add the implicit extensions, but won't output it to arch string.
|
||||||
|
(riscv_parse_add_implicit_subsets): Add implicit zicsr and zifencei
|
||||||
|
for g extension.
|
||||||
|
(riscv_arch_str1): Do not output g to the arch string.
|
||||||
|
* elfxx-riscv.h (RISCV_UNKNOWN_VERSION): Moved to include/opcode/riscv.h.
|
||||||
|
|
||||||
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
* elfnn-riscv.c (riscv_merge_std_ext): Updated since
|
* elfnn-riscv.c (riscv_merge_std_ext): Updated since
|
||||||
|
@ -1173,6 +1173,7 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
|
|||||||
rps->get_default_version (subset, &major_version, &minor_version);
|
rps->get_default_version (subset, &major_version, &minor_version);
|
||||||
|
|
||||||
if (!implicit
|
if (!implicit
|
||||||
|
&& strcmp (subset, "g") != 0
|
||||||
&& (major_version == RISCV_UNKNOWN_VERSION
|
&& (major_version == RISCV_UNKNOWN_VERSION
|
||||||
|| minor_version == RISCV_UNKNOWN_VERSION))
|
|| minor_version == RISCV_UNKNOWN_VERSION))
|
||||||
{
|
{
|
||||||
@ -1354,8 +1355,6 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
/* The g-ext shouldn't has the version, so we just
|
|
||||||
skip the setting if user set a version to it. */
|
|
||||||
p = riscv_parsing_subset_version (rps, march, ++p,
|
p = riscv_parsing_subset_version (rps, march, ++p,
|
||||||
&major_version,
|
&major_version,
|
||||||
&minor_version, TRUE);
|
&minor_version, TRUE);
|
||||||
@ -1363,6 +1362,11 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
|
|||||||
riscv_parse_add_subset (rps, "i",
|
riscv_parse_add_subset (rps, "i",
|
||||||
RISCV_UNKNOWN_VERSION,
|
RISCV_UNKNOWN_VERSION,
|
||||||
RISCV_UNKNOWN_VERSION, FALSE);
|
RISCV_UNKNOWN_VERSION, FALSE);
|
||||||
|
/* g-ext is used to add the implicit extensions, but will
|
||||||
|
not be output to the arch string. */
|
||||||
|
riscv_parse_add_subset (rps, "g",
|
||||||
|
major_version,
|
||||||
|
minor_version, FALSE);
|
||||||
for ( ; *std_exts != 'q'; std_exts++)
|
for ( ; *std_exts != 'q'; std_exts++)
|
||||||
{
|
{
|
||||||
subset[0] = *std_exts;
|
subset[0] = *std_exts;
|
||||||
@ -1742,6 +1746,16 @@ riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
|
|||||||
riscv_parse_add_subset (rps, "zicsr",
|
riscv_parse_add_subset (rps, "zicsr",
|
||||||
RISCV_UNKNOWN_VERSION,
|
RISCV_UNKNOWN_VERSION,
|
||||||
RISCV_UNKNOWN_VERSION, TRUE);
|
RISCV_UNKNOWN_VERSION, TRUE);
|
||||||
|
|
||||||
|
if ((riscv_lookup_subset (rps->subset_list, "g", &subset)))
|
||||||
|
{
|
||||||
|
riscv_parse_add_subset (rps, "zicsr",
|
||||||
|
RISCV_UNKNOWN_VERSION,
|
||||||
|
RISCV_UNKNOWN_VERSION, TRUE);
|
||||||
|
riscv_parse_add_subset (rps, "zifencei",
|
||||||
|
RISCV_UNKNOWN_VERSION,
|
||||||
|
RISCV_UNKNOWN_VERSION, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function for parsing arch string.
|
/* Function for parsing arch string.
|
||||||
@ -1911,10 +1925,11 @@ riscv_arch_str1 (riscv_subset_t *subset,
|
|||||||
|
|
||||||
strncat (attr_str, buf, bufsz);
|
strncat (attr_str, buf, bufsz);
|
||||||
|
|
||||||
/* Skip 'i' extension after 'e'. */
|
/* Skip 'i' extension after 'e', and skip 'g' extension. */
|
||||||
if ((strcasecmp (subset->name, "e") == 0)
|
if (subset->next
|
||||||
&& subset->next
|
&& ((strcmp (subset->name, "e") == 0
|
||||||
&& (strcasecmp (subset->next->name, "i") == 0))
|
&& strcmp (subset->next->name, "i") == 0)
|
||||||
|
|| strcmp (subset->next->name, "g") == 0))
|
||||||
riscv_arch_str1 (subset->next->next, attr_str, buf, bufsz);
|
riscv_arch_str1 (subset->next->next, attr_str, buf, bufsz);
|
||||||
else
|
else
|
||||||
riscv_arch_str1 (subset->next, attr_str, buf, bufsz);
|
riscv_arch_str1 (subset->next, attr_str, buf, bufsz);
|
||||||
|
@ -33,8 +33,6 @@ riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
|
|||||||
extern reloc_howto_type *
|
extern reloc_howto_type *
|
||||||
riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
|
riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
|
||||||
|
|
||||||
#define RISCV_UNKNOWN_VERSION -1
|
|
||||||
|
|
||||||
/* The information of architecture attribute. */
|
/* The information of architecture attribute. */
|
||||||
struct riscv_subset_t
|
struct riscv_subset_t
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
|
* testsuite/gas/riscv/attribute-10.d: Updated.
|
||||||
|
* testsuite/gas/riscv/march-imply-g.d: New testcase for g.
|
||||||
|
* testsuite/gas/riscv/march-imply-unsupported.d: The zicsr and zifencei
|
||||||
|
are not supported in the ISA spec v2.2, so don't add and output them.
|
||||||
|
|
||||||
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
* config/tc-riscv.c (riscv_subset_supports): Updated.
|
* config/tc-riscv.c (riscv_subset_supports): Updated.
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
#source: empty.s
|
#source: empty.s
|
||||||
Attribute Section: riscv
|
Attribute Section: riscv
|
||||||
File Attributes
|
File Attributes
|
||||||
Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0"
|
Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0"
|
||||||
|
6
gas/testsuite/gas/riscv/march-imply-g.d
Normal file
6
gas/testsuite/gas/riscv/march-imply-g.d
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#as: -march=rv32g -march-attr -misa-spec=20191213
|
||||||
|
#readelf: -A
|
||||||
|
#source: empty.s
|
||||||
|
Attribute Section: riscv
|
||||||
|
File Attributes
|
||||||
|
Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_zicsr2p0_zifencei2p0"
|
6
gas/testsuite/gas/riscv/march-imply-unsupported.d
Normal file
6
gas/testsuite/gas/riscv/march-imply-unsupported.d
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#as: -march=rv32g -march-attr -misa-spec=2.2
|
||||||
|
#readelf: -A
|
||||||
|
#source: empty.s
|
||||||
|
Attribute Section: riscv
|
||||||
|
File Attributes
|
||||||
|
Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0"
|
@ -1,3 +1,7 @@
|
|||||||
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
|
* opcode/riscv.h (RISCV_UNKNOWN_VERSION): added.
|
||||||
|
|
||||||
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
|
||||||
|
|
||||||
* opcode/riscv.h (riscv_ext_version):
|
* opcode/riscv.h (riscv_ext_version):
|
||||||
|
@ -354,6 +354,8 @@ enum riscv_isa_spec_class
|
|||||||
ISA_SPEC_CLASS_20191213
|
ISA_SPEC_CLASS_20191213
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define RISCV_UNKNOWN_VERSION -1
|
||||||
|
|
||||||
/* This structure holds version information for specific ISA. */
|
/* This structure holds version information for specific ISA. */
|
||||||
|
|
||||||
struct riscv_ext_version
|
struct riscv_ext_version
|
||||||
|
Loading…
Reference in New Issue
Block a user