Commit Graph

14 Commits

Author SHA1 Message Date
Lulu Cai
21455a847d LoongArch: Discard extra spaces in objdump output
Due to the formatted output of objdump, some instructions
that do not require output operands (such as nop/ret) will
have extra spaces added after them.

Determine whether to output operands through the format
of opcodes. When opc->format is an empty string, no extra
spaces are output.
2024-01-11 14:08:24 +08:00
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
Lulu Cai
98712e137e Add support for ilp32 register alias. 2023-11-10 14:45:09 +08:00
mengqinggang
071726dee7 LoongArch: gas: Add LVZ and LBT instructions support
gas/ChangeLog:
	* config/tc-loongarch.c (md_parse_option): Add LARCH_opts.ase_lvz and
	LARCH_opts.ase_lbt.
	* testsuite/gas/loongarch/uleb128.d: Regenerated.
	* testsuite/gas/loongarch/lvz-lbt.d: New test.
	* testsuite/gas/loongarch/lvz-lbt.s: New test.

include/ChangeLog:
	* opcode/loongarch.h (ase_lvz): New.
	(ase_lbt): New.

opcodes/ChangeLog:
	* loongarch-dis.c (set_default_loongarch_dis_options): Add
	LARCH_opts.ase_lvz and LARCH_opts.ase_lbt.
	* loongarch-opc.c (struct loongarch_ase): Add LVZ and LBT instructions.
2023-06-30 17:32:28 +08:00
WANG Xuerui
6ad6615a79 opcodes/loongarch: print unrecognized insn words with the .word directive
For better round-trip fidelity and readability in general.

gas/ChangeLog:

	* testsuite/gas/loongarch/uleb128.d: Update test case.
	* testsuite/gas/loongarch/raw-insn.d: New test.
	* testsuite/gas/loongarch/raw-insn.s: Likewise.

opcodes/ChangeLog:

	* loongarch-dis.c (disassemble_one): Print ".word" if !opc.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:18:02 +08:00
WANG Xuerui
8b6fefadde opcodes/loongarch: do not print hex notation for signed immediates
The additional hex notation was minimally useful when one had to
inspect code with heavy bit manipulation, or of unclear signedness, but
it clutters the output, and the style is not regular assembly language
syntax either.

Precisely how one approaches the original use case is not taken care of
in this patch (maybe we want a disassembler option forcing a certain
style for immediates, like for example printing every immediate in
decimal or hexadecimal notation), but at least let's stop the current
practice.

ChangeLog:

	* testsuite/gas/loongarch/imm_ins.d: Update test case.
	* testsuite/gas/loongarch/imm_ins_32.d: Likewise.
	* testsuite/gas/loongarch/imm_op.d: Likewise.
	* testsuite/gas/loongarch/jmp_op.d: Likewise.
	* testsuite/gas/loongarch/load_store_op.d: Likewise.
	* testsuite/gas/loongarch/macro_op.d: Likewise.
	* testsuite/gas/loongarch/macro_op_32.d: Likewise.
	* testsuite/gas/loongarch/privilege_op.d: Likewise.
	* testsuite/gas/loongarch/uleb128.d: Likewise.
	* testsuite/gas/loongarch/vector.d: Likewise.

ld/ChangeLog:

	* testsuite/ld-loongarch-elf/jmp_op.d: Update test case.
	* testsuite/ld-loongarch-elf/macro_op.d: Likewise.
	* testsuite/ld-loongarch-elf/macro_op_32.d: Likewise.

opcodes/ChangeLog:

	* loongarch-dis.c (dis_one_arg): Remove the "(0x%x)" part from
	disassembly output of signed immediate operands.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:18:01 +08:00
WANG Xuerui
d04d3bb4a7 opcodes/loongarch: style disassembled address offsets as such
Add a modifier char 'o' telling the disassembler to print the immediate
using the address offset style, and mark the memory access instructions'
offset operands as such.

opcodes/ChangeLog:

	* loongarch-dis.c (dis_one_arg): Style disassembled address
	offsets as such when the operand has a modifier char 'o'.
	* loongarch-opc.c: Add 'o' to operands that represent address
	offsets.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:18:00 +08:00
WANG Xuerui
1b9ea633cb opcodes/loongarch: implement style support in the disassembler
Update the LoongArch disassembler to supply style information to the
disassembler output. The output formatting remains unchanged.

opcodes/ChangeLog:

	* disassemble.c: Mark LoongArch as created_styled_output=true.
	* loongarch-dis.c (dis_one_arg): Use fprintf_styled_func
	throughout with proper styles.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:17:59 +08:00
WANG Xuerui
22be1ca342 opcodes/loongarch: remove unused code
Remove some unused declarations and code.

include/ChangeLog:

	* opcode/loongarch.h: Remove unused declarations.

opcodes/ChangeLog:

	* loongarch-dis.c (loongarch_parse_dis_options): Remove.
	(my_print_address_func): Likewise.
	(loongarch_disassemble_one): Likewise.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:17:58 +08:00
