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 aboutc2rust
and 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 theItemStore
andBuilder [repro.zip](https://github.com/immunant/c2rust/files/11585897/repro.zip)
to make it easier to emit this type of use statement.__v8hi
are emitted when translating C builtins like_cvtss_sh
but were undefined. I've addeduse as
aliasing to define them, although this is unlikely to be correct in all cases.use as
aliasing 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_int
would become0 as libc::c_uint
when 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.