Skip to content

Remove some unused rust specific intrinsics #745

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/panic-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ authors = ["Alex Crichton <[email protected]>"]
edition = "2021"
publish = false

[lib]
test = false
bench = false

[dependencies]
96 changes: 0 additions & 96 deletions src/int/addsub.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/int/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::ops;

mod specialized_div_rem;

pub mod addsub;
mod big;
pub mod bswap;
pub mod leading_zeros;
Expand Down
76 changes: 1 addition & 75 deletions testcrate/tests/addsub.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,9 @@
#![allow(unused_macros)]
#![cfg_attr(f128_enabled, feature(f128))]

#[allow(unused_imports)] // Unused on some archs
use testcrate::*;

mod int_addsub {
use super::*;

macro_rules! sum {
($($i:ty, $fn_add:ident, $fn_sub:ident);*;) => {
$(
#[test]
fn $fn_add() {
use compiler_builtins::int::addsub::{$fn_add, $fn_sub};

fuzz_2(N, |x: $i, y: $i| {
let add0 = x.wrapping_add(y);
let sub0 = x.wrapping_sub(y);
let add1: $i = $fn_add(x, y);
let sub1: $i = $fn_sub(x, y);
if add0 != add1 {
panic!(
"{}({}, {}): std: {}, builtins: {}",
stringify!($fn_add), x, y, add0, add1
);
}
if sub0 != sub1 {
panic!(
"{}({}, {}): std: {}, builtins: {}",
stringify!($fn_sub), x, y, sub0, sub1
);
}
});
}
)*
};
}

macro_rules! overflowing_sum {
($($i:ty, $fn_add:ident, $fn_sub:ident);*;) => {
$(
#[test]
fn $fn_add() {
use compiler_builtins::int::addsub::{$fn_add, $fn_sub};

fuzz_2(N, |x: $i, y: $i| {
let add0 = x.overflowing_add(y);
let sub0 = x.overflowing_sub(y);
let add1: ($i, bool) = $fn_add(x, y);
let sub1: ($i, bool) = $fn_sub(x, y);
if add0.0 != add1.0 || add0.1 != add1.1 {
panic!(
"{}({}, {}): std: {:?}, builtins: {:?}",
stringify!($fn_add), x, y, add0, add1
);
}
if sub0.0 != sub1.0 || sub0.1 != sub1.1 {
panic!(
"{}({}, {}): std: {:?}, builtins: {:?}",
stringify!($fn_sub), x, y, sub0, sub1
);
}
});
}
)*
};
}

// Integer addition and subtraction is very simple, so 100 fuzzing passes should be plenty.
sum! {
u128, __rust_u128_add, __rust_u128_sub;
i128, __rust_i128_add, __rust_i128_sub;
}

overflowing_sum! {
u128, __rust_u128_addo, __rust_u128_subo;
i128, __rust_i128_addo, __rust_i128_subo;
}
}

macro_rules! float_sum {
($($f:ty, $fn_add:ident, $fn_sub:ident, $apfloat_ty:ident, $sys_available:meta);*;) => {
$(
Expand Down
Loading