Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x64: Implement SIMD fma #4474

Merged
merged 5 commits into from
Jul 25, 2022
Merged

x64: Implement SIMD fma #4474

merged 5 commits into from
Jul 25, 2022

Conversation

afonso360
Copy link
Contributor

@afonso360 afonso360 commented Jul 20, 2022

👋 Hey,

Following the discussion in #4462, this PR adds a VEX encoder and lowering for SIMD fma with FMA extension instructions.

The VEX Encoder has an API similar to the EVEX encoder, however instead of writing the instruction as the caller is calling the fields, we store them all and later write the full instruction in encode.

This is because the VEX instruction format is much less predictable than EVEX and I couldn't find a way to cleanly write the bit fields, since at any time we can switch from 2 to 3 byte prefixes.

@abrown mentioned in #4462, there are potentially some improvements that we may want to do.

With that in place, we would probably need think through how to emit AVX instructions; e.g., something like Avx512Opcode but perhaps we want to be able to decide on the VEX/EVEX encoding at a later time (?)

Right now this implements AvxOpcode and always lowers it in VEX encoding. However I like the idea of choosing the encoding based on what is available and most efficient. Suggestions on how we would implement this would be appreciated!

Fixes #4462

This uses a similar builder pattern to the EVEX Encoder.
Does not yet support memory accesses.
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself labels Jul 20, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @fitzgen, @peterhuene

This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "cranelift:meta", "fuzzing", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing
  • peterhuene: wasmtime:api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@afonso360 afonso360 force-pushed the x86-vex branch 2 times, most recently from c4cf522 to f9ef5bb Compare July 20, 2022 12:28
Copy link
Contributor

@abrown abrown left a comment

Choose a reason for hiding this comment

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

LGTM!

cranelift/codegen/src/isa/x64/inst.isle Outdated Show resolved Hide resolved
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

New 4-register form looks good except for the pretty-print, where I think a few of the args are unintentionally reordered.

cranelift/codegen/src/isa/x64/inst/mod.rs Show resolved Hide resolved
@cfallin cfallin enabled auto-merge (squash) July 25, 2022 21:30
@cfallin cfallin merged commit 02c3b47 into bytecodealliance:main Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cranelift: Missing SIMD fma lowering for x86_64
3 participants