-
Notifications
You must be signed in to change notification settings - Fork 229
Has Rust recently updated to an LLVM which emits calls to clzsi2? #260
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
Comments
Thanks for the report! It probably is the case yeah that LLVM has changed from when the README was written to now. We can certainly implement this function! |
@alexcrichton the relevant function is fairly simple EDIT: had the 32-bit only version at first, this works for both 32-bit and 64-bit #[no_mangle]
pub extern "C" fn __clzsi2(mut x: usize) -> usize {
let mut y: usize;
let mut n: usize = if cfg!(target_pointer_width = "32") { 32 } else { 64 };
#[cfg(target_pointer_width = "64")]
{
y = x >> 32;
if y != 0 {
n = n - 32;
x = y;
}
}
y = x >> 16;
if y != 0 {
n = n - 16;
x = y;
}
y = x >> 8;
if y != 0 {
n = n - 8;
x = y;
}
y = x >> 4;
if y != 0 {
n = n - 4;
x = y;
}
y = x >> 2;
if y != 0 {
n = n - 2;
x = y;
}
y = x >> 1;
if y != 0 {
n - 2
} else {
n - x
}
} Should I just put in a PR for this or is there some additional process needed for adding new builtins? |
@Lokathor nah that'd be great to add! It can be hooked up to the test suite we already have to verify correctness as well |
I have another PR waiting, but once it's in I'll get to this one done up. |
#267 is merged |
According to the README, LLVM never emits calls to
__clzsi2
. However, when compiling my code targeting the Game Boy Advance (thumbv4-none-eabi
) with a recent nightly (rustc 1.30.0-nightly (0198a1ea4 2018-09-08)
) compiler-builtins is built with calls to__clzsi2
in many functions, leading to undefined references at link time.Here's my target file on the offchance that's relevant.
It presupposes a devkitARM toolchain is available.
The text was updated successfully, but these errors were encountered: