From ddf6593f8bbfc63f019f0ff49ba407a976f6a130 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Fri, 1 Feb 2019 23:36:17 -0700 Subject: [PATCH] Delete the builtins module The `__clzsi2` function is now part of the compiler-builtins crate, so it's part of all of Rust. --- src/base.rs | 3 -- src/base/builtins.rs | 87 -------------------------------------------- 2 files changed, 90 deletions(-) delete mode 100644 src/base/builtins.rs diff --git a/src/base.rs b/src/base.rs index 4c7b530..5bbf7d2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -5,6 +5,3 @@ pub mod fixed_point; pub mod volatile; pub(crate) use self::volatile::*; - -pub mod builtins; -//pub(crate) use self::builtins::*; diff --git a/src/base/builtins.rs b/src/base/builtins.rs deleted file mode 100644 index 5966450..0000000 --- a/src/base/builtins.rs +++ /dev/null @@ -1,87 +0,0 @@ -#![allow(missing_docs)] - -//! The module to provide "builtin" functions that LLVM expects. -//! -//! You shouldn't need to call anything in here yourself, it just has to be in -//! the translation unit and LLVM will find it. - -#[no_mangle] -#[cfg(any(target_pointer_width = "16", target_pointer_width = "32", target_pointer_width = "64"))] -pub extern "C" fn __clzsi2(mut x: usize) -> usize { - // TODO: const this? Requires const if - let mut y: usize; - let mut n: usize = { - #[cfg(target_pointer_width = "64")] - { - 64 - } - #[cfg(target_pointer_width = "32")] - { - 32 - } - #[cfg(target_pointer_width = "16")] - { - 16 - } - }; - #[cfg(target_pointer_width = "64")] - { - y = x >> 32; - if y != 0 { - n -= 32; - x = y; - } - } - #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] - { - y = x >> 16; - if y != 0 { - n -= 16; - x = y; - } - } - y = x >> 8; - if y != 0 { - n -= 8; - x = y; - } - y = x >> 4; - if y != 0 { - n -= 4; - x = y; - } - y = x >> 2; - if y != 0 { - n -= 2; - x = y; - } - y = x >> 1; - if y != 0 { - n - 2 - } else { - n - x - } -} - -#[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; - } -} - -// TODO: add some shims -// #[no_mangle] extern "aapcs" fn __aeabi_uidiv(num: u32: denom: u32) -> u32 -// #[no_mangle] extern "aapcs" fn __aeabi_idiv(num: i32: denom: i32) -> u32