Skip to content

Commit 5a853b0

Browse files
nagisaest31
authored andcommitted
The windows special-cases only apply to x64
1 parent e0e5377 commit 5a853b0

File tree

1 file changed

+39
-31
lines changed
  • src/libcompiler_builtins

1 file changed

+39
-31
lines changed

src/libcompiler_builtins/lib.rs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ pub mod reimpls {
5151
// match here what LLVM expects from us. This is only
5252
// required for the return type!
5353
#[cfg(not(stage0))]
54-
#[cfg(windows)]
54+
#[cfg(all(windows, target_pointer_width="64"))]
5555
#[repr(simd)]
5656
pub struct u64x2(u64, u64);
5757

5858
#[cfg(not(stage0))]
59-
#[cfg(windows)]
59+
#[cfg(all(windows, target_pointer_width="64")]
6060
type u128ret = u64x2;
6161

62-
#[cfg(any(not(windows),stage0))]
62+
#[cfg(any(not(all(windows, target_pointer_width="64")),stage0))]
6363
type u128ret = u128_;
6464

6565
#[cfg(not(stage0))]
66-
#[cfg(windows)]
66+
#[cfg(all(windows, target_pointer_width="64")]
6767
type i128ret = u64x2;
6868

69-
#[cfg(any(not(windows),stage0))]
69+
#[cfg(any(not(all(windows, target_pointer_width="64")),stage0))]
7070
type i128ret = i128_;
7171

7272
macro_rules! ashl {
@@ -477,11 +477,11 @@ pub mod reimpls {
477477
#[repr(C, packed)] struct Parts(u64, u64);
478478
unsafe { ::core::mem::transmute(Parts(low, high)) }
479479
}
480-
#[cfg(not(windows))]
480+
#[cfg(not(all(windows, target_pointer_width="64")))]
481481
fn to_ret(self) -> u128ret {
482482
self
483483
}
484-
#[cfg(windows)]
484+
#[cfg(all(windows, target_pointer_width="64"))]
485485
fn to_ret(self) -> u128ret {
486486
u64x2(self.low(), self.high())
487487
}
@@ -501,11 +501,11 @@ pub mod reimpls {
501501
fn from_parts(low: u64, high: i64) -> i128 {
502502
u128::from_parts(low, high as u64) as i128
503503
}
504-
#[cfg(not(windows))]
504+
#[cfg(not(all(windows, target_pointer_width="64")))]
505505
fn to_ret(self) -> i128ret {
506506
self
507507
}
508-
#[cfg(windows)]
508+
#[cfg(all(windows, target_pointer_width="64"))]
509509
fn to_ret(self) -> i128ret {
510510
u64x2(self.low(), self.high() as u64)
511511
}
@@ -693,30 +693,35 @@ pub mod reimpls {
693693
// LLVM expectations for ABI on windows are pure madness.
694694

695695
#[cfg(not(stage0))]
696-
#[cfg_attr(windows, export_name="__floattidf")]
697-
pub extern "C" fn i128_as_f64_win(alow: u64, ahigh: i64) -> f64 {
698-
i128_as_f64(i128_::from_parts(alow, ahigh))
699-
}
696+
#[cfg(all(windows, target_pointer_width="64"))]
697+
mod windows_64_workarounds {
698+
#[export_name="__floattidf"]
699+
pub extern "C" fn i128_as_f64_win(alow: u64, ahigh: i64) -> f64 {
700+
::i128_as_f64(i128_::from_parts(alow, ahigh))
701+
}
700702

701-
#[cfg(not(stage0))]
702-
#[cfg_attr(windows, export_name="__floattisf")]
703-
pub extern "C" fn i128_as_f32_win(alow: u64, ahigh: i64) -> f32 {
704-
i128_as_f32(i128_::from_parts(alow, ahigh))
705-
}
703+
#[export_name="__floattisf"]
704+
pub extern "C" fn i128_as_f32_win(alow: u64, ahigh: i64) -> f32 {
705+
::i128_as_f32(i128_::from_parts(alow, ahigh))
706+
}
706707

707-
#[cfg(not(stage0))]
708-
#[cfg_attr(windows, export_name="__floatuntidf")]
709-
pub extern "C" fn u128_as_f64_win(alow: u64, ahigh: u64) -> f64 {
710-
u128_as_f64(u128_::from_parts(alow, ahigh))
711-
}
708+
#[export_name="__floatuntidf"]
709+
pub extern "C" fn u128_as_f64_win(alow: u64, ahigh: u64) -> f64 {
710+
::u128_as_f64(u128_::from_parts(alow, ahigh))
711+
}
712712

713-
#[cfg(not(stage0))]
714-
#[cfg_attr(windows, export_name="__floatuntisf")]
715-
pub extern "C" fn u128_as_f32_win(alow: u64, ahigh: u64) -> f32 {
716-
u128_as_f32(u128_::from_parts(alow, ahigh))
713+
#[export_name="__floatuntisf"]
714+
pub extern "C" fn u128_as_f32_win(alow: u64, ahigh: u64) -> f32 {
715+
::u128_as_f32(u128_::from_parts(alow, ahigh))
716+
}
717717
}
718+
#[cfg(not(stage0))]
719+
#[cfg(all(windows, target_pointer_width="64"))]
720+
pub use windows_64_workarounds::*;
721+
718722

719-
#[cfg_attr(any(not(windows),stage0),export_name="__floattidf")]
723+
#[cfg_attr(not(all(windows, target_pointer_width="64", not(stage0))),
724+
export_name="__floattidf")]
720725
pub extern "C" fn i128_as_f64(a: i128_) -> f64 {
721726
match a.signum() {
722727
1 => u128_as_f64(a.uabs()),
@@ -725,7 +730,8 @@ pub mod reimpls {
725730
}
726731
}
727732

728-
#[cfg_attr(any(not(windows),stage0),export_name="__floattisf")]
733+
#[cfg_attr(not(all(windows, target_pointer_width="64", not(stage0))),
734+
export_name="__floattisf")]
729735
pub extern "C" fn i128_as_f32(a: i128_) -> f32 {
730736
match a.signum() {
731737
1 => u128_as_f32(a.uabs()),
@@ -734,7 +740,8 @@ pub mod reimpls {
734740
}
735741
}
736742

737-
#[cfg_attr(any(not(windows),stage0),export_name="__floatuntidf")]
743+
#[cfg_attr(not(all(windows, target_pointer_width="64", not(stage0))),
744+
export_name="__floatuntidf")]
738745
pub extern "C" fn u128_as_f64(mut a: u128_) -> f64 {
739746
use ::core::f64::MANTISSA_DIGITS;
740747
if a == 0 { return 0.0; }
@@ -770,7 +777,8 @@ pub mod reimpls {
770777
}
771778
}
772779

773-
#[cfg_attr(any(not(windows),stage0),export_name="__floatuntisf")]
780+
#[cfg_attr(not(all(windows, target_pointer_width="64", not(stage0))),
781+
export_name="__floatuntisf")]
774782
pub extern "C" fn u128_as_f32(mut a: u128_) -> f32 {
775783
use ::core::f32::MANTISSA_DIGITS;
776784
if a == 0 { return 0.0; }

0 commit comments

Comments
 (0)