Skip to content

Add _MM_SHUFFLE macro for x86/x86_64 #475

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

Closed
bitshifter opened this issue Jun 12, 2018 · 6 comments
Closed

Add _MM_SHUFFLE macro for x86/x86_64 #475

bitshifter opened this issue Jun 12, 2018 · 6 comments

Comments

@bitshifter
Copy link
Contributor

xmmintrin.h defines a _MM_SHUFFLE macro which is use to generate the mask used for _mm_shuffle and other similar instructions. https://clang.llvm.org/doxygen/xmmintrin_8h.html#a65a052b655bd49ff3fe128b61847df9f. I could not find this macro in std::arch::x86, perhaps it is there but doesn't show up in the docs?

In any case, if it's missing perhaps it would be good to add it. Creating masks by hand is cryptic and having an equivalent to _MM_SHUFFLE would make using the Rust intrinsics more like other languages.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 13, 2018

Thanks for reporting this. Wanna send a PR? Should be pretty easy to implement (check the other macros and consts in the coresimd/x86/sse.rs module.

@bitshifter
Copy link
Contributor Author

Will do.

@bitshifter
Copy link
Contributor Author

@gnzlbg it turns out this is not so straight forward. I've added the macro and a test in this commit bitshifter@727bc11 however it seems that coresimd is re-exported via stdsimd, but I do not know how to re-export the macro.

I was reminded about binary literals when looking at the tests, which are reasonably readable. Perhaps if this macro issue is not easily solved adding and boolean literal example would help.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 15, 2018

@bitshifter you should add a const fn instead of a macro, or why does it need to be a macro?

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 15, 2018

Also, you should call it _MM_SHUFFLE and not _mm_shuffle.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 15, 2018

Otherwise it looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants