Skip to content

Commit

Permalink
remove win64_128bit_abi_hack
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung authored and tgross35 committed Feb 19, 2025
1 parent b2bcfc8 commit 72d0cde
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 80 deletions.
4 changes: 0 additions & 4 deletions src/float/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ intrinsics! {
float_to_unsigned_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixunssfti(f: f32) -> u128 {
float_to_unsigned_int(f)
}
Expand All @@ -418,7 +417,6 @@ intrinsics! {
float_to_unsigned_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixunsdfti(f: f64) -> u128 {
float_to_unsigned_int(f)
}
Expand Down Expand Up @@ -454,7 +452,6 @@ intrinsics! {
float_to_signed_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixsfti(f: f32) -> i128 {
float_to_signed_int(f)
}
Expand All @@ -469,7 +466,6 @@ intrinsics! {
float_to_signed_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixdfti(f: f64) -> i128 {
float_to_signed_int(f)
}
Expand Down
4 changes: 2 additions & 2 deletions src/int/sdiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ sdivmod!(
i128,
maybe_use_optimized_c_shim
);
sdiv!(__udivti3, __divti3, u128, i128, win64_128bit_abi_hack);
smod!(__umodti3, __modti3, u128, i128, win64_128bit_abi_hack);
sdiv!(__udivti3, __divti3, u128, i128,);
smod!(__umodti3, __modti3, u128, i128,);
3 changes: 0 additions & 3 deletions src/int/udiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ intrinsics! {
// the existence of `u128_div_rem` to get 32-bit SPARC to compile, see `u128_divide_sparc` docs.

#[avr_skip]
#[win64_128bit_abi_hack]
/// Returns `n / d`
pub extern "C" fn __udivti3(n: u128, d: u128) -> u128 {
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] {
Expand All @@ -70,7 +69,6 @@ intrinsics! {
}

#[avr_skip]
#[win64_128bit_abi_hack]
/// Returns `n % d`
pub extern "C" fn __umodti3(n: u128, d: u128) -> u128 {
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] {
Expand All @@ -84,7 +82,6 @@ intrinsics! {
}

#[avr_skip]
#[win64_128bit_abi_hack]
/// Returns `n / d` and sets `*rem = n % d`
pub extern "C" fn __udivmodti4(n: u128, d: u128, rem: Option<&mut u128>) -> u128 {
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] {
Expand Down
71 changes: 0 additions & 71 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ macro_rules! public_test_dep {
/// the specified ABI everywhere else.
/// * `unadjusted_on_win64` - like `aapcs_on_arm` this switches to the
/// `"unadjusted"` abi on Win64 and the specified abi elsewhere.
/// * `win64_128bit_abi_hack` - this attribute is used for 128-bit integer
/// intrinsics where the ABI is slightly tweaked on Windows platforms, but
/// it's a normal ABI elsewhere for returning a 128 bit integer.
/// * `arm_aeabi_alias` - handles the "aliasing" of various intrinsics on ARM
/// their otherwise typical names to other prefixed ones.
/// * `ppc_alias` - changes the name of the symbol on PowerPC platforms without
Expand Down Expand Up @@ -231,51 +228,6 @@ macro_rules! intrinsics {
intrinsics!($($rest)*);
);

// Some intrinsics on win64 which return a 128-bit integer have an.. unusual
// calling convention. That's managed here with this "abi hack" which alters
// the generated symbol's ABI.
//
// This will still define a function in this crate with the given name and
// signature, but the actual symbol for the intrinsic may have a slightly
// different ABI on win64.
(
#[win64_128bit_abi_hack]
$(#[$($attr:tt)*])*
pub extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
$($body:tt)*
}

$($rest:tt)*
) => (
#[cfg(all(any(windows, target_os = "uefi"), target_arch = "x86_64"))]
$(#[$($attr)*])*
pub extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
$($body)*
}

#[cfg(all(any(windows, target_os = "uefi"), target_arch = "x86_64", not(feature = "mangled-names")))]
mod $name {
#[no_mangle]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
extern $abi fn $name( $($argname: $ty),* )
-> $crate::macros::win64_128bit_abi_hack::U64x2
{
let e: $($ret)? = super::$name($($argname),*);
$crate::macros::win64_128bit_abi_hack::U64x2::from(e)
}
}

#[cfg(not(all(any(windows, target_os = "uefi"), target_arch = "x86_64")))]
intrinsics! {
$(#[$($attr)*])*
pub extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
$($body)*
}
}

intrinsics!($($rest)*);
);

// `arm_aeabi_alias` would conflict with `f16_apple_{arg,ret}_abi` not handled here. Avoid macro ambiguity by combining in a
// single `#[]`.
(
Expand Down Expand Up @@ -576,26 +528,3 @@ macro_rules! intrinsics {
intrinsics!($($rest)*);
);
}

// Hack for LLVM expectations for ABI on windows. This is used by the
// `#[win64_128bit_abi_hack]` attribute recognized above
#[cfg(all(any(windows, target_os = "uefi"), target_pointer_width = "64"))]
pub mod win64_128bit_abi_hack {
#[repr(simd)]
pub struct U64x2([u64; 2]);

impl From<i128> for U64x2 {
fn from(i: i128) -> U64x2 {
use crate::int::DInt;
let j = i as u128;
U64x2([j.lo(), j.hi()])
}
}

impl From<u128> for U64x2 {
fn from(i: u128) -> U64x2 {
use crate::int::DInt;
U64x2([i.lo(), i.hi()])
}
}
}

0 comments on commit 72d0cde

Please sign in to comment.