From: WANG Xuerui <i.qemu@xen0n.name>
To: Richard Henderson <richard.henderson@linaro.org>,
Song Gao <gaosong@loongson.cn>,
qemu-devel@nongnu.org
Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>, laurent@vivier.eu
Subject: Re: [PATCH v10 04/26] target/loongarch: Add fixed point arithmetic instruction translation
Date: Sat, 13 Nov 2021 11:18:50 +0800 [thread overview]
Message-ID: <8662eafa-8cef-4e54-1d07-db093c924cda@xen0n.name> (raw)
In-Reply-To: <7e6e5c26-2c1a-e4b5-a724-c2db33a36180@linaro.org>
On 11/12/21 22:05, Richard Henderson wrote:
> On 11/12/21 7:53 AM, Song Gao wrote:
>> +#
>> +# Fields
>> +#
>> +%rd 0:5
>> +%rj 5:5
>> +%rk 10:5
>> +%sa2 15:2
>> +%si12 10:s12
>> +%ui12 10:12
>> +%si16 10:s16
>> +%si20 5:s20
>
> You should only create separate field definitions like this when they
> are complex: e.g. the logical field is disjoint or there's a need for
> !function.
>
>> +
>> +#
>> +# Argument sets
>> +#
>> +&fmt_rdrjrk rd rj rk
>> +&fmt_rdrjsi12 rd rj si12
>> +&fmt_rdrjrksa2 rd rj rk sa2
>> +&fmt_rdrjsi16 rd rj si16
>> +&fmt_rdrjui12 rd rj ui12
>> +&fmt_rdsi20 rd si20
>
> Some of these should be combined. The width of the immediate is a
> detail of the format, not the decoded argument set. Thus you should have
>
> &fmt_rdimm rd imm
> &fmt_rdrjimm rd rj imm
> &fmt_rdrjrk rd rj rk
> &fmt_rdrjrksa rd rj rk sa
I'd like to add, that the organization of the whole decodetree file
closely resembles that of the ISA manual, most likely on purpose (while
not stated anywhere in the patch). However the manual itself is not
without errors or inconsistencies; for example, the 9 "base instruction
formats" classification is nowhere near accurate, and here we can see
the author is forced to create ad-hoc names (repeating the operand
slots). I suggest just generating the descriptions from the
loongarch-opcodes project [1]; no need to duplicate work. I'll happily
help if you decide to do that.
[1]: https://github.com/loongson-community/loongarch-opcodes
>
>> +alsl_w 0000 00000000 010 .. ..... ..... .....
>> @fmt_rdrjrksa2
>> +alsl_wu 0000 00000000 011 .. ..... ..... ..... @fmt_rdrjrksa2
>> +alsl_d 0000 00000010 110 .. ..... ..... ..... @fmt_rdrjrksa2
>
> The encoding of these insns is that the shift is sa+1.
>
> While you compensate for this in gen_alsl_*, we print the "wrong"
> number in the disassembly. I think it would be better to do
>
> %sa2p1 15:2 !function=plus_1
> @fmt_rdrjrksa2p1 .... ........ ... .. rk:5 rj:5 rd:5 \
> &fmt_rdrjrksa sa=%sa2p1
Here again, the manual was inconsistent with the binutils
implementation; the manual says (for ALSL.W, it's SLADD in
loongarch-opcodes project's revised mnemonics):
"ALSL.W logically left-shifts rj[31:0] by (sa2+1) bits, [snip]"
(translation mine, not copied from the official translation)
Clearly the "+1" part is not meant to show up in disassembly. Yet the
binutils implementation acts as if the operand should be pre-added 1 in
source code, and disassembles and prints as such, obvious mismatch here.
I'd suggest fixing the disassembly code to remove this inconsistency.
And the "+1" "feature" is not used anywhere else AFAIK, so it wouldn't
hurt to just delete everything about it.
>
>
> r~
>
next prev parent reply other threads:[~2021-11-13 3:20 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 6:53 [PATCH v10 00/26] Add LoongArch linux-user emulation support Song Gao
2021-11-12 6:53 ` [PATCH v10 01/26] target/loongarch: Add README Song Gao
2021-11-12 6:53 ` [PATCH v10 02/26] target/loongarch: Add core definition Song Gao
2021-11-12 6:53 ` [PATCH v10 03/26] target/loongarch: Add main translation routines Song Gao
2021-11-12 6:53 ` [PATCH v10 04/26] target/loongarch: Add fixed point arithmetic instruction translation Song Gao
2021-11-12 14:05 ` Richard Henderson
2021-11-13 3:18 ` WANG Xuerui [this message]
2021-11-15 3:59 ` gaosong
2021-11-15 8:42 ` Richard Henderson
2021-11-17 7:57 ` gaosong
2021-11-17 8:28 ` Richard Henderson
2021-11-17 9:29 ` gaosong
2021-11-17 9:55 ` Richard Henderson
2021-11-18 1:24 ` gaosong
2021-11-12 6:53 ` [PATCH v10 05/26] target/loongarch: Add fixed point shift " Song Gao
2021-11-12 6:53 ` [PATCH v10 06/26] target/loongarch: Add fixed point bit " Song Gao
2021-11-12 6:53 ` [PATCH v10 07/26] target/loongarch: Add fixed point load/store " Song Gao
2021-11-12 6:53 ` [PATCH v10 08/26] target/loongarch: Add fixed point atomic " Song Gao
2021-11-12 6:53 ` [PATCH v10 09/26] target/loongarch: Add fixed point extra " Song Gao
2021-11-12 6:53 ` [PATCH v10 10/26] target/loongarch: Add floating point arithmetic " Song Gao
2021-11-12 6:53 ` [PATCH v10 11/26] target/loongarch: Add floating point comparison " Song Gao
2021-11-12 6:53 ` [PATCH v10 12/26] target/loongarch: Add floating point conversion " Song Gao
2021-11-12 6:53 ` [PATCH v10 13/26] target/loongarch: Add floating point move " Song Gao
2021-11-12 6:53 ` [PATCH v10 14/26] target/loongarch: Add floating point load/store " Song Gao
2021-11-12 6:53 ` [PATCH v10 15/26] target/loongarch: Add branch " Song Gao
2021-11-12 6:53 ` [PATCH v10 16/26] target/loongarch: Add disassembler Song Gao
2021-11-12 7:39 ` Richard Henderson
2021-11-12 9:59 ` gaosong
2021-11-12 6:54 ` [PATCH v10 17/26] linux-user: Add LoongArch generic header files Song Gao
2021-11-16 8:33 ` Philippe Mathieu-Daudé
2021-11-16 11:50 ` gaosong
2021-11-12 6:54 ` [PATCH v10 18/26] linux-user: Add LoongArch specific structures Song Gao
2021-11-12 6:54 ` [PATCH v10 19/26] linux-user: Add LoongArch signal support Song Gao
2021-11-12 6:54 ` [PATCH v10 20/26] linux-user: Add LoongArch elf support Song Gao
2021-11-12 6:54 ` [PATCH v10 21/26] linux-user: Add LoongArch syscall support Song Gao
2021-11-12 6:54 ` [PATCH v10 22/26] linux-user: Add LoongArch cpu_loop support Song Gao
2021-11-12 6:54 ` [PATCH v10 23/26] default-configs: Add loongarch linux-user support Song Gao
2021-11-12 6:54 ` [PATCH v10 24/26] target/loongarch: Add target build suport Song Gao
2021-11-12 6:54 ` [PATCH v10 25/26] target/loongarch: 'make check-tcg' support Song Gao
2021-11-12 6:54 ` [PATCH v10 26/26] scripts: add loongarch64 binfmt config Song Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8662eafa-8cef-4e54-1d07-db093c924cda@xen0n.name \
--to=i.qemu@xen0n.name \
--cc=gaosong@loongson.cn \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yangxiaojuan@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.