[loong64] Implement LSX-based 128-bit SIMD
Categories
(Core :: JavaScript Engine: JIT, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox159 | --- | fixed |
People
(Reporter: csmantle, Assigned: csmantle)
References
(Blocks 1 open bug)
Details
Attachments
(15 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
828.94 KB,
image/png
|
Details | |
|
1.27 MB,
image/png
|
Details | |
|
1.22 MB,
image/png
|
Details | |
|
1.03 MB,
image/png
|
Details |
Loongson hasn't published an official ISA volume for the LoongArch SIMD Extension (LSX), but there are several sources for reference:
- The Unofficial LoongArch Intrinsics Guide contains probed behavioral models and latency/IPC information for L{,A}SX instructions.
- The LoongArch Opcodes (unofficially compiled list) and toolchains like GNU Binutils, GCC, and LLVM contain instruction encoding definitions.
- The official LoongArch ABI specs contains the psABI call convention involving vector arguments.
- V8 contains precedents for common SIMD operations on Loong64.
So an implementation is really possible. I have a stack ready locally, and it currently passes all jit-tests, jstests, and jsapi-tests on my Loongson 3B6000, as well as all JetStream Next cases and Speedometer 3. I'm sure this stack will soon be ready for review.
Note that the Simulator-loong64 support is not part of this stack. This would introduce too much work and be much more prone to coding mistakes than assembly and codegen.
| Assignee | ||
Comment 1•8 days ago
|
||
Due to the various mismatches among LoongArch ISA FP behavior, IEEE Std
754-2008 and WASM semantics, it is sometimes required to manually
construct canonical QNaNs.
| Assignee | ||
Comment 2•8 days ago
|
||
| Assignee | ||
Comment 3•8 days ago
|
||
The implemented instructions is only ~30% of the whole LSX instruction
set, but they should be sufficient for implementing a working SIMD
backend. The selection is inspired by V8 and driven by later parts.
Link: https://github.com/loongson-community/loongarch-opcodes
("LoongArch Opcodes (unofficially compiled list)")
Link:
https://jia.je/unofficial-loongarch-intrinsics-guide/migrating_sse/
("Unofficial LoongArch Intrinsics Guide: Migrating from SSE to LSX")
| Assignee | ||
Comment 4•8 days ago
|
||
| Assignee | ||
Comment 5•8 days ago
|
||
These are required for compiling with ENABLE_JIT_SIMD and will be
implemented in a later part.
| Assignee | ||
Comment 6•8 days ago
|
||
| Assignee | ||
Comment 7•8 days ago
|
||
This allows explicit enablement of SIMD on Loong64 backend. It's not
enabled by default since most methods are stubs and will crash.
| Assignee | ||
Comment 8•8 days ago
|
||
This is the heavy part. Thanks to "Unofficial LoongArch Intrinsics
Guide", the x{86,64} and arm64 backend, the precedent is rich.
Certain relaxed SIMD tests are updated to reflect LoongArch specifics,
which are captured on a Loongson 3B6000. Since we don't have
authoritative sources on how the ISA mandates the behavior, this is just
an observation.
Note that per psABI, the system vector calling convention requires three
kinds of passing method: GPR pair, one GPR plus one stack slot, and two
stack slots. This is not easily implemented. Since I don't see any
native vector calls, this is currently asserted out. For WASM-internal
calls, arguments are stored in available arg-passing FPRs (which are
aliases of the vector registers anyway) and spilled to stack when
exhausted.
Link:
https://github.com/loongson/la-abi-specs/blob/44ef5f63e1755e1a165915ea3b2d98d35f68eed0/lapcs.adoc#passing-arguments
("Procedure Call Standard for the LoongArch(tm) Architecture: Passing
arguments")
| Assignee | ||
Comment 9•8 days ago
|
||
LSX feature detection differs from the previous LAM_BH and LAMCAS ones,
because it introduces extra architectural states that require explicit
kernel support to preserve context. Thus, it's not sufficient to read
them via CPUCFG (which indicates hardware support only).
| Assignee | ||
Comment 10•8 days ago
|
||
Cross-domain (e.g. GPR to FPR) moves seems to be extremely slow and have
terrible IPC. Fortunately, vldi can help materializing small, repetitive
constant patterns directly in the vector register.
Link: https://areweloongyet.com/asmdb/vldiHelper ("AreWeLoongYet? - VLDI
Helper")
Link:
https://github.com/loongson-community/areweloongyet/blob/49a0f6d22506c1fbebc97da24d4c34a9cc116ee5/src/components/AsmDB/vldi.ts
| Assignee | ||
Comment 11•8 days ago
|
||
Finally, this completes the stack.
| Assignee | ||
Comment 12•8 days ago
|
||
Note that per LoongArch Toolchain Conventions, LSX is part of the LA64v1.0 ISA. So, it's probably okay to assume its existence on Firefox-capable platforms.
Updated•8 days ago
|
Updated•8 days ago
|
| Assignee | ||
Comment 13•8 days ago
|
||
| Assignee | ||
Comment 14•8 days ago
|
||
| Assignee | ||
Comment 15•8 days ago
|
||
| Assignee | ||
Comment 16•8 days ago
|
||
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Updated•8 days ago
|
Comment 17•4 days ago
|
||
Comment 18•4 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/59e8d8e0df91
https://hg.mozilla.org/mozilla-central/rev/817eeddffb76
https://hg.mozilla.org/mozilla-central/rev/03e3d7a16848
https://hg.mozilla.org/mozilla-central/rev/0cb375d2a617
https://hg.mozilla.org/mozilla-central/rev/151771679905
https://hg.mozilla.org/mozilla-central/rev/cf950ca03afc
https://hg.mozilla.org/mozilla-central/rev/11af78c273e0
https://hg.mozilla.org/mozilla-central/rev/b1b934b4db4a
https://hg.mozilla.org/mozilla-central/rev/3c951e6e80b0
https://hg.mozilla.org/mozilla-central/rev/b14772739f76
https://hg.mozilla.org/mozilla-central/rev/a3a1c0922431
Description
•