Commit Graph

10369 Commits

Author SHA1 Message Date
liuzhensong
2cb10f02b0 LoongArch: Add testcases for new relocate types.
gas/testsuite/gas/all/
    gas.exp
  gas/testsuite/gas/loongarch/
    jmp_op.d
    jmp_op.s
    macro_op.d
    macro_op.s
    macro_op_32.d
    macro_op_32.s
    macro_op_large_abs.d
    macro_op_large_abs.s
    macro_op_large_pc.d
    macro_op_large_pc.s
    reloc.d
    reloc.s

  ld/testsuite/ld-elf/
    pr26936.d
    shared.exp
  ld/testsuite/ld-loongarch-elf/
    attr-ifunc-4.c
    attr-ifunc-4.out
    disas-jirl.d
    ifunc.exp
    jmp_op.d
    jmp_op.s
    libnopic-global.s
    macro_op.d
    macro_op.s
    macro_op_32.d
    macro_op_32.s
    nopic-global-so.rd
    nopic-global-so.sd
    nopic-global.out
    nopic-global.s
    nopic-global.sd
    nopic-global.xd
    nopic-local.out
    nopic-local.rd
    nopic-local.s
    nopic-local.sd
    nopic-local.xd
    nopic-weak-global-so.rd
    nopic-weak-global-so.sd
    nopic-weak-global.out
    nopic-weak-global.s
    nopic-weak-global.sd
    nopic-weak-global.xd
    nopic-weak-local.out
    nopic-weak-local.rd
    nopic-weak-local.s
    nopic-weak-local.sd
    nopic-weak-local.xd
    pic.exp
    pic.ld
2022-07-25 09:59:08 +08:00
liuzhensong
f09482a874 LoongArch: gas: Add new reloc types.
Generate new relocate types while use new macro insns.

  gas/config/
    loongarch-lex.h
    loongarch-parse.y
    tc-loongarch.c
    tc-loongarch.h
