[PATCH 7/7][LoongArch] Opcodes support

WANG Xuerui i.swmail@xen0n.name
Sat Aug 21 12:45:07 GMT 2021


Hi Paul,

I just took a quick look at the code and have several 
questions/suggestions off the top of my head:

- There is support for the undocumented vector extensions. Maybe don't 
include them until documentation is released? Otherwise we'll be 
shipping dead code. BTW the "$xNN" names for the LASX registers sound 
horrible, they're bound to confuse people with AArch64/RISC-V backgrounds.

- ABI names for integer registers are not updated to match the latest 
LoongArch ELF psABI doc[1]: "$x" still remains, "$s9" is not recognized.

- Also, I don't think "v0/v1" aliases for a0/a1 are necessary any more; 
in an earlier presentation (maybe in 2020?) it is rumored that LoongArch 
assembler is able to consume MIPS assembly, but apparently that 
component is not present here. So we don't need to pretend the separate 
MIPS-like dedicated return value registers exist; other arches don't do 
that, either. I suggest just removing these and be done with that.

- The opcode table seems to be hand-written, which can get fragile and 
hard to maintain. Grouping of instructions seems rather arbitrary. 
There's a machine-readable list of documented LoongArch instructions[2] 
(compiled and edited by me); it would be better to derive the opcode 
table from there.

- The "alsl.X" instructions are implemented differently wrt the manual. 
According to the manual[3], hardware executes "sa2+1" while the syntax 
says just "sa2"; that means, for example, "alsl.d rd, rj, rk, 3" should 
execute the operation "rd = rk + rj << 4". However the instruction 
format in the patch seems to suggest the syntax "alsl.d rd, rj, rk, 4" 
which is clearly not the same.

- Many of the branch instructions are redundant, and can be implemented 
as macros. I already made a patch[4] to demonstrate the right way to do 
these.


[1]: 
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

[2]: https://github.com/loongson-community/loongarch-opcodes

[3]: 
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_alsl_wud

[4]: https://github.com/loongson/binutils-gdb/pull/38



More information about the Binutils mailing list