Stream: git-wasmtime

Topic: wasmtime / PR #6397 riscv64: Add `extractlane` and `splat...


view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 12:37):

afonso360 opened PR #6397 from afonso360:riscv-extract-splat to bytecodealliance:main:

:wave: Hey,

This PR implements both extractlane and splat.

splat is fairly simple in that we have a bunch of move instructions that by default splat the source X or F register into the vector register. These are vmv.v.x, vfmv.v.f and vmv.v.i, for X, F and immediate sources. The only noteworthy thing about these instructions is that they have weird encodings, and I've added two new instruction formats to deal with this. vmv.v.i has no source operands, only a destination register. And the other ones could maybe be encoded using the existing Imm5 instruction format it was becoming a bit weird keeping all of the variations together.

For extractlane we have two additional move instructions vfmv.f.s and vmv.x.s these move element 0 of the source vector into the appropriate X or F register. Additionally for extracting other elements we use vslidedown that moves all elements of a vector down by n positions and then emit the appropriate move into the destination register.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 12:37):

afonso360 requested elliottt for a review on PR #6397.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 12:37):

afonso360 requested wasmtime-compiler-reviewers for a review on PR #6397.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 12:37):

afonso360 requested wasmtime-default-reviewers for a review on PR #6397.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 14:28):

alexcrichton submitted PR review:

Nice!

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 14:28):

alexcrichton submitted PR review:

Nice!

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 14:28):

alexcrichton created PR review comment:

IIRC the aarch64 backend does some trickery along these lines where it iteratively halves the size of a constant if it's splatted, which may serve as good inspiration for supporting this.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 14:28):

alexcrichton created PR review comment:

Out of curiosity, is there a particular motivation for having this helper here vs inlining it into the lowering of extractlane?

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 14:48):

afonso360 created PR review comment:

Mostly to avoid having two rules for float and integer in the slide down cases. vslidedown is generic across integer and float elements, but vmv is not, so we recursively call this rule to decide the correct vmv instruction to use.

That being said, we can probably inline the vslidedown rules and have just a generic vmv that decides the correct instruction based on the type.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 16:24):

alexcrichton created PR review comment:

Oh sorry to clarify I mean that you've got 4 cases of gen_extractlane here, but why not have those 4 cases be cases on lower (extractlane ..)?

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 16:33):

afonso360 created PR review comment:

If I inline it directly into (lower (extractlane ..)) then it would become, 6 rules, right? Since I would have to duplicate vslidedown.vi+vmv, vslidedown.vi+vfm, vslidedown.vx+vmv and vslidedown.vx+vfm, which are currently just 2 rules.

Or can I then recursively call the lower instructions directly?

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 16:34):

afonso360 edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 16:35):

alexcrichton created PR review comment:

Ah I apologize I missed that crucial bit of this being a recursive rule! In that case yeah definitely makes sense as a standalone decl.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 16:48):

afonso360 edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 18:33):

afonso360 updated PR #6397.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 18:33):

afonso360 has enabled auto merge for PR #6397.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2023 at 19:56):

afonso360 merged PR #6397.


Last updated: Dec 23 2024 at 12:05 UTC