-
Notifications
You must be signed in to change notification settings - Fork 211
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
Adding __clzsi2 #267
Adding __clzsi2 #267
Conversation
Thanks! This may be best suited in the various The tests are all generated in this file and the generation here can probably just look at the surrounding functions and match them. |
Also, there are some build fails for GNU on windows, and they don't seem to be related to any file I changed. Is that normal? |
Ah yeah that's a bug on our CI, you can safely ignore them (sorry for the noise!) |
@alexcrichton Alright, maybe I'm not understanding how the test suite works :( What I really want to express is very simple: #[test]
fn __clzsi2_test() {
let mut i: usize = core::usize::MAX;
while i > 0 {
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
i >>= 1;
}
// check 0 also
i = 0;
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
// double check for bit patterns that aren't solid 1s
i = 1;
for _ in 0 .. 63 {
assert_eq!(__clzsi2(i) as u32, i.leading_zeros());
i <<= 2;
i += 1;
}
} |
@Lokathor I think that the errors on CI look legitimate, like it's a bug in the function or a bug in the test? You should be able to inline that test directly into the tests folder I think as well |
Yeah the test is very bugged because it's not setup for usize and so I tried to badly fake it with u64. I was not aware that just putting a normal test into the tests folder was an option (in terms of allowed style). I will do that and update later tonight. |
@alexcrichton okay much better |
Ok great, thanks! Could this use the |
I can make that update. Should any of the attributes be used? I've had success with the plain form, so my first guess is that we don't need any special attribute magic for this one. |
I'd probably stick to the plain form for now, the attributes can be added as necessary for various platforms. Most of them are just inherited for other weird intrinsics. |
@alexcrichton So when I tried to wrap the function in the |
The macro is ideally required yeah because it correctly handles conventions across platforms and mangling vs not, can you share the errors you were getting? |
Seems like the 128-bit errors that my RLS was reporting are just the same false errors that appveyor gets? Travis seems fine with it all. I'm good with things like this if you are. |
👍 |
Will this change go out with the next nightly? Or is there some other pace it uses? |
It will be available once new version is released and Rust's |
So it might be quite a while then? |
It's not up to me but it for sure won't be in next nightly. |
All that needs to happen is a publish and then an update to rust-lang/rust, @Lokathor if you want to push a version bump I can merge and publish and then you can update the lock file in rust-lang/rust |
Uh, sure, I can do that first part really fast. |
…chton Update Cargo.lock to use the latest `compiler_builtins` A very tiny PR per the request of @alexcrichton : rust-lang/compiler-builtins#267 (comment) Rewrite of #57414 cc @Lokathor r? @alexcrichton
Hey all, these days LLVM does attempt to use
__clzsi2
some of the time (despite what the README says), typically only with debug builds but sometimes in release mode.So, here's an implementation of it. I attempted to make it correct for any pointer size all the way down to 16 (which is the minimum pointer size rust could ever support, AIUI). It's placed in the arm file because I need it for ARM and there didn't seem to be a clearer place to put it, but it can be moved.
@alexcrichton said that it can be hooked into the test suites and such, but I don't know how to do that, so this is just the start.