2022-07-25 09:59:08 +08:00
Jan Beulich
987e8a90fa x86/Intel: correct AVX512F scatter insn element sizes
I clearly screwed up in 6ff00b5e12 ("x86/Intel: correct permitted
operand sizes for AVX512 scatter/gather") giving all AVX512F scatter
insns Dword element size. Update testcases (also their gather parts),
utilizing that there previously were two identical lines each (for no
apparent reason).
2022-07-21 12:32:04 +02:00
Alan Modra
e4e340a3ff PR29390, DW_CFA_AARCH64_negate_ra_state vs. DW_CFA_GNU_window_save
PR 29390
binutils/
	* dwarf.c (is_aarch64, DW_CFA_GNU_window_save_name): New.
	(display_debug_frames): Use them.
	(init_dwarf_regnames_aarch64): Set is_aarch64.
	(init_dwarf_regnames_by_elf_machine_code): Clear is_aarch64.
	(init_dwarf_regnames_by_bfd_arch_and_mach): Likewise.
gas/
	* testsuite/gas/aarch64/pac_ab_key.d: Adjust expected output.
	* testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise.
2022-07-21 16:37:06 +09:30
Dmitry Selyutin
ffd29c9c21 gas/symbols: introduce md_resolve_symbol
Assuming GMSD is a special operand, marked as O_md1, the code:

    .set VREG, GMSD
    .set REG, VREG
    extsw REG, 2

...fails upon attempts to resolve the value of the symbol. This happens
since machine-dependent values are not handled in the giant op switch.
We introduce a custom md_resolve_symbol macro; the ports can use this
macro to customize the behavior when resolve_symbol_value hits O_md
operand.
2022-07-20 12:20:14 +09:30
Claudiu Zissulescu
5154216259 arc: Update missing cipher.
The ciphers 5,7, and 9 are missing when parsing an assembly
instruction leading to errors when those ciphers are
used.

gas/config
	* tc-arc.c (md_assembly): Update strspn string with the
          missing ciphers.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2022-07-18 14:25:31 +03:00
Jan Beulich
7e864bf71d x86: correct VMOVSH attributes
Both forms were missing VexW0 (thus allowing Evex.W=1 to be encoded by
suitable means, which would cause #UD). The memory operand form further
was using the wrong Masking value, thus allowing zeroing-masking to be
encoded for the store form (which would again cause #UD).
2022-07-18 11:20:44 +02:00
Alan Modra
5f6c92298a Re: PowerPC: implement md_operand to parse register names
I meant to make this change before committing, to let compilers know
the code on the false branch of md_parse_name is dead.

	* config/tc-ppc.c (ppc_parse_name): Return void.
	* config/tc-ppc.h (md_parse_name): Always true.
	(ppc_parse_name): Update prototype.
2022-07-14 15:25:18 +09:30
Alan Modra
00b37cc41e PowerPC: implement md_operand to parse register names
Allows register names to appear in symbol assignments, so for example
 tocp = %r2
 mr %r3,tocp
now assembles.

	* gas/config/tc-ppc.c (REG_NAME_CNT): Delete, replace uses with
	ARRAY_SIZE.
	(register_name): Rename to..
	(md_operand): ..this.  Only handle %reg.
	(cr_names): Rename to..
	(cr_cond): ..this.  Just keep conditions.
	(ppc_parse_name): Add mode param.  Search both cr_cond and
	pre_defined_registers.  Handle absolute and register symbol
	values here rather than in expr.c:operand().
	(md_assemble): Don't special case register name matching in
	operands, except to set cr_operand as appropriate.
	* gas/config/tc-ppc.h (md_operand): Don't define.
	(md_parse_name, ppc_parse_name): Update.
	* read.c (pseudo_set): Copy over entire O_register value.
	* testsuite/gas/ppc/regsyms.d.
	* testsuite/gas/ppc/regsyms.s: New test.
	* testsuite/gas/ppc/ppc.exp: Run it.
2022-07-14 11:58:40 +09:30
Alan Modra
a14413ddff PowerPC md_end: Don't htab_delete(NULL)
It might be possible to hit md_end before md_begin is called, don't
segfault if so.  Also, remove a useless check.

	* gas/config/tc-ppc.c (insn_calloc): Remove needless overflow
	check.
	(ppc_md_end): Check ppc_hash before deleting.  Clear ppc_hash.
2022-07-12 12:05:28 +09:30
Alan Modra
eb6dce11fc gas: tc-tic54x.c hash tables
Cleaning up the subsym_hash memory is a real pain.  Keys and values
entered into the table are quite diverse.  In some cases the key is
allocated and thus needs to be freed, in others the key is a const
string.  Values are similar, and in some cases not even a string.
Tidy this by inserting a new subsym_ent_t that describes key/value
type.  This meant the math_hash table was no longer needed.  The patch
also tidies how math functions are called, those that are supposed to
return int now no longer return their value in a float.

	* config/tc-tic54x.c (math_hash): Delete.
	(subsym_proc_entry): Move earlier, make proc a union, merge with..
	(math_proc_entry): ..this.  Delete type.
	(math_procs): Merge into subsym_procs.
	(subsym_ent_t): New.  Use this type in subsym_hash..
	(stag_add_field_symbols, tic54x_var, tic54x_macro_info): ..here..
	(md_begin, subsym_create_or_replace, subsym_lookup): ..and here..
	(subsym_substitute): ..and here.  Adjust subsym_proc_entry
	function calls.  Free replacement when not returned.
	(subsym_get_arg): Adjust subsym_lookup.
	(free_subsym_ent, subsym_htab_create ): New functions, use when
	creating subsym_hash.
	(free_local_label_ent, local_label_htab_create): Similarly.
	(tic54x_remove_local_label): Delete.
	(tic54x_clear_local_labels): Simplify.
	(tic54x_asg): Use notes obstack to dup strings.
	(tic54x_eval): Likewise.
	(subsym_ismember): Likewise.
	(math_cvi, math_int, math_sgn): Return int.
	(tic54x_macro_start): Decrement macro_level before calling as_fatal.
	(tic54x_md_end): New function.
	* config/tc-tic54h.c (tic54x_md_end): Declare.
	(md_end): Define.
2022-07-09 21:48:02 +09:30
Alan Modra
0edfd2985b gas: use notes_calloc in string hash
Using notes_calloc means all of the string hash table memory should
now be freed before gas exits, even though htab_delete isn't called.
This also means that the hash table free_f and del_f must be NULL,
because freeing notes obstack memory results in all more recently
allocated notes memory being freed too.  So hash table resizing won't
free any memory, and will be a little faster.  Also, htab_delete won't
do anything (and be quick about it).

Since htab_traverse can also resize hash tables (to make another
traversal faster if the table is largely empty), stop that happening
when only one traversal is done.

	* as.h: Reorder hash.h after symbols.h for notes_calloc decl.
	* hash.h (str_htab_create): Use notes_calloc.  Do not free.
	* symbols.c (resolve_local_symbol_values): Don't resize
	during hash table traversal.
	* config/obj-elf.c (elf_frob_file_after_relocs): Likewise.
	* config/tc-ia64.c (ia64_adjust_symtab, ia64_frob_file): Likewise.
	* config/tc-nds32.c (nds32_elf_analysis_relax_hint): Likewise.
2022-07-09 21:47:24 +09:30
Alan Modra
7bfc4db289 gas: target string hash tables
This allocates entries added to the string hash tables on the notes
obstack, so that at least those do not leak.  A followup patch will
switch over the str_hash allocation to notes_calloc, which is why I
haven't implemented deleting all the target string hash tables.

	* config/obj-coff-seh.c (get_pxdata_name, alloc_pxdata_item): Use
	notes obstack for string hash table entries.
	* config/tc-alpha.c (get_alpha_reloc_tag, md_begin): Likewise.
	* config/tc-h8300.c (md_begin): Likewise.
	* config/tc-ia64.c (dot_rot, dot_pred_rel, dot_alias): Likewise.
	* config/tc-nds32.c (nds32_relax_hint): Likewise.
	* config/tc-riscv.c (riscv_init_csr_hash): Likewise.
	* config/tc-score.c (s3_insert_reg): Likewise.
	(s3_build_score_ops_hsh, s3_build_dependency_insn_hsh): Likewise.
	* config/tc-score7.c (s7_build_score_ops_hsh): Likewise.
	(s7_build_dependency_insn_hsh): Likewise.
	* config/tc-tic4x.c (tic4x_asg): Likewise.
2022-07-09 21:36:10 +09:30
Alan Modra
a51628a9d4 arc gas: don't leak arc_opcode_hash memory
The arc opcode hash table has entries that have a realloc'd field.
This doesn't lend itself to obstack allocation, so freeing must be
done with a purpose built hashtab del_f.

	* config/tc-arc.c (arc_opcode_free): New function.
	(md_begin): Pass the above as del_f to htab_create_alloc.
	(arc_md_end): New function.
	* config/tc-arc.h (arc_md_end): Declare.
	(md_end): Define.
2022-07-09 21:35:15 +09:30
Alan Modra
654d6f31a6 i386 gas: don't leak op_hash or reg_hash memory
This tidies memory used by the two x86 gas string hash tables before
exiting.  I'm using a two-pronged approach, firstly the obvious call
to htab_delete plus telling the libiberty/hashtab.c infrastructure to
free tuples generated by str_hash_insert, and secondly putting the x86
core_optab memory on the notes obstack.  It would be possible to free
core_optab memory by using a custom hash table del_f on x86, as I do
for arc, but a later patch will move all the string hash memory to the
notes obstack.

	* config/tc-i386.c (md_begin): Use notes_alloc for core_optab.
	(386_md_end): New function.
	* config/tc-i386.h (386_md_end): Declare.
	(md_end): Define.
	* hash.h (str_htab_create): Pass free as del_f.
2022-07-09 21:35:02 +09:30
Alan Modra
a887be6996 ppc gas: don't leak ppc_hash memory
* config/tc-ppc.c (insn_obstack): New.
	(insn_calloc): New function.
	(ppc_setup_opcodes): Use insn_obstack for ppc_hash.
	(ppc_md_end): New function.
	* config/tc-ppc.h (ppc_md_end): Declare
	(md_end): Define.
2022-07-09 21:34:10 +09:30
Alan Modra
1309c3165c gas hash.h tidy
Only inline functions should be defined in hash.h, there's no benefit
in having multiple copies of hash_string_tuple and eq_string_tuple.
Also, use the table alloc_f when allocating tuples to be stored, so
that these functions are usable with different memory allocation
strategies.

	* hash.h (struct string_tuple, string_tuple_t): Move earlier.
	(string_tuple_alloc): Add table param, allocate using table alloc_f.
	(str_hash_insert): Adjust to suit.  Call table->free_f when
	entry is not used.
	(hash_string_tuple, eq_string_tuple): Move to..
	* hash.c: ..here.
2022-07-09 21:33:49 +09:30
Alan Modra
ed2917de68 gas: rename md_end to md_finish
Currently md_end is typically used for some final actions rather than
freeing memory like other *_end functions.  Rename it to md_finish,
and rename target implementation.  The renaming of target functions
makes it possible to find them all with "grep md_finish",
eg. md_mips_end is renamed to mips_md_finish, not md_mips_finish.
This patch leaves a number of md_end functions unchanged, those that
either do nothing or deallocate memory, and calls them late.

The idea here is that target maintainers implement md_end functions to
tidy memory, if anyone cares.  Freeing persistent memory in gas is
not at all important, except that it can hide more important memory
leaks, those that happen once per some frequent gas operation, amongst
these unimportant memory leaks.

	* as.c (main): Rename md_end to md_finish.
	* config/tc-alpha.c, * config/tc-alpha.h,
	* config/tc-arc.c, * config/tc-arc.h,
	* config/tc-arm.c, * config/tc-arm.h,
	* config/tc-csky.c, * config/tc-csky.h,
	* config/tc-ia64.c, * config/tc-ia64.h,
	* config/tc-mcore.c, * config/tc-mcore.h,
	* config/tc-mips.c, * config/tc-mips.h,
	* config/tc-mmix.c, * config/tc-mmix.h,
	* config/tc-msp430.c, * config/tc-msp430.h,
	* config/tc-nds32.c, * config/tc-nds32.h,
	* config/tc-ppc.c, * config/tc-ppc.h,
	* config/tc-pru.c, * config/tc-pru.h,
	* config/tc-riscv.c, * config/tc-riscv.h,
	* config/tc-s390.c, * config/tc-s390.h,
	* config/tc-sparc.c, * config/tc-sparc.h,
	* config/tc-tic4x.c, * config/tc-tic4x.h,
	* config/tc-tic6x.c, * config/tc-tic6x.h,
	* config/tc-v850.c, * config/tc-v850.h,
	* config/tc-xtensa.c, * config/tc-xtensa.h,
	* config/tc-z80.c, * config/tc-z80.h: Similarly.
	* output-file.c (output_file_close): Call md_end.
2022-07-09 21:23:00 +09:30
Alan Modra
af3d7ab74f gas: set up notes obstack earlier
So that the notes obstack can be used for persistent storage in
parse_args.

	* as.c (parse_args): Use notes_alloc and notes_strdup.
	(free_notes): New function.
	(main): Init notes obstack, and arrange to be freed on exit.
	* read.c (read_begin): Don't init notes obstack.
	(read_end): Free cond_obstack.
	* subsegs.c (subsegs_end): Don't free cond_obstack or notes.
2022-07-09 21:22:51 +09:30
Alan Modra
f1307e43df gas: itbl_files
itbl_files seems to be debug code.  Get rid of it.

	* as.c (struct itbl_file_list): Delete.
	(itbl_files): Delete.
	(parse_args): Don't keep itbl_files list.
2022-07-09 21:22:39 +09:30
Alan Modra
b18220936c gas: free sy_hash, macro_hash and po_hash
* macro.c (macro_end): New function.
	* macro.h (macro_end): Declare.
	* read.c (read_end, poend): New functions.
	* read.h (read_end): Declare.
	* symbols.c (symbol_end): New function.
	* symbols.h (symbol_end): Declare.
	* output-file.c (output_file_close): Call new *_end functions.
2022-07-09 21:22:28 +09:30
Alan Modra
5a210b9fe8 dw2gencfi.c: use notes obstack
Use notes obstack for dwcfi_hash entries, and free table.  Freeing the
table makes memory checkers complain more about "definitely lost"
memory as we've moved some from the "still reachable" category.
That will be fixed with a later patch.

	* dw2gencfi.c (get_debugseg_name): Allocate on notes obstack.
	(alloc_debugseg_item): Likewise.
	(dwcfi_hash_find_or_make): Adjust failure path free.
	(cfi_finish): Delete dwfci_hash.
2022-07-09 21:22:10 +09:30
Alan Modra
951e757db6 expr.c make_expr_symbol: use notes obstack
* expr.c (make_expr_symbol): Use notes_alloc.
2022-07-09 21:22:03 +09:30
Alan Modra
714ccdeb99 read.c assign_symbol: use notes obstack for dummy listing frag
* read.c (assign_symbol): Use notes_calloc for dummy_frag.
2022-07-09 21:21:56 +09:30
Alan Modra
825816f1cc read.c s_include: use notes obstack for path
* read.c (s_include): Use notes obstack for path mem.
2022-07-09 21:21:48 +09:30
Alan Modra
bdcc1de1ec macro.c: use string hash from hash.h for macro_hash
Another case of duplicated hash.h code, the only minor difference
being that macro->format_hash was created with 7 entries vs. str_hash
with 16 entries.

	* macro.c (macro_init, define_macro): Use str_htab_create.
	(do_formals, define_macro, macro_expand_body): Use str_hash_insert
	(macro_expand_body): Use str_hash_find and str_hash_delete.
	(delete_macro): Likewise.
	(sub_actual, macro_expand, check_macro): Use str_hash_find.
	(expand_irp): Use str_htab_create and str_hash_insert.
	* macro.h (struct macro_struct): Tidy.
	(struct macro_hash_entry, macro_hash_entry_t, hash_macro_entry),
	(eq_macro_entry, macro_entry_alloc, macro_entry_find),
	(struct formal_hash_entry, formal_hash_entry_t),
	(hash_formal_entry, eq_formal_entry, formal_entry_alloc),
	(formal_entry_find): Delete.
	* config/tc-iq2000.c (iq2000_add_macro): Use str_htab_create
	and str_hash_insert.
2022-07-09 21:21:36 +09:30
Alan Modra
d1cffdc364 read.c: use string hash from hash.h for po_hash
po_hash code duplicates the str_hash code in hash.h for no good reason.

	* read.c (struct po_entry, po_entry_t): Delete.
	(hash_po_entry, eq_po_entry, po_entry_alloc, po_entry_find): Delete.
	(pop_insert): Use str_hash_insert.
	(pobegin): Use str_htab_create.
	(read_a_source_file, s_macro): Use str_hash_find.
2022-07-09 21:21:23 +09:30
Alan Modra
9f6e589719 free read_symbol_name string
read_symbol_name mallocs the string it returns.  Free it when done.

	* read.c (read_symbol_name): Free name on error path.
	* config/tc-ppc.c (ppc_GNU_visibility): Free name returned from
	read_symbol_name.
	(ppc_extern, ppc_globl, ppc_weak): Likewise.
2022-07-09 21:20:52 +09:30
Alan Modra
07e64e0b7c gas: output_file_close
This is mostly a tidy with the aim of being able to free
out_file_name, but it does fix a possible attempt to unlink the output
file twice (not that that matters).

	* as.h (keep_it): New global.
	* as.c (keep_it): Delete.
	(close_output_file): Delete, merged into..
	* output-file.c (output_file_close): ..here.  Delete parameter.
	* output-file.h (output_file_close): Update prototype.
2022-07-09 21:20:31 +09:30
Alan Modra
c30081c1f9 gas: utility notes memory alloc functions
Makes it a little easier to use the notes obstack for persistent
storage.

	* as.h (gas_mul_overflow): Define.
	* symbols.h (notes_alloc, notes_calloc, notes_memdup),
	(notes_strdup, notes_concat, notes_free): Declare.
	* symbols.c (notes_alloc, notes_calloc, notes_memdup),
	(notes_strdup, notes_concat, notes_free): New functions.
	(save_symbol_name): Use notes_strdup.
	(symbol_create, local_symbol_make, local_symbol_convert),
	(symbol_clone, decode_local_label_name): Use notes_alloc.
2022-07-09 21:15:30 +09:30
Alan Modra
d3be5dab55 gas: arm -mwarn-syms duplicates
arm gas is only supposed to warn once per symbol for -mwarn-syms, but
doesn't because the str_hash_find added with commit 629310abec
always returns NULL.  That's so because the str_hash_insert inserts a
NULL value for the key,value pair.  Let str_hash_insert do the job
instead.

	* config/tc-arm.c (arm_tc_equal_in_insn): Correct already_warned
	logic.
	* testsuite/gas/arm/pr18347.s: Modify to generate duplicate
	warning without this patch.
2022-07-09 21:00:09 +09:30
Alan Modra
b95830931f Regenerate with automake-1.15.1
Until we update the recommended versions of autoconf/automake, files
should be regenerated with automake-1.15.1 and autoconf-2.69.  That's
not because we think those versions are golden, and newer versions are
bad.  It's simply because maintainers want to be able to update
configury files without trouble, and if someone regenerates files with
automake-1.16.5 then --enable-maintainer-mode builds will hit errors:

checking that generated files are newer than configure... configure.ac:26: error: version mismatch.  This is Automake 1.15.1,
configure.ac:26: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:26: comes from Automake 1.16.5.  You should recreate
configure.ac:26: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.15' is probably too old.

Correcting this requires regenerating the files by hand.
2022-07-09 20:10:47 +09:30
Nick Clifton
631ec08cb1 Update version to 2.39.50 and regenerate files 2022-07-08 11:19:44 +01:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
Tsukasa OI
045f385d9a RISC-V: Added Zfhmin and Zhinxmin.
This commit adds Zfhmin and Zhinxmin extensions (subsets of Zfh and
Zhinx extensions, respectively).  In the process supporting Zfhmin and
Zhinxmin extension, this commit also changes how instructions are
categorized considering Zfhmin, Zhinx and Zhinxmin extensions.

Detailed changes,

* From INSN_CLASS_ZFH to INSN_CLASS_ZFHMIN:

flh, fsh, fmv.x.h and fmv.h.x.

* From INSN_CLASS_ZFH to INSN_CLASS_ZFH_OR_ZHINX:

fmv.h.

* From INSN_CLASS_ZFH_OR_ZHINX to INSN_CLASS_ZFH_OR_ZHINX:

fneg.h, fabs.h, fsgnj.h, fsgnjn.h, fsgnjx.h,
fadd.h, fsub.h, fmul.h, fdiv.h, fsqrt.h, fmin.h, fmax.h,
fmadd.h, fnmadd.h, fmsub.h, fnmsub.h,
fcvt.w.h, fcvt.wu.h, fcvt.h.w, fcvt.h.wu,
fcvt.l.h, fcvt.lu.h, fcvt.h.l, fcvt.h.lu,
feq.h, flt.h, fle.h, fgt.h, fge.h,
fclass.h.

* From INSN_CLASS_ZFH_OR_ZHINX to INSN_CLASS_ZFHMIN_OR_ZHINXMIN:

fcvt.s.h and fcvt.h.s.

* From INSN_CLASS_D_AND_ZFH_INX to INSN_CLASS_ZFHMIN_AND_D:

fcvt.d.h and fcvt.h.d.

* From INSN_CLASS_Q_AND_ZFH_INX to INSN_CLASS_ZFHMIN_AND_Q:

fcvt.q.h and fcvt.h.q.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Change implicit
	subsets.  Zfh->Zicsr is not needed and Zfh->F is replaced with
	Zfh->Zfhmin and Zfhmin->F.  Zhinx->Zicsr is not needed and
	Zhinx->Zfinx is replaced with Zhinx->Zhinxmin and
	Zhinxmin->Zfinx.
	(riscv_supported_std_z_ext): Added zfhmin and zhinxmin.
	(riscv_multi_subset_supports):  Rewrite handling for new
	instruction classes.
	(riscv_multi_subset_supports_ext): Updated.
	(riscv_parse_check_conflicts): Change error message to include
	zfh and zfhmin extensions.

gas/ChangeLog:

	* testsuite/gas/riscv/zfhmin-d-insn-class-fail.s: New complex
	error handling test.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-1.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-1.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-2.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-2.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-3.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-3.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-4.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-4.l: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-5.d: Likewise.
	* testsuite/gas/riscv/zfhmin-d-insn-class-fail-5.l: Likewise.
	* testsuite/gas/riscv/zhinx.d: Renamed from fp-zhinx-insns.d
	and refactored.
	* testsuite/gas/riscv/zhinx.s: Likewise.

include/ChangeLog:

	* opcode/riscv.h (enum riscv_insn_class): Removed INSN_CLASS_ZFH,
	INSN_CLASS_D_AND_ZFH_INX and INSN_CLASS_Q_AND_ZFH_INX.  Added
	INSN_CLASS_ZFHMIN, INSN_CLASS_ZFHMIN_OR_ZHINXMIN,
	INSN_CLASS_ZFHMIN_AND_D and INSN_CLASS_ZFHMIN_AND_Q.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Change instruction classes for
	Zfh and Zfhmin instructions.  Fix `fcvt.h.lu' instruction
	(two operand variant) mask.
2022-07-07 16:23:54 +08:00
Tsukasa OI
3d5d6bd554 RISC-V: Fix disassembling Zfinx with -M numeric
This commit fixes floating point operand register names from ABI ones
to dynamically set ones.

gas/ChangeLog:

	* testsuite/gas/riscv/zfinx-dis-numeric.s: Test new behavior of
	Zfinx extension and -M numeric disassembler option.
	* testsuite/gas/riscv/zfinx-dis-numeric.d: Likewise.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_disassemble_insn): Use dynamically set GPR
	names to disassemble Zfinx instructions.
2022-07-07 12:06:02 +08:00
Tsukasa OI
37cf60c6a6 RISC-V: Fix requirement handling on Zhinx+{D,Q}
This commit fixes how instructions are masked on Zhinx+Z{d,q}inx.
fcvt.h.d and fcvt.d.h require ((D&&Zfh)||(Zdinx&&Zhinx)) and
fcvt.h.q and fcvt.q.h require ((Q&&Zfh)||(Zqinx&&Zhinx)).

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Fix feature gate
	on INSN_CLASS_{D,Q}_AND_ZFH_INX.
	(riscv_multi_subset_supports_ext): Fix feature gate diagnostics
	on INSN_CLASS_{D,Q}_AND_ZFH_INX.

gas/ChangeLog:

	* testsuite/gas/riscv/fp-zhinx-insns.d: Add Zqinx to -march
	for proper testing.
2022-07-07 12:05:56 +08:00
Alan Modra
9b5ebf652b PR29320, 'struct obstack' declared inside parameter list
PR 29320
	* frags.h: Move declaration of struct obstack..
	* as.h: ..to here.
2022-07-07 11:52:05 +09:30
Jan Beulich
8bd915b770 x86: make D attribute usable for XOP and FMA4 insns
This once again allows to reduce redundancy in (and size of) the opcode
table.

Don't go as far as also making D work on the two 5-operand XOP insns:
This would significantly complicate the code, as there the first
(immediate) operand would need special treatment in several places.

Note that the .s suffix isn't being enabled to have any effect, for
being deprecated. Whereas neither {load} nor {store} pseudo prefixes
make sense here, as the respective operands are inputs (loads) only
anyway, regardless of order. Hence there is (as before) no way for the
programmer to request the alternative encoding to be used for register-
only insns.

Note further that it is always the first original template which is
retained (and altered), to make sure the same encoding as before is
used for register-only insns. This has the slightly odd (but pre-
existing) effect of XOP register-only insns having XOP.W clear, but FMA4
ones having VEX.W set.
2022-07-06 15:40:04 +02:00
Jan Beulich
3d0738af2a x86: fold two switch() statements in match_template()
I don't see why two of them were introduced (very long ago) using
similar fall-through logic.
2022-07-06 15:39:37 +02:00
Jan Beulich
c975cec5ff x86: fix 3-operand insn reverse-matching
The middle operand would have gone entirely unchecked, allowing e.g.

	vmovss		%xmm0, %esp, %xmm2

to assemble successfully, or e.g.

	vmovss		%xmm0, $4, %xmm2

causing an internal error. Alongside dealing with this also drop a
related comment, which hasn't been applicable anymore since the
introduction of 3-operand patterns with D set (and which perhaps never
had been logical to be there, as reverse-matched insns don't make it
there in the first place).
2022-07-06 15:39:03 +02:00
Jan Beulich
f68697e823 x86: introduce a state stack for .arch
When using just slightly non-trivial combinations of .arch, it can be
quite useful to be able to go back to prior state without needing to
re-invoke perhaps many earlier directives and without needing to invoke
perhaps many "negative" ones. Like some other architectures allow
saving (pushing) and restoring (popping) present/prior state.

For now require the same .code<N> to be in effect for ".arch pop" that
was in effect for the corresponding ".arch push".

Also change the global "no_cond_jump_promotion" to be bool, to match the
new struct field.
2022-07-06 09:22:47 +02:00
Jan Beulich
ae89daecb1 x86: generalize disabling of sub-architectures
I never really understood upon what basis ".arch .no*" options were made
available. Let's not have any "criteria" at all, and simply allow
disabling of all of them. Then we also have all data for a sub-arch in
a single place, as we now only need a single table.
2022-07-06 09:22:11 +02:00
Jan Beulich
3ce2ebcf88 x86: permit "default" with .arch
So far there was no way to reset the architecture to that assembly would
start with in the absence of any overrides (command line or directives).
Note that for Intel MCU "default" is merely an alias of "iamcu".

While there also zap a stray @item from the doc section, as noticed
when inspecting the generated output (which still has some quirks, but
those aren't easy to address without re-flowing almost the entire
section).
2022-07-06 09:21:40 +02:00
Jan Beulich
d92c7521f9 x86: don't leak sub-architecture accumulated strings
While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.
2022-07-06 09:20:29 +02:00
Jan Beulich
c368d2a802 x86: introduce fake processor type to mark sub-arch entries in cpu_arch[]
This is in preparation of dropping the leading . from the strings.

While there also move PROCESSOR_GENERIC{32,64} from the middle of AMD
entries to near the top.
2022-07-05 08:40:39 +02:00
Jan Beulich
6ceeed2506 x86: macro-ize cpu_arch[] entries
Putting individual elements behind macros, besides (imo) improving
readability, will make subsequent (and likely also future) changes less
intrusive.

Utilize this right away to pack the table a little more tightly, by
converting "skip" to bool and putting it earlier in a group of bitfields
together with "len".
2022-07-05 08:40:09 +02:00
Jan Beulich
8180707f90 x86: de-duplicate sub-architecture strings accumulation
Introduce a helper function to replace 4 instances of similar code. Use
reconcat() to cover the previously explicit free().
2022-07-05 08:39:43 +02:00
Alan Modra
eeeaf705fe alloc gas seginfo on notes obstack
Lots of memory used in gas should go on this obstack.  The patch also
frees all the gas obstacks on exit, which isn't a completely trivial
task.

	* subsegs.c (alloc_seginfo): New function.
	(subseg_change, subseg_get): Use it.
	(subsegs_end): New function.
	* as.h (subsegs_end): Declare.
	* output-file.c: Include subsegs.h
	(stash_frchain_obs): New function.
	(output_file_close): Save obstacks attached to output bfd before
	closing.  Call subsegs_end with the array of obstacks.
2022-07-04 22:51:56 +09:30
Jan Beulich
58098fd779 gas/testsuite: properly exclude aout in all/weakref1u
Use the (wider) predicate rather than a triplet. This eliminates the sole
i386-msdos failure in the testsuite.
2022-07-04 08:42:10 +02:00