Update Vector Operations#940
Draft
novafacing wants to merge 6 commits intoimmunant:masterfrom
Draft
Conversation
…g because of _cvtss_sh type functions
Contributor
|
This looks like useful work, do you intend to take it out of draft? |
Author
|
I haven't heard any feedback on this draft (here or in discord), so unless someone from Immunant wants to chime in probably not. You are welcome to grab this code though if you'd like @LegNeato! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I discovered several issues when trying to transpile
ggml.c(Attached along with acompile_commands.json) and decided to learn a little bit aboutc2rustand try and tackle them. I'm submitting as a draft PR for reference, I'm interested in tackling some of this myself but I'm not a member of the project so I wanted to start a discussion before putting in that effort. The issues I spotted are:translator/builtins.rs(I added the builtins I needed, but the list instd::core::(x86|x86_64)is now quite long and more intrinsics can be supported than when it looks like this was initially written)use path::elem::X as Y;was difficult to access. I've added some functionality to theItemStoreandBuilder [repro.zip](https://github.com/immunant/c2rust/files/11585897/repro.zip)to make it easier to emit this type of use statement.__v8hiare emitted when translating C builtins like_cvtss_shbut were undefined. I've addeduse asaliasing to define them, although this is unlikely to be correct in all cases.use asaliasing for these too. I'm not sure if there is any case where it's incorrect to emit an aligned vector type where an unaligned type was before (although I suspect there may be some performance impact).0 as libc::c_uint as libc::c_intwould become0 as libc::c_uintwhen the parameter type was indeedlibc::c_int). I couldn't find a case where this caused more errors than it fixed, although again this may be the wrong approach.There is one problem I didn't address which is that implicit casting between vector types doesn't seem to be supported anywhere. I couldn't figure out where I could access the "destination type" of these casts, but in general vector type cast builtins like _mm256_castps_pd can be emitted (these calls are free, they're just casts) to explicitly convert these types whenever an implicit cast is found.