Skip to content

Rollup of 5 pull requests #129479

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 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0b87af9
Add `-Z embed-source=yes` to embed source code in DWARF debug info
Mrmaxmeier Apr 27, 2024
608901b
Add run-make test for -Zembed-source=yes
Mrmaxmeier Jul 16, 2024
6899f5a
-Zembed-source: Don't try to warn about incompatible codegen backends
Mrmaxmeier Aug 6, 2024
803cbaf
Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs
rezwanahmedsami Aug 17, 2024
9f39427
Added #[cfg(target_arch = x86_64)] to f16 and f128
rezwanahmedsami Aug 18, 2024
275a526
library: Move unstable API of new_uninit to new features
workingjubilee Aug 22, 2024
f62b9e0
rustc: Simplify getting sysroot library directory
petrochenkov Jul 30, 2024
cee7f18
compiletest: implement `needs-lvm-zstd` directive
lqd Aug 10, 2024
16b444d
mark `rust-lld-compress-debug-sections` test as needing zstd
lqd Aug 10, 2024
8b5118c
make `compressed-debuginfo` test about zlib only
lqd Aug 10, 2024
de40866
prepare test for expanding scope
lqd Aug 10, 2024
9d24aa8
expand zstd debuginfo compression test
lqd Aug 10, 2024
182eded
move and rename zstd script
lqd Aug 10, 2024
5950529
strip whitespace for ignored tests reason comments
lqd Aug 11, 2024
9d29bf9
enable `llvm.libzstd` on test x64 linux builder
lqd Aug 11, 2024
0452bf4
allow `llvm.libzstd` with `download-ci-llvm = true`
lqd Aug 20, 2024
4e0ca2b
CI: rfl: move to temporary commit
ojeda Aug 23, 2024
6d08619
Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwco
jieyouxu Aug 23, 2024
8a38ad4
Rollup merge of #128935 - lqd:needs-zstd, r=Kobzol
jieyouxu Aug 23, 2024
5438d97
Rollup merge of #129190 - rezwanahmedsami:master, r=tgross35
jieyouxu Aug 23, 2024
f17b9c1
Rollup merge of #129416 - workingjubilee:partial-move-from-stabilizat…
jieyouxu Aug 23, 2024
730c6db
Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxu
jieyouxu Aug 23, 2024
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
Prev Previous commit
Next Next commit
Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs
  • Loading branch information
rezwanahmedsami committed Aug 17, 2024
commit 803cbaf5fb5021eafaa60578ed33d708370ba3c0
65 changes: 64 additions & 1 deletion tests/ui/consts/const-float-bits-conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]
#![feature(f16)]
#![feature(f128)]
#![allow(unused_macro_rules)]

// Don't promote
const fn nop<T>(x: T) -> T { x }

Expand All @@ -28,6 +29,36 @@ fn has_broken_floats() -> bool {
std::env::var("TARGET").is_ok_and(|v| v.contains("i586"))
}

fn f16(){
const_assert!((1f16).to_bits(), 0x3c00);
const_assert!(u16::from_be_bytes(1f16.to_be_bytes()), 0x3c00);
const_assert!((12.5f16).to_bits(), 0x4a40);
const_assert!(u16::from_le_bytes(12.5f16.to_le_bytes()), 0x4a40);
const_assert!((1337f16).to_bits(), 0x6539);
const_assert!(u16::from_ne_bytes(1337f16.to_ne_bytes()), 0x6539);
const_assert!((-14.25f16).to_bits(), 0xcb20);
const_assert!(f16::from_bits(0x3c00), 1.0);
const_assert!(f16::from_be_bytes(0x3c00u16.to_be_bytes()), 1.0);
const_assert!(f16::from_bits(0x4a40), 12.5);
const_assert!(f16::from_le_bytes(0x4a40u16.to_le_bytes()), 12.5);
const_assert!(f16::from_bits(0x5be0), 252.0);
const_assert!(f16::from_ne_bytes(0x5be0u16.to_ne_bytes()), 252.0);
const_assert!(f16::from_bits(0xcb20), -14.25);

// Check that NaNs roundtrip their bits regardless of signalingness
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
const QUIET_NAN: u16 = f16::NAN.to_bits() ^ 0x0155;
const SIGNALING_NAN: u16 = f16::NAN.to_bits() ^ 0x02AA;

const_assert!(f16::from_bits(QUIET_NAN).is_nan());
const_assert!(f16::from_bits(SIGNALING_NAN).is_nan());
const_assert!(f16::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
if !has_broken_floats() {
const_assert!(f16::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
}
}

fn f32() {
const_assert!((1f32).to_bits(), 0x3f800000);
const_assert!(u32::from_be_bytes(1f32.to_be_bytes()), 0x3f800000);
Expand Down Expand Up @@ -88,7 +119,39 @@ fn f64() {
}
}

fn f128() {
const_assert!((1f128).to_bits(), 0x3fff0000000000000000000000000000);
const_assert!(u128::from_be_bytes(1f128.to_be_bytes()), 0x3fff0000000000000000000000000000);
const_assert!((12.5f128).to_bits(), 0x40029000000000000000000000000000);
const_assert!(u128::from_le_bytes(12.5f128.to_le_bytes()), 0x40029000000000000000000000000000);
const_assert!((1337f128).to_bits(), 0x40094e40000000000000000000000000);
const_assert!(u128::from_ne_bytes(1337f128.to_ne_bytes()), 0x40094e40000000000000000000000000);
const_assert!((-14.25f128).to_bits(), 0xc002c800000000000000000000000000);
const_assert!(f128::from_bits(0x3fff0000000000000000000000000000), 1.0);
const_assert!(f128::from_be_bytes(0x3fff0000000000000000000000000000u128.to_be_bytes()), 1.0);
const_assert!(f128::from_bits(0x40029000000000000000000000000000), 12.5);
const_assert!(f128::from_le_bytes(0x40029000000000000000000000000000u128.to_le_bytes()), 12.5);
const_assert!(f128::from_bits(0x40094e40000000000000000000000000), 1337.0);
assert_eq!(f128::from_ne_bytes(0x40094e40000000000000000000000000u128.to_ne_bytes()), 1337.0);
const_assert!(f128::from_bits(0xc002c800000000000000000000000000), -14.25);

// Check that NaNs roundtrip their bits regardless of signalingness
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
// NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
const QUIET_NAN: u128 = f128::NAN.to_bits() | 0x0000_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA_AAAA;
const SIGNALING_NAN: u128 = f128::NAN.to_bits() ^ 0x0000_5555_5555_5555_5555_5555_5555_5555;

const_assert!(f128::from_bits(QUIET_NAN).is_nan());
const_assert!(f128::from_bits(SIGNALING_NAN).is_nan());
const_assert!(f128::from_bits(QUIET_NAN).to_bits(), QUIET_NAN);
if !has_broken_floats() {
const_assert!(f128::from_bits(SIGNALING_NAN).to_bits(), SIGNALING_NAN);
}
}

fn main() {
f16();
f32();
f64();
f128();
}
Loading