aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-riscv.h
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2018-12-03 13:59:44 -0800
committerJim Wilson <jimw@sifive.com>2018-12-03 14:05:17 -0800
commit1080bf78c05b220f5f4bbc5c50d6a0ef6490d738 (patch)
tree13e723b5e05e1858e2208b713d5bf94b38801439 /bfd/elfxx-riscv.h
parent57b64c4103ffeadd524eb80b4a7d61be8c8ec871 (diff)
downloadgdb-1080bf78c05b220f5f4bbc5c50d6a0ef6490d738.zip
gdb-1080bf78c05b220f5f4bbc5c50d6a0ef6490d738.tar.gz
gdb-1080bf78c05b220f5f4bbc5c50d6a0ef6490d738.tar.bz2
RISC-V: Accept version, supervisor ext and more than one NSE for -march.
This patch moves all -march parsing logic into bfd, because we will use this code in ELF attributes. bfd/ * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): New macro. (struct riscv_subset_t): New structure. (riscv_subset_t): New typedef. (riscv_subset_list_t): New structure. (riscv_release_subset_list): New prototype. (riscv_add_subset): Likewise. (riscv_lookup_subset): Likewise. (riscv_lookup_subset_version): Likewise. (riscv_release_subset_list): Likewise. * elfxx-riscv.c: Include safe-ctype.h. (riscv_parsing_subset_version): New function. (riscv_supported_std_ext): Likewise. (riscv_parse_std_ext): Likewise. (riscv_parse_sv_or_non_std_ext): Likewise. (riscv_parse_subset): Likewise. (riscv_add_subset): Likewise. (riscv_lookup_subset): Likewise. (riscv_lookup_subset_version): Likewise. (riscv_release_subset_list): Likewise. gas/ * config/tc-riscv.c: Include elfxx-riscv.h. (struct riscv_subset): Removed. (riscv_subsets): Change type to riscv_subset_list_t. (riscv_subset_supports): Removed argument: xlen_required and move logic into libbfd. (riscv_multi_subset_supports): Removed argument: xlen_required. (riscv_clear_subsets): Removed. (riscv_add_subset): Ditto. (riscv_set_arch): Extract parsing logic into libbfd. (riscv_ip): Update argument for riscv_multi_subset_supports and riscv_subset_supports. Update riscv_subsets due to struct definition changed. (riscv_after_parse_args): Update riscv_subsets due to struct definition changed, update and argument for riscv_subset_supports. * testsuite/gas/riscv/empty.s: New. * testsuite/gas/riscv/march-fail-rv32ef.d: Likewise. * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise. * testsuite/gas/riscv/march-fail-rv32i.d: Likewise. * testsuite/gas/riscv/march-fail-rv32i.l: Likewise. * testsuite/gas/riscv/march-fail-rv32iam.d: Likewise. * testsuite/gas/riscv/march-fail-rv32iam.l: Likewise. * testsuite/gas/riscv/march-fail-rv32ic.d: Likewise. * testsuite/gas/riscv/march-fail-rv32ic.l: Likewise. * testsuite/gas/riscv/march-fail-rv32icx2p.d: Likewise. * testsuite/gas/riscv/march-fail-rv32icx2p.l: Likewise. * testsuite/gas/riscv/march-fail-rv32imc.d: Likewise. * testsuite/gas/riscv/march-fail-rv32imc.l: Likewise. * testsuite/gas/riscv/march-fail-rv64I.d: Likewise. * testsuite/gas/riscv/march-fail-rv64I.l: Likewise. * testsuite/gas/riscv/march-fail-rv64e.d: Likewise. * testsuite/gas/riscv/march-fail-rv64e.l: Likewise. * testsuite/gas/riscv/march-ok-g2.d: Likewise. * testsuite/gas/riscv/march-ok-g2p0.d: Likewise. * testsuite/gas/riscv/march-ok-i2p0.d: Likewise. * testsuite/gas/riscv/march-ok-nse-with-version.: Likewise.d * testsuite/gas/riscv/march-ok-s-with-version.d: Likewise. * testsuite/gas/riscv/march-ok-s.d: Likewise. * testsuite/gas/riscv/march-ok-sx.d: Likewise. * testsuite/gas/riscv/march-ok-two-nse.d: Likewise. * testsuite/gas/riscv/march-ok-g2_p1.d: Likewise. * testsuite/gas/riscv/march-ok-i2p0m2_a2f2.d: Likewise. include/ * opcode/riscv.h (riscv_opcode): Change type of xlen_requirement to unsigned. opcodes/ * riscv-opc.c: Change the type of xlen, because type of xlen_requirement changed.
Diffstat (limited to 'bfd/elfxx-riscv.h')
-rw-r--r--bfd/elfxx-riscv.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index 836f05d..64e41b8 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -31,3 +31,55 @@ riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
extern reloc_howto_type *
riscv_elf_rtype_to_howto (bfd *, unsigned int r_type);
+
+#define RISCV_DONT_CARE_VERSION -1
+
+/* The information of architecture attribute. */
+struct riscv_subset_t
+{
+ const char *name;
+ int major_version;
+ int minor_version;
+ struct riscv_subset_t *next;
+};
+
+typedef struct riscv_subset_t riscv_subset_t;
+
+typedef struct {
+ riscv_subset_t *head;
+ riscv_subset_t *tail;
+} riscv_subset_list_t;
+
+extern void
+riscv_release_subset_list (riscv_subset_list_t *);
+
+extern void
+riscv_add_subset (riscv_subset_list_t *,
+ const char *,
+ int, int);
+
+extern riscv_subset_t *
+riscv_lookup_subset (const riscv_subset_list_t *,
+ const char *);
+
+extern riscv_subset_t *
+riscv_lookup_subset_version (const riscv_subset_list_t *,
+ const char *,
+ int, int);
+
+typedef struct {
+ riscv_subset_list_t *subset_list;
+ void (*error_handler) (const char *,
+ ...) ATTRIBUTE_PRINTF_1;
+ unsigned *xlen;
+} riscv_parse_subset_t;
+
+extern bfd_boolean
+riscv_parse_subset (riscv_parse_subset_t *,
+ const char *);
+
+extern const char *
+riscv_supported_std_ext (void);
+
+extern void
+riscv_release_subset_list (riscv_subset_list_t *);