-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Rewrite platform intrinsic generation as a build script #41885
Comments
I would like to work on this issue! |
(not sure why that issue link didn't show up...), also sorry, should have mentioned that in the issue earlier! |
ok no problem, I guess I should leave this to @F001 . @alexcrichton Are there any other scripts that need to be rewritten? |
Thanks. I will work on this. |
@F001 are you still working on this? |
@theduke I'm sorry, I have not wok on this for more than two months. And I guess I won't have enough time for the comming 2 months. I have updated my code on https://github.com/F001/librustc_platform_intrinsics, in a very early stage. If anyone want to take this, that's OK. You can start from scratch or base on my project, it's your choice. I will probably come back to this issue at least 2 months later, if no one finish this task at that time. |
I see this was taken out of "impl period", but it is a desirable thing to have implemented at the moment? It looks interesting, and I think I have time to look into it, so I'd be happy to give it a go (unless @tommyip wants a go first 😄). I also have some questions: the |
@laumann go for it! I am kinda busy at the moment. |
@laumann oh awesome! We may not want to do a straight translation of |
@tommyip Cool 👍 @alexcrichton I think I'm wondering where in the build process this should be hooked in. Is the idea that the Are you thinking of something specific that'd be easier with a macro rather than the JSON? |
@laumann ah yeah as a build script this'll just get naturally run and compiled whenever the crate's built. I don't think you'll need to take Oh whatever's easiest should be fine, I'd just imagine that long-term JSON isn't really necessary, it was probably just easy for Python. |
@alexcrichton So I've been working on this here (btw, so sorry I never got to say hi at RöstiFest!). I forked @F001's project as a starting point. Status is that it seems mostly complete, except for values that need to be plugged into the generated match arms. @F001 I wanted to ask why the width is an |
Gah sorry I missed you @laumann! But nice job on the work here so far! |
No problem, you were kinda mobbed most of the time 😄 |
This commit rewrites (updates) the `rustc_platform_intrinsics` crate in this repository. This crate was previously procedurally generated from a number of JSON files and was intended to be the basis for how we bind SIMD in Rust. This crate is quite old at this point and is actually only used very little. The `stdsimd` crate and `std::arch` modules are the "new" way for stabilizing SIMD intrinsics. Despite this, however, the crate isn't useless! Most LLVM intrinsics are called directly in the `stdsimd` crate using the `link_llvm_intrinsics` feature, but not all intrinsics can be expressed directly in Rust. Instead some intrinsics, notably those that return LLVM aggregates, need to be compiler-defined to ensure they're declared with the correct signature. A good example of this is the x86 rdrand/rdseed family of LLVM intrinsics, all of which return an aggregate of some form. The stdsimd functions which provide these x86 intrinsics link to functions defined by this crate, so we need to keep those! Adding all that together, this commit performs the following tasks: * Deletes the now-outdated `src/etc/platform-intrinsics` infrastructure * Deletes all `src/librustc_platform_intrinsics/*` intrinsics that are otherwise compatible to be defined in Rust itself. This includes everything that doesn't deal with aggregates basically. Empty architecture files are removed. * The style of `src/librustc_platform_intrinsics/` was updated slightly to make it a bit easier to handwrite. The `x86` rdrand/rdseed intrinsics and some `aarch64` intrinsics which return aggregates have all survived to continue to be defined by this crate. Closes rust-lang#41885
Triage: #57416 fixed this bug 🎊 |
Right now the compiler has a
rustc_platform_intrinsics
crate which is basically a database of all platform intrinsics with their inputs/outputs and LLVM names, etc. This is the information the compiler uses to typecheck all intrinsics and also generate code for them with LLVM. An example generated file looks likeaarch64.rs
.These files are all generated by a
generator.py
script in thesrc/etc
dir. This generator slurps up a ton of JSON definitions, for example all the files insrc/etc/platform-intrinsics/x86
and then generates these Rust files.Now that we're using Cargo as a build system we can avoid checking in these generated source files. Instead we can translate
generator.py
into Rust as a build script and use build-time code generation to generate all of these files.This isn't necessarily an easy task because
generator.py
is not exactly a trivial script, but I'm more than willing to help out if anyone's got any questions!The text was updated successfully, but these errors were encountered: