Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Add some f32x4 instructions - #165

Merged
ngzhian merged 4 commits into
WebAssembly:masterfrom
ngzhian:some-f32x4-support
Apr 22, 2020
Merged

ngzhian merged 4 commits into
WebAssembly:masterfrom
ngzhian:some-f32x4-support

Conversation

@ngzhian

@ngzhian ngzhian commented Dec 20, 2019

Copy link
Copy Markdown
Member

Add f32x4 min, max, abs extract lane, and i32x4 extract lane as examples
of how SIMD operations can be implemented.

extract_lane operations are missing validation, which can be added in
future patches.

With this patch, we don't fully support running the test simd_f32x4.wast yet, due to missing parsing of the result token in scripts. In particular, right now we only support const literal or a single canonical/arithmetic NaN. We will need to add support for parsing v128.const containing literals and/or canonical/arithmetic NaN, this can be done in a future patch.

@ngzhian
ngzhian requested review from arunetm and rossberg December 20, 2019 22:34
@dtig
dtig requested a review from binji February 7, 2020 17:59

@binji binji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, though I'm not an ocaml expert :)

ngzhian added 3 commits March 20, 2020 10:22
Add f32x4 min, max, abs extract lane, and i32x4 extract lane as examples
of how SIMD operations can be implemented.

extract_lane operations are missing validation, which can be added in
future patches.
@ngzhian
ngzhian force-pushed the some-f32x4-support branch from 852fe31 to 53aa177 Compare March 20, 2020 18:01
@ngzhian

ngzhian commented Mar 20, 2020

Copy link
Copy Markdown
Member Author

Not proud of the many unreachable in the lexer, I couldn't figure out a way to say that an operation is not yet implemented (other that sprinkling lots of error lexbuf "unimplemented" in line. I think it's fine for now, as we implement more operations, those unreachable will go away.

@binji

binji commented Mar 20, 2020

Copy link
Copy Markdown
Member

@rossberg can you take a quick look? Thanks!

@ngzhian

ngzhian commented Mar 31, 2020

Copy link
Copy Markdown
Member Author

@rossberg rebased this recently, ptal, thanks!

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, I missed the previous notifications for this PR.

Comment thread interpreter/exec/v128.ml Outdated
let to_string s = s

let to_i32x4 s =
List.map (fun i -> I32.of_bits @@ Bytes.get_int32_le (Bytes.of_string s) i) Simd.f32x4_indices

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Ocaml's @@ is confusing with our own use of the operator. We should rename that at some point, but until then I would prefer to avoid using @@, esp in cases like this, where it actually makes the line longer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, fixed!

Comment thread interpreter/valid/valid.ml Outdated
| Values.V128 unop ->
let open V128Op in
(match unop with
| I32x4ExtractLane _ -> V128Type, I32Type

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the unop/binop/relop/testop abstraction was that they are only used for homogeneously typed operators of the respective kind. That assumption shows up in a couple of places. Extract operations are different, so like for conversions, it's better to introduce a separate AST node for them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 905d249, introduced a new ast node called ExtractLane. I put this outside of the whole Values.op type, and directly deal with it in the eval.ml, which calls into the SimdOp module logic in eval_numeric, since it knows how to evaluate other simd stuff. LMK if this approach makes sense at all. Thanks for your review!

@ngzhian ngzhian mentioned this pull request Apr 7, 2020

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay!

LGTM. The one suggestion I'd have is moving the extractop impl from eval_numeric into a new module eval_simd (which will probably accumulate more stuff). But feel free to do that in a follow-up.

@ngzhian

ngzhian commented Apr 22, 2020

Copy link
Copy Markdown
Member Author

I can definitely add eval_simd in a follow-up, thanks for the review!

@ngzhian
ngzhian merged commit cb0326e into WebAssembly:master Apr 22, 2020
@ngzhian
ngzhian deleted the some-f32x4-support branch April 22, 2020 17:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants