diff options
115 files changed, 1371 insertions, 685 deletions
diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 1b71104..c6d9d60 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -214,9 +214,11 @@ static bool MY_bfd_copy_private_section_data (bfd *ibfd, asection *isec ATTRIBUTE_UNUSED, bfd *obfd, - asection *osec ATTRIBUTE_UNUSED) + asection *osec ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info) { - if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour + if (link_info == NULL + && bfd_get_flavour (ibfd) == bfd_target_aout_flavour && bfd_get_flavour (obfd) == bfd_target_aout_flavour) obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); return true; @@ -562,9 +564,6 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info) #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #endif -#define MY_init_private_section_data \ - _bfd_generic_init_private_section_data - #ifndef MY_bfd_copy_private_symbol_data #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index d5d1b51..b013ef9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1034,11 +1034,12 @@ bool bfd_malloc_and_get_section (bfd *abfd, asection *section, bfd_byte **buf); bool bfd_copy_private_section_data - (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, + struct bfd_link_info *link_info); -#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ +#define bfd_copy_private_section_data(ibfd, isec, obfd, osec, link_info) \ BFD_SEND (obfd, _bfd_copy_private_section_data, \ - (ibfd, isection, obfd, osection)) + (ibfd, isec, obfd, osec, link_info)) bool bfd_generic_is_group_section (bfd *, const asection *sec); const char *bfd_generic_group_name (bfd *, const asection *sec); @@ -7636,7 +7637,6 @@ typedef struct bfd_target #define BFD_JUMP_TABLE_COPY(NAME) \ NAME##_bfd_copy_private_bfd_data, \ NAME##_bfd_merge_private_bfd_data, \ - NAME##_init_private_section_data, \ NAME##_bfd_copy_private_section_data, \ NAME##_bfd_copy_private_symbol_data, \ NAME##_bfd_copy_private_header_data, \ @@ -7649,16 +7649,10 @@ typedef struct bfd_target /* Called to merge BFD general private data from one object file to a common output file when linking. */ bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); - /* Called to initialize BFD private section data from one object file - to another. */ -#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ - BFD_SEND (obfd, _bfd_init_private_section_data, \ - (ibfd, isec, obfd, osec, link_info)) - bool (*_bfd_init_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, - struct bfd_link_info *); /* Called to copy BFD private section data from one object file to another. */ - bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr); + bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, + struct bfd_link_info *); /* Called to copy BFD private symbol data from one symbol to another. */ bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index ae9a0f6..3c18518 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4456,8 +4456,6 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = { #define _bfd_xcoff_get_section_contents _bfd_generic_get_section_contents /* For copy private data entry points. */ -#define _bfd_xcoff_init_private_section_data \ - _bfd_generic_init_private_section_data #define _bfd_xcoff_bfd_copy_private_bfd_data \ _bfd_xcoff_copy_private_bfd_data #define _bfd_xcoff_bfd_merge_private_bfd_data \ diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index ec7ed08..d335348 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2621,7 +2621,6 @@ const bfd_target rs6000_xcoff64_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, _bfd_generic_bfd_merge_private_bfd_data, - _bfd_generic_init_private_section_data, _bfd_generic_bfd_copy_private_section_data, _bfd_generic_bfd_copy_private_symbol_data, _bfd_generic_bfd_copy_private_header_data, @@ -2892,7 +2891,6 @@ const bfd_target rs6000_xcoff64_aix_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, _bfd_generic_bfd_merge_private_bfd_data, - _bfd_generic_init_private_section_data, _bfd_generic_bfd_copy_private_section_data, _bfd_generic_bfd_copy_private_symbol_data, _bfd_generic_bfd_copy_private_header_data, diff --git a/bfd/coffcode.h b/bfd/coffcode.h index bd0374f..b81195d 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -5955,8 +5955,6 @@ static const bfd_coff_backend_data bigobj_swap_table = #define coff_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #endif -#define coff_init_private_section_data _bfd_generic_init_private_section_data - #ifndef coff_bfd_copy_private_section_data #define coff_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #endif diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index f625709..2bd855a 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2393,10 +2393,8 @@ extern bool _bfd_elf_copy_private_header_data (bfd *, bfd *); extern bool _bfd_elf_copy_private_symbol_data (bfd *, asymbol *, bfd *, asymbol *); -extern bool _bfd_elf_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); extern bool _bfd_elf_copy_private_section_data - (bfd *, asection *, bfd *, asection *); + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); extern bool _bfd_elf_write_object_contents (bfd *); extern bool _bfd_elf_write_corefile_contents diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c index 24a3d35..d74235b 100644 --- a/bfd/elf-sframe.c +++ b/bfd/elf-sframe.c @@ -23,6 +23,7 @@ #include "libbfd.h" #include "elf-bfd.h" #include "sframe-api.h" +#include "sframe-internal.h" /* Return TRUE if the function has been marked for deletion during the linking process. */ @@ -373,8 +374,8 @@ _bfd_elf_merge_section_sframe (bfd *abfd, uint8_t tflags = dctx_flags & ~SFRAME_F_FDE_SORTED; /* ld always generates an output section with SFRAME_F_FDE_FUNC_START_PCREL flag set. Later using - SFRAME_F_LD_MUSTHAVE_FLAGS, it is enforced that the provided input - sections also have this flag set. */ + SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS, it is enforced that the provided + input sections also have this flag set. */ tflags |= SFRAME_F_FDE_FUNC_START_PCREL; htab->sfe_info.sfe_ctx = sframe_encode (SFRAME_VERSION_2, tflags, /* SFrame flags. */ @@ -430,8 +431,8 @@ _bfd_elf_merge_section_sframe (bfd *abfd, related flags set. The implementation does not support updating these data encodings on the fly; confirm by checking the ectx_flags. */ ectx_flags = sframe_encoder_get_flags (sfe_ctx); - if ((dctx_flags & ectx_flags & SFRAME_F_LD_MUSTHAVE_FLAGS) - != SFRAME_F_LD_MUSTHAVE_FLAGS) + if ((dctx_flags & ectx_flags & SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) + != SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) { _bfd_error_handler (_("SFrame sections with unexpected data encoding prevent" @@ -8375,25 +8375,34 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd) return rewrite_elf_program_header (ibfd, obfd, maxpagesize); } -/* Initialize private output section information from input section. */ +/* Copy private section information from input to output. This function + is called both by objcopy where LINK_INFO is NULL, and ld where + LINK_INFO is non-NULL in the usual case but NULL for a special case + when dealing with LTO IR or cloning output sections. */ bool -_bfd_elf_init_private_section_data (bfd *ibfd, +_bfd_elf_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, struct bfd_link_info *link_info) - { - Elf_Internal_Shdr *ihdr, *ohdr; - bool final_link = (link_info != NULL - && !bfd_link_relocatable (link_info)); - if (ibfd->xvec->flavour != bfd_target_elf_flavour || obfd->xvec->flavour != bfd_target_elf_flavour) return true; - BFD_ASSERT (elf_section_data (osec) != NULL); + Elf_Internal_Shdr *ihdr = &elf_section_data (isec)->this_hdr; + Elf_Internal_Shdr *ohdr = &elf_section_data (osec)->this_hdr; + if (link_info == NULL) + { + ohdr->sh_entsize = ihdr->sh_entsize; + + if (ihdr->sh_type == SHT_SYMTAB + || ihdr->sh_type == SHT_DYNSYM + || ihdr->sh_type == SHT_GNU_verneed + || ihdr->sh_type == SHT_GNU_verdef) + ohdr->sh_info = ihdr->sh_info; + } /* If this is a known ABI section, ELF section type and flags may have been set up when OSEC was created. For normal sections we @@ -8403,11 +8412,14 @@ _bfd_elf_init_private_section_data (bfd *ibfd, || elf_section_type (osec) == SHT_NOTE || elf_section_type (osec) == SHT_NOBITS) elf_section_type (osec) = SHT_NULL; + /* For objcopy and relocatable link, copy the ELF section type from the input file if the BFD section flags are the same. (If they are different the user may be doing something like "objcopy --set-section-flags .text=alloc,data".) For a final link allow some flags that the linker clears to differ. */ + bool final_link = (link_info != NULL + && !bfd_link_relocatable (link_info)); if (elf_section_type (osec) == SHT_NULL && (osec->flags == isec->flags || (final_link @@ -8445,14 +8457,11 @@ _bfd_elf_init_private_section_data (bfd *ibfd, elf_section_flags (osec) |= (elf_section_flags (isec) & SHF_COMPRESSED); - ihdr = &elf_section_data (isec)->this_hdr; - /* We need to handle elf_linked_to_section for SHF_LINK_ORDER. We don't use the output section of the linked-to section since it may be NULL at this point. */ if ((ihdr->sh_flags & SHF_LINK_ORDER) != 0) { - ohdr = &elf_section_data (osec)->this_hdr; ohdr->sh_flags |= SHF_LINK_ORDER; elf_linked_to_section (osec) = elf_linked_to_section (isec); } @@ -8462,36 +8471,6 @@ _bfd_elf_init_private_section_data (bfd *ibfd, return true; } -/* Copy private section information. This copies over the entsize - field, and sometimes the info field. */ - -bool -_bfd_elf_copy_private_section_data (bfd *ibfd, - asection *isec, - bfd *obfd, - asection *osec) -{ - Elf_Internal_Shdr *ihdr, *ohdr; - - if (ibfd->xvec->flavour != bfd_target_elf_flavour - || obfd->xvec->flavour != bfd_target_elf_flavour) - return true; - - ihdr = &elf_section_data (isec)->this_hdr; - ohdr = &elf_section_data (osec)->this_hdr; - - ohdr->sh_entsize = ihdr->sh_entsize; - - if (ihdr->sh_type == SHT_SYMTAB - || ihdr->sh_type == SHT_DYNSYM - || ihdr->sh_type == SHT_GNU_verneed - || ihdr->sh_type == SHT_GNU_verdef) - ohdr->sh_info = ihdr->sh_info; - - return _bfd_elf_init_private_section_data (ibfd, isec, obfd, osec, - NULL); -} - /* Look at all the SHT_GROUP sections in IBFD, making any adjustments necessary if we are removing either the SHT_GROUP section or any of the group member sections. DISCARDED is the value that a section's diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index b9b3cf8..c40a0c5 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -6136,13 +6136,14 @@ elf_x86_64_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, static bool elf_x86_64_copy_private_section_data (bfd *ibfd, asection *isec, - bfd *obfd, asection *osec) + bfd *obfd, asection *osec, + struct bfd_link_info *link_info) { - if (!_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)) + if (!_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec, link_info)) return false; /* objcopy --set-section-flags without "large" drops SHF_X86_64_LARGE. */ - if (ibfd != obfd) + if (link_info == NULL && ibfd != obfd) elf_section_flags (osec) &= ~SHF_X86_64_LARGE; return true; diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 43d3c0d..1200032 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1178,9 +1178,20 @@ static bool check_implicit_for_zcf (riscv_parse_subset_t *rps, const riscv_subset_t *subset ATTRIBUTE_UNUSED) { - riscv_subset_t *tmp = NULL; - return *rps->xlen == 32 - && riscv_lookup_subset (rps->subset_list, "f", &tmp); + return (rps != NULL + && rps->xlen != NULL + && *rps->xlen == 32 + && riscv_subset_supports (rps, "f")); +} + +/* Add the implicit only when 'd' extension is also available. */ + +static bool +check_implicit_for_zcd (riscv_parse_subset_t *rps, + const riscv_subset_t *subset ATTRIBUTE_UNUSED) +{ + return (rps != NULL + && riscv_subset_supports (rps, "d")); } /* Record all implicit information for the subsets. */ @@ -1237,15 +1248,6 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zvl128b", "+zvl64b", check_implicit_always}, {"zvl64b", "+zvl32b", check_implicit_always}, - {"zce", "+zca,+zcb,+zcmp,+zcmt", check_implicit_always}, - {"zce", "+zcf", check_implicit_for_zcf}, - {"zcb", "+zca", check_implicit_always}, - {"zcd", "+d,+zca", check_implicit_always}, - {"zcf", "+f,+zca", check_implicit_always}, - {"zcmp", "+zca", check_implicit_always}, - {"zcmop", "+zca", check_implicit_always}, - {"zcmt", "+zca,+zicsr", check_implicit_always}, - {"zicfilp", "+zicsr", check_implicit_always}, {"zicfiss", "+zimop,+zicsr", check_implicit_always}, {"zclsd", "+zca,+zilsd", check_implicit_always}, @@ -1262,6 +1264,9 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zhinx", "+zhinxmin", check_implicit_always}, {"zhinxmin", "+zfinx", check_implicit_always}, + {"zcd", "+d,+zca", check_implicit_always}, + {"zcf", "+f,+zca", check_implicit_always}, + {"q", "+d", check_implicit_always}, {"zqinx", "+zdinx", check_implicit_always}, @@ -1275,6 +1280,16 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = {"zfinx", "+zicsr", check_implicit_always}, {"f", "+zicsr", check_implicit_always}, + {"zce", "+zcb,+zcmp,+zcmt", check_implicit_always}, + {"zce", "+zcf", check_implicit_for_zcf}, + {"zcb", "+zca", check_implicit_always}, + {"zcmp", "+zca", check_implicit_always}, + {"zcmop", "+zca", check_implicit_always}, + {"zcmt", "+zca,+zicsr", check_implicit_always}, + {"c", "+zcf", check_implicit_for_zcf}, + {"c", "+zcd", check_implicit_for_zcd}, + {"c", "+zca", check_implicit_always}, + {"b", "+zba,+zbb,+zbs", check_implicit_always}, {"zk", "+zkn,+zkr,+zkt", check_implicit_always}, @@ -2208,7 +2223,7 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps) && riscv_subset_supports (rps, "zcd")) { rps->error_handler - (_("zcmp' is incompatible with `d/zcd' extension")); + (_("zcmp' is incompatible with `d' and `c', or `zcd' extension")); no_conflict = false; } if (riscv_lookup_subset (rps->subset_list, "zcf", &subset) @@ -2602,7 +2617,7 @@ riscv_remove_subset (riscv_subset_list_t *subset_list, called from riscv_update_subset./ The IMPLICIT_EXTS, +extension[version] [,...,+extension_n[version_n]] - -extension [,...,-extension_n], + (Deprecated) -extension [,...,-extension_n], full ISA. */ static bool @@ -2694,16 +2709,26 @@ riscv_update_subset1 (riscv_parse_subset_t *rps, return false; } - if (explicit_subset == NULL - && (strcmp (subset, "i") == 0 - || strcmp (subset, "e") == 0 - || strcmp (subset, "g") == 0)) + if (explicit_subset == NULL) { - rps->error_handler - (_("%scannot + or - base extension `%s' in %s `%s'"), - errmsg_internal, subset, errmsg_caller, implicit_exts); - free (subset); - return false; + if (removed) + { + rps->error_handler + (_("%sdeprecated - extension `%s' in %s `%s'"), + errmsg_internal, subset, errmsg_caller, implicit_exts); + free (subset); + return false; + } + else if (strcmp (subset, "i") == 0 + || strcmp (subset, "e") == 0 + || strcmp (subset, "g") == 0) + { + rps->error_handler + (_("%scannot + base extension `%s' in %s `%s'"), + errmsg_internal, subset, errmsg_caller, implicit_exts); + free (subset); + return false; + } } if (removed) @@ -2729,8 +2754,8 @@ riscv_update_subset1 (riscv_parse_subset_t *rps, return no_conflict; } -/* Add/Remove an extension to/from the subset list. This is used for - the .option rvc or norvc, and .option arch directives. */ +/* Add an extension to/from the subset list. This is used for the .option rvc + and .option arch directives. */ bool riscv_update_subset (riscv_parse_subset_t *rps, @@ -2739,6 +2764,16 @@ riscv_update_subset (riscv_parse_subset_t *rps, return riscv_update_subset1 (rps, NULL, str); } +/* Called from .option norvc directives. */ + +bool +riscv_update_subset_norvc (riscv_parse_subset_t *rps) +{ + return riscv_update_subset1 (rps, rps->subset_list->head, + "-c,-zca,-zcd,-zcf,-zcb,-zce,-zcmp,-zcmt," + "-zcmop,-zclsd"); +} + /* Check if the FEATURE subset is supported or not in the subset list. Return true if it is supported; Otherwise, return false. */ @@ -2775,10 +2810,9 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps, return riscv_subset_supports (rps, "zifencei"); case INSN_CLASS_ZIHINTNTL: return riscv_subset_supports (rps, "zihintntl"); - case INSN_CLASS_ZIHINTNTL_AND_C: - return (riscv_subset_supports (rps, "zihintntl") - && (riscv_subset_supports (rps, "c") - || riscv_subset_supports (rps, "zca"))); + case INSN_CLASS_ZIHINTNTL_AND_ZCA: + return riscv_subset_supports (rps, "zihintntl") + && riscv_subset_supports (rps, "zca"); case INSN_CLASS_ZIHINTPAUSE: return riscv_subset_supports (rps, "zihintpause"); case INSN_CLASS_ZIMOP: @@ -2813,17 +2847,12 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps, return riscv_subset_supports (rps, "d"); case INSN_CLASS_Q: return riscv_subset_supports (rps, "q"); - case INSN_CLASS_C: - return (riscv_subset_supports (rps, "c") - || riscv_subset_supports (rps, "zca")); - case INSN_CLASS_F_AND_C: - return (riscv_subset_supports (rps, "f") - && (riscv_subset_supports (rps, "c") - || riscv_subset_supports (rps, "zcf"))); - case INSN_CLASS_D_AND_C: - return (riscv_subset_supports (rps, "d") - && (riscv_subset_supports (rps, "c") - || riscv_subset_supports (rps, "zcd"))); + case INSN_CLASS_ZCA: + return riscv_subset_supports (rps, "zca"); + case INSN_CLASS_ZCF: + return riscv_subset_supports (rps, "zcf"); + case INSN_CLASS_ZCD: + return riscv_subset_supports (rps, "zcd"); case INSN_CLASS_F_INX: return (riscv_subset_supports (rps, "f") || riscv_subset_supports (rps, "zfinx")); @@ -3070,11 +3099,10 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps, return "zicfilp"; case INSN_CLASS_ZIHINTNTL: return "zihintntl"; - case INSN_CLASS_ZIHINTNTL_AND_C: + case INSN_CLASS_ZIHINTNTL_AND_ZCA: if (!riscv_subset_supports (rps, "zihintntl")) { - if (!riscv_subset_supports (rps, "c") - && !riscv_subset_supports (rps, "zca")) + if (!riscv_subset_supports (rps, "zca")) return _("zihintntl' and `c', or `zihintntl' and `zca"); else return "zihintntl"; @@ -3105,30 +3133,12 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps, return "d"; case INSN_CLASS_Q: return "q"; - case INSN_CLASS_C: + case INSN_CLASS_ZCA: return _("c' or `zca"); - case INSN_CLASS_F_AND_C: - if (!riscv_subset_supports (rps, "f")) - { - if (!riscv_subset_supports (rps, "c") - && !riscv_subset_supports (rps, "zcf")) - return _("f' and `c', or `f' and `zcf"); - else - return "f"; - } - else - return _("c' or `zcf"); - case INSN_CLASS_D_AND_C: - if (!riscv_subset_supports (rps, "d")) - { - if (!riscv_subset_supports (rps, "c") - && !riscv_subset_supports (rps, "zcd")) - return _("d' and `c', or `d' and `zcd"); - else - return "d"; - } - else - return _("c' or `zcd"); + case INSN_CLASS_ZCF: + return _("f' and `c', or `zcf"); + case INSN_CLASS_ZCD: + return _("d' and `c', or `zcd"); case INSN_CLASS_F_INX: return _("f' or `zfinx"); case INSN_CLASS_D_INX: diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h index db494d0..fbbefb5 100644 --- a/bfd/elfxx-riscv.h +++ b/bfd/elfxx-riscv.h @@ -119,6 +119,9 @@ extern bool riscv_update_subset (riscv_parse_subset_t *, const char *); extern bool +riscv_update_subset_norvc (riscv_parse_subset_t *); + +extern bool riscv_subset_supports (riscv_parse_subset_t *, const char *); extern bool diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 625243c..4cf02bb 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -225,8 +225,6 @@ _bfd_elf_copy_private_symbol_data #endif -#define bfd_elfNN_init_private_section_data \ - _bfd_elf_init_private_section_data #ifndef bfd_elfNN_bfd_copy_private_section_data #define bfd_elfNN_bfd_copy_private_section_data \ _bfd_elf_copy_private_section_data diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index ae6d303..213cc7d 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -270,17 +270,14 @@ extern bool _bfd_generic_get_section_contents #define _bfd_generic_bfd_merge_private_bfd_data \ _bfd_bool_bfd_link_true #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true -#define _bfd_generic_bfd_copy_private_section_data \ - _bfd_bool_bfd_asection_bfd_asection_true +extern bool _bfd_generic_bfd_copy_private_section_data + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) + ATTRIBUTE_HIDDEN; #define _bfd_generic_bfd_copy_private_symbol_data \ _bfd_bool_bfd_asymbol_bfd_asymbol_true #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true -extern bool _bfd_generic_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) - ATTRIBUTE_HIDDEN; - /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */ diff --git a/bfd/libbfd.c b/bfd/libbfd.c index f2daf79..6587fc1 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1514,11 +1514,11 @@ _bfd_write_unsigned_leb128 (bfd_byte *p, bfd_byte *end, bfd_vma val) } bool -_bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, - asection *isec ATTRIBUTE_UNUSED, - bfd *obfd ATTRIBUTE_UNUSED, - asection *osec ATTRIBUTE_UNUSED, - struct bfd_link_info *link_info ATTRIBUTE_UNUSED) +_bfd_generic_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, + asection *isec ATTRIBUTE_UNUSED, + bfd *obfd ATTRIBUTE_UNUSED, + asection *osec ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info ATTRIBUTE_UNUSED) { return true; } diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 3cb3c14..bab1f71 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -276,17 +276,14 @@ extern bool _bfd_generic_get_section_contents #define _bfd_generic_bfd_merge_private_bfd_data \ _bfd_bool_bfd_link_true #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true -#define _bfd_generic_bfd_copy_private_section_data \ - _bfd_bool_bfd_asection_bfd_asection_true +extern bool _bfd_generic_bfd_copy_private_section_data + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) + ATTRIBUTE_HIDDEN; #define _bfd_generic_bfd_copy_private_symbol_data \ _bfd_bool_bfd_asymbol_bfd_asymbol_true #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true -extern bool _bfd_generic_init_private_section_data - (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) - ATTRIBUTE_HIDDEN; - /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */ diff --git a/bfd/libecoff.h b/bfd/libecoff.h index 51a00e0..08b601d 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -250,9 +250,6 @@ extern bool _bfd_ecoff_get_section_contents #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs -#define _bfd_ecoff_init_private_section_data \ - _bfd_generic_init_private_section_data - extern bool _bfd_ecoff_bfd_copy_private_bfd_data (bfd *, bfd *); #define _bfd_ecoff_bfd_copy_private_section_data \ diff --git a/bfd/libpei.h b/bfd/libpei.h index 4932fb1..fc1ada2 100644 --- a/bfd/libpei.h +++ b/bfd/libpei.h @@ -473,7 +473,7 @@ CODEVIEW_INFO *_bfd_XXi_slurp_codeview_record unsigned _bfd_XX_only_swap_filehdr_out (bfd *, void *, void *); unsigned _bfd_XXi_only_swap_filehdr_out (bfd *, void *, void *); bool _bfd_XX_bfd_copy_private_section_data - (bfd *, asection *, bfd *, asection *); + (bfd *, asection *, bfd *, asection *, struct bfd_link_info *); bool _bfd_pe_print_ce_compressed_pdata (bfd *, void *); bool _bfd_pe64_print_ce_compressed_pdata (bfd *, void *); diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c index fa1953f..e402d3a 100644 --- a/bfd/mach-o-target.c +++ b/bfd/mach-o-target.c @@ -74,7 +74,6 @@ #define bfd_mach_o_write_armap _bfd_noarchive_write_armap #define bfd_mach_o_get_elt_at_index _bfd_noarchive_get_elt_at_index #define bfd_mach_o_update_armap_timestamp _bfd_noarchive_update_armap_timestamp -#define bfd_mach_o_init_private_section_data _bfd_generic_init_private_section_data #define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend) diff --git a/bfd/mach-o.c b/bfd/mach-o.c index fb5bde1..cc191b9 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -583,15 +583,17 @@ bfd_mach_o_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED, bool bfd_mach_o_bfd_copy_private_section_data (bfd *ibfd, asection *isection, - bfd *obfd, asection *osection) + bfd *obfd, asection *osection, + struct bfd_link_info *link_info) { - bfd_mach_o_section *os = bfd_mach_o_get_mach_o_section (osection); - bfd_mach_o_section *is = bfd_mach_o_get_mach_o_section (isection); - - if (ibfd->xvec->flavour != bfd_target_mach_o_flavour + if (link_info != NULL + || ibfd->xvec->flavour != bfd_target_mach_o_flavour || obfd->xvec->flavour != bfd_target_mach_o_flavour) return true; + bfd_mach_o_section *os = bfd_mach_o_get_mach_o_section (osection); + bfd_mach_o_section *is = bfd_mach_o_get_mach_o_section (isection); + BFD_ASSERT (is != NULL && os != NULL); os->flags = is->flags; diff --git a/bfd/mach-o.h b/bfd/mach-o.h index 3aaae38..1cda072 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -691,7 +691,8 @@ bool bfd_mach_o_write_contents (bfd *); bool bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *, bfd *, asymbol *); bool bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *, - bfd *, asection *); + bfd *, asection *, + struct bfd_link_info *); bool bfd_mach_o_bfd_copy_private_header_data (bfd *, bfd *); bool bfd_mach_o_bfd_set_private_flags (bfd *, flagword); bool bfd_mach_o_bfd_print_private_bfd_data (bfd *, void *); @@ -3350,7 +3350,6 @@ mmo_write_object_contents (bfd *abfd) #define mmo_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define mmo_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #define mmo_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data -#define mmo_init_private_section_data _bfd_generic_init_private_section_data const bfd_target mmix_mmo_vec = { diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 19f38a4..c337fc5 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -3115,9 +3115,11 @@ bool _bfd_XX_bfd_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, - asection *osec) + asection *osec, + struct bfd_link_info *link_info) { - if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour + if (link_info != NULL + || bfd_get_flavour (ibfd) != bfd_target_coff_flavour || bfd_get_flavour (obfd) != bfd_target_coff_flavour) return true; diff --git a/bfd/plugin.c b/bfd/plugin.c index d57ae59..1c72b74 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -73,8 +73,6 @@ dlerror (void) #define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cached_info #define bfd_plugin_new_section_hook _bfd_generic_new_section_hook #define bfd_plugin_get_section_contents _bfd_generic_get_section_contents -#define bfd_plugin_init_private_section_data _bfd_generic_init_private_section_data -#define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define bfd_plugin_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define bfd_plugin_bfd_set_private_flags _bfd_generic_bfd_set_private_flags @@ -782,7 +780,8 @@ static bool bfd_plugin_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, asection *isection ATTRIBUTE_UNUSED, bfd *obfd ATTRIBUTE_UNUSED, - asection *osection ATTRIBUTE_UNUSED) + asection *osection ATTRIBUTE_UNUSED, + struct bfd_link_info *link_info ATTRIBUTE_UNUSED) { BFD_ASSERT (0); return true; diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index b4b59c9..dd70267 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -474,7 +474,6 @@ ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg) #define ppcboot_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define ppcboot_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define ppcboot_init_private_section_data _bfd_generic_init_private_section_data #define ppcboot_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #define ppcboot_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #define ppcboot_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data diff --git a/bfd/section.c b/bfd/section.c index 9460ff9..5f0cf6e 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1667,7 +1667,8 @@ FUNCTION SYNOPSIS bool bfd_copy_private_section_data - (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec, + struct bfd_link_info *link_info); DESCRIPTION Copy private section information from @var{isec} in the BFD @@ -1678,9 +1679,9 @@ DESCRIPTION o <<bfd_error_no_memory>> - Not enough memory exists to create private data for @var{osec}. -.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ +.#define bfd_copy_private_section_data(ibfd, isec, obfd, osec, link_info) \ . BFD_SEND (obfd, _bfd_copy_private_section_data, \ -. (ibfd, isection, obfd, osection)) +. (ibfd, isec, obfd, osec, link_info)) */ /* @@ -5372,17 +5372,17 @@ static bool som_bfd_copy_private_section_data (bfd *ibfd, asection *isection, bfd *obfd, - asection *osection) + asection *osection, + struct bfd_link_info *link_info) { - size_t amt; - /* One day we may try to grok other private data. */ - if (ibfd->xvec->flavour != bfd_target_som_flavour + if (link_info != NULL + || ibfd->xvec->flavour != bfd_target_som_flavour || obfd->xvec->flavour != bfd_target_som_flavour || (!som_is_space (isection) && !som_is_subspace (isection))) return true; - amt = sizeof (struct som_copyable_section_data_struct); + size_t amt = sizeof (struct som_copyable_section_data_struct); som_section_data (osection)->copy_data = bfd_zalloc (obfd, amt); if (som_section_data (osection)->copy_data == NULL) return false; @@ -5401,7 +5401,8 @@ som_bfd_copy_private_section_data (bfd *ibfd, { /* User has specified a subspace without its containing space. */ _bfd_error_handler (_("%pB[%pA]: no output section for space %pA"), - obfd, osection, som_section_data (osection)->copy_data->container); + obfd, osection, + som_section_data (osection)->copy_data->container); return false; } } @@ -6779,7 +6780,6 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) #define som_bfd_link_hide_symbol _bfd_generic_link_hide_symbol #define som_bfd_define_start_stop bfd_generic_define_start_stop #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define som_init_private_section_data _bfd_generic_init_private_section_data #define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags #define som_find_inliner_info _bfd_nosymbols_find_inliner_info diff --git a/bfd/targets.c b/bfd/targets.c index 18f5782..2333370 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -282,7 +282,6 @@ BFD_JUMP_TABLE macros. .#define BFD_JUMP_TABLE_COPY(NAME) \ . NAME##_bfd_copy_private_bfd_data, \ . NAME##_bfd_merge_private_bfd_data, \ -. NAME##_init_private_section_data, \ . NAME##_bfd_copy_private_section_data, \ . NAME##_bfd_copy_private_symbol_data, \ . NAME##_bfd_copy_private_header_data, \ @@ -295,16 +294,10 @@ BFD_JUMP_TABLE macros. . {* Called to merge BFD general private data from one object file . to a common output file when linking. *} . bool (*_bfd_merge_private_bfd_data) (bfd *, struct bfd_link_info *); -. {* Called to initialize BFD private section data from one object file -. to another. *} -.#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ -. BFD_SEND (obfd, _bfd_init_private_section_data, \ -. (ibfd, isec, obfd, osec, link_info)) -. bool (*_bfd_init_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, -. struct bfd_link_info *); . {* Called to copy BFD private section data from one object file . to another. *} -. bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr); +. bool (*_bfd_copy_private_section_data) (bfd *, sec_ptr, bfd *, sec_ptr, +. struct bfd_link_info *); . {* Called to copy BFD private symbol data from one symbol . to another. *} . bool (*_bfd_copy_private_symbol_data) (bfd *, asymbol *, diff --git a/bfd/version.h b/bfd/version.h index 4371993..7739244 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -16,7 +16,7 @@ In releases, the date is not included in either version strings or sonames. */ -#define BFD_VERSION_DATE 20250709 +#define BFD_VERSION_DATE 20250710 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 548a979..c4b2484 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -10156,7 +10156,6 @@ bfd_vms_get_data (bfd *abfd) #define vms_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #define vms_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data -#define vms_init_private_section_data _bfd_generic_init_private_section_data #define vms_bfd_copy_private_section_data _bfd_generic_bfd_copy_private_section_data #define vms_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data #define vms_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 2e98ba4..8c90773 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4398,7 +4398,7 @@ setup_section (bfd *ibfd, sec_ptr isection, bfd *obfd) /* Allow the BFD backend to copy any private data it understands from the input section to the output section. */ - if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection, NULL)) err = _("failed to copy private data"); if (make_nobits) @@ -14,6 +14,9 @@ * Support for x86 AVX10.2 256 bit rounding has been dropped, as all the hardware would directly support 512 bit vecotr width. +* For RISC-V, the ".option arch, -ext" format is deprecated due to its + controversial use. + * For RISC-V, stop generating mapping symbols $x and replace with $x<isa>. The $x was defined to have the same ISA as previous $x<isa>, but now is defined to have the same ISA as elf architecture attribute. Once used .option arch diff --git a/gas/atof-generic.c b/gas/atof-generic.c index 944f209..59d1110 100644 --- a/gas/atof-generic.c +++ b/gas/atof-generic.c @@ -351,7 +351,6 @@ atof_generic (/* return pointer to just AFTER number we read. */ unsigned int more_than_enough_bits_for_digits; unsigned int more_than_enough_littlenums_for_digits; unsigned int size_of_digits_in_littlenums; - unsigned int size_of_digits_in_chars; FLONUM_TYPE power_of_10_flonum; FLONUM_TYPE digits_flonum; @@ -375,11 +374,8 @@ atof_generic (/* return pointer to just AFTER number we read. */ number_of_digits_to_use = number_of_digits_available; } - /* Cast these to SIGNED LONG first, otherwise, on systems with - LONG wider than INT (such as Alpha OSF/1), unsignedness may - cause unexpected results. */ - decimal_exponent += ((long) number_of_digits_before_decimal - - (long) number_of_digits_to_use); + decimal_exponent += number_of_digits_before_decimal; + decimal_exponent -= number_of_digits_to_use; more_than_enough_bits_for_digits = (number_of_digits_to_use * 3321928 / 1000000 + 1); @@ -398,13 +394,9 @@ atof_generic (/* return pointer to just AFTER number we read. */ object). */ size_of_digits_in_littlenums = more_than_enough_littlenums_for_digits; - size_of_digits_in_chars = size_of_digits_in_littlenums - * sizeof (LITTLENUM_TYPE); - digits_binary_low = (LITTLENUM_TYPE *) - xmalloc (size_of_digits_in_chars); - - memset ((char *) digits_binary_low, '\0', size_of_digits_in_chars); + digits_binary_low = xcalloc (size_of_digits_in_littlenums, + sizeof (LITTLENUM_TYPE)); /* Digits_binary_low[] is allocated and zeroed. */ @@ -514,13 +506,13 @@ atof_generic (/* return pointer to just AFTER number we read. */ /* From now on: the decimal exponent is > 0. Its sign is separate. */ - size_of_power_in_chars = size_of_power_in_littlenums - * sizeof (LITTLENUM_TYPE) + 2; + size_of_power_in_chars = (size_of_power_in_littlenums + * sizeof (LITTLENUM_TYPE)) + 2; - power_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars); - temporary_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars); + power_binary_low = xmalloc (size_of_power_in_chars); + temporary_binary_low = xmalloc (size_of_power_in_chars); - memset ((char *) power_binary_low, '\0', size_of_power_in_chars); + memset (power_binary_low, '\0', size_of_power_in_chars); *power_binary_low = 1; power_of_10_flonum.exponent = 0; power_of_10_flonum.low = power_binary_low; @@ -632,8 +624,7 @@ atof_generic (/* return pointer to just AFTER number we read. */ #ifdef TRACE static void -flonum_print (f) - const FLONUM_TYPE *f; +flonum_print (const FLONUM_TYPE *f) { LITTLENUM_TYPE *lp; char littlenum_format[10]; @@ -504,7 +504,7 @@ ignore_input (void) else { if (s[-1] != '.') - return (current_cframe != NULL) && (current_cframe->ignoring); + return current_cframe != NULL && current_cframe->ignoring; } /* We cannot ignore certain pseudo ops. */ @@ -526,15 +526,14 @@ ignore_input (void) break; } - return (current_cframe != NULL) && (current_cframe->ignoring); + return current_cframe != NULL && current_cframe->ignoring; } static void initialize_cframe (struct conditional_frame *cframe) { memset (cframe, 0, sizeof (*cframe)); - cframe->if_file_line.file - = as_where (&cframe->if_file_line.line); + cframe->if_file_line.file = as_where (&cframe->if_file_line.line); cframe->previous_cframe = current_cframe; cframe->dead_tree = current_cframe != NULL && current_cframe->ignoring; cframe->macro_nest = macro_nest; diff --git a/gas/config/atof-ieee.c b/gas/config/atof-ieee.c index 92b9f74..a1c3ca2 100644 --- a/gas/config/atof-ieee.c +++ b/gas/config/atof-ieee.c @@ -147,12 +147,12 @@ make_invalid_floating_point_number (LITTLENUM_TYPE *words) { as_bad (_("cannot create floating-point number")); /* Zero the leftmost bit. */ - words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1; - words[1] = (LITTLENUM_TYPE) -1; - words[2] = (LITTLENUM_TYPE) -1; - words[3] = (LITTLENUM_TYPE) -1; - words[4] = (LITTLENUM_TYPE) -1; - words[5] = (LITTLENUM_TYPE) -1; + words[0] = (LITTLENUM_TYPE) -1 >> 1; + words[1] = -1; + words[2] = -1; + words[3] = -1; + words[4] = -1; + words[5] = -1; } /* Build a floating point constant at str into a IEEE floating @@ -283,7 +283,7 @@ atof_ieee (char *str, /* Text to convert to binary. */ default: make_invalid_floating_point_number (words); - return (NULL); + return NULL; } return atof_ieee_detail (str, precision, exponent_bits, words, NULL); diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c index 06b21c9..ea96f3d 100644 --- a/gas/config/kvx-parse.c +++ b/gas/config/kvx-parse.c @@ -458,7 +458,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ { int cur = 0; int found = 0; - int tok_sz = token->end - token->begin; + size_t tok_sz = token->end - token->begin; char *tok = token->insn + token->begin; expressionS exp; @@ -557,7 +557,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ for (int i = 0; !found && i < class[cur].sz; ++i) { const char *ref = class[cur].class_values[i]; - found = ((long) strlen (ref) == tok_sz) && !strncmp (tok, ref, tok_sz); + found = (strlen (ref) == tok_sz) && !strncmp (tok, ref, tok_sz); token->val = i; } @@ -669,7 +669,7 @@ static struct token_list * create_token (struct token_s tok, int len, int loc) { struct token_list *tl = calloc (1, sizeof *tl); - int tok_sz = tok.end - tok.begin; + size_t tok_sz = tok.end - tok.begin; tl->tok = calloc (tok_sz + 1, sizeof (char)); memcpy (tl->tok, tok.insn + tok.begin, tok_sz * sizeof (char)); tl->val = tok.val; diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 6ca2433..03b6c24 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1228,7 +1228,7 @@ obj_elf_section (int push) if (push && ISDIGIT (*input_line_pointer)) { /* .pushsection has an optional subsection. */ - new_subsection = (subsegT) get_absolute_expression (); + new_subsection = get_absolute_expression (); SKIP_WHITESPACE (); @@ -1459,7 +1459,7 @@ obj_elf_section (int push) char *t = input_line_pointer; match.sh_info = strtoul (input_line_pointer, &input_line_pointer, 0); - if (match.sh_info == (unsigned int) -1) + if (match.sh_info == -1u) { as_warn (_("unsupported mbind section info: %s"), t); match.sh_info = 0; @@ -1496,8 +1496,7 @@ obj_elf_section (int push) errno = 0; id = strtoul (input_line_pointer, &input_line_pointer, 0); - overflow = (id == (unsigned long) -1 - && errno == ERANGE); + overflow = id == -1ul && errno == ERANGE; } else { @@ -1506,7 +1505,7 @@ obj_elf_section (int push) (const char **) &input_line_pointer, 0); overflow = id == ~(bfd_vma) 0; } - if (overflow || id > (unsigned int) -1) + if (overflow || id > -1u) { char *linefeed, saved_char = 0; if ((linefeed = strchr (t, '\n')) != NULL) diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c index 17bb697..01e76c5 100644 --- a/gas/config/obj-macho.c +++ b/gas/config/obj-macho.c @@ -531,8 +531,8 @@ obj_mach_o_zerofill (int ignore ATTRIBUTE_UNUSED) SKIP_WHITESPACE (); if (*input_line_pointer == ',') { - align = (unsigned int) parse_align (0); - if (align == (unsigned int) -1) + align = parse_align (0); + if (align == -1u) { as_warn (_("align value not recognized, using size")); align = size; @@ -1800,7 +1800,7 @@ obj_mach_o_set_indirect_symbols (bfd *abfd, asection *sec, entry size, we're dead ... */ gas_assert (eltsiz != 0); - ncalc = (unsigned int) (sect_size / eltsiz); + ncalc = sect_size / eltsiz; if (nactual != ncalc) as_bad (_("the number of .indirect_symbols defined in section %s" " does not match the number expected (%d defined, %d" diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c index cfd0b37..dc8ee74 100644 --- a/gas/config/tc-csky.c +++ b/gas/config/tc-csky.c @@ -5596,25 +5596,25 @@ md_apply_fix (fixS *fixP, case BFD_RELOC_CKCORE_PCREL_IMM8BY4: case BFD_RELOC_CKCORE_PCREL_IMM10BY4: case BFD_RELOC_CKCORE_PCREL_IMM16BY4: - max = (offsetT) howto->dst_mask; + max = howto->dst_mask; min = 0; break; /* lrw16. */ case BFD_RELOC_CKCORE_PCREL_IMM7BY4: if (do_extend_lrw) - max = (offsetT)((1 << (howto->bitsize + 1)) - 2); + max = ((valueT) 1 << (howto->bitsize + 1)) - 2; else - max = (offsetT)((1 << howto->bitsize) - 1); + max = ((valueT) 1 << howto->bitsize) - 1; min = 0; break; /* flrws, flrwd: the offset bits are divided in two parts. */ case BFD_RELOC_CKCORE_PCREL_FLRW_IMM8BY4: - max = (offsetT)((1 << howto->bitsize) - 1); + max = ((valueT) 1 << howto->bitsize) - 1; min = 0; break; /* Offset is signed. */ default: - max = (offsetT)(howto->dst_mask >> 1); + max = howto->dst_mask >> 1; min = - max - 1; issigned = 1; } @@ -5630,7 +5630,7 @@ md_apply_fix (fixS *fixP, if (do_extend_lrw && (opcode & 0xfc00) == CSKYV2_INST_LRW16) val &= 0xff; else - val &= issigned ? (offsetT)(howto->dst_mask) : max; + val &= issigned ? (offsetT) howto->dst_mask : max; if (fixP->fx_r_type == BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4) val = (val & 0xf) << 12; diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c index 08948d2..69c8f49 100644 --- a/gas/config/tc-dlx.c +++ b/gas/config/tc-dlx.c @@ -539,7 +539,7 @@ static char * fix_ld_st_operand (unsigned long opcode, char* str) { /* Check the opcode. */ - switch ((int) opcode) + switch (opcode) { case LBOP: case LBUOP: diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index a22d094..744613f 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -1562,7 +1562,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, if (fragP->fr_type == rs_machine_dependent) { - switch ((int) fragP->fr_subtype) + switch (fragP->fr_subtype) { case 0: fragP->fr_type = rs_fill; @@ -6615,7 +6615,7 @@ pa_type_args (symbolS *symbolP, int is_export) than BFD understands. This is how we get this information to the SOM BFD backend. */ #ifdef obj_set_symbol_type - obj_set_symbol_type (bfdsym, (int) type); + obj_set_symbol_type (bfdsym, type); #else (void) type; #endif @@ -7548,7 +7548,6 @@ pa_subspace (int create_new) /* Now that all the flags are set, update an existing subspace, or create a new one. */ if (ssd) - current_subspace = update_subspace (space, ss_name, loadable, code_only, comdat, common, dup_common, sort, zero, access_ctr, @@ -7973,7 +7972,7 @@ pa_subsegment_to_subspace (asection *seg, subsegT subseg) for (subspace_chain = space_chain->sd_subspaces; subspace_chain; subspace_chain = subspace_chain->ssd_next) - if (subspace_chain->ssd_subseg == (int) subseg) + if (subspace_chain->ssd_subseg == subseg) return subspace_chain; } } @@ -8432,12 +8431,12 @@ hppa_force_relocation (struct fix *fixp) hppa_fixp = fixp->tc_fix_data; #ifdef OBJ_SOM - if (fixp->fx_r_type == (int) R_HPPA_ENTRY - || fixp->fx_r_type == (int) R_HPPA_EXIT - || fixp->fx_r_type == (int) R_HPPA_BEGIN_BRTAB - || fixp->fx_r_type == (int) R_HPPA_END_BRTAB - || fixp->fx_r_type == (int) R_HPPA_BEGIN_TRY - || fixp->fx_r_type == (int) R_HPPA_END_TRY + if (fixp->fx_r_type == R_HPPA_ENTRY + || fixp->fx_r_type == R_HPPA_EXIT + || fixp->fx_r_type == R_HPPA_BEGIN_BRTAB + || fixp->fx_r_type == R_HPPA_END_BRTAB + || fixp->fx_r_type == R_HPPA_BEGIN_TRY + || fixp->fx_r_type == R_HPPA_END_TRY || (fixp->fx_addsy != NULL && fixp->fx_subsy != NULL && (hppa_fixp->segment->flags & SEC_CODE) != 0)) return 1; diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index ac610b7..88f9563 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -741,7 +741,7 @@ typedef struct unw_rec_list { struct unw_rec_list *next; } unw_rec_list; -#define SLOT_NUM_NOT_SET (unsigned)-1 +#define SLOT_NUM_NOT_SET -1UL /* Linked list of saved prologue counts. A very poor implementation of a map from label numbers to prologue counts. */ @@ -1045,9 +1045,9 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) const char *sec_name; char *sym_name; char c; - offsetT size; - offsetT cur_size; - offsetT temp; + valueT size; + valueT cur_size; + valueT temp; symbolS *symbolP; segT current_seg = now_seg; subsegT current_subseg = now_subseg; @@ -1109,7 +1109,7 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) temp = get_absolute_expression (); size = temp; - size &= ((offsetT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1; + size &= ((valueT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1; if (temp != size) { as_warn (_("size (%ld) out of range, ignored"), (long) temp); @@ -1150,7 +1150,7 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) record_alignment (now_seg, log_align); cur_size = bfd_section_size (now_seg); - if ((int) size > cur_size) + if (size > cur_size) { char *pfrag = frag_var (rs_fill, 1, 1, 0, NULL, size - cur_size, NULL); *pfrag = 0; diff --git a/gas/config/tc-iq2000.c b/gas/config/tc-iq2000.c index 1a31e8e..76ff841 100644 --- a/gas/config/tc-iq2000.c +++ b/gas/config/tc-iq2000.c @@ -790,7 +790,7 @@ get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c index 59e2b29..b4ca25c 100644 --- a/gas/config/tc-kvx.c +++ b/gas/config/tc-kvx.c @@ -1021,7 +1021,7 @@ kvx_print_insn (struct kvxopc * op ATTRIBUTE_UNUSED) /* This is a hack which works because the Bundling is the same for all cores for now. */ - switch ((int) op->bundling) + switch (op->bundling) { case Bundling_kv3_v1_ALL: insn_type = "ALL "; @@ -1109,7 +1109,7 @@ kvx_reorder_bundle (struct kvxinsn *bundle_insn[], int bundle_insncnt) tag = -1, exu = -1; /* This is a hack. It works because all the Bundling are the same for all cores for now. */ - switch ((int) find_bundling (kvxinsn)) + switch (find_bundling (kvxinsn)) { case Bundling_kv3_v1_ALL: if (bundle_insncnt > 1) diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index b620d47..7b53b6f 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -452,7 +452,7 @@ static hashval_t align_sec_sym_hash (const void *entry) { const align_sec_sym *e = entry; - return (hashval_t) (e->sec_id); + return e->sec_id; } static int diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index aa1354f..e5c8f5c 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -7333,7 +7333,7 @@ m68k_set_extension (char const *name, int allow_m, int silent) if (negated) not_current_architecture |= (ext->control_regs - ? *(unsigned *)ext->control_regs: ext->arch); + ? *ext->control_regs: ext->arch); else current_architecture |= ext->arch; return 1; diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c index 5e0eaa2..055d9ee 100644 --- a/gas/config/tc-microblaze.c +++ b/gas/config/tc-microblaze.c @@ -484,7 +484,7 @@ parse_reg (char * s, unsigned * reg) } else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int) tmpreg >= MIN_PVR_REGNUM && tmpreg <= MAX_PVR_REGNUM) + if (tmpreg - MIN_PVR_REGNUM <= MAX_PVR_REGNUM - MIN_PVR_REGNUM) *reg = REG_PVR + tmpreg; else { @@ -513,7 +513,7 @@ parse_reg (char * s, unsigned * reg) else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int) tmpreg >= MIN_REGNUM && tmpreg <= MAX_REGNUM) + if (tmpreg - MIN_REGNUM <= MAX_REGNUM - MIN_REGNUM) *reg = tmpreg; else { @@ -550,7 +550,7 @@ parse_reg (char * s, unsigned * reg) else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int)tmpreg >= MIN_REGNUM && tmpreg <= MAX_REGNUM) + if (tmpreg - MIN_REGNUM <= MAX_REGNUM - MIN_REGNUM) *reg = tmpreg; else { diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 8b648ae..9134cef 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1135,8 +1135,7 @@ static bool mips_ignore_branch_isa; but it's not clear that it would actually improve performance. */ #define RELAX_BRANCH_ENCODE(at, pic, \ uncond, likely, link, toofar) \ - ((relax_substateT) \ - (0xc0000000 \ + ((0xc0000000 \ | ((at) & 0x1f) \ | ((pic) ? 0x20 : 0) \ | ((toofar) ? 0x40 : 0) \ @@ -16227,7 +16226,7 @@ get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c index 5ae158d..88b7bc4 100644 --- a/gas/config/tc-mmix.c +++ b/gas/config/tc-mmix.c @@ -2489,8 +2489,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment) case BFD_RELOC_MMIX_PUSHJ_STUBBABLE: /* If this fixup is out of range, punt to the linker to emit an error. This should only happen with -no-expand. */ - if (val < -(((offsetT) 1 << 19)/2) - || val >= ((offsetT) 1 << 19)/2 - 1 + if (val < -((1 << 19) / 2) + || val >= (1 << 19) / 2 - 1 || (val & 3) != 0) { if (warn_on_expansion) @@ -2513,8 +2513,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment) case BFD_RELOC_MMIX_JMP: /* If this fixup is out of range, punt to the linker to emit an error. This should only happen with -no-expand. */ - if (val < -(((offsetT) 1 << 27)/2) - || val >= ((offsetT) 1 << 27)/2 - 1 + if (val < -((1 << 27) / 2) + || val >= (1 << 27) / 2 - 1 || (val & 3) != 0) { if (warn_on_expansion) @@ -2773,7 +2773,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP) && (bfd_vma) val + 256 > lowest_data_loc && bfd_is_abs_section (addsec)) { - val -= (offsetT) lowest_data_loc; + val -= lowest_data_loc; addsy = section_symbol (data_section); } /* Likewise text section. */ @@ -2781,7 +2781,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP) && (bfd_vma) val + 256 > lowest_text_loc && bfd_is_abs_section (addsec)) { - val -= (offsetT) lowest_text_loc; + val -= lowest_text_loc; addsy = section_symbol (text_section); } } @@ -3437,9 +3437,8 @@ mmix_md_relax_frag (segT seg, fragS *fragP, long stretch) if (fragP == seginfo->tc_segment_info_data.last_stubfrag) seginfo->tc_segment_info_data.nstubs = 0; - return - (mmix_relax_table[fragP->fr_subtype].rlx_length - - mmix_relax_table[prev_type].rlx_length); + return (mmix_relax_table[fragP->fr_subtype].rlx_length + - mmix_relax_table[prev_type].rlx_length); } case ENCODE_RELAX (STATE_PUSHJ, STATE_MAX): @@ -3634,7 +3633,7 @@ mmix_md_finish (void) if (! merge_gregs) continue; - osymval = (offsetT) S_GET_VALUE (symbolP); + osymval = S_GET_VALUE (symbolP); osymfrag = symbol_get_frag (symbolP); /* If the symbol isn't defined, we can't say that another symbol @@ -3725,7 +3724,7 @@ mmix_frob_file (void) } sym = fixP->fx_addsy; - offs = (offsetT) fixP->fx_offset; + offs = fixP->fx_offset; /* If the symbol is defined, then it must be resolved to a section symbol at this time, or else we don't know how to handle it. */ @@ -3748,7 +3747,7 @@ mmix_frob_file (void) && (bfd_vma) offs + 256 > lowest_data_loc && bfd_is_abs_section (S_GET_SEGMENT (sym))) { - offs -= (offsetT) lowest_data_loc; + offs -= lowest_data_loc; sym = section_symbol (data_section); } /* Likewise text section. */ @@ -3756,7 +3755,7 @@ mmix_frob_file (void) && (bfd_vma) offs + 256 > lowest_text_loc && bfd_is_abs_section (S_GET_SEGMENT (sym))) { - offs -= (offsetT) lowest_text_loc; + offs -= lowest_text_loc; sym = section_symbol (text_section); } diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c index f57540e..210e9b0 100644 --- a/gas/config/tc-mn10200.c +++ b/gas/config/tc-mn10200.c @@ -828,8 +828,7 @@ mn10200_insert_operand (unsigned long *insnp, if (operand->bits < 24 && (operand->flags & MN10200_OPERAND_NOCHECK) == 0) { - long min, max; - offsetT test; + offsetT min, max; if ((operand->flags & MN10200_OPERAND_SIGNED) != 0) { @@ -842,11 +841,8 @@ mn10200_insert_operand (unsigned long *insnp, min = 0; } - test = val; - - if (test < min || test > max) - as_warn_value_out_of_range (_("operand"), test, (offsetT) min, - (offsetT) max, file, line); + if (val < min || val > max) + as_warn_value_out_of_range (_("operand"), val, min, max, file, line); } if ((operand->flags & MN10200_OPERAND_EXTENDED) == 0) diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index 537c2cb..a1d89f0 100644 --- a/gas/config/tc-mn10300.c +++ b/gas/config/tc-mn10300.c @@ -1103,7 +1103,7 @@ check_operand (const struct mn10300_operand *operand, test = val; - if (test < (offsetT) min || test > (offsetT) max) + if (test < min || test > max) return false; } return true; @@ -1146,8 +1146,9 @@ mn10300_insert_operand (unsigned long *insnp, test = val; - if (test < (offsetT) min || test > (offsetT) max) - as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line); + if (test < min || test > max) + as_warn_value_out_of_range (_("operand"), test, (offsetT) min, + (offsetT) max, file, line); } if ((operand->flags & MN10300_OPERAND_SPLIT) != 0) @@ -1209,20 +1210,20 @@ mn10300_insert_operand (unsigned long *insnp, } else if ((operand->flags & MN10300_OPERAND_EXTENDED) == 0) { - *insnp |= (((long) val & ((1 << operand->bits) - 1)) + *insnp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift)); if ((operand->flags & MN10300_OPERAND_REPEATED) != 0) - *insnp |= (((long) val & ((1 << operand->bits) - 1)) + *insnp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift + operand->bits)); } else { - *extensionp |= (((long) val & ((1 << operand->bits) - 1)) + *extensionp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift)); if ((operand->flags & MN10300_OPERAND_REPEATED) != 0) - *extensionp |= (((long) val & ((1 << operand->bits) - 1)) + *extensionp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift + operand->bits)); } } diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index f5c021d..647744f 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -3896,7 +3896,7 @@ nds32_adjust_label (int n) /* Only frag by alignment when needed. Otherwise, it will fail to optimize labels on 4-byte boundary. (bug8454) See md_convert_frag () and RELAX_SET_RELAXABLE (frag) for details. */ - if (frag_now_fix () & ((1 << n) -1 )) + if (frag_now_fix () & (((addressT) 1 << n) - 1)) { if (subseg_text_p (now_seg)) { @@ -3921,7 +3921,7 @@ nds32_adjust_label (int n) old_frag = symbol_get_frag (label); old_value = S_GET_VALUE (label); - new_value = (valueT) frag_now_fix (); + new_value = frag_now_fix (); /* Multiple labels may be on the same address. And the last symbol may not be a label at all, e.g., register name, external function names, @@ -4208,8 +4208,6 @@ struct relax_hint_id *record_id_head = NULL; /* Is the buffer large enough? */ #define MAX_BUFFER 12 -static char *nds_itoa (int n); - static char * nds_itoa (int n) { diff --git a/gas/config/tc-pru.c b/gas/config/tc-pru.c index 9e12ab6..dcc23ba 100644 --- a/gas/config/tc-pru.c +++ b/gas/config/tc-pru.c @@ -255,7 +255,7 @@ pru_align (int log_size, const char *pfill, symbolS *label) old_frag = symbol_get_frag (label); old_value = S_GET_VALUE (label); - new_value = (valueT) frag_now_fix (); + new_value = frag_now_fix (); /* It is possible to have more than one label at a particular address, especially if debugging is enabled, so we must @@ -949,7 +949,7 @@ pru_assemble_expression (const char *exprstr, if (pru_mode == PRU_MODE_TEST && ep->X_op == O_constant) value = ep->X_add_number; - return (unsigned long) value; + return value; } /* Try to parse a non-relocatable expression. */ @@ -1100,7 +1100,6 @@ pru_assemble_arg_b (pru_insn_infoS *insn_info, const char *argstr) SET_INSN_FIELD (RS2, insn_info->insn_code, src2->index); SET_INSN_FIELD (RS2SEL, insn_info->insn_code, src2->regsel); } - } static void @@ -1554,7 +1553,6 @@ md_show_usage (FILE *stream) " -mlink-relax generate relocations for linker relaxation (default).\n" " -mno-link-relax don't generate relocations for linker relaxation.\n" )); - } /* This function is called once, at assembler startup time. diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 0492311..8a33568 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -4322,12 +4322,12 @@ riscv_ip_hardcode (char *str, switch (imm_expr->X_op) { case O_constant: - values[num++] = (insn_t) imm_expr->X_add_number; + values[num++] = imm_expr->X_add_number; break; case O_big: /* Extract lower 32-bits of a big number. Assume that generic_bignum_to_int32 work on such number. */ - values[num++] = (insn_t) generic_bignum_to_int32 (); + values[num++] = generic_bignum_to_int32 (); break; default: /* The first value isn't constant, so it should be @@ -4616,7 +4616,7 @@ bool riscv_parse_name (const char *name, struct expressionS *ep, gas_assert (mode == expr_normal); regno = reg_lookup_internal (name, RCLASS_GPR); - if (regno == (unsigned int)-1) + if (regno == -1u) return false; if (symbol_find (name) != NULL) @@ -5073,8 +5073,7 @@ s_riscv_option (int x ATTRIBUTE_UNUSED) } else if (strcmp (name, "norvc") == 0) { - riscv_update_subset (&riscv_rps_as, "-c,-zca,-zcd,-zcf,-zcb,-zce,-zcmp," - "-zcmt,-zcmop,-zclsd"); + riscv_update_subset_norvc (&riscv_rps_as); riscv_arch_str (xlen, riscv_rps_as.subset_list, true/* update */); riscv_set_rvc (false); } diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c index 438418a..5110470 100644 --- a/gas/config/tc-s12z.c +++ b/gas/config/tc-s12z.c @@ -579,9 +579,7 @@ lex_opr (uint8_t *buffer, int *n_bytes, expressionS *exp, } else if (lex_reg_name (REG_BIT_Dn, ®2)) { - if (c >= -1 * (long) (0x1u << 17) - && - c < (long) (0x1u << 17) - 1) + if (c >= -1 * (1L << 17) && c < (1L << 17) - 1) { *n_bytes = 3; *xb = 0x80; diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c index 6d4748e..d5d3976 100644 --- a/gas/config/tc-s390.c +++ b/gas/config/tc-s390.c @@ -727,9 +727,9 @@ s390_insert_operand (unsigned char *insn, { if (operand->flags & S390_OPERAND_PCREL) { - val = (offsetT) ((addressT) val << 1); - min = (offsetT) ((addressT) min << 1); - max = (offsetT) ((addressT) max << 1); + val = (addressT) val << 1; + min = (addressT) min << 1; + max = (addressT) max << 1; } s390_bad_operand_out_of_range (operand_number, val, min, max, @@ -738,7 +738,7 @@ s390_insert_operand (unsigned char *insn, return; } /* val is ok, now restrict it to operand->bits bits. */ - uval = (addressT) val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1); + uval = val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1); /* val is restrict, now check for special case. */ if (operand->bits == 20 && operand->shift == 20) uval = (uval >> 12) | ((uval & 0xfff) << 8); @@ -748,8 +748,8 @@ s390_insert_operand (unsigned char *insn, addressT min, max; max = (((addressT) 1 << (operand->bits - 1)) << 1) - 1; - min = (offsetT) 0; - uval = (addressT) val; + min = 0; + uval = val; /* Vector register operands have an additional bit in the RXB field. */ diff --git a/gas/config/tc-score.c b/gas/config/tc-score.c index cf8687bb..f3f1b2a 100644 --- a/gas/config/tc-score.c +++ b/gas/config/tc-score.c @@ -1507,7 +1507,7 @@ s3_data_op2 (char **str, int shift, enum score_data_type data_type) sprintf (s3_err_msg, _("invalid constant: %d bit expression not in range %u..%u"), s3_score_df_range[data_type].bits, - 0, (unsigned)0xffffffff); + 0, 0xffffffff); } else if (data_type == _IMM5_MULTI_LOAD) { @@ -4124,7 +4124,7 @@ s3_build_la_pic (int reg_rd, expressionS exp) var_num = 1; /* Fix part For an external symbol: addi rD, <constant> */ - sprintf (tmp, "addi r%d, %d", reg_rd, (int)add_number); + sprintf (tmp, "addi r%d, %d", reg_rd, (int) add_number); if (s3_append_insn (tmp, false) == s3_FAIL) return; @@ -4811,13 +4811,15 @@ s3_nopic_need_relax (symbolS * sym, int before_relaxing) { return 1; } - else if ((!S_IS_DEFINED (sym) || S_IS_COMMON (sym)) && (0 - /* We must defer this decision until after the whole file has been read, - since there might be a .extern after the first use of this symbol. */ - || (before_relaxing - && S_GET_VALUE (sym) == 0) - || (S_GET_VALUE (sym) != 0 - && S_GET_VALUE (sym) <= s3_g_switch_value))) + else if ((!S_IS_DEFINED (sym) || S_IS_COMMON (sym)) + && (0 + /* We must defer this decision until after the + whole file has been read, since there might be a + .extern after the first use of this symbol. */ + || (before_relaxing + && S_GET_VALUE (sym) == 0) + || (S_GET_VALUE (sym) != 0 + && S_GET_VALUE (sym) <= s3_g_switch_value))) { return 0; } @@ -5601,7 +5603,7 @@ s3_get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } @@ -6449,7 +6451,7 @@ s3_begin (void) s3_build_dependency_insn_hsh (); - for (i = (int)s3_REG_TYPE_FIRST; i < (int)s3_REG_TYPE_MAX; i++) + for (i = s3_REG_TYPE_FIRST; i < s3_REG_TYPE_MAX; i++) s3_build_reg_hsh (s3_all_reg_maps + i); /* Initialize dependency vector. */ @@ -6767,7 +6769,7 @@ s3_relax_branch_inst16 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN16_SIZE); offset = (inst_value & 0x1ff) << 1; @@ -6810,7 +6812,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN_SIZE); offset = (inst_value & 0x1) diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c index 8543718..7b6b685 100644 --- a/gas/config/tc-score7.c +++ b/gas/config/tc-score7.c @@ -5251,7 +5251,7 @@ s7_b32_relax_to_b16 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; value = s7_md_chars_to_number (fragp->fr_literal, s7_INSN_SIZE); @@ -5440,7 +5440,7 @@ s7_get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } @@ -6080,7 +6080,7 @@ s7_begin (void) s7_build_dependency_insn_hsh (); - for (i = (int) REG_TYPE_FIRST; i < (int) s7_REG_TYPE_MAX; i++) + for (i = REG_TYPE_FIRST; i < s7_REG_TYPE_MAX; i++) s7_build_reg_hsh (s7_all_reg_maps + i); /* Initialize dependency vector. */ diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 2a25937..5653583 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -3703,8 +3703,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) if (val >= 0) val >>= shift; else - val = ((val >> shift) - | ((long) -1 & ~ ((long) -1 >> shift))); + val = (val >> shift) | (-1L & ~ (-1L >> shift)); } /* Extend sign for 64-bit host. */ diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 61f43e0..0dd9205 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -1254,7 +1254,7 @@ synthetize_setuw (const struct sparc_opcode *insn) && (the_insn.exp.X_add_number < -(offsetT) U0x80000000 || the_insn.exp.X_add_number > (offsetT) U0xffffffff)) as_warn (_("set: number not in -2147483648..4294967295 range")); - the_insn.exp.X_add_number = (int) the_insn.exp.X_add_number; + the_insn.exp.X_add_number = (int32_t) the_insn.exp.X_add_number; } } diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c index 323f8bb..2c80f97 100644 --- a/gas/config/tc-tic30.c +++ b/gas/config/tc-tic30.c @@ -598,7 +598,7 @@ tic30_operand (char *token) current_op->immediate.s_number = current_op->immediate.imm_expr.X_add_number; current_op->immediate.u_number - = (unsigned int) current_op->immediate.imm_expr.X_add_number; + = current_op->immediate.imm_expr.X_add_number; current_op->immediate.resolved = 1; } } @@ -610,8 +610,8 @@ tic30_operand (char *token) current_op->immediate.decimal_found = 1; current_op->immediate.label = xstrdup (token); current_op->immediate.f_number = (float) atof (token); - current_op->immediate.s_number = (int) atoi (token); - current_op->immediate.u_number = (unsigned int) atoi (token); + current_op->immediate.s_number = atoi (token); + current_op->immediate.u_number = atoi (token); current_op->immediate.resolved = 1; } current_op->op_type = Disp | Abs24 | Imm16 | Imm24; @@ -1279,7 +1279,7 @@ md_atof (int what_statement_type, if (mant == 0) { mant |= 0x00800000; - exp = (long) exp - 0x01000000; + exp = exp - 0x01000000; } } tmsfloat = exp | mant; diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c index 25efad6..515b843 100644 --- a/gas/config/tc-tic54x.c +++ b/gas/config/tc-tic54x.c @@ -478,7 +478,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) char c; char *name; char *p; - int words; + offsetT words; segT current_seg; subsegT current_subseg; symbolS *symbolP; @@ -504,7 +504,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) words = get_absolute_expression (); if (words < 0) { - as_bad (_(".bss size %d < 0!"), words); + as_bad (_(".bss size %d < 0!"), (int) words); ignore_rest_of_line (); return; } @@ -860,7 +860,7 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED) static void tic54x_struct_field (int type) { - int size; + unsigned int size; int count = 1; int new_bitfield_offset = 0; int field_align = current_stag->current_bitfield_offset != 0; @@ -964,12 +964,12 @@ tic54x_struct_field (int type) if (current_stag->is_union) { /* Note we treat the element as if it were an array of COUNT. */ - if (current_stag->size < (unsigned) size * count) + if (current_stag->size < size * count) current_stag->size = size * count; } else { - abs_section_offset += (unsigned) size * count; + abs_section_offset += size * count; current_stag->current_bitfield_offset = new_bitfield_offset; } line_label = NULL; @@ -1831,7 +1831,7 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED) /* OR in existing value. */ if (alloc_frag->tc_frag_data) - value |= ((unsigned short) p[1] << 8) | p[0]; + value |= ((uint16_t) p[1] << 8) | p[0]; md_number_to_chars (p, value, 2); alloc_frag->tc_frag_data += size; if (alloc_frag->tc_frag_data == 16) @@ -3937,16 +3937,14 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand) if (strcasecmp (operand->buf, "st0") == 0 || strcasecmp (operand->buf, "st1") == 0) { - insn->opcode[0].word |= - ((unsigned short) (operand->buf[2] - '0')) << 9; + insn->opcode[0].word |= ((uint16_t) (operand->buf[2] - '0')) << 9; return 1; } else if (operand->exp.X_op == O_constant && (operand->exp.X_add_number == 0 || operand->exp.X_add_number == 1)) { - insn->opcode[0].word |= - ((unsigned short) (operand->exp.X_add_number)) << 9; + insn->opcode[0].word |= ((uint16_t) (operand->exp.X_add_number)) << 9; return 1; } as_bad (_("Invalid status register \"%s\""), operand->buf); @@ -5269,7 +5267,7 @@ tic54x_relax_frag (fragS *frag, long stretch ATTRIBUTE_UNUSED) valueT value = bi->value; value <<= available - size; - value |= ((unsigned short) p[1] << 8) | p[0]; + value |= ((uint16_t) p[1] << 8) | p[0]; md_number_to_chars (p, value, 2); if ((prev_frag->tc_frag_data += size) == 16) prev_frag->tc_frag_data = 0; diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c index 99ec7ec..7862236 100644 --- a/gas/config/tc-tic6x.c +++ b/gas/config/tc-tic6x.c @@ -3525,7 +3525,7 @@ md_assemble (char *str) bool found_match = false; for (i = 0; i < TIC6X_NUM_PREFER; i++) - opc_rank[i] = (unsigned int) -1; + opc_rank[i] = -1u; min_rank = TIC6X_NUM_PREFER - 1; max_rank = 0; @@ -3574,7 +3574,7 @@ md_assemble (char *str) if (rank > max_rank) max_rank = rank; - if (opc_rank[rank] == (unsigned int) -1) + if (opc_rank[rank] == -1u) opc_rank[rank] = i; else /* The opcode table should provide a total ordering @@ -3605,7 +3605,7 @@ md_assemble (char *str) { fix_needed = false; - if (opc_rank[try_rank] == (unsigned int) -1) + if (opc_rank[try_rank] == -1u) continue; opcode_value = tic6x_try_encode (opcm[opc_rank[try_rank]], operands, @@ -4466,7 +4466,7 @@ tic6x_pcrel_from_section (fixS *fixp, segT sec) && (!S_IS_DEFINED (fixp->fx_addsy) || S_GET_SEGMENT (fixp->fx_addsy) != sec)) return 0; - return (fixp->fx_where + fixp->fx_frag->fr_address) & ~(long) 0x1f; + return (fixp->fx_where + fixp->fx_frag->fr_address) & ~0x1fULL; } /* Round up a section size to the appropriate boundary. */ diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c index 853e940..84daf05 100644 --- a/gas/config/tc-tilegx.c +++ b/gas/config/tc-tilegx.c @@ -441,25 +441,25 @@ apply_special_operator (operatorT op, offsetT num, const char *file, check_shift = 0; /* Fall through. */ case O_hw0: - ret = (signed short)num; + ret = (int16_t) num; break; case O_hw1_last: check_shift = 16; /* Fall through. */ case O_hw1: - ret = (signed short)(num >> 16); + ret = (int16_t) (num >> 16); break; case O_hw2_last: check_shift = 32; /* Fall through. */ case O_hw2: - ret = (signed short)(num >> 32); + ret = (int16_t) (num >> 32); break; case O_hw3: - ret = (signed short)(num >> 48); + ret = (int16_t) (num >> 48); break; default: @@ -959,10 +959,8 @@ tilegx_flush_bundle (void) /* Figure out what pipe the fnop must be in via arithmetic. * p0 + p1 + p2 must sum to the sum of TILEGX_PIPELINE_Y[012]. */ current_bundle[0].pipe = - (tilegx_pipeline)((TILEGX_PIPELINE_Y0 - + TILEGX_PIPELINE_Y1 - + TILEGX_PIPELINE_Y2) - - (current_bundle[1].pipe + current_bundle[2].pipe)); + (TILEGX_PIPELINE_Y0 + TILEGX_PIPELINE_Y1 + TILEGX_PIPELINE_Y2 + - current_bundle[1].pipe - current_bundle[2].pipe); } check_illegal_reg_writes (); diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c index 4481731..8c90217 100644 --- a/gas/config/tc-tilepro.c +++ b/gas/config/tc-tilepro.c @@ -387,13 +387,13 @@ apply_special_operator (operatorT op, int num) switch (op) { case O_lo16: - return (signed short)num; + return (int16_t) num; case O_hi16: - return (signed short)(num >> 16); + return (int16_t) (num >> 16); case O_ha16: - return (signed short)((num + 0x8000) >> 16); + return (int16_t) ((num + 0x8000) >> 16); default: abort (); @@ -846,10 +846,8 @@ tilepro_flush_bundle (void) /* Figure out what pipe the fnop must be in via arithmetic. * p0 + p1 + p2 must sum to the sum of TILEPRO_PIPELINE_Y[012]. */ current_bundle[0].pipe = - (tilepro_pipeline)((TILEPRO_PIPELINE_Y0 - + TILEPRO_PIPELINE_Y1 - + TILEPRO_PIPELINE_Y2) - - (current_bundle[1].pipe + current_bundle[2].pipe)); + (TILEPRO_PIPELINE_Y0 + TILEPRO_PIPELINE_Y1 + TILEPRO_PIPELINE_Y2 + - current_bundle[1].pipe - current_bundle[2].pipe); } check_illegal_reg_writes (); diff --git a/gas/config/tc-visium.c b/gas/config/tc-visium.c index 1e3e3a8..01767f3 100644 --- a/gas/config/tc-visium.c +++ b/gas/config/tc-visium.c @@ -412,10 +412,9 @@ relaxed_symbol_addr (fragS *fragp, long stretch) if (f->fr_type == rs_align || f->fr_type == rs_align_code) { if (stretch < 0) - stretch = - ((- stretch) - & ~ ((1 << (int) f->fr_offset) - 1)); + stretch = -(-stretch & ~((1ul << f->fr_offset) - 1)); else - stretch &= ~ ((1 << (int) f->fr_offset) - 1); + stretch &= ~((1ul << f->fr_offset) - 1); if (stretch == 0) break; } @@ -683,7 +682,7 @@ md_apply_fix (fixS * fixP, valueT * value, segT segment) default: as_bad_where (fixP->fx_file, fixP->fx_line, "bad or unhandled relocation type: 0x%02x", - fixP->fx_r_type); + (unsigned int) fixP->fx_r_type); break; } @@ -1373,9 +1372,8 @@ md_assemble (char *str0) if (imm < 0 || imm > 31) as_bad ("immediate value out of range"); - opcode |= - (r1 << 10) | (r2 << 16) | (1 << 9) | ((imm & 0x1f) << - 4); + opcode |= ((r1 << 10) | (r2 << 16) | (1 << 9) + | ((imm & 0x1f) << 4)); } else { @@ -1889,9 +1887,8 @@ md_assemble (char *str0) if (finst < 0 || finst > 15) as_bad ("finst out of range"); - opcode |= - ((finst & 0xf) << 27) | (r1 << 10) | (r2 << 16) | (r3 << - 4); + opcode |= (((finst & 0xf) << 27) + | (r1 << 10) | (r2 << 16) | (r3 << 4)); } else { @@ -1955,9 +1952,8 @@ md_assemble (char *str0) if (finst < 0 || finst > 15) as_bad ("finst out of range"); - opcode |= - ((finst & 0xf) << 27) | (r1 << 10) | (r2 << 16) | (r3 << - 4); + opcode |= (((finst & 0xf) << 27) + | (r1 << 10) | (r2 << 16) | (r3 << 4)); } else { diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 38af6d0..af1154e 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -1869,7 +1869,7 @@ expression_end (const char *name) } -#define ERROR_REG_NUM ((unsigned) -1) +#define ERROR_REG_NUM (-1u) static unsigned tc_get_register (const char *prefix) @@ -1961,7 +1961,7 @@ expression_maybe_register (xtensa_opcode opc, int opnd, expressionS *tok) case BFD_RELOC_HI16: if (tok->X_op == O_constant) { - tok->X_add_number = ((unsigned) tok->X_add_number) >> 16; + tok->X_add_number = ((uint32_t) tok->X_add_number) >> 16; return; } break; diff --git a/gas/debug.c b/gas/debug.c index 794dc4c..9fe9a30 100644 --- a/gas/debug.c +++ b/gas/debug.c @@ -22,7 +22,8 @@ #include "as.h" #include "subsegs.h" -dmp_frags () +void +dmp_frags (void) { asection *s; frchainS *chp; @@ -48,9 +49,8 @@ dmp_frags () } } -dmp_frag (fp, indent) - struct frag *fp; - char *indent; +void +dmp_frag (struct frag *fp, char *indent) { for (; fp; fp = fp->fr_next) { @@ -90,9 +90,8 @@ dmp_frag (fp, indent) } } -var_chars (fp, n) - struct frag *fp; - int n; +void +var_chars (struct frag *fp, int n) { unsigned char *p; diff --git a/gas/doc/c-riscv.texi b/gas/doc/c-riscv.texi index a4c819e..ea4be32 100644 --- a/gas/doc/c-riscv.texi +++ b/gas/doc/c-riscv.texi @@ -181,12 +181,14 @@ instead of just It's not expected that options are changed in this manner during regular use, but there are a handful of esoteric cases like the one above where users need to disable particular features of the assembler for particular code sequences. -However, it's also useful to enable/disable the extensions for some specific -code regions by @samp{.option arch, +-}. This is very common in the ifunc -libraries. We can support functions which are implemented by different -extensions in the same library, but these should not affect any file-level -settings, like the elf architecture attribute. The complete list of option -arguments is shown below: +However, it's also useful to enable and reset the extensions for some specific +code regions by @samp{.option arch, +ext} and @samp{.option arch, ISA}. Or +use @samp{.option push} and @samp{.option pop} at the beginning and end of the +code, so that we can indirectly turn on and off extensions in this range. This +is very common in the ifunc libraries. We can support functions which are +implemented by different extensions in the same library, but these should not +affect any file-level settings, like the elf architecture attribute. The +complete list of option arguments is shown below: @table @code @item push @@ -197,9 +199,11 @@ command-line options are respected for the bulk of the file being assembled. @item rvc @itemx norvc -Enables or disables the generation of compressed instructions. Instructions -are opportunistically compressed by the RISC-V assembler when possible, but -sometimes this behavior is not desirable, especially when handling alignments. +Enable the generation of base compressed instructions (C extension), or +disable the generation of all compressed instructions (C and all Zc* +extensions). Instructions are opportunistically compressed by the RISC-V +assembler when possible, but sometimes this behavior is not desirable, +especially when handling alignments. @item pic @itemx nopic @@ -217,17 +221,11 @@ desirable. Enables or disables the CSR checking. @item arch, @var{+extension[version]} [,...,@var{+extension_n[version_n]}] -@itemx arch, @var{-extension} [,...,@var{-extension_n}] @itemx arch, @var{ISA} -Enables or disables the extensions for specific code region. For example, -@samp{.option arch, +m2p0} means add m extension with version 2.0, and -@samp{.option arch, -f, -d} means remove extensions, f and d, from the -architecture string. Note that, @samp{.option arch, +c, -c} have the same -behavior as @samp{.option rvc, norvc}. However, they are also undesirable -sometimes. Besides, @samp{.option arch, -i} is illegal, since we cannot -remove the base i extension anytime. If you want to reset the whole ISA -string, you can also use @samp{.option arch, rv32imac} to overwrite the -previous settings. +Enable or reset the extensions for specific code region. For example, +@samp{.option arch, +m2p0} means add m extension with version 2.0. +@samp{.option arch, rv32imac} means reset and overwrite the previous settings +by rv32imac. @end table @cindex INSN directives diff --git a/gas/ecoff.c b/gas/ecoff.c index ba8f6d8..7411595 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -3669,9 +3669,8 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend, else if (l->next->frag->fr_address + l->next->paddr > l->frag->fr_address + l->paddr) { - count = ((l->next->frag->fr_address + l->next->paddr - - (l->frag->fr_address + l->paddr)) - >> 2); + count = (l->next->frag->fr_address + l->next->paddr + - (l->frag->fr_address + l->paddr)) >> 2; } else { @@ -3785,7 +3784,7 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend, while (count > 0) { if (bufptr >= *bufend) - bufptr = ecoff_add_bytes (buf, bufend, bufptr, (long) 1); + bufptr = ecoff_add_bytes (buf, bufend, bufptr, 1); /* 1 is added to each count read. */ --count; if (count > 0x0f) diff --git a/gas/ehopt.c b/gas/ehopt.c index 8852820..5a9d9d6 100644 --- a/gas/ehopt.c +++ b/gas/ehopt.c @@ -537,7 +537,7 @@ eh_frame_convert_frag (fragS *frag) int loc4_fix, ca; loc4_frag = (fragS *) frag->fr_opcode; - loc4_fix = (int) frag->fr_offset; + loc4_fix = frag->fr_offset; diff = resolve_symbol_value (frag->fr_symbol); @@ -1991,8 +1991,8 @@ expr (int rankarg, /* Larger # is higher rank. */ symbol_get_frag (right.X_add_symbol), &frag_off)) { - offsetT symval_diff = S_GET_VALUE (resultP->X_add_symbol) - - S_GET_VALUE (right.X_add_symbol); + offsetT symval_diff = (S_GET_VALUE (resultP->X_add_symbol) + - S_GET_VALUE (right.X_add_symbol)); subtract_from_result (resultP, right.X_add_number, right.X_extrabit); subtract_from_result (resultP, frag_off / OCTETS_PER_BYTE, 0); add_to_result (resultP, symval_diff, symval_diff < 0); diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 7e29f84..3cba508 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -21,7 +21,7 @@ #include "as.h" #include "subsegs.h" #include "sframe.h" -#include "sframe-api.h" +#include "sframe-internal.h" #include "gen-sframe.h" #include "dw2gencfi.h" @@ -685,8 +685,8 @@ output_sframe_internal (void) out_one (SFRAME_VERSION); /* gas must ensure emitted SFrame sections have at least the required flags set. */ - gas_assert ((sframe_flags & SFRAME_F_LD_MUSTHAVE_FLAGS) - == SFRAME_F_LD_MUSTHAVE_FLAGS); + gas_assert ((sframe_flags & SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS) + == SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS); out_one (sframe_flags); /* abi/arch. */ #ifdef sframe_get_abi_arch diff --git a/gas/input-scrub.c b/gas/input-scrub.c index 93d1e8e..c967a39 100644 --- a/gas/input-scrub.c +++ b/gas/input-scrub.c @@ -419,8 +419,8 @@ input_scrub_next_buffer (char **bufp) partial_size = limit - p; /* Save the fragment after that last newline. */ - memcpy (save_source, partial_where, (int) AFTER_SIZE); - memcpy (partial_where, AFTER_STRING, (int) AFTER_SIZE); + memcpy (save_source, partial_where, AFTER_SIZE); + memcpy (partial_where, AFTER_STRING, AFTER_SIZE); return partial_where; read_more: diff --git a/gas/listing.c b/gas/listing.c index dbf4782..92c560c 100644 --- a/gas/listing.c +++ b/gas/listing.c @@ -795,7 +795,7 @@ calc_hex (list_info_type *list) { size_t data_buffer_size; list_info_type *first = list; - unsigned int address = ~(unsigned int) 0; + unsigned int address = ~0u; fragS *frag; fragS *frag_ptr; unsigned int octet_in_frag; @@ -817,7 +817,7 @@ calc_hex (list_info_type *list) while (octet_in_frag < frag_ptr->fr_fix && data_buffer_size < MAX_BYTES - 3) { - if (address == ~(unsigned int) 0) + if (address == ~0u) address = frag_ptr->fr_address / OCTETS_PER_BYTE; sprintf (data_buffer + data_buffer_size, @@ -836,7 +836,7 @@ calc_hex (list_info_type *list) < frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset) && data_buffer_size < MAX_BYTES - 3) { - if (address == ~(unsigned int) 0) + if (address == ~0u) address = frag_ptr->fr_address / OCTETS_PER_BYTE; sprintf (data_buffer + data_buffer_size, @@ -875,7 +875,7 @@ print_lines (list_info_type *list, unsigned int lineno, nchars = (LISTING_WORD_SIZE * 2 + 1) * listing_lhs_width; /* Print the hex for the first line. */ - if (address == ~(unsigned int) 0) + if (address == ~0u) { fprintf (list_file, "% 4d ", lineno); for (idx = 0; idx < nchars; idx++) @@ -1302,7 +1302,7 @@ listing_listing (char *name ATTRIBUTE_UNUSED) p = buffer_line (list->file, buffer, width); if (list->file->linenum < list_line) - address = ~(unsigned int) 0; + address = ~0u; else address = calc_hex (list); @@ -1354,11 +1354,11 @@ print_timestamp (void) } static void -print_single_option (char * opt, int *pos) +print_single_option (char *opt, size_t *pos) { size_t opt_len = strlen (opt); - if ((*pos + opt_len) < paper_width) + if (*pos + opt_len < paper_width) { fprintf (list_file, _("%s "), opt); *pos = *pos + opt_len; @@ -1376,7 +1376,7 @@ static void print_options (char ** argv) { const char *field_name = _("\n options passed\t: "); - int pos = strlen (field_name); + size_t pos = strlen (field_name); char **p; fputs (field_name, list_file); @@ -3174,7 +3174,7 @@ s_rept (int expand_count) { size_t count; - count = (size_t) get_absolute_expression (); + count = get_absolute_expression (); do_repeat (count, "REPT", "ENDR", expand_count ? "" : NULL); } @@ -4636,7 +4636,7 @@ emit_expr_with_reloc (expressionS *exp, /* We can ignore any carry out, because it will be handled by extra_digit if it is needed. */ - extra_digit = (valueT) -1; + extra_digit = -1; op = O_big; } @@ -5453,7 +5453,7 @@ emit_leb128_expr (expressionS *exp, int sign) /* Let check_eh_frame know that data is being emitted. nbytes == -1 is a signal that this is leb128 data. It shouldn't optimize this away. */ - nbytes = (unsigned int) -1; + nbytes = -1u; if (check_eh_frame (exp, &nbytes)) abort (); @@ -6293,7 +6293,7 @@ char /* Return terminator. */ get_absolute_expression_and_terminator (long *val_pointer /* Return value of expression. */) { /* FIXME: val_pointer should probably be offsetT *. */ - *val_pointer = (long) get_absolute_expression (); + *val_pointer = get_absolute_expression (); return (*input_line_pointer++); } @@ -6357,7 +6357,7 @@ demand_copy_string (int *lenP) ignore_rest_of_line (); } *lenP = len; - return (retval); + return retval; } /* In: Input_line_pointer->next character. diff --git a/gas/symbols.c b/gas/symbols.c index 5d6d141..275d056 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -746,7 +746,7 @@ symbol_find_or_make (const char *name) symbol_table_insert (symbolP); } /* if symbol wasn't found */ - return (symbolP); + return symbolP; } symbolS * @@ -760,7 +760,7 @@ symbol_make (const char *name) if (!symbolP) symbolP = symbol_new (name, undefined_section, &zero_address_frag, 0); - return (symbolP); + return symbolP; } symbolS * @@ -2241,7 +2241,7 @@ S_GET_VALUE_WHERE (symbolS *s, const char * file, unsigned int line) S_GET_NAME (s)); } } - return (valueT) s->x->value.X_add_number; + return s->x->value.X_add_number; } valueT diff --git a/gas/testsuite/gas/riscv/align-1.s b/gas/testsuite/gas/riscv/align-1.s index ec28556..ee6a94d 100644 --- a/gas/testsuite/gas/riscv/align-1.s +++ b/gas/testsuite/gas/riscv/align-1.s @@ -1,3 +1,3 @@ - .option arch, -c + .option norvc .align 2 .align 1 diff --git a/gas/testsuite/gas/riscv/attribute-10.d b/gas/testsuite/gas/riscv/attribute-10.d index 04c322a..cb3ae5a 100644 --- a/gas/testsuite/gas/riscv/attribute-10.d +++ b/gas/testsuite/gas/riscv/attribute-10.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0" + Tag_RISCV_arch: "rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zcf1p0" diff --git a/gas/testsuite/gas/riscv/attribute-17.d b/gas/testsuite/gas/riscv/attribute-17.d index 8e87e8e..f431b04 100644 --- a/gas/testsuite/gas/riscv/attribute-17.d +++ b/gas/testsuite/gas/riscv/attribute-17.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicsr2p0_zmmul1p0_za128rs1p0_zaamo1p0_zalrsc1p0" + Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicsr2p0_zmmul1p0_za128rs1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0" diff --git a/gas/testsuite/gas/riscv/attribute-19.d b/gas/testsuite/gas/riscv/attribute-19.d index d73e3f0..b9b5a40 100644 --- a/gas/testsuite/gas/riscv/attribute-19.d +++ b/gas/testsuite/gas/riscv/attribute-19.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_supm1p0" + Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_supm1p0" diff --git a/gas/testsuite/gas/riscv/attribute-20.d b/gas/testsuite/gas/riscv/attribute-20.d index 22bcc13..7fbfda0 100644 --- a/gas/testsuite/gas/riscv/attribute-20.d +++ b/gas/testsuite/gas/riscv/attribute-20.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_supm1p0" + Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_supm1p0" diff --git a/gas/testsuite/gas/riscv/attribute-rva23s.d b/gas/testsuite/gas/riscv/attribute-rva23s.d index 54e79aa..b38b7b9 100644 --- a/gas/testsuite/gas/riscv/attribute-rva23s.d +++ b/gas/testsuite/gas/riscv/attribute-rva23s.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_h1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_sha1p0_shcounterenw1p0_shgatpa1p0_shtvala1p0_shvsatpa1p0_shvstvala1p0_shvstvecd1p0_ssccptr1p0_sscofpmf1p0_sscounterenw1p0_ssnpm1p0_ssstateen1p0_sstc1p0_sstvala1p0_sstvecd1p0_ssu64xl1p0_supm1p0_svade1p0_svbare1p0_svinval1p0_svnapot1p0_svpbmt1p0" + Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_h1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_sha1p0_shcounterenw1p0_shgatpa1p0_shtvala1p0_shvsatpa1p0_shvstvala1p0_shvstvecd1p0_ssccptr1p0_sscofpmf1p0_sscounterenw1p0_ssnpm1p0_ssstateen1p0_sstc1p0_sstvala1p0_sstvecd1p0_ssu64xl1p0_supm1p0_svade1p0_svbare1p0_svinval1p0_svnapot1p0_svpbmt1p0" diff --git a/gas/testsuite/gas/riscv/attribute-rvb23s.d b/gas/testsuite/gas/riscv/attribute-rvb23s.d index 5cee65a..87e243c 100644 --- a/gas/testsuite/gas/riscv/attribute-rvb23s.d +++ b/gas/testsuite/gas/riscv/attribute-rvb23s.d @@ -3,4 +3,4 @@ #source: empty.s Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl32b1p0_ssccptr1p0_sscofpmf1p0_sscounterenw1p0_sstc1p0_sstvala1p0_sstvecd1p0_ssu64xl1p0_supm1p0_svade1p0_svbare1p0_svinval1p0_svnapot1p0_svpbmt1p0" + Tag_RISCV_arch: "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_zicclsm1p0_ziccrse1p0_zicntr2p0_zicond1p0_zicsr2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zvfhmin1p0_zvkb1p0_zvkt1p0_zvl32b1p0_ssccptr1p0_sscofpmf1p0_sscounterenw1p0_sstc1p0_sstvala1p0_sstvecd1p0_ssu64xl1p0_supm1p0_svade1p0_svbare1p0_svinval1p0_svnapot1p0_svpbmt1p0" diff --git a/gas/testsuite/gas/riscv/dis-addr-addiw.s b/gas/testsuite/gas/riscv/dis-addr-addiw.s index 7c878f8..38dc1c9 100644 --- a/gas/testsuite/gas/riscv/dis-addr-addiw.s +++ b/gas/testsuite/gas/riscv/dis-addr-addiw.s @@ -11,7 +11,7 @@ .global _start _start: .option push - .option arch, -c + .option norvc # _start + 0x00 auipc t0, 0 addiw t1, t0, 0x18 diff --git a/gas/testsuite/gas/riscv/dis-addr-overflow.s b/gas/testsuite/gas/riscv/dis-addr-overflow.s index 77ca39c..db48ae3 100644 --- a/gas/testsuite/gas/riscv/dis-addr-overflow.s +++ b/gas/testsuite/gas/riscv/dis-addr-overflow.s @@ -24,7 +24,7 @@ topbase = 0 target: .option push - .option arch, -c + .option norvc ## Use hi_addr # Load lui t0, 0xfffff @@ -50,7 +50,7 @@ target: c.addi t6, -20 .ifdef rv64 .option push - .option arch, -c + .option norvc # ADDIW (not compressed) lui s6, 0xffff8 addiw s7, s6, -24 diff --git a/gas/testsuite/gas/riscv/ext.s b/gas/testsuite/gas/riscv/ext.s index 0268dca..b6ccce0 100644 --- a/gas/testsuite/gas/riscv/ext.s +++ b/gas/testsuite/gas/riscv/ext.s @@ -1,5 +1,5 @@ target: - .option arch, -c + .option norvc zext.b a0, a0 zext.h a0, a0 sext.b a0, a0 diff --git a/gas/testsuite/gas/riscv/imply.d b/gas/testsuite/gas/riscv/imply.d index b68da92..c60711c 100644 --- a/gas/testsuite/gas/riscv/imply.d +++ b/gas/testsuite/gas/riscv/imply.d @@ -45,12 +45,6 @@ SYMBOL TABLE: [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zve32x1p0_zvl128b1p0_zvl256b1p0_zvl32b1p0_zvl64b1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zve32x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_zvl64b1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcb1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_zicsr2p0_zca1p0_zcd1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_zicsr2p0_zca1p0_zcf1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcmp1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcmop1p0 -[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zca1p0_zcmt1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicfilp1p0_zicsr2p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicfiss1p0_zicsr2p0_zimop1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_h1p0_zicsr2p0_sha1p0_shcounterenw1p0_shgatpa1p0_shtvala1p0_shvsatpa1p0_shvstvala1p0_shvstvecd1p0_ssstateen1p0 @@ -63,6 +57,8 @@ SYMBOL TABLE: [0-9a-f]+ l .text 0+000 \$xrv32i2p1_h1p0_zicsr2p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zfinx1p0_zhinx1p0_zhinxmin1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zfinx1p0_zhinxmin1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_zicsr2p0_zca1p0_zcd1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_zicsr2p0_zca1p0_zcf1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_q2p2_zicsr2p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zfinx1p0_zdinx1p0_zqinx1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_zicsr2p0 @@ -73,6 +69,20 @@ SYMBOL TABLE: [0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_zicsr2p0_zfhmin1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zfinx1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_zicsr2p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcf1p0_zcmp1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv64i2p1_f2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcf1p0_zcmp1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv64i2p1_f2p2_d2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcb1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcmp1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zca1p0_zcmop1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_zicsr2p0_zca1p0_zcmt1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_c2p0_zicsr2p0_zca1p0_zcf1p0 +[0-9a-f]+ l .text 0+000 \$xrv64i2p1_f2p2_c2p0_zicsr2p0_zca1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_f2p2_d2p2_c2p0_zicsr2p0_zca1p0_zcd1p0_zcf1p0 +[0-9a-f]+ l .text 0+000 \$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zca1p0_zcd1p0 +[0-9a-f]+ l .text 0+000 \$xrv32i2p1_c2p0_zca1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_b1p0_zba1p0_zbb1p0_zbs1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zbkb1p0_zbkc1p0_zbkx1p0_zk1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0_zkr1p0_zkt1p0 [0-9a-f]+ l .text 0+000 \$xrv32i2p1_zbkb1p0_zbkc1p0_zbkx1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0 diff --git a/gas/testsuite/gas/riscv/imply.s b/gas/testsuite/gas/riscv/imply.s index 35c68d3..74f2892 100644 --- a/gas/testsuite/gas/riscv/imply.s +++ b/gas/testsuite/gas/riscv/imply.s @@ -1,6 +1,6 @@ -.macro imply string base=i +.macro imply string base=i xlen=32 .option push -.option arch, rv32\base\string +.option arch, rv\xlen\base\string nop .option pop .endm @@ -50,13 +50,6 @@ imply zve32x_zvl256b imply zve32x_zvl128b imply zve32x_zvl64b -imply zcb -imply zcd -imply zcf -imply zcmp -imply zcmop -imply zcmt - imply zicfilp imply zicfiss @@ -72,6 +65,9 @@ imply h imply zhinx imply zhinxmin +imply zcd +imply zcf + imply q imply zqinx @@ -85,6 +81,21 @@ imply zfhmin imply zfinx imply f +imply zce,if,32 +imply zce,if,64 +imply zce,id,32 +imply zce,id,64 +imply zce +imply zcb +imply zcmp +imply zcmop +imply zcmt +imply c,if,32 +imply c,if,64 +imply c,id,32 +imply c,id,64 +imply c + imply b imply zk diff --git a/gas/testsuite/gas/riscv/mapping-symbols.d b/gas/testsuite/gas/riscv/mapping-symbols.d index ab1d470..ddc1502 100644 --- a/gas/testsuite/gas/riscv/mapping-symbols.d +++ b/gas/testsuite/gas/riscv/mapping-symbols.d @@ -9,43 +9,43 @@ SYMBOL TABLE: 0+00 l d .data 0+00 .data 0+00 l d .bss 0+00 .bss 0+00 l d .text.cross.section.A 0+00 .text.cross.section.A -0+00 l .text.cross.section.A 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.cross.section.A 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .text.cross.section.B 0+00 .text.cross.section.B -0+00 l .text.cross.section.B 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.cross.section.B 0+00 \$xrv32i2p1_c2p0_zca1p0 0+02 l .text.cross.section.B 0+00 \$xrv32i2p1 0+00 l d .text.data 0+00 .text.data 0+00 l .text.data 0+00 \$d -0+08 l .text.data 0+00 \$xrv32i2p1_c2p0 +0+08 l .text.data 0+00 \$xrv32i2p1_c2p0_zca1p0 0+0c l .text.data 0+00 \$d 0+00 l d .text.odd.align.start.insn 0+00 .text.odd.align.start.insn -0+00 l .text.odd.align.start.insn 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.odd.align.start.insn 0+00 \$xrv32i2p1_c2p0_zca1p0 0+02 l .text.odd.align.start.insn 0+00 \$d 0+00 l d .text.odd.align.start.data 0+00 .text.odd.align.start.data 0+00 l .text.odd.align.start.data 0+00 \$d 0+00 l d .text.zero.fill.first 0+00 .text.zero.fill.first -0+00 l .text.zero.fill.first 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.zero.fill.first 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .text.zero.fill.last 0+00 .text.zero.fill.last -0+00 l .text.zero.fill.last 0+00 \$xrv32i2p1_c2p0 -0+02 l .text.zero.fill.last 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.zero.fill.last 0+00 \$xrv32i2p1_c2p0_zca1p0 +0+02 l .text.zero.fill.last 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .text.zero.fill.align.A 0+00 .text.zero.fill.align.A -0+00 l .text.zero.fill.align.A 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.zero.fill.align.A 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .text.zero.fill.align.B 0+00 .text.zero.fill.align.B 0+00 l .text.zero.fill.align.B 0+00 \$xrv32i2p1 0+00 l d .text.last.section 0+00 .text.last.section 0+00 l .text.last.section 0+00 \$xrv32i2p1 0+04 l .text.last.section 0+00 \$d 0+00 l d .text.section.padding 0+00 .text.section.padding -0+00 l .text.section.padding 0+00 \$xrv32i2p1_c2p0 -0+04 l .text.section.padding 0+00 \$xrv32i2p1_a2p1_c2p0_zaamo1p0_zalrsc1p0 +0+00 l .text.section.padding 0+00 \$xrv32i2p1_c2p0_zca1p0 +0+04 l .text.section.padding 0+00 \$xrv32i2p1_a2p1_c2p0_zaamo1p0_zalrsc1p0_zca1p0 0+06 l .text.section.padding 0+00 \$d 0+00 l d .text.relax.align 0+00 .text.relax.align -0+00 l .text.relax.align 0+00 \$xrv32i2p1_c2p0 +0+00 l .text.relax.align 0+00 \$xrv32i2p1_c2p0_zca1p0 0+08 l .text.relax.align 0+00 \$xrv32i2p1 -0+0a l .text.section.padding 0+00 \$xrv32i2p1_c2p0 +0+0a l .text.section.padding 0+00 \$xrv32i2p1_c2p0_zca1p0 0+03 l .text.odd.align.start.insn 0+00 \$d 0+04 l .text.odd.align.start.insn 0+00 \$xrv32i2p1 0+01 l .text.odd.align.start.data 0+00 \$d -0+02 l .text.odd.align.start.data 0+00 \$xrv32i2p1_c2p0 +0+02 l .text.odd.align.start.data 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .riscv.attributes 0+00 .riscv.attributes 0+00 g .text.cross.section.A 0+00 funcA 0+00 g .text.cross.section.B 0+00 funcB diff --git a/gas/testsuite/gas/riscv/mapping-x.s b/gas/testsuite/gas/riscv/mapping-x.s index f17cf22..2131253 100644 --- a/gas/testsuite/gas/riscv/mapping-x.s +++ b/gas/testsuite/gas/riscv/mapping-x.s @@ -1,5 +1,5 @@ .attribute arch, "rv32ic" -.option arch, -c +.option norvc .insn 4, 0x00000013 $x: .insn 2, 0x0001 diff --git a/gas/testsuite/gas/riscv/mapping.s b/gas/testsuite/gas/riscv/mapping.s index 0382cfc..c8ed24c 100644 --- a/gas/testsuite/gas/riscv/mapping.s +++ b/gas/testsuite/gas/riscv/mapping.s @@ -11,7 +11,7 @@ j funcA # rv32ic .globl funcB funcB: addi a0, zero, 2 # rv32ic, need to be added since start of section -.option arch, -c +.option norvc j funcB # rv32i .option pop @@ -35,7 +35,7 @@ addi a0, zero, 2 # $x, but same as previous addi, so removed .option arch, +c addi a0, zero, 1 # $xrv32ic .byte 1 # $d -.option arch, -c +.option norvc .align 3 # odd alignment, $x replaced by $d + $x addi a0, zero, 2 # $xrv32i .option pop @@ -81,7 +81,7 @@ addi a0, zero, 2 .align 2 # $xrv32ic, .align and .fill are in the different frag, so neither be removed, # but will be removed in riscv_check_mapping_symbols .fill 1, 0, 0 # $d with zero size, removed in make_mapping_symbol when adding $xrv32ic -.option arch, -c +.option norvc addi a0, zero, 1 # $xrv32i addi a0, zero, 2 .option pop @@ -89,7 +89,7 @@ addi a0, zero, 2 .section .text.last.section, "ax" .option push .option norelax -.option arch, -c +.option norvc addi a0, zero, 1 # $xrv32i .word 1 # $d .align 2 # zero section padding, $x at the end of section, removed in riscv_check_mapping_symbols @@ -112,7 +112,7 @@ addi a0, zero, 2 # $xrv32iac .option arch, rv32ic .balign 4 # $xrv32ic, add at the start of section addi a0, zero, 1 # $x, won't added -.option arch, -c +.option norvc .align 3 # $x, won't added addi a0, zero, 2 # $xrv32i .option pop diff --git a/gas/testsuite/gas/riscv/march-imply-zce-f-32.d b/gas/testsuite/gas/riscv/march-imply-zce-f-32.d deleted file mode 100644 index e0cca82..0000000 --- a/gas/testsuite/gas/riscv/march-imply-zce-f-32.d +++ /dev/null @@ -1,6 +0,0 @@ -#as: -march=rv32if_zce -march-attr -misa-spec=20191213 -#readelf: -A -#source: empty.s -Attribute Section: riscv -File Attributes - Tag_RISCV_arch: "rv32i2p1_f2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcf1p0_zcmp1p0_zcmt1p0" diff --git a/gas/testsuite/gas/riscv/march-imply-zce-f-64.d b/gas/testsuite/gas/riscv/march-imply-zce-f-64.d deleted file mode 100644 index f0ccd7a..0000000 --- a/gas/testsuite/gas/riscv/march-imply-zce-f-64.d +++ /dev/null @@ -1,6 +0,0 @@ -#as: -march=rv64if_zce -march-attr -misa-spec=20191213 -#readelf: -A -#source: empty.s -Attribute Section: riscv -File Attributes - Tag_RISCV_arch: "rv64i2p1_f2p2_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0" diff --git a/gas/testsuite/gas/riscv/march-imply-zce.d b/gas/testsuite/gas/riscv/march-imply-zce.d deleted file mode 100644 index fd1cd3f..0000000 --- a/gas/testsuite/gas/riscv/march-imply-zce.d +++ /dev/null @@ -1,6 +0,0 @@ -#as: -march=rv32i_zce -march-attr -misa-spec=20191213 -#readelf: -A -#source: empty.s -Attribute Section: riscv -File Attributes - Tag_RISCV_arch: "rv32i2p1_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0" diff --git a/gas/testsuite/gas/riscv/march-ok-reorder.d b/gas/testsuite/gas/riscv/march-ok-reorder.d index 712c1bd..883d6a2 100644 --- a/gas/testsuite/gas/riscv/march-ok-reorder.d +++ b/gas/testsuite/gas/riscv/march-ok-reorder.d @@ -4,4 +4,4 @@ Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv32i2p0_m1p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zba1p0_xbar2p0_xfoo2p0" + Tag_RISCV_arch: "rv32i2p0_m1p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zcf1p0_zba1p0_xbar2p0_xfoo2p0" diff --git a/gas/testsuite/gas/riscv/option-arch-attr.d b/gas/testsuite/gas/riscv/option-arch-attr.d index 8c1f665..27df69d 100644 --- a/gas/testsuite/gas/riscv/option-arch-attr.d +++ b/gas/testsuite/gas/riscv/option-arch-attr.d @@ -4,4 +4,4 @@ Attribute Section: riscv File Attributes - Tag_RISCV_arch: "rv64i2p0_c2p0" + Tag_RISCV_arch: "rv64i2p0_c2p0_zca1p0" diff --git a/gas/testsuite/gas/riscv/option-arch-dis.d b/gas/testsuite/gas/riscv/option-arch-dis.d index e4b603b..bee01f1 100644 --- a/gas/testsuite/gas/riscv/option-arch-dis.d +++ b/gas/testsuite/gas/riscv/option-arch-dis.d @@ -8,10 +8,10 @@ SYMBOL TABLE: 0+00 l d .text 0+00 .text 0+00 l d .data 0+00 .data 0+00 l d .bss 0+00 .bss -0+00 l .text 0+00 \$xrv64i2p0_c2p0 +0+00 l .text 0+00 \$xrv64i2p0_c2p0_zca1p0 0+02 l .text 0+00 \$xrv64i2p0_f2p0_d2p0_xvendor1p0 -0+0a l .text 0+00 \$xrv64i2p0_m3p0_f2p0_d3p0_c2p0_zmmul1p0_xvendor32x3p0 -0+0c l .text 0+00 \$xrv32i2p1_c2p0 +0+0a l .text 0+00 \$xrv64i2p0_m3p0_f2p0_d3p0_c2p0_zmmul1p0_zca1p0_zcd1p0_xvendor32x3p0 +0+0c l .text 0+00 \$xrv32i2p1_c2p0_zca1p0 0+00 l d .riscv.attributes 0+00 .riscv.attributes diff --git a/gas/testsuite/gas/riscv/option-arch-fail.l b/gas/testsuite/gas/riscv/option-arch-fail.l index d83f01d..191f088 100644 --- a/gas/testsuite/gas/riscv/option-arch-fail.l +++ b/gas/testsuite/gas/riscv/option-arch-fail.l @@ -1,8 +1,9 @@ .*Assembler messages: .*Error: m2p0: ISA string must begin with rv32, rv64 or Profiles -.*Error: cannot \+ or \- base extension `i' in .option arch `\-i' -.*Error: cannot \+ or \- base extension `e' in .option arch `\+e' -.*Error: cannot \+ or \- base extension `g' in .option arch `\-g' +.*Error: deprecated \- extension `i' in .option arch `\-i' +.*Error: cannot \+ base extension `e' in .option arch `\+e' +.*Error: deprecated \- extension `g' in .option arch `\-g' +.*Error: deprecated \- extension `c' in .option arch `\-c' .*Error: unknown ISA extension `zsubset' in .option arch `\+zsubset2p0' .*Error: unknown ISA extension `f2p0_d' in .option arch `\+f2p0_d2p0' .*Error: unknown ISA extension `' in .option arch `\+' diff --git a/gas/testsuite/gas/riscv/option-arch-fail.s b/gas/testsuite/gas/riscv/option-arch-fail.s index 101587a..2ba7a16 100644 --- a/gas/testsuite/gas/riscv/option-arch-fail.s +++ b/gas/testsuite/gas/riscv/option-arch-fail.s @@ -4,6 +4,7 @@ .option arch, -i .option arch, +e .option arch, -g +.option arch, -c .option arch, +zsubset2p0 .option arch, +f2p0_d2p0 .option arch, + diff --git a/gas/testsuite/gas/riscv/option-arch.s b/gas/testsuite/gas/riscv/option-arch.s index a37659f..8836bc1 100644 --- a/gas/testsuite/gas/riscv/option-arch.s +++ b/gas/testsuite/gas/riscv/option-arch.s @@ -1,7 +1,8 @@ .attribute arch, "rv64ic" # file-level, rv64ic add a0, a0, a1 .option push -.option arch, +d2p0, -c, +xvendor1p0 +.option arch, +d2p0, +xvendor1p0 +.option norvc add a0, a0, a1 # func-level, rv64i_d2p0_xvendor1p0 frcsr a0 .option pop diff --git a/gas/testsuite/gas/riscv/option-norvc.d b/gas/testsuite/gas/riscv/option-norvc.d index 6f36ed6..5a4b976 100644 --- a/gas/testsuite/gas/riscv/option-norvc.d +++ b/gas/testsuite/gas/riscv/option-norvc.d @@ -8,11 +8,11 @@ SYMBOL TABLE: 0+00 l d .text 0+00 .text 0+00 l d .data 0+00 .data 0+00 l d .bss 0+00 .bss -0+00 l .text 0+00 \$xrv64i2p0_c2p0 +0+00 l .text 0+00 \$xrv64i2p0_c2p0_zca1p0 0+02 l .text 0+00 \$xrv64i2p0 -0+06 l .text 0+00 \$xrv32i2p0_f2p0_c2p0 +0+06 l .text 0+00 \$xrv32i2p0_f2p0_c2p0_zca1p0_zcf1p0 0+08 l .text 0+00 \$xrv32i2p0_f2p0 -0+0c l .text 0+00 \$xrv64i2p0_f2p0_d2p0_c2p0 +0+0c l .text 0+00 \$xrv64i2p0_f2p0_d2p0_c2p0_zca1p0_zcd1p0 0+0e l .text 0+00 \$xrv64i2p0_f2p0_d2p0 0+12 l .text 0+00 \$xrv64i2p0_f2p0_d2p0_zca1p0 0+14 l .text 0+00 \$xrv64i2p0_f2p0_d2p0 diff --git a/gas/testsuite/gas/riscv/shamt-32.s b/gas/testsuite/gas/riscv/shamt-32.s index a673f88..9fa18fb 100644 --- a/gas/testsuite/gas/riscv/shamt-32.s +++ b/gas/testsuite/gas/riscv/shamt-32.s @@ -1,4 +1,4 @@ - .option arch, -c + .option norvc slli a0, a0, 0 slli a0, a0, 31 slli a0, a0, 32 diff --git a/gas/testsuite/gas/riscv/shamt-64.s b/gas/testsuite/gas/riscv/shamt-64.s index 8878318..5ca5e6d 100644 --- a/gas/testsuite/gas/riscv/shamt-64.s +++ b/gas/testsuite/gas/riscv/shamt-64.s @@ -1,4 +1,4 @@ - .option arch, -c + .option norvc slli a0, a0, 0 slli a0, a0, 31 slli a0, a0, 32 diff --git a/gas/write.c b/gas/write.c index ca6fedf..455dc44 100644 --- a/gas/write.c +++ b/gas/write.c @@ -587,8 +587,8 @@ size_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx ATTRIBUTE_UNUSED) size = 0; flags = bfd_section_flags (sec); - if (size == 0 && bfd_section_size (sec) != 0 && - (flags & SEC_HAS_CONTENTS) != 0) + if (size == 0 && bfd_section_size (sec) != 0 + && (flags & SEC_HAS_CONTENTS) != 0) return; if (size > 0 && ! seginfo->bss) diff --git a/include/doubly-linked-list.h b/include/doubly-linked-list.h new file mode 100644 index 0000000..3f5ea28 --- /dev/null +++ b/include/doubly-linked-list.h @@ -0,0 +1,447 @@ +/* Manipulate doubly linked lists. + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + +#ifndef _DOUBLY_LINKED_LIST_H +#define _DOUBLY_LINKED_LIST_H + +/* Doubly linked list implementation enforcing typing. + + This implementation of doubly linked list tries to achieve the enforcement of + typing similarly to C++ templates, but without encapsulation. + + All the functions are prefixed with the type of the value: "AType_xxx". + Some functions are prefixed with "_AType_xxx" and are not part of the public + API, so should not be used, except for _##LTYPE##_merge_sort with a caveat + (see note above its definition). + + Each function (### is a placeholder for method name) has a macro for: + (1) its invocation LINKED_LIST_###(LTYPE). + (2) its prototype LINKED_LIST_DECL_###(A, A2, scope). To add in a header + file, or a source file for forward declaration. 'scope' should be set + respectively to 'extern', or 'static'. + (3) its definition LINKED_LIST_DEFN_###(A, A2, scope). To add in a source + file with the 'scope' set respectively to nothing, or 'static' depending + on (2). + + Data structures requirements: + - LTYPE corresponds to the node of a doubly linked list. It needs to define + attributes 'prev' and 'next' which are pointers on the type of a node. + For instance: + struct my_list_node + { + T value; + struct my_list_node *prev; + struct my_list_node *next; + }; + - LWRAPPERTYPE is a structure wrapping the nodes and others metadata (first, + last, size). + */ + + +/* Mutative operations: + - append + - prepend + - insert_before + - pop_front + - pop_back + - remove + - swap + The header and body of each of those operation can be declared individually, + or as a whole via LINKED_LIST_MUTATIVE_OPS_PROTOTYPE for the prototypes, and + LINKED_LIST_MUTATIVE_OPS_DECL for the implementations. */ + +/* Append the given node new_ to the exising list. + Precondition: prev and next of new_ must be NULL. */ +#define LINKED_LIST_APPEND(LTYPE) LTYPE##_append + +#define LINKED_LIST_DECL_APPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT void \ + LTYPE##_append (LWRAPPERTYPE *wrapper, LTYPE *new_) + +#define LINKED_LIST_DEFN_APPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT void \ +LTYPE##_append (LWRAPPERTYPE *wrapper, LTYPE *new_) \ +{ \ + if (wrapper->last == NULL) \ + wrapper->first = new_; \ + else \ + { \ + new_->prev = wrapper->last; \ + wrapper->last->next = new_; \ + } \ + wrapper->last = new_; \ + ++wrapper->size; \ +} + +/* Prepend the given node new_ to the existing list. + Precondition: prev and next of new_ must be NULL. */ +#define LINKED_LIST_PREPEND(LTYPE) LTYPE##_prepend + +#define LINKED_LIST_DECL_PREPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT void \ + LTYPE##_prepend (LWRAPPERTYPE *wrapper, LTYPE *new_) + +#define LINKED_LIST_DEFN_PREPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT void \ +LTYPE##_prepend (LWRAPPERTYPE *wrapper, LTYPE *new_) \ +{ \ + if (wrapper->first == NULL) \ + wrapper->last = new_; \ + else \ + { \ + new_->next = wrapper->first; \ + wrapper->first->prev = new_; \ + } \ + wrapper->first = new_; \ + ++wrapper->size; \ +} + +/* Insert the given node new_ before 'where' in the existing list. + If where == NULL, the insertion is equivalent to an append. + If where == first, the insertion is equivalent to a prepend. */ +#define LINKED_LIST_INSERT_BEFORE(LTYPE) LTYPE##_insert_before + +#define LINKED_LIST_DECL_INSERT_BEFORE(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT void \ + LTYPE##_insert_before (LWRAPPERTYPE *wrapper, \ + LTYPE *new_, \ + LTYPE *where) + +#define LINKED_LIST_DEFN_INSERT_BEFORE(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT void \ +LTYPE##_insert_before (LWRAPPERTYPE *wrapper, \ + LTYPE *new_, \ + LTYPE *where) \ +{ \ + if (where == wrapper->first) \ + LTYPE##_prepend (wrapper, new_); \ + else if (where == NULL) \ + LTYPE##_append (wrapper, new_); \ + else \ + { \ + where->prev->next = new_; \ + new_->prev = where->prev; \ + where->prev = new_; \ + new_->next = where; \ + ++wrapper->size; \ + } \ +} + +/* Pop the first node of the list. */ +#define LINKED_LIST_POP_FRONT(LTYPE) LTYPE##_pop_front + +#define LINKED_LIST_DECL_POP_FRONT(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT LTYPE * \ + LTYPE##_pop_front (LWRAPPERTYPE *wrapper) + +#define LINKED_LIST_DEFN_POP_FRONT(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT LTYPE * \ +LTYPE##_pop_front (LWRAPPERTYPE *wrapper) \ +{ \ + LTYPE *front_node = wrapper->first; \ + if (front_node != NULL) \ + { \ + wrapper->first = front_node->next; \ + if (wrapper->last == front_node) \ + wrapper->last = NULL; \ + else \ + { \ + front_node->next->prev = NULL; \ + front_node->next = NULL; \ + } \ + front_node->next = NULL; \ + --wrapper->size; \ + } \ + return front_node; \ +} + +/* Pop the last node of the list. */ +#define LINKED_LIST_POP_BACK(LTYPE) LTYPE##_pop_back + +#define LINKED_LIST_DECL_POP_BACK(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT LTYPE * \ + LTYPE##_pop_back (LWRAPPERTYPE *wrapper) + +#define LINKED_LIST_DEFN_POP_BACK(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT LTYPE * \ +LTYPE##_pop_back (LWRAPPERTYPE *wrapper) \ +{ \ + LTYPE *back_node = wrapper->last; \ + if (back_node != NULL) \ + { \ + wrapper->last = back_node->prev; \ + if (wrapper->first == back_node) \ + wrapper->first = NULL; \ + else \ + { \ + back_node->prev->next = NULL; \ + back_node->prev = NULL; \ + } \ + back_node->prev = NULL; \ + --wrapper->size; \ + } \ + return back_node; \ +} + +/* Remove the given node from the existing list, and return the previous + node. */ +#define LINKED_LIST_REMOVE(LTYPE) LTYPE##_remove + +#define LINKED_LIST_DECL_REMOVE(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT LTYPE * \ + LTYPE##_remove (LWRAPPERTYPE *wrapper, LTYPE *node) + +#define LINKED_LIST_DEFN_REMOVE(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT LTYPE * \ +LTYPE##_remove (LWRAPPERTYPE *wrapper, LTYPE *node) \ +{ \ + LTYPE *previous = NULL; \ + \ + if (node->prev != NULL) \ + { \ + node->prev->next = node->next; \ + if (node->next == NULL) \ + wrapper->last = node->prev; \ + else \ + node->next->prev = node->prev; \ + previous = node->prev; \ + node->next = NULL; \ + node->prev = NULL; \ + --wrapper->size; \ + } \ + else \ + LTYPE##_pop_front (wrapper); \ + \ + return previous; \ +} + +/* Generic swap. */ +#define LINKED_LIST_SWAP(LTYPE) LTYPE##_swap + +#define LINKED_LIST_DECL_SWAP(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT void \ + LTYPE##_swap (LWRAPPERTYPE *wrapper, LTYPE *node1, LTYPE *node2) + +/* Swap two nodes in a list. */ +#define LINKED_LIST_DEFN_SWAP(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT void \ +LTYPE##_swap (LWRAPPERTYPE *wrapper, LTYPE *node1, LTYPE *node2) \ +{ \ + LTYPE *prev1 = node1->prev; \ + LTYPE *next1 = node1->next; \ + LTYPE *prev2 = node2->prev; \ + LTYPE *next2 = node2->next; \ + \ + if (prev1 != NULL) \ + prev1->next = node2; \ + else \ + wrapper->first = node2; \ + if (prev2 != NULL) \ + prev2->next = node1; \ + else \ + wrapper->first = node1; \ + \ + if (next1 != NULL) \ + next1->prev = node2; \ + else \ + wrapper->last = node2; \ + if (next2 != NULL) \ + next2->prev = node1; \ + else \ + wrapper->last = node1; \ + \ + { \ + LTYPE *temp = node1->next; \ + node1->next = node2->next; \ + node2->next = temp; \ + } \ + { \ + LTYPE *temp = node1->prev; \ + node1->prev = node2->prev; \ + node2->prev = temp; \ + } \ +} + +/* Note: all the mutative operations below also update the data in the wrapper, + i.e. first, last and size. */ +#define LINKED_LIST_MUTATIVE_OPS_PROTOTYPE(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DECL_APPEND(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_PREPEND(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_INSERT_BEFORE(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_POP_FRONT(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_POP_BACK(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_REMOVE(LWRAPPERTYPE, LTYPE, EXPORT); \ + LINKED_LIST_DECL_SWAP(LWRAPPERTYPE, LTYPE, EXPORT) + +#define LINKED_LIST_MUTATIVE_OPS_DECL(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_APPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_PREPEND(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_INSERT_BEFORE(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_POP_FRONT(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_POP_BACK(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_REMOVE(LWRAPPERTYPE, LTYPE, EXPORT) \ + LINKED_LIST_DEFN_SWAP(LWRAPPERTYPE, LTYPE, EXPORT) + + +/* Sorting. */ + +#define LINKED_LIST_MERGE_SORT_(LTYPE) LTYPE##_merge_sort_ + +#define LINKED_LIST_MERGE_SORT(LTYPE) LTYPE##_merge_sort + +#define LINKED_LIST_MERGE_SORT_PROTOTYPE_(LTYPE, EXPORT) \ + EXPORT LTYPE * \ + LTYPE##_merge_sort_ (LTYPE *node, \ + int (*fn_cmp) (const LTYPE *, const LTYPE *)) + +#define LINKED_LIST_MERGE_SORT_PROTOTYPE(LWRAPPERTYPE, LTYPE, EXPORT) \ + EXPORT void \ + LTYPE##_merge_sort (LWRAPPERTYPE *wrapper, \ + int (*fn_cmp) (const LTYPE *, const LTYPE *)) + +/* Note: all the functions and macros below starting with "_" should be + considered private. */ + +/* Compute the middle element of the list based on the turtle and hare + approach, i.e. the hare runs twice faster than the turtle. */ +#define _MERGE_SORT_IMPL_COMPUTE_TURTLE(LTYPE) \ +static inline LTYPE * \ +LTYPE##_merge_sort_compute_turtle_ (LTYPE *node) \ +{ \ + if (node == NULL) \ + return node; \ + \ + LTYPE *turtle = node, *hare = node->next; \ + while (hare != NULL && hare->next != NULL) \ + { \ + turtle = turtle->next; \ + hare = hare->next->next; \ + } \ + return turtle; \ +} + +/* Append n at the end of l_out, and return the next node after n. + l_out and l_last should be ideally encapsulated into a list structure + but this is overkill for what we need here. */ +#define _MERGE_SORT_IMPL_OUT_APPEND(LTYPE) \ +static inline LTYPE * \ +LTYPE##_merge_sort_out_append_ (LTYPE **l_out, LTYPE **l_last, \ + LTYPE *n) \ +{ \ + if (*l_last == NULL) \ + { \ + *l_last = n; \ + *l_out = n; \ + n->prev = NULL; \ + } \ + else \ + { \ + (*l_last)->next = n; \ + n->prev = *l_last; \ + *l_last = n; \ + } \ + \ + return n->next; \ +} + +/* Merge two sorted lists together. + The returned value corresponds to the first element of the list. + Note: both input lists are invalidated after the call. */ +#define _MERGE_SORT_IMPL_MERGE(LTYPE) \ +static inline LTYPE * \ +LTYPE##_merge_sort_merge_ (LTYPE *l_left, LTYPE *l_right, \ + int (*fn_cmp) (const LTYPE *, const LTYPE *))\ +{ \ + if (l_left == NULL) \ + return l_right; \ + else if (l_right == NULL) \ + return l_left; \ + \ + LTYPE *l_out = NULL, *l_last = NULL; \ + \ + LTYPE *l_l = l_left, *l_r = l_right; \ + while (l_l != NULL && l_r != NULL) \ + { \ + int cmp = fn_cmp (l_l, l_r); \ + if (cmp <= 0) \ + l_l = LTYPE##_merge_sort_out_append_ (&l_out, &l_last, l_l); \ + else \ + l_r = LTYPE##_merge_sort_out_append_ (&l_out, &l_last, l_r); \ + } \ + \ + LTYPE *l_remaining = (l_l != NULL) ? l_l : l_r; \ + while (l_remaining != NULL) \ + l_remaining = \ + LTYPE##_merge_sort_out_append_ (&l_out, &l_last, l_remaining); \ + \ + return l_out; \ +} + +/* Merge sort implementation taking the first node of the list to sort, + and the comparison function. Returns the first node of the sorted list. + Note: use this if you don't care about updating the information in the + wrapper. */ +#define _MERGE_SORT_DEFN_SORT(LTYPE, EXPORT) \ +EXPORT LTYPE * \ +LTYPE##_merge_sort_ (LTYPE *node, \ + int (*fn_cmp)(const LTYPE *, const LTYPE *)) \ +{ \ + if (node == NULL) \ + return NULL; \ + else if (node->next == NULL) \ + return node; \ + \ + LTYPE *left_end = LTYPE##_merge_sort_compute_turtle_ (node); \ + LTYPE *left_begin = node; \ + LTYPE *right_begin = left_end->next; \ + /* break the list. */ \ + left_end->next = NULL; \ + right_begin->prev = NULL; \ + \ + left_begin = LTYPE##_merge_sort_ (left_begin, fn_cmp); \ + right_begin = LTYPE##_merge_sort_ (right_begin, fn_cmp); \ + return LTYPE##_merge_sort_merge_ (left_begin, right_begin, fn_cmp); \ +} + +/* Merge sort wrapper that the end-user should be using as it updates the + first and last metadata of the list in wrapper as well. + If the user does not want to pay the cost of the update of the data, + it can directly use _##LTYPE##_merge_sort_merge. */ +#define _MERGE_SORT_DEFN_WRAPPER_SORT(LWRAPPERTYPE, LTYPE, EXPORT) \ +EXPORT void \ +LTYPE##_merge_sort (LWRAPPERTYPE *wrapper, \ + int (*fn_cmp) (const LTYPE *, const LTYPE *)) \ +{ \ + wrapper->first = LTYPE##_merge_sort_ (wrapper->first, fn_cmp); \ + \ + if (wrapper->first == NULL || wrapper->first->next == NULL) \ + wrapper->last = wrapper->first; \ + else \ + for (LTYPE *node = wrapper->first; \ + node != NULL; \ + node = node->next) \ + wrapper->last = node; \ +} + +#define LINKED_LIST_MERGE_SORT_DECL(LWRAPPERTYPE, LTYPE, EXPORT) \ + _MERGE_SORT_IMPL_COMPUTE_TURTLE(LTYPE) \ + _MERGE_SORT_IMPL_OUT_APPEND(LTYPE) \ + _MERGE_SORT_IMPL_MERGE(LTYPE) \ + _MERGE_SORT_DEFN_SORT(LTYPE, EXPORT) \ + _MERGE_SORT_DEFN_WRAPPER_SORT(LWRAPPERTYPE, LTYPE, EXPORT) + +#endif /* _DOUBLY_LINKED_LIST_H */ diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h index 2b146af..858fcce 100644 --- a/include/opcode/riscv.h +++ b/include/opcode/riscv.h @@ -493,18 +493,18 @@ enum riscv_insn_class INSN_CLASS_NONE, INSN_CLASS_I, - INSN_CLASS_C, + INSN_CLASS_ZCA, INSN_CLASS_M, INSN_CLASS_F, INSN_CLASS_D, INSN_CLASS_Q, - INSN_CLASS_F_AND_C, - INSN_CLASS_D_AND_C, + INSN_CLASS_ZCF, + INSN_CLASS_ZCD, INSN_CLASS_ZICOND, INSN_CLASS_ZICSR, INSN_CLASS_ZIFENCEI, INSN_CLASS_ZIHINTNTL, - INSN_CLASS_ZIHINTNTL_AND_C, + INSN_CLASS_ZIHINTNTL_AND_ZCA, INSN_CLASS_ZIHINTPAUSE, INSN_CLASS_ZIMOP, INSN_CLASS_ZMMUL, diff --git a/include/sframe-api.h b/include/sframe-api.h index 753a91f..3dc18b6 100644 --- a/include/sframe-api.h +++ b/include/sframe-api.h @@ -36,11 +36,6 @@ typedef struct sframe_encoder_ctx sframe_encoder_ctx; #define MAX_OFFSET_BYTES \ ((SFRAME_FRE_OFFSET_4B * 2 * MAX_NUM_STACK_OFFSETS)) -/* Set of flags that are required to be harmonious between all decoder and - encoder objects participating in a link. */ -#define SFRAME_F_LD_MUSTHAVE_FLAGS \ - (SFRAME_F_FDE_FUNC_START_PCREL) - /* User interfacing SFrame Row Entry. An abstraction provided by libsframe so the consumer is decoupled from the binary format representation of the same. diff --git a/include/sframe-internal.h b/include/sframe-internal.h new file mode 100644 index 0000000..a246f26 --- /dev/null +++ b/include/sframe-internal.h @@ -0,0 +1,30 @@ +/* Internal header for SFrame. + + Used by GNU as and ld. + + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _SFRAME_INTERNAL_H +#define _SFRAME_INTERNAL_H + +#include "sframe.h" + +/* Set of flags which are required to be harmonious between GNU as and ld. All + objects participating in the link for GNU ld must have these flags set. */ +#define SFRAME_V2_GNU_AS_LD_ENCODING_FLAGS \ + (SFRAME_F_FDE_FUNC_START_PCREL) + +#endif /* _SFRAME_INTERNAL_H */ diff --git a/ld/ldlang.c b/ld/ldlang.c index 32e6e7a..cd1825b 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2874,7 +2874,7 @@ lang_add_section (lang_statement_list_type *ptr, /* This must happen after flags have been updated. The output section may have been created before we saw its first input section, eg. for a data statement. */ - bfd_init_private_section_data (section->owner, section, + bfd_copy_private_section_data (section->owner, section, link_info.output_bfd, output->bfd_section, &link_info); @@ -10494,7 +10494,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *p) /* Allow the BFD backend to copy any private data it understands from the input section to the output section. */ - if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection, NULL)) { err = _("failed to copy private data"); goto loser; diff --git a/ld/ldwrite.c b/ld/ldwrite.c index 7613def..974245f 100644 --- a/ld/ldwrite.c +++ b/ld/ldwrite.c @@ -366,7 +366,7 @@ clone_section (bfd *abfd, asection *s, const char *name, int *count) n->reloc_count = 0; n->alignment_power = s->alignment_power; - bfd_copy_private_section_data (abfd, s, abfd, n); + bfd_copy_private_section_data (abfd, s, abfd, n, NULL); return n; } diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 387975d..d507f27 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -237,6 +237,7 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \ INSTALLED_HEADERS = \ $(INCDIR)/ansidecl.h \ $(INCDIR)/demangle.h \ + $(INCDIR)/doubly-linked-list.h \ $(INCDIR)/dyn-string.h \ $(INCDIR)/fibheap.h \ $(INCDIR)/floatformat.h \ diff --git a/libiberty/testsuite/Makefile.in b/libiberty/testsuite/Makefile.in index 2b0883c..ef549ca 100644 --- a/libiberty/testsuite/Makefile.in +++ b/libiberty/testsuite/Makefile.in @@ -45,7 +45,8 @@ all: check: @CHECK@ really-check: check-cplus-dem check-d-demangle check-rust-demangle \ - check-pexecute check-expandargv check-strtol + check-pexecute check-expandargv check-strtol \ + check-doubly-linked-list # Run some tests of the demangler. check-cplus-dem: test-demangle $(srcdir)/demangle-expected @@ -69,6 +70,10 @@ check-expandargv: test-expandargv check-strtol: test-strtol ./test-strtol +# Check the linked list functionality +check-doubly-linked-list: test-doubly-linked-list + ./test-doubly-linked-list + # Run the demangler fuzzer fuzz-demangler: demangler-fuzzer ./demangler-fuzzer @@ -90,6 +95,10 @@ test-strtol: $(srcdir)/test-strtol.c ../libiberty.a $(TEST_COMPILE) -DHAVE_CONFIG_H -I.. -o test-strtol \ $(srcdir)/test-strtol.c ../libiberty.a +test-doubly-linked-list: $(srcdir)/test-doubly-linked-list.c + $(TEST_COMPILE) -DHAVE_CONFIG_H -I.. -o test-doubly-linked-list \ + $(srcdir)/test-doubly-linked-list.c + demangler-fuzzer: $(srcdir)/demangler-fuzzer.c ../libiberty.a $(TEST_COMPILE) -o demangler-fuzzer \ $(srcdir)/demangler-fuzzer.c ../libiberty.a @@ -104,6 +113,7 @@ mostlyclean: rm -f test-pexecute rm -f test-expandargv rm -f test-strtol + rm -f test-doubly-linked-list rm -f demangler-fuzzer rm -f core clean: mostlyclean diff --git a/libiberty/testsuite/test-doubly-linked-list.c b/libiberty/testsuite/test-doubly-linked-list.c new file mode 100644 index 0000000..1e1fc63 --- /dev/null +++ b/libiberty/testsuite/test-doubly-linked-list.c @@ -0,0 +1,269 @@ +#include <stdbool.h> +#include <stdlib.h> +#include <stdio.h> + +#include "doubly-linked-list.h" + +#ifndef EXIT_SUCCESS +#define EXIT_SUCCESS 0 +#endif + +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif + +/* Implementation */ + +typedef int T; + +typedef struct ListNodeType +{ + T value; + struct ListNodeType *next; + struct ListNodeType *prev; +} ListNodeType; + +ListNodeType * l_new_node (T value) +{ + ListNodeType *n = malloc (sizeof (ListNodeType)); + n->next = NULL; + n->prev = NULL; + n->value = value; + return n; +} + +typedef struct LinkedListWrapperType +{ + ListNodeType *first; + ListNodeType *last; + size_t size; +} LinkedListWrapperType; + +int compare_nodes (const ListNodeType *n1, const ListNodeType *n2) +{ + if (n1->value == n2->value) + return 0; + else if (n1->value < n2->value) + return -1; + else + return 1; +} + +LINKED_LIST_MUTATIVE_OPS_PROTOTYPE (LinkedListWrapperType, ListNodeType, static); +LINKED_LIST_MERGE_SORT_PROTOTYPE (LinkedListWrapperType, ListNodeType, static); + +LINKED_LIST_MUTATIVE_OPS_DECL (LinkedListWrapperType, ListNodeType, static) +LINKED_LIST_MERGE_SORT_DECL (LinkedListWrapperType, ListNodeType, static) + +ListNodeType * find_last_node (ListNodeType *head) +{ + if (head == NULL) + return NULL; + + ListNodeType *n = head; + while (n->next != NULL) + n = n->next; + + return n; +} + +void l_print (ListNodeType *node) +{ + for (ListNodeType *l = node; l != NULL; l = l->next) + printf ("%d ", l->value); + printf ("\n"); +} + +void l_reverse_print (ListNodeType *last_node) +{ + for (ListNodeType *l = last_node; l != NULL; l = l->prev) + printf ("%d ", l->value); + printf ("\n"); +} + +struct test_data_t +{ + T const *content; + size_t size; +}; + +bool run_test (const struct test_data_t *expect, + LinkedListWrapperType *current, + bool reversed) +{ + ListNodeType *node = (reversed) ? current->last : current->first; + bool passed = true; + for (int i=0; i<expect->size && node != NULL; ++i) + { + if (reversed) + { + if (expect->content[expect->size - 1 - i] != node->value) + { + printf ("FAIL: mismatching expected (%d) VS current (%d).\n", + expect->content[expect->size - 1 - i], node->value); + passed = false; + } + if (node->prev == NULL && current->first != node) + { + printf ("FAIL: first is not matching the first node.\n"); + passed = false; + } + } + else + { + if (expect->content[i] != node->value) + { + printf ("FAIL: mismatching expected (%d) VS current (%d).\n", + expect->content[i], node->value); + passed = false; + } + if (node->next == NULL && current->last != node) + { + printf ("FAIL: last_ is not matching the last node.\n"); + passed = false; + } + } + + if (!passed) + return false; + + if (reversed) + node = node->prev; + else + node = node->next; + } + + if (node != NULL) + { + printf ("FAIL: the list is longer than expected.\n"); + passed = false; + } + if (expect->size != current->size) + { + printf ("FAIL: size (%ld) is not matching the real size of the list (%ld).\n", + current->size, expect->size); + passed = false; + } + + return passed; +} + +bool check(const char *op, + const struct test_data_t *expect, + LinkedListWrapperType *wrapper) +{ + bool success = true; + bool res; + + l_print (wrapper->first); + res = run_test (expect, wrapper, false); + printf ("%s: test-linked-list::%s: check forward conformity\n", + res ? "PASS": "FAIL", op); + success &= res; + + l_reverse_print (wrapper->last); + res = run_test (expect, wrapper, true); + printf ("%s: test-linked-list::%s: check backward conformity\n", + res ? "PASS": "FAIL", op); + success &= res; + + printf("\n"); + + return success; +} + +const int EXPECT_0 [] = { 10, 4, 3, 1, 9, 2 }; +const int EXPECT_1 [] = { 1, 2, 3, 4, 9, 10 }; +const int EXPECT_2 [] = { 11, 1, 2, 3, 4, 9, 10 }; +const int EXPECT_3 [] = { 11, 1, 2, 3, 4, 9, 8, 10 }; +const int EXPECT_4 [] = { 11, 2, 3, 4, 9, 8, 10 }; +const int EXPECT_5 [] = { 10, 2, 3, 4, 9, 8, 11 }; +const int EXPECT_6 [] = { 10, 3, 2, 4, 9, 8, 11 }; +const int EXPECT_7 [] = { 10, 9, 2, 4, 3, 8, 11 }; +const int EXPECT_8 [] = { 2, 3, 4, 8, 9, 10, 11 }; +const int EXPECT_9 [] = { 3, 4, 8, 9, 10, 11 }; +const int EXPECT_10 [] = { 3, 4, 8, 9, 10 }; +const struct test_data_t test_data[] = { + { .content = EXPECT_0, .size = sizeof(EXPECT_0) / sizeof(EXPECT_0[0]) }, + { .content = EXPECT_1, .size = sizeof(EXPECT_1) / sizeof(EXPECT_1[0]) }, + { .content = EXPECT_2, .size = sizeof(EXPECT_2) / sizeof(EXPECT_2[0]) }, + { .content = EXPECT_3, .size = sizeof(EXPECT_3) / sizeof(EXPECT_3[0]) }, + { .content = EXPECT_4, .size = sizeof(EXPECT_4) / sizeof(EXPECT_4[0]) }, + { .content = EXPECT_5, .size = sizeof(EXPECT_5) / sizeof(EXPECT_5[0]) }, + { .content = EXPECT_6, .size = sizeof(EXPECT_6) / sizeof(EXPECT_6[0]) }, + { .content = EXPECT_7, .size = sizeof(EXPECT_7) / sizeof(EXPECT_7[0]) }, + { .content = EXPECT_8, .size = sizeof(EXPECT_8) / sizeof(EXPECT_8[0]) }, + { .content = EXPECT_9, .size = sizeof(EXPECT_9) / sizeof(EXPECT_9[0]) }, + { .content = EXPECT_10, .size = sizeof(EXPECT_10) / sizeof(EXPECT_10[0]) }, +}; + +int main (void) +{ + int failures = 0; + + LinkedListWrapperType wrapper = { + .first = NULL, + .last = NULL, + .size = 0, + }; + + /* Append nodes. */ + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (10)); + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (4)); + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (3)); + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (1)); + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (9)); + LINKED_LIST_APPEND(ListNodeType) (&wrapper, l_new_node (2)); + + failures += ! check ("append", &test_data[0], &wrapper); + + /* Sort nodes (without updating wrapper). */ + wrapper.first = + LINKED_LIST_MERGE_SORT_(ListNodeType) (wrapper.first, compare_nodes); + wrapper.last = find_last_node (wrapper.first); + + failures += ! check ("sort", &test_data[1], &wrapper); + + /* Save a reference to this node for later. */ + ListNodeType *n_to_remove = wrapper.first; + + /* Prepend node. */ + LINKED_LIST_PREPEND(ListNodeType) (&wrapper, l_new_node (11)); + failures += ! check ("prepend", &test_data[2], &wrapper); + + /* Insert node. */ + LINKED_LIST_INSERT_BEFORE(ListNodeType) (&wrapper, l_new_node (8), wrapper.last); + failures += ! check ("insert_before", &test_data[3], &wrapper); + + /* Remove a node. */ + LINKED_LIST_REMOVE(ListNodeType) (&wrapper, n_to_remove); + failures += ! check ("remove", &test_data[4], &wrapper); + + /* Swap first and last. */ + LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first, wrapper.last); + failures += ! check ("swap first and last", &test_data[5], &wrapper); + + /* Swap adjacent nodes. */ + LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first->next, + wrapper.first->next->next); + failures += ! check ("swap adjacent nodes", &test_data[6], &wrapper); + + /* Swap non-adjacent nodes, but neither first nor last. */ + LINKED_LIST_SWAP(ListNodeType) (&wrapper, wrapper.first->next, + wrapper.first->next->next->next->next); + failures += ! check ("swap non-adjacent nodes", &test_data[7], &wrapper); + + /* Sort nodes. */ + LINKED_LIST_MERGE_SORT(ListNodeType) (&wrapper, compare_nodes); + failures += ! check ("sort", &test_data[8], &wrapper); + + /* Pop front. */ + LINKED_LIST_POP_FRONT(ListNodeType) (&wrapper); + failures += ! check ("pop_front", &test_data[9], &wrapper); + + /* Pop back. */ + LINKED_LIST_POP_BACK(ListNodeType) (&wrapper); + failures += ! check ("pop_back", &test_data[10], &wrapper); + + exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); +} diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c index f17d284..56ef62a 100644 --- a/opcodes/riscv-opc.c +++ b/opcodes/riscv-opc.c @@ -464,34 +464,34 @@ const struct riscv_opcode riscv_opcodes[] = {"prefetch.i", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_I, MASK_PREFETCH_I, match_opcode, 0 }, {"prefetch.r", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_R, MASK_PREFETCH_R, match_opcode, 0 }, {"prefetch.w", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_W, MASK_PREFETCH_W, match_opcode, 0 }, -{"ntl.p1", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_P1, MASK_C_NTL_P1, match_opcode, INSN_ALIAS }, +{"ntl.p1", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_P1, MASK_C_NTL_P1, match_opcode, INSN_ALIAS }, {"ntl.p1", 0, INSN_CLASS_ZIHINTNTL, "", MATCH_NTL_P1, MASK_NTL_P1, match_opcode, 0 }, -{"ntl.pall", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_PALL, MASK_C_NTL_PALL, match_opcode, INSN_ALIAS }, +{"ntl.pall", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_PALL, MASK_C_NTL_PALL, match_opcode, INSN_ALIAS }, {"ntl.pall", 0, INSN_CLASS_ZIHINTNTL, "", MATCH_NTL_PALL, MASK_NTL_PALL, match_opcode, 0 }, -{"ntl.s1", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_S1, MASK_C_NTL_S1, match_opcode, INSN_ALIAS }, +{"ntl.s1", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_S1, MASK_C_NTL_S1, match_opcode, INSN_ALIAS }, {"ntl.s1", 0, INSN_CLASS_ZIHINTNTL, "", MATCH_NTL_S1, MASK_NTL_S1, match_opcode, 0 }, -{"ntl.all", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_ALL, MASK_C_NTL_ALL, match_opcode, INSN_ALIAS }, +{"ntl.all", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_ALL, MASK_C_NTL_ALL, match_opcode, INSN_ALIAS }, {"ntl.all", 0, INSN_CLASS_ZIHINTNTL, "", MATCH_NTL_ALL, MASK_NTL_ALL, match_opcode, 0 }, -{"c.ntl.p1", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_P1, MASK_C_NTL_P1, match_opcode, 0 }, -{"c.ntl.pall", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_PALL, MASK_C_NTL_PALL, match_opcode, 0 }, -{"c.ntl.s1", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_S1, MASK_C_NTL_S1, match_opcode, 0 }, -{"c.ntl.all", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_ALL, MASK_C_NTL_ALL, match_opcode, 0 }, +{"c.ntl.p1", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_P1, MASK_C_NTL_P1, match_opcode, 0 }, +{"c.ntl.pall", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_PALL, MASK_C_NTL_PALL, match_opcode, 0 }, +{"c.ntl.s1", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_S1, MASK_C_NTL_S1, match_opcode, 0 }, +{"c.ntl.all", 0, INSN_CLASS_ZIHINTNTL_AND_ZCA, "", MATCH_C_NTL_ALL, MASK_C_NTL_ALL, match_opcode, 0 }, {"pause", 0, INSN_CLASS_ZIHINTPAUSE, "", MATCH_PAUSE, MASK_PAUSE, match_opcode, 0 }, /* Basic RVI instructions and aliases. */ -{"unimp", 0, INSN_CLASS_C, "", 0, 0xffffU, match_opcode, INSN_ALIAS }, +{"unimp", 0, INSN_CLASS_ZCA, "", 0, 0xffffU, match_opcode, INSN_ALIAS }, {"unimp", 0, INSN_CLASS_I, "", MATCH_CSRRW|(CSR_CYCLE << OP_SH_CSR), 0xffffffffU, match_opcode, 0 }, /* csrw cycle, x0 */ -{"ebreak", 0, INSN_CLASS_C, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, INSN_ALIAS }, +{"ebreak", 0, INSN_CLASS_ZCA, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, INSN_ALIAS }, {"ebreak", 0, INSN_CLASS_I, "", MATCH_EBREAK, MASK_EBREAK, match_opcode, 0 }, -{"sbreak", 0, INSN_CLASS_C, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, INSN_ALIAS }, +{"sbreak", 0, INSN_CLASS_ZCA, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, INSN_ALIAS }, {"sbreak", 0, INSN_CLASS_I, "", MATCH_EBREAK, MASK_EBREAK, match_opcode, INSN_ALIAS }, -{"ret", 0, INSN_CLASS_C, "", MATCH_C_JR|(X_RA << OP_SH_RD), MASK_C_JR|MASK_RD, match_opcode, INSN_ALIAS|INSN_BRANCH }, +{"ret", 0, INSN_CLASS_ZCA, "", MATCH_C_JR|(X_RA << OP_SH_RD), MASK_C_JR|MASK_RD, match_opcode, INSN_ALIAS|INSN_BRANCH }, {"ret", 0, INSN_CLASS_I, "", MATCH_JALR|(X_RA << OP_SH_RS1), MASK_JALR|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, INSN_ALIAS|INSN_BRANCH }, -{"jr", 0, INSN_CLASS_C, "d", MATCH_C_JR, MASK_C_JR, match_rd_nonzero, INSN_ALIAS|INSN_BRANCH }, +{"jr", 0, INSN_CLASS_ZCA, "d", MATCH_C_JR, MASK_C_JR, match_rd_nonzero, INSN_ALIAS|INSN_BRANCH }, {"jr", 0, INSN_CLASS_I, "s", MATCH_JALR, MASK_JALR|MASK_RD|MASK_IMM, match_opcode, INSN_ALIAS|INSN_BRANCH }, {"jr", 0, INSN_CLASS_I, "o(s)", MATCH_JALR, MASK_JALR|MASK_RD, match_opcode, INSN_ALIAS|INSN_BRANCH }, {"jr", 0, INSN_CLASS_I, "s,j", MATCH_JALR, MASK_JALR|MASK_RD, match_opcode, INSN_ALIAS|INSN_BRANCH }, -{"jalr", 0, INSN_CLASS_C, "d", MATCH_C_JALR, MASK_C_JALR, match_rd_nonzero, INSN_ALIAS|INSN_JSR }, +{"jalr", 0, INSN_CLASS_ZCA, "d", MATCH_C_JALR, MASK_C_JALR, match_rd_nonzero, INSN_ALIAS|INSN_JSR }, {"jalr", 0, INSN_CLASS_I, "s", MATCH_JALR|(X_RA << OP_SH_RD), MASK_JALR|MASK_RD|MASK_IMM, match_opcode, INSN_ALIAS|INSN_JSR }, {"jalr", 0, INSN_CLASS_I, "o(s)", MATCH_JALR|(X_RA << OP_SH_RD), MASK_JALR|MASK_RD, match_opcode, INSN_ALIAS|INSN_JSR }, {"jalr", 0, INSN_CLASS_I, "s,j", MATCH_JALR|(X_RA << OP_SH_RD), MASK_JALR|MASK_RD, match_opcode, INSN_ALIAS|INSN_JSR }, @@ -499,9 +499,9 @@ const struct riscv_opcode riscv_opcodes[] = {"jalr", 0, INSN_CLASS_I, "d,o(s)", MATCH_JALR, MASK_JALR, match_opcode, INSN_JSR }, {"jalr", 0, INSN_CLASS_I, "d,s,1", MATCH_JALR, MASK_JALR|MASK_IMM, match_opcode, INSN_JSR }, {"jalr", 0, INSN_CLASS_I, "d,s,j", MATCH_JALR, MASK_JALR, match_opcode, INSN_JSR }, -{"j", 0, INSN_CLASS_C, "Ca", MATCH_C_J, MASK_C_J, match_opcode, INSN_ALIAS|INSN_BRANCH }, +{"j", 0, INSN_CLASS_ZCA, "Ca", MATCH_C_J, MASK_C_J, match_opcode, INSN_ALIAS|INSN_BRANCH }, {"j", 0, INSN_CLASS_I, "a", MATCH_JAL, MASK_JAL|MASK_RD, match_opcode, INSN_ALIAS|INSN_BRANCH }, -{"jal", 32, INSN_CLASS_C, "Ca", MATCH_C_JAL, MASK_C_JAL, match_opcode, INSN_ALIAS|INSN_JSR }, +{"jal", 32, INSN_CLASS_ZCA, "Ca", MATCH_C_JAL, MASK_C_JAL, match_opcode, INSN_ALIAS|INSN_JSR }, {"jal", 0, INSN_CLASS_I, "a", MATCH_JAL|(X_RA << OP_SH_RD), MASK_JAL|MASK_RD, match_opcode, INSN_ALIAS|INSN_JSR }, {"jal", 0, INSN_CLASS_I, "d,a", MATCH_JAL, MASK_JAL, match_opcode, INSN_JSR }, {"call", 0, INSN_CLASS_I, "d,c", (X_T1 << OP_SH_RS1), (int) M_CALL, NULL, INSN_MACRO }, @@ -509,31 +509,31 @@ const struct riscv_opcode riscv_opcodes[] = {"tail", 0, INSN_CLASS_ZICFILP, "c", (X_T2 << OP_SH_RS1), (int) M_CALL, NULL, INSN_MACRO }, {"tail", 0, INSN_CLASS_I, "c", (X_T1 << OP_SH_RS1), (int) M_CALL, NULL, INSN_MACRO }, {"jump", 0, INSN_CLASS_I, "c,s", 0, (int) M_CALL, match_rs1_nonzero, INSN_MACRO }, -{"nop", 0, INSN_CLASS_C, "", MATCH_C_ADDI, 0xffff, match_opcode, INSN_ALIAS }, +{"nop", 0, INSN_CLASS_ZCA, "", MATCH_C_ADDI, 0xffff, match_opcode, INSN_ALIAS }, {"nop", 0, INSN_CLASS_I, "", MATCH_ADDI, MASK_ADDI|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, INSN_ALIAS }, -{"lui", 0, INSN_CLASS_C, "d,Cu", MATCH_C_LUI, MASK_C_LUI, match_c_lui, INSN_ALIAS }, +{"lui", 0, INSN_CLASS_ZCA, "d,Cu", MATCH_C_LUI, MASK_C_LUI, match_c_lui, INSN_ALIAS }, {"lui", 0, INSN_CLASS_I, "d,u", MATCH_LUI, MASK_LUI, match_opcode, 0 }, -{"li", 0, INSN_CLASS_C, "d,Cv", MATCH_C_LUI, MASK_C_LUI, match_c_lui, INSN_ALIAS }, -{"li", 0, INSN_CLASS_C, "d,Co", MATCH_C_LI, MASK_C_LI, match_rd_nonzero, INSN_ALIAS }, +{"li", 0, INSN_CLASS_ZCA, "d,Cv", MATCH_C_LUI, MASK_C_LUI, match_c_lui, INSN_ALIAS }, +{"li", 0, INSN_CLASS_ZCA, "d,Co", MATCH_C_LI, MASK_C_LI, match_rd_nonzero, INSN_ALIAS }, {"li", 0, INSN_CLASS_I, "d,j", MATCH_ADDI, MASK_ADDI|MASK_RS1, match_opcode, INSN_ALIAS }, /* addi */ {"li", 0, INSN_CLASS_I, "d,I", 0, (int) M_LI, NULL, INSN_MACRO }, -{"mv", 0, INSN_CLASS_C, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, +{"mv", 0, INSN_CLASS_ZCA, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, {"mv", 0, INSN_CLASS_I, "d,s", MATCH_ADDI, MASK_ADDI|MASK_IMM, match_opcode, INSN_ALIAS }, -{"move", 0, INSN_CLASS_C, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, +{"move", 0, INSN_CLASS_ZCA, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, {"move", 0, INSN_CLASS_I, "d,s", MATCH_ADDI, MASK_ADDI|MASK_IMM, match_opcode, INSN_ALIAS }, {"zext.b", 0, INSN_CLASS_ZCB, "Cs,Cw", MATCH_C_ZEXT_B, MASK_C_ZEXT_B, match_opcode, INSN_ALIAS }, {"zext.b", 0, INSN_CLASS_I, "d,s", MATCH_ANDI|ENCODE_ITYPE_IMM (255), MASK_ANDI | MASK_IMM, match_opcode, INSN_ALIAS }, {"andi", 0, INSN_CLASS_ZCB, "Cs,Cw,Wcf",MATCH_C_ZEXT_B, MASK_C_ZEXT_B, match_opcode, INSN_ALIAS }, -{"andi", 0, INSN_CLASS_C, "Cs,Cw,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, INSN_ALIAS }, +{"andi", 0, INSN_CLASS_ZCA, "Cs,Cw,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, INSN_ALIAS }, {"andi", 0, INSN_CLASS_I, "d,s,j", MATCH_ANDI, MASK_ANDI, match_opcode, 0 }, -{"and", 0, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_AND, MASK_C_AND, match_opcode, INSN_ALIAS }, -{"and", 0, INSN_CLASS_C, "Cs,Ct,Cw", MATCH_C_AND, MASK_C_AND, match_opcode, INSN_ALIAS }, -{"and", 0, INSN_CLASS_C, "Cs,Cw,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, INSN_ALIAS }, +{"and", 0, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_AND, MASK_C_AND, match_opcode, INSN_ALIAS }, +{"and", 0, INSN_CLASS_ZCA, "Cs,Ct,Cw", MATCH_C_AND, MASK_C_AND, match_opcode, INSN_ALIAS }, +{"and", 0, INSN_CLASS_ZCA, "Cs,Cw,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, INSN_ALIAS }, {"and", 0, INSN_CLASS_I, "d,s,t", MATCH_AND, MASK_AND, match_opcode, 0 }, {"and", 0, INSN_CLASS_I, "d,s,j", MATCH_ANDI, MASK_ANDI, match_opcode, INSN_ALIAS }, -{"beqz", 0, INSN_CLASS_C, "Cs,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, +{"beqz", 0, INSN_CLASS_ZCA, "Cs,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"beqz", 0, INSN_CLASS_I, "s,p", MATCH_BEQ, MASK_BEQ|MASK_RS2, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, -{"beq", 0, INSN_CLASS_C, "Cs,Cz,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, +{"beq", 0, INSN_CLASS_ZCA, "Cs,Cz,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"beq", 0, INSN_CLASS_I, "s,t,p", MATCH_BEQ, MASK_BEQ, match_opcode, INSN_CONDBRANCH }, {"blez", 0, INSN_CLASS_I, "t,p", MATCH_BGE, MASK_BGE|MASK_RS1, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"bgez", 0, INSN_CLASS_I, "s,p", MATCH_BGE, MASK_BGE|MASK_RS2, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, @@ -547,23 +547,23 @@ const struct riscv_opcode riscv_opcodes[] = {"bltu", 0, INSN_CLASS_I, "s,t,p", MATCH_BLTU, MASK_BLTU, match_opcode, INSN_CONDBRANCH }, {"bgt", 0, INSN_CLASS_I, "t,s,p", MATCH_BLT, MASK_BLT, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"bgtu", 0, INSN_CLASS_I, "t,s,p", MATCH_BLTU, MASK_BLTU, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, -{"bnez", 0, INSN_CLASS_C, "Cs,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, +{"bnez", 0, INSN_CLASS_ZCA, "Cs,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"bnez", 0, INSN_CLASS_I, "s,p", MATCH_BNE, MASK_BNE|MASK_RS2, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, -{"bne", 0, INSN_CLASS_C, "Cs,Cz,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, +{"bne", 0, INSN_CLASS_ZCA, "Cs,Cz,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_ALIAS|INSN_CONDBRANCH }, {"bne", 0, INSN_CLASS_I, "s,t,p", MATCH_BNE, MASK_BNE, match_opcode, INSN_CONDBRANCH }, -{"addi", 0, INSN_CLASS_C, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, INSN_ALIAS }, -{"addi", 0, INSN_CLASS_C, "d,CU,Cj", MATCH_C_ADDI, MASK_C_ADDI, match_rd_nonzero, INSN_ALIAS }, -{"addi", 0, INSN_CLASS_C, "d,CU,z", MATCH_C_NOP, MASK_C_ADDI|MASK_RVC_IMM, match_c_nop, INSN_ALIAS }, -{"addi", 0, INSN_CLASS_C, "Cc,Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, INSN_ALIAS }, -{"addi", 0, INSN_CLASS_C, "d,Cz,Co", MATCH_C_LI, MASK_C_LI, match_rd_nonzero, INSN_ALIAS }, -{"addi", 0, INSN_CLASS_C, "d,CV,z", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "d,CU,Cj", MATCH_C_ADDI, MASK_C_ADDI, match_rd_nonzero, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "d,CU,z", MATCH_C_NOP, MASK_C_ADDI|MASK_RVC_IMM, match_c_nop, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "Cc,Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "d,Cz,Co", MATCH_C_LI, MASK_C_LI, match_rd_nonzero, INSN_ALIAS }, +{"addi", 0, INSN_CLASS_ZCA, "d,CV,z", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, {"addi", 0, INSN_CLASS_I, "d,s,j", MATCH_ADDI, MASK_ADDI, match_opcode, 0 }, -{"add", 0, INSN_CLASS_C, "d,CU,CV", MATCH_C_ADD, MASK_C_ADD, match_c_add, INSN_ALIAS }, -{"add", 0, INSN_CLASS_C, "d,CV,CU", MATCH_C_ADD, MASK_C_ADD, match_c_add, INSN_ALIAS }, -{"add", 0, INSN_CLASS_C, "d,CU,Co", MATCH_C_ADDI, MASK_C_ADDI, match_rd_nonzero, INSN_ALIAS }, -{"add", 0, INSN_CLASS_C, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, INSN_ALIAS }, -{"add", 0, INSN_CLASS_C, "Cc,Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, INSN_ALIAS }, -{"add", 0, INSN_CLASS_C, "d,Cz,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "d,CU,CV", MATCH_C_ADD, MASK_C_ADD, match_c_add, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "d,CV,CU", MATCH_C_ADD, MASK_C_ADD, match_c_add, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "d,CU,Co", MATCH_C_ADDI, MASK_C_ADDI, match_rd_nonzero, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "Cc,Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, INSN_ALIAS }, +{"add", 0, INSN_CLASS_ZCA, "d,Cz,CV", MATCH_C_MV, MASK_C_MV, match_c_add, INSN_ALIAS }, {"add", 0, INSN_CLASS_I, "d,s,t", MATCH_ADD, MASK_ADD, match_opcode, 0 }, {"add", 0, INSN_CLASS_I, "d,s,t,1", MATCH_ADD, MASK_ADD, match_opcode, 0 }, {"add", 0, INSN_CLASS_I, "d,s,j", MATCH_ADDI, MASK_ADDI, match_opcode, INSN_ALIAS }, @@ -577,22 +577,22 @@ const struct riscv_opcode riscv_opcodes[] = {"mips.ehb", 0, INSN_CLASS_XMIPSEXECTL, "", MATCH_MIPS_EHB, MASK_MIPS_EHB, match_opcode, 0 }, {"mips.ihb", 0, INSN_CLASS_XMIPSEXECTL, "", MATCH_MIPS_IHB, MASK_MIPS_IHB, match_opcode, 0 }, {"mips.pause", 0, INSN_CLASS_XMIPSEXECTL, "", MATCH_MIPS_PAUSE, MASK_MIPS_PAUSE, match_opcode, 0 }, -{"slli", 0, INSN_CLASS_C, "d,CU,C>", MATCH_C_SLLI, MASK_C_SLLI, match_slli_as_c_slli, INSN_ALIAS }, +{"slli", 0, INSN_CLASS_ZCA, "d,CU,C>", MATCH_C_SLLI, MASK_C_SLLI, match_slli_as_c_slli, INSN_ALIAS }, {"slli", 0, INSN_CLASS_I, "d,s,>", MATCH_SLLI, MASK_SLLI, match_opcode, 0 }, -{"sll", 0, INSN_CLASS_C, "d,CU,C>", MATCH_C_SLLI, MASK_C_SLLI, match_slli_as_c_slli, INSN_ALIAS }, +{"sll", 0, INSN_CLASS_ZCA, "d,CU,C>", MATCH_C_SLLI, MASK_C_SLLI, match_slli_as_c_slli, INSN_ALIAS }, {"sll", 0, INSN_CLASS_I, "d,s,t", MATCH_SLL, MASK_SLL, match_opcode, 0 }, {"sll", 0, INSN_CLASS_I, "d,s,>", MATCH_SLLI, MASK_SLLI, match_opcode, INSN_ALIAS }, -{"srli", 0, INSN_CLASS_C, "Cs,Cw,C>", MATCH_C_SRLI, MASK_C_SRLI, match_srxi_as_c_srxi, INSN_ALIAS }, +{"srli", 0, INSN_CLASS_ZCA, "Cs,Cw,C>", MATCH_C_SRLI, MASK_C_SRLI, match_srxi_as_c_srxi, INSN_ALIAS }, {"srli", 0, INSN_CLASS_I, "d,s,>", MATCH_SRLI, MASK_SRLI, match_opcode, 0 }, -{"srl", 0, INSN_CLASS_C, "Cs,Cw,C>", MATCH_C_SRLI, MASK_C_SRLI, match_srxi_as_c_srxi, INSN_ALIAS }, +{"srl", 0, INSN_CLASS_ZCA, "Cs,Cw,C>", MATCH_C_SRLI, MASK_C_SRLI, match_srxi_as_c_srxi, INSN_ALIAS }, {"srl", 0, INSN_CLASS_I, "d,s,t", MATCH_SRL, MASK_SRL, match_opcode, 0 }, {"srl", 0, INSN_CLASS_I, "d,s,>", MATCH_SRLI, MASK_SRLI, match_opcode, INSN_ALIAS }, -{"srai", 0, INSN_CLASS_C, "Cs,Cw,C>", MATCH_C_SRAI, MASK_C_SRAI, match_srxi_as_c_srxi, INSN_ALIAS }, +{"srai", 0, INSN_CLASS_ZCA, "Cs,Cw,C>", MATCH_C_SRAI, MASK_C_SRAI, match_srxi_as_c_srxi, INSN_ALIAS }, {"srai", 0, INSN_CLASS_I, "d,s,>", MATCH_SRAI, MASK_SRAI, match_opcode, 0 }, -{"sra", 0, INSN_CLASS_C, "Cs,Cw,C>", MATCH_C_SRAI, MASK_C_SRAI, match_srxi_as_c_srxi, INSN_ALIAS }, +{"sra", 0, INSN_CLASS_ZCA, "Cs,Cw,C>", MATCH_C_SRAI, MASK_C_SRAI, match_srxi_as_c_srxi, INSN_ALIAS }, {"sra", 0, INSN_CLASS_I, "d,s,t", MATCH_SRA, MASK_SRA, match_opcode, 0 }, {"sra", 0, INSN_CLASS_I, "d,s,>", MATCH_SRAI, MASK_SRAI, match_opcode, INSN_ALIAS }, -{"sub", 0, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_SUB, MASK_C_SUB, match_opcode, INSN_ALIAS }, +{"sub", 0, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_SUB, MASK_C_SUB, match_opcode, INSN_ALIAS }, {"sub", 0, INSN_CLASS_I, "d,s,t", MATCH_SUB, MASK_SUB, match_opcode, 0 }, {"lb", 0, INSN_CLASS_I, "d,o(s)", MATCH_LB, MASK_LB, match_opcode, INSN_DREF|INSN_1_BYTE }, {"lb", 0, INSN_CLASS_I, "d,A", 0, (int) M_Lx, match_rd_nonzero, INSN_MACRO }, @@ -605,16 +605,16 @@ const struct riscv_opcode riscv_opcodes[] = {"lhu", 0, INSN_CLASS_ZCB, "Ct,Wch(Cs)", MATCH_C_LHU, MASK_C_LHU, match_opcode, INSN_ALIAS|INSN_DREF|INSN_2_BYTE }, {"lhu", 0, INSN_CLASS_I, "d,o(s)", MATCH_LHU, MASK_LHU, match_opcode, INSN_DREF|INSN_2_BYTE }, {"lhu", 0, INSN_CLASS_I, "d,A", 0, (int) M_Lx, match_rd_nonzero, INSN_MACRO }, -{"lw", 0, INSN_CLASS_C, "d,Cm(Cc)", MATCH_C_LWSP, MASK_C_LWSP, match_rd_nonzero, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, -{"lw", 0, INSN_CLASS_C, "Ct,Ck(Cs)", MATCH_C_LW, MASK_C_LW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"lw", 0, INSN_CLASS_ZCA, "d,Cm(Cc)", MATCH_C_LWSP, MASK_C_LWSP, match_rd_nonzero, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"lw", 0, INSN_CLASS_ZCA, "Ct,Ck(Cs)", MATCH_C_LW, MASK_C_LW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, {"lw", 0, INSN_CLASS_I, "d,o(s)", MATCH_LW, MASK_LW, match_opcode, INSN_DREF|INSN_4_BYTE }, {"lw", 0, INSN_CLASS_I, "d,A", 0, (int) M_Lx, match_rd_nonzero, INSN_MACRO }, {"not", 0, INSN_CLASS_ZCB, "Cs,Cw", MATCH_C_NOT, MASK_C_NOT, match_opcode, INSN_ALIAS }, {"not", 0, INSN_CLASS_I, "d,s", MATCH_XORI|MASK_IMM, MASK_XORI|MASK_IMM, match_opcode, INSN_ALIAS }, {"ori", 0, INSN_CLASS_I, "d,s,j", MATCH_ORI, MASK_ORI, match_opcode, 0 }, {"or", 0, INSN_CLASS_I, "d,s,j", MATCH_ORI, MASK_ORI, match_opcode, INSN_ALIAS }, -{"or", 0, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS }, -{"or", 0, INSN_CLASS_C, "Cs,Ct,Cw", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS }, +{"or", 0, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS }, +{"or", 0, INSN_CLASS_ZCA, "Cs,Ct,Cw", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS }, {"or", 0, INSN_CLASS_I, "d,s,t", MATCH_OR, MASK_OR, match_opcode, 0 }, /* Zicfilp instructions. */ @@ -639,8 +639,8 @@ const struct riscv_opcode riscv_opcodes[] = {"sh", 0, INSN_CLASS_ZCB, "Ct,Wch(Cs)", MATCH_C_SH, MASK_C_SH, match_opcode, INSN_DREF|INSN_2_BYTE|INSN_ALIAS }, {"sh", 0, INSN_CLASS_I, "t,q(s)", MATCH_SH, MASK_SH, match_opcode, INSN_DREF|INSN_2_BYTE }, {"sh", 0, INSN_CLASS_I, "t,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero, INSN_MACRO }, -{"sw", 0, INSN_CLASS_C, "CV,CM(Cc)", MATCH_C_SWSP, MASK_C_SWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, -{"sw", 0, INSN_CLASS_C, "Ct,Ck(Cs)", MATCH_C_SW, MASK_C_SW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"sw", 0, INSN_CLASS_ZCA, "CV,CM(Cc)", MATCH_C_SWSP, MASK_C_SWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"sw", 0, INSN_CLASS_ZCA, "Ct,Ck(Cs)", MATCH_C_SW, MASK_C_SW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, {"sw", 0, INSN_CLASS_I, "t,q(s)", MATCH_SW, MASK_SW, match_opcode, INSN_DREF|INSN_4_BYTE }, {"sw", 0, INSN_CLASS_I, "t,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero, INSN_MACRO }, {"fence", 0, INSN_CLASS_I, "", MATCH_FENCE|MASK_PRED|MASK_SUCC, MASK_FENCE|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, INSN_ALIAS }, @@ -657,34 +657,34 @@ const struct riscv_opcode riscv_opcodes[] = {"scall", 0, INSN_CLASS_I, "", MATCH_SCALL, MASK_SCALL, match_opcode, 0 }, {"xori", 0, INSN_CLASS_I, "d,s,j", MATCH_XORI, MASK_XORI, match_opcode, 0 }, {"xor", 0, INSN_CLASS_I, "d,s,j", MATCH_XORI, MASK_XORI, match_opcode, INSN_ALIAS }, -{"xor", 0, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_XOR, MASK_C_XOR, match_opcode, INSN_ALIAS }, -{"xor", 0, INSN_CLASS_C, "Cs,Ct,Cw", MATCH_C_XOR, MASK_C_XOR, match_opcode, INSN_ALIAS }, +{"xor", 0, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_XOR, MASK_C_XOR, match_opcode, INSN_ALIAS }, +{"xor", 0, INSN_CLASS_ZCA, "Cs,Ct,Cw", MATCH_C_XOR, MASK_C_XOR, match_opcode, INSN_ALIAS }, {"xor", 0, INSN_CLASS_I, "d,s,t", MATCH_XOR, MASK_XOR, match_opcode, 0 }, {"lwu", 64, INSN_CLASS_I, "d,o(s)", MATCH_LWU, MASK_LWU, match_opcode, INSN_DREF|INSN_4_BYTE }, {"lwu", 64, INSN_CLASS_I, "d,A", 0, (int) M_Lx, match_rd_nonzero, INSN_MACRO }, -{"ld", 64, INSN_CLASS_C, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_nonzero, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, -{"ld", 64, INSN_CLASS_C, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"ld", 64, INSN_CLASS_ZCA, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_nonzero, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"ld", 64, INSN_CLASS_ZCA, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"ld", 64, INSN_CLASS_I, "d,o(s)", MATCH_LD, MASK_LD, match_opcode, INSN_DREF|INSN_8_BYTE }, {"ld", 64, INSN_CLASS_I, "d,A", 0, (int) M_Lx, match_rd_nonzero, INSN_MACRO }, {"ld", 32, INSN_CLASS_ZCLSD, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_even_nonzero, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"ld", 32, INSN_CLASS_ZCLSD, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_crs2s_even, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"ld", 32, INSN_CLASS_ZILSD, "d,o(s)", MATCH_LD, MASK_LD, match_rd_even, INSN_DREF|INSN_8_BYTE }, {"ld", 32, INSN_CLASS_ZILSD, "d,A", 0, (int) M_Lx, match_rd_even_nonzero, INSN_MACRO }, -{"sd", 64, INSN_CLASS_C, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, -{"sd", 64, INSN_CLASS_C, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"sd", 64, INSN_CLASS_ZCA, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"sd", 64, INSN_CLASS_ZCA, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"sd", 64, INSN_CLASS_I, "t,q(s)", MATCH_SD, MASK_SD, match_opcode, INSN_DREF|INSN_8_BYTE }, {"sd", 64, INSN_CLASS_I, "t,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero, INSN_MACRO }, {"sd", 32, INSN_CLASS_ZCLSD, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_crs2_even, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"sd", 32, INSN_CLASS_ZCLSD, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_crs2s_even, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"sd", 32, INSN_CLASS_ZILSD, "t,q(s)", MATCH_SD, MASK_SD, match_rs2_even, INSN_DREF|INSN_8_BYTE }, {"sd", 32, INSN_CLASS_ZILSD, "t,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero_rs2_even, INSN_MACRO }, -{"sext.w", 64, INSN_CLASS_C, "d,CU", MATCH_C_ADDIW, MASK_C_ADDIW|MASK_RVC_IMM, match_rd_nonzero, INSN_ALIAS }, +{"sext.w", 64, INSN_CLASS_ZCA, "d,CU", MATCH_C_ADDIW, MASK_C_ADDIW|MASK_RVC_IMM, match_rd_nonzero, INSN_ALIAS }, {"sext.w", 64, INSN_CLASS_I, "d,s", MATCH_ADDIW, MASK_ADDIW|MASK_IMM, match_opcode, INSN_ALIAS }, -{"addiw", 64, INSN_CLASS_C, "d,CU,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, INSN_ALIAS }, +{"addiw", 64, INSN_CLASS_ZCA, "d,CU,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, INSN_ALIAS }, {"addiw", 64, INSN_CLASS_I, "d,s,j", MATCH_ADDIW, MASK_ADDIW, match_opcode, 0 }, -{"addw", 64, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, INSN_ALIAS }, -{"addw", 64, INSN_CLASS_C, "Cs,Ct,Cw", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, INSN_ALIAS }, -{"addw", 64, INSN_CLASS_C, "d,CU,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, INSN_ALIAS }, +{"addw", 64, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, INSN_ALIAS }, +{"addw", 64, INSN_CLASS_ZCA, "Cs,Ct,Cw", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, INSN_ALIAS }, +{"addw", 64, INSN_CLASS_ZCA, "d,CU,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, INSN_ALIAS }, {"addw", 64, INSN_CLASS_I, "d,s,t", MATCH_ADDW, MASK_ADDW, match_opcode, 0 }, {"addw", 64, INSN_CLASS_I, "d,s,j", MATCH_ADDIW, MASK_ADDIW, match_opcode, INSN_ALIAS }, {"negw", 64, INSN_CLASS_I, "d,t", MATCH_SUBW, MASK_SUBW|MASK_RS1, match_opcode, INSN_ALIAS }, /* sub 0 */ @@ -697,7 +697,7 @@ const struct riscv_opcode riscv_opcodes[] = {"sraiw", 64, INSN_CLASS_I, "d,s,<", MATCH_SRAIW, MASK_SRAIW, match_opcode, 0 }, {"sraw", 64, INSN_CLASS_I, "d,s,t", MATCH_SRAW, MASK_SRAW, match_opcode, 0 }, {"sraw", 64, INSN_CLASS_I, "d,s,<", MATCH_SRAIW, MASK_SRAIW, match_opcode, INSN_ALIAS }, -{"subw", 64, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_SUBW, MASK_C_SUBW, match_opcode, INSN_ALIAS }, +{"subw", 64, INSN_CLASS_ZCA, "Cs,Cw,Ct", MATCH_C_SUBW, MASK_C_SUBW, match_opcode, INSN_ALIAS }, {"subw", 64, INSN_CLASS_I, "d,s,t", MATCH_SUBW, MASK_SUBW, match_opcode, 0 }, /* Atomic memory operation instruction subset. */ @@ -993,12 +993,12 @@ const struct riscv_opcode riscv_opcodes[] = {"fsflags", 0, INSN_CLASS_F_INX, "d,s", MATCH_FSFLAGS, MASK_FSFLAGS, match_opcode, INSN_ALIAS }, {"fsflagsi", 0, INSN_CLASS_F_INX, "d,Z", MATCH_FSFLAGSI, MASK_FSFLAGSI, match_opcode, INSN_ALIAS }, {"fsflagsi", 0, INSN_CLASS_F_INX, "Z", MATCH_FSFLAGSI, MASK_FSFLAGSI|MASK_RD, match_opcode, INSN_ALIAS }, -{"flw", 32, INSN_CLASS_F_AND_C, "D,Cm(Cc)", MATCH_C_FLWSP, MASK_C_FLWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, -{"flw", 32, INSN_CLASS_F_AND_C, "CD,Ck(Cs)", MATCH_C_FLW, MASK_C_FLW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"flw", 32, INSN_CLASS_ZCF, "D,Cm(Cc)", MATCH_C_FLWSP, MASK_C_FLWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"flw", 32, INSN_CLASS_ZCF, "CD,Ck(Cs)", MATCH_C_FLW, MASK_C_FLW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, {"flw", 0, INSN_CLASS_F, "D,o(s)", MATCH_FLW, MASK_FLW, match_opcode, INSN_DREF|INSN_4_BYTE }, {"flw", 0, INSN_CLASS_F, "D,A,s", 0, (int) M_FLx, match_rs1_nonzero, INSN_MACRO }, -{"fsw", 32, INSN_CLASS_F_AND_C, "CT,CM(Cc)", MATCH_C_FSWSP, MASK_C_FSWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, -{"fsw", 32, INSN_CLASS_F_AND_C, "CD,Ck(Cs)", MATCH_C_FSW, MASK_C_FSW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"fsw", 32, INSN_CLASS_ZCF, "CT,CM(Cc)", MATCH_C_FSWSP, MASK_C_FSWSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, +{"fsw", 32, INSN_CLASS_ZCF, "CD,Ck(Cs)", MATCH_C_FSW, MASK_C_FSW, match_opcode, INSN_ALIAS|INSN_DREF|INSN_4_BYTE }, {"fsw", 0, INSN_CLASS_F, "T,q(s)", MATCH_FSW, MASK_FSW, match_opcode, INSN_DREF|INSN_4_BYTE }, {"fsw", 0, INSN_CLASS_F, "T,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero, INSN_MACRO }, {"fmv.x.w", 0, INSN_CLASS_F, "d,S", MATCH_FMV_X_S, MASK_FMV_X_S, match_opcode, 0 }, @@ -1055,12 +1055,12 @@ const struct riscv_opcode riscv_opcodes[] = {"fcvt.s.lu", 64, INSN_CLASS_F_INX, "D,s,m", MATCH_FCVT_S_LU, MASK_FCVT_S_LU, match_opcode, 0 }, /* Double-precision floating-point instruction subset. */ -{"fld", 0, INSN_CLASS_D_AND_C, "D,Cn(Cc)", MATCH_C_FLDSP, MASK_C_FLDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, -{"fld", 0, INSN_CLASS_D_AND_C, "CD,Cl(Cs)", MATCH_C_FLD, MASK_C_FLD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"fld", 0, INSN_CLASS_ZCD, "D,Cn(Cc)", MATCH_C_FLDSP, MASK_C_FLDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"fld", 0, INSN_CLASS_ZCD, "CD,Cl(Cs)", MATCH_C_FLD, MASK_C_FLD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"fld", 0, INSN_CLASS_D, "D,o(s)", MATCH_FLD, MASK_FLD, match_opcode, INSN_DREF|INSN_8_BYTE }, {"fld", 0, INSN_CLASS_D, "D,A,s", 0, (int) M_FLx, match_rs1_nonzero, INSN_MACRO }, -{"fsd", 0, INSN_CLASS_D_AND_C, "CT,CN(Cc)", MATCH_C_FSDSP, MASK_C_FSDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, -{"fsd", 0, INSN_CLASS_D_AND_C, "CD,Cl(Cs)", MATCH_C_FSD, MASK_C_FSD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"fsd", 0, INSN_CLASS_ZCD, "CT,CN(Cc)", MATCH_C_FSDSP, MASK_C_FSDSP, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, +{"fsd", 0, INSN_CLASS_ZCD, "CD,Cl(Cs)", MATCH_C_FSD, MASK_C_FSD, match_opcode, INSN_ALIAS|INSN_DREF|INSN_8_BYTE }, {"fsd", 0, INSN_CLASS_D, "T,q(s)", MATCH_FSD, MASK_FSD, match_opcode, INSN_DREF|INSN_8_BYTE }, {"fsd", 0, INSN_CLASS_D, "T,A,s", 0, (int) M_Sx_FSx, match_rs1_nonzero, INSN_MACRO }, {"fmv.d", 0, INSN_CLASS_D_INX, "D,U", MATCH_FSGNJ_D, MASK_FSGNJ_D, match_rs1_eq_rs2, INSN_ALIAS }, @@ -1174,57 +1174,57 @@ const struct riscv_opcode riscv_opcodes[] = {"fcvt.q.lu", 64, INSN_CLASS_Q_INX, "D,s,m", MATCH_FCVT_Q_LU, MASK_FCVT_Q_LU, match_opcode, 0 }, /* Compressed instructions. */ -{"c.unimp", 0, INSN_CLASS_C, "", 0, 0xffffU, match_opcode, 0 }, -{"c.ebreak", 0, INSN_CLASS_C, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, 0 }, -{"c.jr", 0, INSN_CLASS_C, "d", MATCH_C_JR, MASK_C_JR, match_rd_nonzero, INSN_BRANCH }, -{"c.jalr", 0, INSN_CLASS_C, "d", MATCH_C_JALR, MASK_C_JALR, match_rd_nonzero, INSN_JSR }, -{"c.j", 0, INSN_CLASS_C, "Ca", MATCH_C_J, MASK_C_J, match_opcode, INSN_BRANCH }, -{"c.jal", 32, INSN_CLASS_C, "Ca", MATCH_C_JAL, MASK_C_JAL, match_opcode, INSN_JSR }, -{"c.beqz", 0, INSN_CLASS_C, "Cs,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_CONDBRANCH }, -{"c.bnez", 0, INSN_CLASS_C, "Cs,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_CONDBRANCH }, -{"c.lwsp", 0, INSN_CLASS_C, "d,Cm(Cc)", MATCH_C_LWSP, MASK_C_LWSP, match_rd_nonzero, 0 }, -{"c.lw", 0, INSN_CLASS_C, "Ct,Ck(Cs)", MATCH_C_LW, MASK_C_LW, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.swsp", 0, INSN_CLASS_C, "CV,CM(Cc)", MATCH_C_SWSP, MASK_C_SWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.sw", 0, INSN_CLASS_C, "Ct,Ck(Cs)", MATCH_C_SW, MASK_C_SW, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.nop", 0, INSN_CLASS_C, "", MATCH_C_ADDI, 0xffff, match_opcode, INSN_ALIAS }, -{"c.nop", 0, INSN_CLASS_C, "Cj", MATCH_C_ADDI, MASK_C_ADDI|MASK_RD, match_opcode, INSN_ALIAS }, -{"c.mv", 0, INSN_CLASS_C, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add_with_hint, 0 }, -{"c.lui", 0, INSN_CLASS_C, "d,Cu", MATCH_C_LUI, MASK_C_LUI, match_c_lui_with_hint, 0 }, -{"c.li", 0, INSN_CLASS_C, "d,Co", MATCH_C_LI, MASK_C_LI, match_opcode, 0 }, -{"c.addi4spn", 0, INSN_CLASS_C, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, 0 }, -{"c.addi16sp", 0, INSN_CLASS_C, "Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, 0 }, -{"c.addi", 0, INSN_CLASS_C, "d,Co", MATCH_C_ADDI, MASK_C_ADDI, match_opcode, 0 }, -{"c.add", 0, INSN_CLASS_C, "d,CV", MATCH_C_ADD, MASK_C_ADD, match_c_add_with_hint, 0 }, -{"c.sub", 0, INSN_CLASS_C, "Cs,Ct", MATCH_C_SUB, MASK_C_SUB, match_opcode, 0 }, -{"c.and", 0, INSN_CLASS_C, "Cs,Ct", MATCH_C_AND, MASK_C_AND, match_opcode, 0 }, -{"c.or", 0, INSN_CLASS_C, "Cs,Ct", MATCH_C_OR, MASK_C_OR, match_opcode, 0 }, -{"c.xor", 0, INSN_CLASS_C, "Cs,Ct", MATCH_C_XOR, MASK_C_XOR, match_opcode, 0 }, -{"c.slli", 0, INSN_CLASS_C, "d,C>", MATCH_C_SLLI, MASK_C_SLLI, match_c_slli, 0 }, -{"c.srli", 0, INSN_CLASS_C, "Cs,C>", MATCH_C_SRLI, MASK_C_SRLI, match_c_slli, 0 }, -{"c.srai", 0, INSN_CLASS_C, "Cs,C>", MATCH_C_SRAI, MASK_C_SRAI, match_c_slli, 0 }, -{"c.slli64", 0, INSN_CLASS_C, "d", MATCH_C_SLLI64, MASK_C_SLLI64, match_c_slli64, 0 }, -{"c.srli64", 0, INSN_CLASS_C, "Cs", MATCH_C_SRLI64, MASK_C_SRLI64, match_c_slli64, 0 }, -{"c.srai64", 0, INSN_CLASS_C, "Cs", MATCH_C_SRAI64, MASK_C_SRAI64, match_c_slli64, 0 }, -{"c.andi", 0, INSN_CLASS_C, "Cs,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, 0 }, -{"c.addiw", 64, INSN_CLASS_C, "d,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, 0 }, -{"c.addw", 64, INSN_CLASS_C, "Cs,Ct", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, 0 }, -{"c.subw", 64, INSN_CLASS_C, "Cs,Ct", MATCH_C_SUBW, MASK_C_SUBW, match_opcode, 0 }, +{"c.unimp", 0, INSN_CLASS_ZCA, "", 0, 0xffffU, match_opcode, 0 }, +{"c.ebreak", 0, INSN_CLASS_ZCA, "", MATCH_C_EBREAK, MASK_C_EBREAK, match_opcode, 0 }, +{"c.jr", 0, INSN_CLASS_ZCA, "d", MATCH_C_JR, MASK_C_JR, match_rd_nonzero, INSN_BRANCH }, +{"c.jalr", 0, INSN_CLASS_ZCA, "d", MATCH_C_JALR, MASK_C_JALR, match_rd_nonzero, INSN_JSR }, +{"c.j", 0, INSN_CLASS_ZCA, "Ca", MATCH_C_J, MASK_C_J, match_opcode, INSN_BRANCH }, +{"c.jal", 32, INSN_CLASS_ZCA, "Ca", MATCH_C_JAL, MASK_C_JAL, match_opcode, INSN_JSR }, +{"c.beqz", 0, INSN_CLASS_ZCA, "Cs,Cp", MATCH_C_BEQZ, MASK_C_BEQZ, match_opcode, INSN_CONDBRANCH }, +{"c.bnez", 0, INSN_CLASS_ZCA, "Cs,Cp", MATCH_C_BNEZ, MASK_C_BNEZ, match_opcode, INSN_CONDBRANCH }, +{"c.lwsp", 0, INSN_CLASS_ZCA, "d,Cm(Cc)", MATCH_C_LWSP, MASK_C_LWSP, match_rd_nonzero, 0 }, +{"c.lw", 0, INSN_CLASS_ZCA, "Ct,Ck(Cs)", MATCH_C_LW, MASK_C_LW, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.swsp", 0, INSN_CLASS_ZCA, "CV,CM(Cc)", MATCH_C_SWSP, MASK_C_SWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.sw", 0, INSN_CLASS_ZCA, "Ct,Ck(Cs)", MATCH_C_SW, MASK_C_SW, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.nop", 0, INSN_CLASS_ZCA, "", MATCH_C_ADDI, 0xffff, match_opcode, INSN_ALIAS }, +{"c.nop", 0, INSN_CLASS_ZCA, "Cj", MATCH_C_ADDI, MASK_C_ADDI|MASK_RD, match_opcode, INSN_ALIAS }, +{"c.mv", 0, INSN_CLASS_ZCA, "d,CV", MATCH_C_MV, MASK_C_MV, match_c_add_with_hint, 0 }, +{"c.lui", 0, INSN_CLASS_ZCA, "d,Cu", MATCH_C_LUI, MASK_C_LUI, match_c_lui_with_hint, 0 }, +{"c.li", 0, INSN_CLASS_ZCA, "d,Co", MATCH_C_LI, MASK_C_LI, match_opcode, 0 }, +{"c.addi4spn", 0, INSN_CLASS_ZCA, "Ct,Cc,CK", MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN, match_c_addi4spn, 0 }, +{"c.addi16sp", 0, INSN_CLASS_ZCA, "Cc,CL", MATCH_C_ADDI16SP, MASK_C_ADDI16SP, match_c_addi16sp, 0 }, +{"c.addi", 0, INSN_CLASS_ZCA, "d,Co", MATCH_C_ADDI, MASK_C_ADDI, match_opcode, 0 }, +{"c.add", 0, INSN_CLASS_ZCA, "d,CV", MATCH_C_ADD, MASK_C_ADD, match_c_add_with_hint, 0 }, +{"c.sub", 0, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_SUB, MASK_C_SUB, match_opcode, 0 }, +{"c.and", 0, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_AND, MASK_C_AND, match_opcode, 0 }, +{"c.or", 0, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_OR, MASK_C_OR, match_opcode, 0 }, +{"c.xor", 0, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_XOR, MASK_C_XOR, match_opcode, 0 }, +{"c.slli", 0, INSN_CLASS_ZCA, "d,C>", MATCH_C_SLLI, MASK_C_SLLI, match_c_slli, 0 }, +{"c.srli", 0, INSN_CLASS_ZCA, "Cs,C>", MATCH_C_SRLI, MASK_C_SRLI, match_c_slli, 0 }, +{"c.srai", 0, INSN_CLASS_ZCA, "Cs,C>", MATCH_C_SRAI, MASK_C_SRAI, match_c_slli, 0 }, +{"c.slli64", 0, INSN_CLASS_ZCA, "d", MATCH_C_SLLI64, MASK_C_SLLI64, match_c_slli64, 0 }, +{"c.srli64", 0, INSN_CLASS_ZCA, "Cs", MATCH_C_SRLI64, MASK_C_SRLI64, match_c_slli64, 0 }, +{"c.srai64", 0, INSN_CLASS_ZCA, "Cs", MATCH_C_SRAI64, MASK_C_SRAI64, match_c_slli64, 0 }, +{"c.andi", 0, INSN_CLASS_ZCA, "Cs,Co", MATCH_C_ANDI, MASK_C_ANDI, match_opcode, 0 }, +{"c.addiw", 64, INSN_CLASS_ZCA, "d,Co", MATCH_C_ADDIW, MASK_C_ADDIW, match_rd_nonzero, 0 }, +{"c.addw", 64, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_ADDW, MASK_C_ADDW, match_opcode, 0 }, +{"c.subw", 64, INSN_CLASS_ZCA, "Cs,Ct", MATCH_C_SUBW, MASK_C_SUBW, match_opcode, 0 }, {"c.ldsp", 32, INSN_CLASS_ZCLSD, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_even_nonzero, INSN_DREF|INSN_8_BYTE }, -{"c.ldsp", 64, INSN_CLASS_C, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_nonzero, INSN_DREF|INSN_8_BYTE }, +{"c.ldsp", 64, INSN_CLASS_ZCA, "d,Cn(Cc)", MATCH_C_LDSP, MASK_C_LDSP, match_rd_nonzero, INSN_DREF|INSN_8_BYTE }, {"c.ld", 32, INSN_CLASS_ZCLSD, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_crs2s_even, INSN_DREF|INSN_8_BYTE }, -{"c.ld", 64, INSN_CLASS_C, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.ld", 64, INSN_CLASS_ZCA, "Ct,Cl(Cs)", MATCH_C_LD, MASK_C_LD, match_opcode, INSN_DREF|INSN_8_BYTE }, {"c.sdsp", 32, INSN_CLASS_ZCLSD, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_crs2_even, INSN_DREF|INSN_8_BYTE }, -{"c.sdsp", 64, INSN_CLASS_C, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.sdsp", 64, INSN_CLASS_ZCA, "CV,CN(Cc)", MATCH_C_SDSP, MASK_C_SDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, {"c.sd", 32, INSN_CLASS_ZCLSD, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_crs2s_even, INSN_DREF|INSN_8_BYTE }, -{"c.sd", 64, INSN_CLASS_C, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_opcode, INSN_DREF|INSN_8_BYTE }, -{"c.fldsp", 0, INSN_CLASS_D_AND_C, "D,Cn(Cc)", MATCH_C_FLDSP, MASK_C_FLDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, -{"c.fld", 0, INSN_CLASS_D_AND_C, "CD,Cl(Cs)", MATCH_C_FLD, MASK_C_FLD, match_opcode, INSN_DREF|INSN_8_BYTE }, -{"c.fsdsp", 0, INSN_CLASS_D_AND_C, "CT,CN(Cc)", MATCH_C_FSDSP, MASK_C_FSDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, -{"c.fsd", 0, INSN_CLASS_D_AND_C, "CD,Cl(Cs)", MATCH_C_FSD, MASK_C_FSD, match_opcode, INSN_DREF|INSN_8_BYTE }, -{"c.flwsp", 32, INSN_CLASS_F_AND_C, "D,Cm(Cc)", MATCH_C_FLWSP, MASK_C_FLWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.flw", 32, INSN_CLASS_F_AND_C, "CD,Ck(Cs)", MATCH_C_FLW, MASK_C_FLW, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.fswsp", 32, INSN_CLASS_F_AND_C, "CT,CM(Cc)", MATCH_C_FSWSP, MASK_C_FSWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, -{"c.fsw", 32, INSN_CLASS_F_AND_C, "CD,Ck(Cs)", MATCH_C_FSW, MASK_C_FSW, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.sd", 64, INSN_CLASS_ZCA, "Ct,Cl(Cs)", MATCH_C_SD, MASK_C_SD, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.fldsp", 0, INSN_CLASS_ZCD, "D,Cn(Cc)", MATCH_C_FLDSP, MASK_C_FLDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.fld", 0, INSN_CLASS_ZCD, "CD,Cl(Cs)", MATCH_C_FLD, MASK_C_FLD, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.fsdsp", 0, INSN_CLASS_ZCD, "CT,CN(Cc)", MATCH_C_FSDSP, MASK_C_FSDSP, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.fsd", 0, INSN_CLASS_ZCD, "CD,Cl(Cs)", MATCH_C_FSD, MASK_C_FSD, match_opcode, INSN_DREF|INSN_8_BYTE }, +{"c.flwsp", 32, INSN_CLASS_ZCF, "D,Cm(Cc)", MATCH_C_FLWSP, MASK_C_FLWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.flw", 32, INSN_CLASS_ZCF, "CD,Ck(Cs)", MATCH_C_FLW, MASK_C_FLW, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.fswsp", 32, INSN_CLASS_ZCF, "CT,CM(Cc)", MATCH_C_FSWSP, MASK_C_FSWSP, match_opcode, INSN_DREF|INSN_4_BYTE }, +{"c.fsw", 32, INSN_CLASS_ZCF, "CD,Ck(Cs)", MATCH_C_FSW, MASK_C_FSW, match_opcode, INSN_DREF|INSN_4_BYTE }, /* Zicbom and Zicboz instructions. */ {"cbo.clean", 0, INSN_CLASS_ZICBOM, "0(s)", MATCH_CBO_CLEAN, MASK_CBO_CLEAN, match_opcode, 0 }, @@ -3664,39 +3664,39 @@ const struct riscv_opcode riscv_insn_types[] = {"j", 0, INSN_CLASS_I, "O4,d,a", 0, 0, NULL, 0 }, {"j", 0, INSN_CLASS_F, "O4,D,a", 0, 0, NULL, 0 }, -{"cr", 0, INSN_CLASS_C, "O2,CF4,d,CV", 0, 0, NULL, 0 }, -{"cr", 0, INSN_CLASS_F_AND_C, "O2,CF4,D,CV", 0, 0, NULL, 0 }, -{"cr", 0, INSN_CLASS_F_AND_C, "O2,CF4,d,CT", 0, 0, NULL, 0 }, -{"cr", 0, INSN_CLASS_F_AND_C, "O2,CF4,D,CT", 0, 0, NULL, 0 }, +{"cr", 0, INSN_CLASS_ZCA, "O2,CF4,d,CV", 0, 0, NULL, 0 }, +{"cr", 0, INSN_CLASS_ZCF, "O2,CF4,D,CV", 0, 0, NULL, 0 }, +{"cr", 0, INSN_CLASS_ZCF, "O2,CF4,d,CT", 0, 0, NULL, 0 }, +{"cr", 0, INSN_CLASS_ZCF, "O2,CF4,D,CT", 0, 0, NULL, 0 }, -{"ci", 0, INSN_CLASS_C, "O2,CF3,d,Co", 0, 0, NULL, 0 }, -{"ci", 0, INSN_CLASS_F_AND_C, "O2,CF3,D,Co", 0, 0, NULL, 0 }, +{"ci", 0, INSN_CLASS_ZCA, "O2,CF3,d,Co", 0, 0, NULL, 0 }, +{"ci", 0, INSN_CLASS_ZCF, "O2,CF3,D,Co", 0, 0, NULL, 0 }, -{"ciw", 0, INSN_CLASS_C, "O2,CF3,Ct,C8", 0, 0, NULL, 0 }, -{"ciw", 0, INSN_CLASS_F_AND_C, "O2,CF3,CD,C8", 0, 0, NULL, 0 }, +{"ciw", 0, INSN_CLASS_ZCA, "O2,CF3,Ct,C8", 0, 0, NULL, 0 }, +{"ciw", 0, INSN_CLASS_ZCF, "O2,CF3,CD,C8", 0, 0, NULL, 0 }, -{"css", 0, INSN_CLASS_C, "O2,CF3,CV,C6", 0, 0, NULL, 0 }, -{"css", 0, INSN_CLASS_F_AND_C, "O2,CF3,CT,C6", 0, 0, NULL, 0 }, +{"css", 0, INSN_CLASS_ZCA, "O2,CF3,CV,C6", 0, 0, NULL, 0 }, +{"css", 0, INSN_CLASS_ZCF, "O2,CF3,CT,C6", 0, 0, NULL, 0 }, -{"cl", 0, INSN_CLASS_C, "O2,CF3,Ct,C5(Cs)", 0, 0, NULL, 0 }, -{"cl", 0, INSN_CLASS_F_AND_C, "O2,CF3,CD,C5(Cs)", 0, 0, NULL, 0 }, -{"cl", 0, INSN_CLASS_F_AND_C, "O2,CF3,Ct,C5(CS)", 0, 0, NULL, 0 }, -{"cl", 0, INSN_CLASS_F_AND_C, "O2,CF3,CD,C5(CS)", 0, 0, NULL, 0 }, +{"cl", 0, INSN_CLASS_ZCA, "O2,CF3,Ct,C5(Cs)", 0, 0, NULL, 0 }, +{"cl", 0, INSN_CLASS_ZCF, "O2,CF3,CD,C5(Cs)", 0, 0, NULL, 0 }, +{"cl", 0, INSN_CLASS_ZCF, "O2,CF3,Ct,C5(CS)", 0, 0, NULL, 0 }, +{"cl", 0, INSN_CLASS_ZCF, "O2,CF3,CD,C5(CS)", 0, 0, NULL, 0 }, -{"cs", 0, INSN_CLASS_C, "O2,CF3,Ct,C5(Cs)", 0, 0, NULL, 0 }, -{"cs", 0, INSN_CLASS_F_AND_C, "O2,CF3,CD,C5(Cs)", 0, 0, NULL, 0 }, -{"cs", 0, INSN_CLASS_F_AND_C, "O2,CF3,Ct,C5(CS)", 0, 0, NULL, 0 }, -{"cs", 0, INSN_CLASS_F_AND_C, "O2,CF3,CD,C5(CS)", 0, 0, NULL, 0 }, +{"cs", 0, INSN_CLASS_ZCA, "O2,CF3,Ct,C5(Cs)", 0, 0, NULL, 0 }, +{"cs", 0, INSN_CLASS_ZCF, "O2,CF3,CD,C5(Cs)", 0, 0, NULL, 0 }, +{"cs", 0, INSN_CLASS_ZCF, "O2,CF3,Ct,C5(CS)", 0, 0, NULL, 0 }, +{"cs", 0, INSN_CLASS_ZCF, "O2,CF3,CD,C5(CS)", 0, 0, NULL, 0 }, -{"ca", 0, INSN_CLASS_C, "O2,CF6,CF2,Cs,Ct", 0, 0, NULL, 0 }, -{"ca", 0, INSN_CLASS_F_AND_C, "O2,CF6,CF2,CS,Ct", 0, 0, NULL, 0 }, -{"ca", 0, INSN_CLASS_F_AND_C, "O2,CF6,CF2,Cs,CD", 0, 0, NULL, 0 }, -{"ca", 0, INSN_CLASS_F_AND_C, "O2,CF6,CF2,CS,CD", 0, 0, NULL, 0 }, +{"ca", 0, INSN_CLASS_ZCA, "O2,CF6,CF2,Cs,Ct", 0, 0, NULL, 0 }, +{"ca", 0, INSN_CLASS_ZCF, "O2,CF6,CF2,CS,Ct", 0, 0, NULL, 0 }, +{"ca", 0, INSN_CLASS_ZCF, "O2,CF6,CF2,Cs,CD", 0, 0, NULL, 0 }, +{"ca", 0, INSN_CLASS_ZCF, "O2,CF6,CF2,CS,CD", 0, 0, NULL, 0 }, -{"cb", 0, INSN_CLASS_C, "O2,CF3,Cs,Cp", 0, 0, NULL, 0 }, -{"cb", 0, INSN_CLASS_F_AND_C, "O2,CF3,CS,Cp", 0, 0, NULL, 0 }, +{"cb", 0, INSN_CLASS_ZCA, "O2,CF3,Cs,Cp", 0, 0, NULL, 0 }, +{"cb", 0, INSN_CLASS_ZCF, "O2,CF3,CS,Cp", 0, 0, NULL, 0 }, -{"cj", 0, INSN_CLASS_C, "O2,CF3,Ca", 0, 0, NULL, 0 }, +{"cj", 0, INSN_CLASS_ZCA, "O2,CF3,Ca", 0, 0, NULL, 0 }, /* Terminate the list. */ {0, 0, INSN_CLASS_NONE, 0, 0, 0, 0, 0} diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index 4c949c4..172c593 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -1302,7 +1302,7 @@ execute_one (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) case INSN_CLASS_ZAAMO: case INSN_CLASS_ZALRSC: return execute_a (cpu, iw, op); - case INSN_CLASS_C: + case INSN_CLASS_ZCA: /* Check whether model with C extension is selected. */ if (riscv_cpu->csr.misa & 4) return execute_c (cpu, iw, op); |