Repository navigation
Add some f32x4 instructions - #165
Conversation
binji
left a comment
There was a problem hiding this comment.
lgtm, though I'm not an ocaml expert :)
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.
852fe31 to
53aa177
Compare
|
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 |
|
@rossberg can you take a quick look? Thanks! |
|
@rossberg rebased this recently, ptal, thanks! |
rossberg
left a comment
There was a problem hiding this comment.
Ah, sorry, I missed the previous notifications for this PR.
| 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 |
There was a problem hiding this comment.
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.
| | Values.V128 unop -> | ||
| let open V128Op in | ||
| (match unop with | ||
| | I32x4ExtractLane _ -> V128Type, I32Type |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
rossberg
left a comment
There was a problem hiding this comment.
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.
|
I can definitely add |
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.wastyet, due to missing parsing of theresulttoken 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.