WANG Xuerui
17f9439038 LoongArch: support disassembling certain pseudo-instructions
Add a flag in the pinfo field for being able to mark certain specialized
matchers as disassembler-only, so some degree of isolation between
assembler-side and disassembler-side can be achieved.

This isolation is necessary, firstly because some pseudo-instructions
cannot be fully described in the opcode table, like `li.[wd]`, so the
corresponding opcode entry cannot have meaningful match/mask values.
Secondly, some of these pseudo-instructions can be realized in more than
one plausible ways; e.g. `li.w rd, <something between 0 and 0x7ff>` can
be realized on LA64 with any of `addi.w`, `addi.d` or `ori`. If we tie
disassembly of such aliases with the corresponding GAS support, only one
canonical form among the above would be recognized as `li.w`, and it
would mildly impact the readability of disassembly output.
People wanting the exact disassembly can always set `-M no-aliases` to
get the original behavior back.

In addition, in certain cases, information is irreversibly lost after
assembling, so perfect round-trip would not be possible in such cases.
For example, `li.w` and `li.d` of immediates within int32_t range
produce the same code; in this patch, `addi.d rd, $zero, imm` is treated
as `li.d`, while `addi.w` and `ori` immediate loads are shown as `li.w`,
due to the expressible value range well within 32 bits.

gas/ChangeLog:

	* config/tc-loongarch.c (get_loongarch_opcode): Ignore
	disassembler-only aliases.
	* testsuite/gas/loongarch/64_pcrel.d: Update test case.
	* testsuite/gas/loongarch/imm_ins.d: Likewise.
	* testsuite/gas/loongarch/imm_ins_32.d: Likewise.
	* testsuite/gas/loongarch/jmp_op.d: Likewise.
	* testsuite/gas/loongarch/li.d: Likewise.
	* testsuite/gas/loongarch/macro_op.d: Likewise.
	* testsuite/gas/loongarch/macro_op_32.d: Likewise.
	* testsuite/gas/loongarch/macro_op_large_abs.d: Likewise.
	* testsuite/gas/loongarch/macro_op_large_pc.d: Likewise.
	* testsuite/gas/loongarch/nop.d: Likewise.
	* testsuite/gas/loongarch/relax_align.d: Likewise.
	* testsuite/gas/loongarch/reloc.d: Likewise.

include/ChangeLog:

	* opcode/loongarch.h (INSN_DIS_ALIAS): Add.

ld/ChangeLog:

	* testsuite/ld-loongarch-elf/jmp_op.d: Update test case.
	* testsuite/ld-loongarch-elf/macro_op.d: Likewise.
	* testsuite/ld-loongarch-elf/macro_op_32.d: Likewise.
	* testsuite/ld-loongarch-elf/relax-align.dd: Likewise.

opcodes/ChangeLog:

	* loongarch-dis.c: Move register name map declarations to top.
	(get_loongarch_opcode_by_binfmt): Consider aliases when
	disassembling without the no-aliases option.
	(parse_loongarch_dis_option): Support the no-aliases option.
	* loongarch-opc.c: Collect pseudo instructions into a new
	dedicated table.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-06-30 10:17:56 +08:00
Feiyang Chen
4142b23683 LoongArch: Support referring to FCSRs as $fcsrX
Previously, FCSRs were referred to as $rX, which seemed strange.
We refer to FCSRs as $fcsrX, which ensures compatibility with LLVM
IAS as well.

gas/ChangeLog:

        * config/tc-loongarch.c:
        (loongarch_fc_normal_name): New definition.
        (loongarch_fc_numeric_name): New definition.
        (loongarch_single_float_opcodes): Modify `movgr2fcsr` and
        `movfcsr2gr`.
        testsuite/gas/loongarch/float_op.d: Likewise.
        testsuite/gas/loongarch/float_op.s: Likewise.

include/ChangeLog:

        * opcode/loongarch.h:
        (loongarch_fc_normal_name): New extern.
        (loongarch_fc_numeric_name): New extern.

opcodes/ChangeLog:

        * opcodes/loongarch-dis.c (loongarch_after_parse_args): Support
        referring to FCSRs as $fcsrX.
        * opcodes/loongarch-opc.c (loongarch_args_parser_can_match_arg_helper):
        Likewise.

Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
2023-06-25 15:06:32 +08:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
liuzhensong
6cc76c40a9 LoongArch opcodes support
2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
	    Zhensong Liu  <liuzhensong@loongson.cn>
	    Weinan Liu  <liuweinan@loongson.cn>

include/
	* opcode/loongarch.h: New.
	* dis-asm.h: Declare print_loongarch_disassembler_options.
opcodes/
	* Makefile.am: Add LoongArch.
	* configure.ac: Likewise.
	* disassemble.c: Likewise.
	* disassemble.h: Declare print_insn_loongarch.
	* loongarch-coder.c: New.
	* loongarch-dis.c: New.
	* loongarch-opc.c: New.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/POTFILES.in: Regenerate.
2021-10-24 21:36:31 +10:30