Skip to content
Merged
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
116 changes: 81 additions & 35 deletions src/float/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ intrinsics! {
}
}

#[unadjusted_on_win64]
pub extern "C" fn __floattisf(i: i128) -> f32 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floattidf(i: i128) -> f64 {
int_to_float(i)
}

#[arm_aeabi_alias = __aeabi_ui2f]
pub extern "C" fn __floatunsisf(i: u32) -> f32 {
int_to_float(i)
Expand All @@ -140,16 +130,6 @@ intrinsics! {
pub extern "C" fn __floatundidf(i: u64) -> f64 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floatuntisf(i: u128) -> f32 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floatuntidf(i: u128) -> f64 {
int_to_float(i)
}
}

fn float_to_int<F: Float, I: Int>(f: F) -> I
Expand Down Expand Up @@ -224,11 +204,6 @@ intrinsics! {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixsfti(f: f32) -> i128 {
float_to_int(f)
}

#[arm_aeabi_alias = __aeabi_d2iz]
pub extern "C" fn __fixdfsi(f: f64) -> i32 {
float_to_int(f)
Expand All @@ -239,11 +214,6 @@ intrinsics! {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixdfti(f: f64) -> i128 {
float_to_int(f)
}

#[arm_aeabi_alias = __aeabi_f2uiz]
pub extern "C" fn __fixunssfsi(f: f32) -> u32 {
float_to_int(f)
Expand All @@ -254,11 +224,6 @@ intrinsics! {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixunssfti(f: f32) -> u128 {
float_to_int(f)
}

#[arm_aeabi_alias = __aeabi_d2uiz]
pub extern "C" fn __fixunsdfsi(f: f64) -> u32 {
float_to_int(f)
Expand All @@ -268,6 +233,87 @@ intrinsics! {
pub extern "C" fn __fixunsdfdi(f: f64) -> u64 {
float_to_int(f)
}
}

// The ABI for the following intrinsics changed in LLVM 14. On Win64, they now
// use Win64 ABI rather than unadjusted ABI. Pick the correct ABI based on the
// llvm14-builtins-abi target feature.

#[cfg(target_feature = "llvm14-builtins-abi")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this target feature be behind a feature gate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, we don't feature-gate #[cfg(target_feature)] (though we do gate #[target_feature]). cfg(target_feature) exposes all unstable target features on nightly builds.

intrinsics! {
pub extern "C" fn __floattisf(i: i128) -> f32 {
int_to_float(i)
}

pub extern "C" fn __floattidf(i: i128) -> f64 {
int_to_float(i)
}

pub extern "C" fn __floatuntisf(i: u128) -> f32 {
int_to_float(i)
}

pub extern "C" fn __floatuntidf(i: u128) -> f64 {
int_to_float(i)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixsfti(f: f32) -> i128 {
float_to_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixdfti(f: f64) -> i128 {
float_to_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixunssfti(f: f32) -> u128 {
float_to_int(f)
}

#[win64_128bit_abi_hack]
pub extern "C" fn __fixunsdfti(f: f64) -> u128 {
float_to_int(f)
}
}

#[cfg(not(target_feature = "llvm14-builtins-abi"))]
intrinsics! {
#[unadjusted_on_win64]
pub extern "C" fn __floattisf(i: i128) -> f32 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floattidf(i: i128) -> f64 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floatuntisf(i: u128) -> f32 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __floatuntidf(i: u128) -> f64 {
int_to_float(i)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixsfti(f: f32) -> i128 {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixdfti(f: f64) -> i128 {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixunssfti(f: f32) -> u128 {
float_to_int(f)
}

#[unadjusted_on_win64]
pub extern "C" fn __fixunsdfti(f: f64) -> u128 {
Expand Down