Rollup merge of #140323 - tgross35:cfg-unstable-float, r=Urgau
Implement the internal feature `cfg_target_has_reliable_f16_f128`
Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable.
Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates:
* `cfg(target_has_reliable_f16)`
* `cfg(target_has_reliable_f16_math)`
* `cfg(target_has_reliable_f128)`
* `cfg(target_has_reliable_f128_math)`
`reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs.
These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up.
The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend.
MCP: https://github.com/rust-lang/compiler-team/issues/866
Closes: https://github.com/rust-lang/compiler-team/issues/866
[1]: 555e1d0386/library/std/build.rs (L84-L186)
---
The second commit makes use of this config to replace `cfg_{f16,f128}{,_math}` in `library/`. I omitted providing a `cfg(bootstrap)` configuration to keep things simpler since the next beta branch is in two weeks.
try-job: aarch64-gnu
try-job: i686-msvc-1
try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-ext2
This commit is contained in:
commit
e082bf341f
27 changed files with 959 additions and 289 deletions
|
|
@ -41,8 +41,8 @@ use std::sync::Arc;
|
|||
|
||||
use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::settings::{self, Configurable};
|
||||
use rustc_codegen_ssa::CodegenResults;
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_codegen_ssa::{CodegenResults, TargetConfig};
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_session::Session;
|
||||
|
|
@ -178,7 +178,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
|||
}
|
||||
}
|
||||
|
||||
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
|
||||
let target_features = if sess.target.arch == "x86_64" && sess.target.os != "none" {
|
||||
// x86_64 mandates SSE2 support and rustc requires the x87 feature to be enabled
|
||||
|
|
@ -197,7 +197,16 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
|||
};
|
||||
// FIXME do `unstable_target_features` properly
|
||||
let unstable_target_features = target_features.clone();
|
||||
(target_features, unstable_target_features)
|
||||
|
||||
TargetConfig {
|
||||
target_features,
|
||||
unstable_target_features,
|
||||
// Cranelift does not yet support f16 or f128
|
||||
has_reliable_f16: false,
|
||||
has_reliable_f16_math: false,
|
||||
has_reliable_f128: false,
|
||||
has_reliable_f128_math: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn print_version(&self) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
|||
)
|
||||
} else if let Some(feature) = feature.strip_prefix('-') {
|
||||
// FIXME: Why do we not remove implied features on "-" here?
|
||||
// We do the equivalent above in `target_features_cfg`.
|
||||
// We do the equivalent above in `target_config`.
|
||||
// See <https://github.com/rust-lang/rust/issues/134792>.
|
||||
all_rust_features.push((false, feature));
|
||||
} else if !feature.is_empty() && diagnostics {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ use rustc_codegen_ssa::back::write::{
|
|||
};
|
||||
use rustc_codegen_ssa::base::codegen_crate;
|
||||
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync::IntoDynSyncSend;
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
|
|
@ -260,8 +260,8 @@ impl CodegenBackend for GccCodegenBackend {
|
|||
.join(sess)
|
||||
}
|
||||
|
||||
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
target_features_cfg(sess, &self.target_info)
|
||||
fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
target_config(sess, &self.target_info)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -485,10 +485,7 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
|
|||
}
|
||||
|
||||
/// Returns the features that should be set in `cfg(target_feature)`.
|
||||
fn target_features_cfg(
|
||||
sess: &Session,
|
||||
target_info: &LockedTargetInfo,
|
||||
) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
fn target_config(sess: &Session, target_info: &LockedTargetInfo) -> TargetConfig {
|
||||
// TODO(antoyo): use global_gcc_features.
|
||||
let f = |allow_unstable| {
|
||||
sess.target
|
||||
|
|
@ -523,5 +520,14 @@ fn target_features_cfg(
|
|||
|
||||
let target_features = f(false);
|
||||
let unstable_target_features = f(true);
|
||||
(target_features, unstable_target_features)
|
||||
|
||||
TargetConfig {
|
||||
target_features,
|
||||
unstable_target_features,
|
||||
// There are no known bugs with GCC support for f16 or f128
|
||||
has_reliable_f16: true,
|
||||
has_reliable_f16_math: true,
|
||||
has_reliable_f128: true,
|
||||
has_reliable_f128_math: true,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use back::owned_target_machine::OwnedTargetMachine;
|
|||
use back::write::{create_informational_target_machine, create_target_machine};
|
||||
use context::SimpleCx;
|
||||
use errors::{AutoDiffWithoutLTO, ParseTargetMachineConfig};
|
||||
use llvm_util::target_features_cfg;
|
||||
use llvm_util::target_config;
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
|
||||
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
|
||||
|
|
@ -37,7 +37,7 @@ use rustc_codegen_ssa::back::write::{
|
|||
CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn,
|
||||
};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::{DiagCtxtHandle, FatalError};
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
|
|
@ -338,8 +338,8 @@ impl CodegenBackend for LlvmCodegenBackend {
|
|||
llvm_util::print_version();
|
||||
}
|
||||
|
||||
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
target_features_cfg(sess)
|
||||
fn target_config(&self, sess: &Session) -> TargetConfig {
|
||||
target_config(sess)
|
||||
}
|
||||
|
||||
fn codegen_crate<'tcx>(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use std::sync::Once;
|
|||
use std::{ptr, slice, str};
|
||||
|
||||
use libc::c_int;
|
||||
use rustc_codegen_ssa::TargetConfig;
|
||||
use rustc_codegen_ssa::base::wants_wasm_eh;
|
||||
use rustc_codegen_ssa::codegen_attrs::check_tied_features;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
|
|
@ -302,7 +303,7 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
|
|||
/// Must express features in the way Rust understands them.
|
||||
///
|
||||
/// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled outside codegen.
|
||||
pub(crate) fn target_features_cfg(sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
pub(crate) fn target_config(sess: &Session) -> TargetConfig {
|
||||
// Add base features for the target.
|
||||
// We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below.
|
||||
// The reason is that if LLVM considers a feature implied but we do not, we don't want that to
|
||||
|
|
@ -402,7 +403,89 @@ pub(crate) fn target_features_cfg(sess: &Session) -> (Vec<Symbol>, Vec<Symbol>)
|
|||
|
||||
let target_features = f(false);
|
||||
let unstable_target_features = f(true);
|
||||
(target_features, unstable_target_features)
|
||||
let mut cfg = TargetConfig {
|
||||
target_features,
|
||||
unstable_target_features,
|
||||
has_reliable_f16: true,
|
||||
has_reliable_f16_math: true,
|
||||
has_reliable_f128: true,
|
||||
has_reliable_f128_math: true,
|
||||
};
|
||||
|
||||
update_target_reliable_float_cfg(sess, &mut cfg);
|
||||
cfg
|
||||
}
|
||||
|
||||
/// Determine whether or not experimental float types are reliable based on known bugs.
|
||||
fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
|
||||
let target_arch = sess.target.arch.as_ref();
|
||||
let target_os = sess.target.options.os.as_ref();
|
||||
let target_env = sess.target.options.env.as_ref();
|
||||
let target_abi = sess.target.options.abi.as_ref();
|
||||
let target_pointer_width = sess.target.pointer_width;
|
||||
|
||||
cfg.has_reliable_f16 = match (target_arch, target_os) {
|
||||
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
|
||||
("s390x", _) => false,
|
||||
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
|
||||
("arm64ec", _) => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
|
||||
("csky", _) => false,
|
||||
("hexagon", _) => false,
|
||||
("powerpc" | "powerpc64", _) => false,
|
||||
("sparc" | "sparc64", _) => false,
|
||||
("wasm32" | "wasm64", _) => false,
|
||||
// `f16` support only requires that symbols converting to and from `f32` are available. We
|
||||
// provide these in `compiler-builtins`, so `f16` should be available on all platforms that
|
||||
// do not have other ABI issues or LLVM crashes.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
cfg.has_reliable_f128 = match (target_arch, target_os) {
|
||||
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
|
||||
("arm64ec", _) => false,
|
||||
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
|
||||
("mips64" | "mips64r6", _) => false,
|
||||
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
|
||||
("nvptx64", _) => false,
|
||||
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
|
||||
// list at <https://github.com/rust-lang/rust/issues/116909>)
|
||||
("powerpc" | "powerpc64", _) => false,
|
||||
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
|
||||
("sparc", _) => false,
|
||||
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
|
||||
// not fail if our compiler-builtins is linked.
|
||||
("x86", _) => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
// There are no known problems on other platforms, so the only requirement is that symbols
|
||||
// are available. `compiler-builtins` provides all symbols required for core `f128`
|
||||
// support, so this should work for everything else.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
cfg.has_reliable_f16_math = match (target_arch, target_os) {
|
||||
// x86 has a crash for `powi`: <https://github.com/llvm/llvm-project/issues/105747>
|
||||
("x86" | "x86_64", _) => false,
|
||||
// Assume that working `f16` means working `f16` math for most platforms, since
|
||||
// operations just go through `f32`.
|
||||
_ => true,
|
||||
} && cfg.has_reliable_f16;
|
||||
|
||||
cfg.has_reliable_f128_math = match (target_arch, target_os) {
|
||||
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
|
||||
// `long double` is not IEEE binary128. See
|
||||
// <https://github.com/llvm/llvm-project/issues/44744>.
|
||||
//
|
||||
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
|
||||
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
|
||||
// (ld is 80-bit extended precision).
|
||||
("x86_64", _) => false,
|
||||
(_, "linux") if target_pointer_width == 64 => true,
|
||||
_ => false,
|
||||
} && cfg.has_reliable_f128;
|
||||
}
|
||||
|
||||
pub(crate) fn print_version() {
|
||||
|
|
@ -686,7 +769,7 @@ pub(crate) fn global_llvm_features(
|
|||
)
|
||||
} else if let Some(feature) = feature.strip_prefix('-') {
|
||||
// FIXME: Why do we not remove implied features on "-" here?
|
||||
// We do the equivalent above in `target_features_cfg`.
|
||||
// We do the equivalent above in `target_config`.
|
||||
// See <https://github.com/rust-lang/rust/issues/134792>.
|
||||
all_rust_features.push((false, feature));
|
||||
} else if !feature.is_empty() {
|
||||
|
|
|
|||
|
|
@ -235,6 +235,24 @@ pub struct CrateInfo {
|
|||
pub lint_levels: CodegenLintLevels,
|
||||
}
|
||||
|
||||
/// Target-specific options that get set in `cfg(...)`.
|
||||
///
|
||||
/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
|
||||
pub struct TargetConfig {
|
||||
/// Options to be set in `cfg(target_features)`.
|
||||
pub target_features: Vec<Symbol>,
|
||||
/// Options to be set in `cfg(target_features)`, but including unstable features.
|
||||
pub unstable_target_features: Vec<Symbol>,
|
||||
/// Option for `cfg(target_has_reliable_f16)`, true if `f16` basic arithmetic works.
|
||||
pub has_reliable_f16: bool,
|
||||
/// Option for `cfg(target_has_reliable_f16_math)`, true if `f16` math calls work.
|
||||
pub has_reliable_f16_math: bool,
|
||||
/// Option for `cfg(target_has_reliable_f128)`, true if `f128` basic arithmetic works.
|
||||
pub has_reliable_f128: bool,
|
||||
/// Option for `cfg(target_has_reliable_f128_math)`, true if `f128` math calls work.
|
||||
pub has_reliable_f128_math: bool,
|
||||
}
|
||||
|
||||
#[derive(Encodable, Decodable)]
|
||||
pub struct CodegenResults {
|
||||
pub modules: Vec<CompiledModule>,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use super::write::WriteBackendMethods;
|
|||
use crate::back::archive::ArArchiveBuilderBuilder;
|
||||
use crate::back::link::link_binary;
|
||||
use crate::back::write::TargetMachineFactoryFn;
|
||||
use crate::{CodegenResults, ModuleCodegen};
|
||||
use crate::{CodegenResults, ModuleCodegen, TargetConfig};
|
||||
|
||||
pub trait BackendTypes {
|
||||
type Value: CodegenObject;
|
||||
|
|
@ -50,8 +50,15 @@ pub trait CodegenBackend {
|
|||
/// - The second is like the first, but also includes unstable features.
|
||||
///
|
||||
/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
|
||||
fn target_features_cfg(&self, _sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
|
||||
(vec![], vec![])
|
||||
fn target_config(&self, _sess: &Session) -> TargetConfig {
|
||||
TargetConfig {
|
||||
target_features: vec![],
|
||||
unstable_target_features: vec![],
|
||||
has_reliable_f16: true,
|
||||
has_reliable_f16_math: true,
|
||||
has_reliable_f128: true,
|
||||
has_reliable_f128_math: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn print_passes(&self) {}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,26 @@ const GATED_CFGS: &[GatedCfg] = &[
|
|||
// this is consistent with naming of the compiler flag it's for
|
||||
(sym::fmt_debug, sym::fmt_debug, Features::fmt_debug),
|
||||
(sym::emscripten_wasm_eh, sym::cfg_emscripten_wasm_eh, Features::cfg_emscripten_wasm_eh),
|
||||
(
|
||||
sym::target_has_reliable_f16,
|
||||
sym::cfg_target_has_reliable_f16_f128,
|
||||
Features::cfg_target_has_reliable_f16_f128,
|
||||
),
|
||||
(
|
||||
sym::target_has_reliable_f16_math,
|
||||
sym::cfg_target_has_reliable_f16_f128,
|
||||
Features::cfg_target_has_reliable_f16_f128,
|
||||
),
|
||||
(
|
||||
sym::target_has_reliable_f128,
|
||||
sym::cfg_target_has_reliable_f16_f128,
|
||||
Features::cfg_target_has_reliable_f16_f128,
|
||||
),
|
||||
(
|
||||
sym::target_has_reliable_f128_math,
|
||||
sym::cfg_target_has_reliable_f16_f128,
|
||||
Features::cfg_target_has_reliable_f16_f128,
|
||||
),
|
||||
];
|
||||
|
||||
/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
|
||||
|
|
|
|||
|
|
@ -205,6 +205,8 @@ declare_features! (
|
|||
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
|
||||
/// Allows access to the emscripten_wasm_eh config, used by panic_unwind and unwind
|
||||
(internal, cfg_emscripten_wasm_eh, "1.86.0", None),
|
||||
/// Allows checking whether or not the backend correctly supports unstable float types.
|
||||
(internal, cfg_target_has_reliable_f16_f128, "CURRENT_RUSTC_VERSION", None),
|
||||
/// Allows identifying the `compiler_builtins` crate.
|
||||
(internal, compiler_builtins, "1.13.0", None),
|
||||
/// Allows writing custom MIR
|
||||
|
|
|
|||
|
|
@ -38,14 +38,25 @@ pub(crate) fn add_configuration(
|
|||
codegen_backend: &dyn CodegenBackend,
|
||||
) {
|
||||
let tf = sym::target_feature;
|
||||
let tf_cfg = codegen_backend.target_config(sess);
|
||||
|
||||
let (target_features, unstable_target_features) = codegen_backend.target_features_cfg(sess);
|
||||
sess.unstable_target_features.extend(tf_cfg.unstable_target_features.iter().copied());
|
||||
sess.target_features.extend(tf_cfg.target_features.iter().copied());
|
||||
|
||||
sess.unstable_target_features.extend(unstable_target_features.iter().copied());
|
||||
cfg.extend(tf_cfg.target_features.into_iter().map(|feat| (tf, Some(feat))));
|
||||
|
||||
sess.target_features.extend(target_features.iter().copied());
|
||||
|
||||
cfg.extend(target_features.into_iter().map(|feat| (tf, Some(feat))));
|
||||
if tf_cfg.has_reliable_f16 {
|
||||
cfg.insert((sym::target_has_reliable_f16, None));
|
||||
}
|
||||
if tf_cfg.has_reliable_f16_math {
|
||||
cfg.insert((sym::target_has_reliable_f16_math, None));
|
||||
}
|
||||
if tf_cfg.has_reliable_f128 {
|
||||
cfg.insert((sym::target_has_reliable_f128, None));
|
||||
}
|
||||
if tf_cfg.has_reliable_f128_math {
|
||||
cfg.insert((sym::target_has_reliable_f128_math, None));
|
||||
}
|
||||
|
||||
if sess.crt_static(None) {
|
||||
cfg.insert((tf, Some(sym::crt_dash_static)));
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
|
|||
| (sym::target_has_atomic, Some(_))
|
||||
| (sym::target_has_atomic_equal_alignment, Some(_))
|
||||
| (sym::target_has_atomic_load_store, Some(_))
|
||||
| (sym::target_has_reliable_f16, None | Some(_))
|
||||
| (sym::target_has_reliable_f16_math, None | Some(_))
|
||||
| (sym::target_has_reliable_f128, None | Some(_))
|
||||
| (sym::target_has_reliable_f128_math, None | Some(_))
|
||||
| (sym::target_thread_local, None) => disallow(cfg, "--target"),
|
||||
(sym::fmt_debug, None | Some(_)) => disallow(cfg, "-Z fmt-debug"),
|
||||
(sym::emscripten_wasm_eh, None | Some(_)) => disallow(cfg, "-Z emscripten_wasm_eh"),
|
||||
|
|
|
|||
|
|
@ -614,6 +614,7 @@ symbols! {
|
|||
cfg_target_feature,
|
||||
cfg_target_has_atomic,
|
||||
cfg_target_has_atomic_equal_alignment,
|
||||
cfg_target_has_reliable_f16_f128,
|
||||
cfg_target_thread_local,
|
||||
cfg_target_vendor,
|
||||
cfg_trace: "<cfg>", // must not be a valid identifier
|
||||
|
|
@ -2068,6 +2069,10 @@ symbols! {
|
|||
target_has_atomic,
|
||||
target_has_atomic_equal_alignment,
|
||||
target_has_atomic_load_store,
|
||||
target_has_reliable_f128,
|
||||
target_has_reliable_f128_math,
|
||||
target_has_reliable_f16,
|
||||
target_has_reliable_f16_math,
|
||||
target_os,
|
||||
target_pointer_width,
|
||||
target_thread_local,
|
||||
|
|
|
|||
|
|
@ -163,4 +163,10 @@ check-cfg = [
|
|||
# and to the `backtrace` crate which messes-up with Cargo list
|
||||
# of declared features, we therefor expect any feature cfg
|
||||
'cfg(feature, values(any()))',
|
||||
# Internal features aren't marked known config by default, we use these to
|
||||
# gate tests.
|
||||
'cfg(target_has_reliable_f16)',
|
||||
'cfg(target_has_reliable_f16_math)',
|
||||
'cfg(target_has_reliable_f128)',
|
||||
'cfg(target_has_reliable_f128_math)',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,12 +7,6 @@ fn main() {
|
|||
let target_vendor =
|
||||
env::var("CARGO_CFG_TARGET_VENDOR").expect("CARGO_CFG_TARGET_VENDOR was not set");
|
||||
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
|
||||
let target_abi = env::var("CARGO_CFG_TARGET_ABI").expect("CARGO_CFG_TARGET_ABI was not set");
|
||||
let target_pointer_width: u32 = env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
|
||||
.expect("CARGO_CFG_TARGET_POINTER_WIDTH was not set")
|
||||
.parse()
|
||||
.unwrap();
|
||||
let is_miri = env::var_os("CARGO_CFG_MIRI").is_some();
|
||||
|
||||
println!("cargo:rustc-check-cfg=cfg(netbsd10)");
|
||||
if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
|
||||
|
|
@ -80,108 +74,4 @@ fn main() {
|
|||
println!("cargo:rustc-cfg=backtrace_in_libstd");
|
||||
|
||||
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
|
||||
|
||||
// Emit these on platforms that have no known ABI bugs, LLVM selection bugs, lowering bugs,
|
||||
// missing symbols, or other problems, to determine when tests get run.
|
||||
// If more broken platforms are found, please update the tracking issue at
|
||||
// <https://github.com/rust-lang/rust/issues/116909>
|
||||
//
|
||||
// Some of these match arms are redundant; the goal is to separate reasons that the type is
|
||||
// unreliable, even when multiple reasons might fail the same platform.
|
||||
println!("cargo:rustc-check-cfg=cfg(reliable_f16)");
|
||||
println!("cargo:rustc-check-cfg=cfg(reliable_f128)");
|
||||
|
||||
// This is a step beyond only having the types and basic functions available. Math functions
|
||||
// aren't consistently available or correct.
|
||||
println!("cargo:rustc-check-cfg=cfg(reliable_f16_math)");
|
||||
println!("cargo:rustc-check-cfg=cfg(reliable_f128_math)");
|
||||
|
||||
let has_reliable_f16 = match (target_arch.as_str(), target_os.as_str()) {
|
||||
// We can always enable these in Miri as that is not affected by codegen bugs.
|
||||
_ if is_miri => true,
|
||||
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
|
||||
("s390x", _) => false,
|
||||
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
|
||||
("arm64ec", _) => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
|
||||
("csky", _) => false,
|
||||
("hexagon", _) => false,
|
||||
("powerpc" | "powerpc64", _) => false,
|
||||
("sparc" | "sparc64", _) => false,
|
||||
("wasm32" | "wasm64", _) => false,
|
||||
// `f16` support only requires that symbols converting to and from `f32` are available. We
|
||||
// provide these in `compiler-builtins`, so `f16` should be available on all platforms that
|
||||
// do not have other ABI issues or LLVM crashes.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
let has_reliable_f128 = match (target_arch.as_str(), target_os.as_str()) {
|
||||
// We can always enable these in Miri as that is not affected by codegen bugs.
|
||||
_ if is_miri => true,
|
||||
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
|
||||
("arm64ec", _) => false,
|
||||
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
|
||||
("mips64" | "mips64r6", _) => false,
|
||||
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
|
||||
("nvptx64", _) => false,
|
||||
// ABI bugs <https://github.com/rust-lang/rust/issues/125109> et al. (full
|
||||
// list at <https://github.com/rust-lang/rust/issues/116909>)
|
||||
("powerpc" | "powerpc64", _) => false,
|
||||
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
|
||||
("sparc", _) => false,
|
||||
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
|
||||
// not fail if our compiler-builtins is linked.
|
||||
("x86", _) => false,
|
||||
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
|
||||
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
|
||||
// There are no known problems on other platforms, so the only requirement is that symbols
|
||||
// are available. `compiler-builtins` provides all symbols required for core `f128`
|
||||
// support, so this should work for everything else.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
// Configure platforms that have reliable basics but may have unreliable math.
|
||||
|
||||
// LLVM is currently adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
|
||||
let has_reliable_f16_math = has_reliable_f16
|
||||
&& match (target_arch.as_str(), target_os.as_str()) {
|
||||
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
|
||||
_ if is_miri => false,
|
||||
// x86 has a crash for `powi`: <https://github.com/llvm/llvm-project/issues/105747>
|
||||
("x86" | "x86_64", _) => false,
|
||||
// Assume that working `f16` means working `f16` math for most platforms, since
|
||||
// operations just go through `f32`.
|
||||
_ => true,
|
||||
};
|
||||
|
||||
let has_reliable_f128_math = has_reliable_f128
|
||||
&& match (target_arch.as_str(), target_os.as_str()) {
|
||||
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
|
||||
_ if is_miri => false,
|
||||
// LLVM lowers `fp128` math to `long double` symbols even on platforms where
|
||||
// `long double` is not IEEE binary128. See
|
||||
// <https://github.com/llvm/llvm-project/issues/44744>.
|
||||
//
|
||||
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
|
||||
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
|
||||
// (ld is 80-bit extended precision).
|
||||
("x86_64", _) => false,
|
||||
(_, "linux") if target_pointer_width == 64 => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if has_reliable_f16 {
|
||||
println!("cargo:rustc-cfg=reliable_f16");
|
||||
}
|
||||
if has_reliable_f128 {
|
||||
println!("cargo:rustc-cfg=reliable_f128");
|
||||
}
|
||||
if has_reliable_f16_math {
|
||||
println!("cargo:rustc-cfg=reliable_f16_math");
|
||||
}
|
||||
if has_reliable_f128_math {
|
||||
println!("cargo:rustc-cfg=reliable_f128_math");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 3.7_f128;
|
||||
/// let g = 3.0_f128;
|
||||
|
|
@ -49,7 +53,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 3.01_f128;
|
||||
/// let g = 4.0_f128;
|
||||
|
|
@ -76,7 +84,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 3.3_f128;
|
||||
/// let g = -3.3_f128;
|
||||
|
|
@ -108,7 +120,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 3.3_f128;
|
||||
/// let g = -3.3_f128;
|
||||
|
|
@ -138,7 +154,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 3.7_f128;
|
||||
/// let g = 3.0_f128;
|
||||
|
|
@ -166,7 +186,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 3.6_f128;
|
||||
/// let y = -3.6_f128;
|
||||
|
|
@ -203,7 +227,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let m = 10.0_f128;
|
||||
/// let x = 4.0_f128;
|
||||
|
|
@ -247,7 +275,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let a: f128 = 7.0;
|
||||
/// let b = 4.0;
|
||||
|
|
@ -289,7 +321,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let a: f128 = 7.0;
|
||||
/// let b = 4.0;
|
||||
|
|
@ -326,7 +362,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 2.0_f128;
|
||||
/// let abs_difference = (x.powi(2) - (x * x)).abs();
|
||||
|
|
@ -354,7 +394,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 2.0_f128;
|
||||
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
|
||||
|
|
@ -386,7 +430,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let positive = 4.0_f128;
|
||||
/// let negative = -4.0_f128;
|
||||
|
|
@ -417,7 +465,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let one = 1.0f128;
|
||||
/// // e^1
|
||||
|
|
@ -448,7 +500,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 2.0f128;
|
||||
///
|
||||
|
|
@ -479,7 +535,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let one = 1.0f128;
|
||||
/// // e^1
|
||||
|
|
@ -495,7 +555,11 @@ impl f128 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f128.ln(), f128::NEG_INFINITY);
|
||||
/// assert!((-42_f128).ln().is_nan());
|
||||
|
|
@ -526,7 +590,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let five = 5.0f128;
|
||||
///
|
||||
|
|
@ -540,7 +608,11 @@ impl f128 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f128.log(10.0), f128::NEG_INFINITY);
|
||||
/// assert!((-42_f128).log(10.0).is_nan());
|
||||
|
|
@ -567,7 +639,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let two = 2.0f128;
|
||||
///
|
||||
|
|
@ -581,7 +657,11 @@ impl f128 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f128.log2(), f128::NEG_INFINITY);
|
||||
/// assert!((-42_f128).log2().is_nan());
|
||||
|
|
@ -608,7 +688,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let ten = 10.0f128;
|
||||
///
|
||||
|
|
@ -622,7 +706,11 @@ impl f128 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f128.log10(), f128::NEG_INFINITY);
|
||||
/// assert!((-42_f128).log10().is_nan());
|
||||
|
|
@ -651,7 +739,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 8.0f128;
|
||||
///
|
||||
|
|
@ -687,7 +779,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 2.0f128;
|
||||
/// let y = 3.0f128;
|
||||
|
|
@ -717,7 +813,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = std::f128::consts::FRAC_PI_2;
|
||||
///
|
||||
|
|
@ -745,7 +845,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 2.0 * std::f128::consts::PI;
|
||||
///
|
||||
|
|
@ -776,7 +880,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = std::f128::consts::FRAC_PI_4;
|
||||
/// let abs_difference = (x.tan() - 1.0).abs();
|
||||
|
|
@ -808,7 +916,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = std::f128::consts::FRAC_PI_2;
|
||||
///
|
||||
|
|
@ -843,7 +955,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = std::f128::consts::FRAC_PI_4;
|
||||
///
|
||||
|
|
@ -877,7 +993,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let f = 1.0f128;
|
||||
///
|
||||
|
|
@ -915,7 +1035,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// // Positive angles measured counter-clockwise
|
||||
/// // from positive x axis
|
||||
|
|
@ -957,7 +1081,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = std::f128::consts::FRAC_PI_4;
|
||||
/// let f = x.sin_cos();
|
||||
|
|
@ -992,7 +1120,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 1e-8_f128;
|
||||
///
|
||||
|
|
@ -1028,7 +1160,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 1e-8_f128;
|
||||
///
|
||||
|
|
@ -1043,7 +1179,11 @@ impl f128 {
|
|||
/// Out-of-range values:
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// assert_eq!((-1.0_f128).ln_1p(), f128::NEG_INFINITY);
|
||||
/// assert!((-2.0_f128).ln_1p().is_nan());
|
||||
|
|
@ -1072,7 +1212,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let e = std::f128::consts::E;
|
||||
/// let x = 1.0f128;
|
||||
|
|
@ -1107,7 +1251,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let e = std::f128::consts::E;
|
||||
/// let x = 1.0f128;
|
||||
|
|
@ -1142,7 +1290,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let e = std::f128::consts::E;
|
||||
/// let x = 1.0f128;
|
||||
|
|
@ -1174,7 +1326,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 1.0f128;
|
||||
/// let f = x.sinh().asinh();
|
||||
|
|
@ -1206,7 +1362,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 1.0f128;
|
||||
/// let f = x.cosh().acosh();
|
||||
|
|
@ -1240,7 +1400,11 @@ impl f128 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let e = std::f128::consts::E;
|
||||
/// let f = e.tanh().atanh();
|
||||
|
|
@ -1274,7 +1438,11 @@ impl f128 {
|
|||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// #![feature(float_gamma)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 5.0f128;
|
||||
///
|
||||
|
|
@ -1309,7 +1477,11 @@ impl f128 {
|
|||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// #![feature(float_gamma)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
///
|
||||
/// let x = 2.0f128;
|
||||
///
|
||||
|
|
@ -1344,7 +1516,11 @@ impl f128 {
|
|||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// #![feature(float_erf)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
/// /// The error function relates what percent of a normal distribution lies
|
||||
/// /// within `x` standard deviations (scaled by `1/sqrt(2)`).
|
||||
/// fn within_standard_deviations(x: f128) -> f128 {
|
||||
|
|
@ -1383,7 +1559,11 @@ impl f128 {
|
|||
/// ```
|
||||
/// #![feature(f128)]
|
||||
/// #![feature(float_erf)]
|
||||
/// # #[cfg(reliable_f128_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f128_math)] {
|
||||
/// let x: f128 = 0.123;
|
||||
///
|
||||
/// let one = x.erf() + x.erfc();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 3.7_f16;
|
||||
/// let g = 3.0_f16;
|
||||
|
|
@ -49,7 +53,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 3.01_f16;
|
||||
/// let g = 4.0_f16;
|
||||
|
|
@ -76,7 +84,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 3.3_f16;
|
||||
/// let g = -3.3_f16;
|
||||
|
|
@ -108,7 +120,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 3.3_f16;
|
||||
/// let g = -3.3_f16;
|
||||
|
|
@ -138,7 +154,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 3.7_f16;
|
||||
/// let g = 3.0_f16;
|
||||
|
|
@ -166,7 +186,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 3.6_f16;
|
||||
/// let y = -3.6_f16;
|
||||
|
|
@ -203,7 +227,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let m = 10.0_f16;
|
||||
/// let x = 4.0_f16;
|
||||
|
|
@ -247,7 +275,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let a: f16 = 7.0;
|
||||
/// let b = 4.0;
|
||||
|
|
@ -289,7 +321,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let a: f16 = 7.0;
|
||||
/// let b = 4.0;
|
||||
|
|
@ -326,7 +362,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 2.0_f16;
|
||||
/// let abs_difference = (x.powi(2) - (x * x)).abs();
|
||||
|
|
@ -354,7 +394,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 2.0_f16;
|
||||
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
|
||||
|
|
@ -386,7 +430,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let positive = 4.0_f16;
|
||||
/// let negative = -4.0_f16;
|
||||
|
|
@ -417,7 +465,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let one = 1.0f16;
|
||||
/// // e^1
|
||||
|
|
@ -448,7 +500,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 2.0f16;
|
||||
///
|
||||
|
|
@ -479,7 +535,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let one = 1.0f16;
|
||||
/// // e^1
|
||||
|
|
@ -495,7 +555,11 @@ impl f16 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f16.ln(), f16::NEG_INFINITY);
|
||||
/// assert!((-42_f16).ln().is_nan());
|
||||
|
|
@ -526,7 +590,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let five = 5.0f16;
|
||||
///
|
||||
|
|
@ -540,7 +608,11 @@ impl f16 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f16.log(10.0), f16::NEG_INFINITY);
|
||||
/// assert!((-42_f16).log(10.0).is_nan());
|
||||
|
|
@ -567,7 +639,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let two = 2.0f16;
|
||||
///
|
||||
|
|
@ -581,7 +657,11 @@ impl f16 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f16.log2(), f16::NEG_INFINITY);
|
||||
/// assert!((-42_f16).log2().is_nan());
|
||||
|
|
@ -608,7 +688,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let ten = 10.0f16;
|
||||
///
|
||||
|
|
@ -622,7 +706,11 @@ impl f16 {
|
|||
/// Non-positive values:
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// assert_eq!(0_f16.log10(), f16::NEG_INFINITY);
|
||||
/// assert!((-42_f16).log10().is_nan());
|
||||
|
|
@ -650,7 +738,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 8.0f16;
|
||||
///
|
||||
|
|
@ -685,7 +777,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 2.0f16;
|
||||
/// let y = 3.0f16;
|
||||
|
|
@ -715,7 +811,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = std::f16::consts::FRAC_PI_2;
|
||||
///
|
||||
|
|
@ -743,7 +843,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 2.0 * std::f16::consts::PI;
|
||||
///
|
||||
|
|
@ -774,7 +878,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = std::f16::consts::FRAC_PI_4;
|
||||
/// let abs_difference = (x.tan() - 1.0).abs();
|
||||
|
|
@ -806,7 +914,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = std::f16::consts::FRAC_PI_2;
|
||||
///
|
||||
|
|
@ -841,7 +953,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = std::f16::consts::FRAC_PI_4;
|
||||
///
|
||||
|
|
@ -875,7 +991,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let f = 1.0f16;
|
||||
///
|
||||
|
|
@ -913,7 +1033,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// // Positive angles measured counter-clockwise
|
||||
/// // from positive x axis
|
||||
|
|
@ -955,7 +1079,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = std::f16::consts::FRAC_PI_4;
|
||||
/// let f = x.sin_cos();
|
||||
|
|
@ -990,7 +1118,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 1e-4_f16;
|
||||
///
|
||||
|
|
@ -1026,7 +1158,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 1e-4_f16;
|
||||
///
|
||||
|
|
@ -1041,7 +1177,11 @@ impl f16 {
|
|||
/// Out-of-range values:
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// assert_eq!((-1.0_f16).ln_1p(), f16::NEG_INFINITY);
|
||||
/// assert!((-2.0_f16).ln_1p().is_nan());
|
||||
|
|
@ -1070,7 +1210,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let e = std::f16::consts::E;
|
||||
/// let x = 1.0f16;
|
||||
|
|
@ -1105,7 +1249,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let e = std::f16::consts::E;
|
||||
/// let x = 1.0f16;
|
||||
|
|
@ -1140,7 +1288,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let e = std::f16::consts::E;
|
||||
/// let x = 1.0f16;
|
||||
|
|
@ -1172,7 +1324,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 1.0f16;
|
||||
/// let f = x.sinh().asinh();
|
||||
|
|
@ -1204,7 +1360,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 1.0f16;
|
||||
/// let f = x.cosh().acosh();
|
||||
|
|
@ -1238,7 +1398,11 @@ impl f16 {
|
|||
///
|
||||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let e = std::f16::consts::E;
|
||||
/// let f = e.tanh().atanh();
|
||||
|
|
@ -1272,7 +1436,11 @@ impl f16 {
|
|||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// #![feature(float_gamma)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 5.0f16;
|
||||
///
|
||||
|
|
@ -1307,7 +1475,11 @@ impl f16 {
|
|||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// #![feature(float_gamma)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
///
|
||||
/// let x = 2.0f16;
|
||||
///
|
||||
|
|
@ -1342,7 +1514,11 @@ impl f16 {
|
|||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// #![feature(float_erf)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
/// /// The error function relates what percent of a normal distribution lies
|
||||
/// /// within `x` standard deviations (scaled by `1/sqrt(2)`).
|
||||
/// fn within_standard_deviations(x: f16) -> f16 {
|
||||
|
|
@ -1381,7 +1557,11 @@ impl f16 {
|
|||
/// ```
|
||||
/// #![feature(f16)]
|
||||
/// #![feature(float_erf)]
|
||||
/// # #[cfg(reliable_f16_math)] {
|
||||
/// # #![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
/// # #![cfg_attr(not(bootstrap), expect(internal_features))]
|
||||
/// # #[cfg(not(miri))]
|
||||
/// # #[cfg(not(bootstrap))]
|
||||
/// # #[cfg(target_has_reliable_f16_math)] {
|
||||
/// let x: f16 = 0.123;
|
||||
///
|
||||
/// let one = x.erf() + x.erfc();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
|
||||
#![cfg(reliable_f128)]
|
||||
#![cfg(not(bootstrap))]
|
||||
#![cfg(target_has_reliable_f128)]
|
||||
|
||||
use std::f128::consts;
|
||||
use std::num::FpCategory as Fp;
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
use std::ops::Rem;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
|
||||
|
|
@ -19,7 +22,9 @@ const TOL: f128 = 1e-12;
|
|||
|
||||
/// Tolerances for math that is allowed to be imprecise, usually due to multiple chained
|
||||
/// operations.
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
const TOL_IMPR: f128 = 1e-10;
|
||||
|
||||
/// Smallest number
|
||||
|
|
@ -66,8 +71,13 @@ fn test_num_f128() {
|
|||
assert_eq!(ten.div(two), ten / two);
|
||||
}
|
||||
|
||||
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
|
||||
// the intrinsics.
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_num_f128_rem() {
|
||||
let ten = 10f128;
|
||||
let two = 2f128;
|
||||
|
|
@ -75,28 +85,36 @@ fn test_num_f128_rem() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_min_nan() {
|
||||
assert_eq!(f128::NAN.min(2.0), 2.0);
|
||||
assert_eq!(2.0f128.min(f128::NAN), 2.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_max_nan() {
|
||||
assert_eq!(f128::NAN.max(2.0), 2.0);
|
||||
assert_eq!(2.0f128.max(f128::NAN), 2.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_minimum() {
|
||||
assert!(f128::NAN.minimum(2.0).is_nan());
|
||||
assert!(2.0f128.minimum(f128::NAN).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_maximum() {
|
||||
assert!(f128::NAN.maximum(2.0).is_nan());
|
||||
assert!(2.0f128.maximum(f128::NAN).is_nan());
|
||||
|
|
@ -253,7 +271,9 @@ fn test_classify() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_floor() {
|
||||
assert_approx_eq!(1.0f128.floor(), 1.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.3f128.floor(), 1.0f128, TOL_PRECISE);
|
||||
|
|
@ -268,7 +288,9 @@ fn test_floor() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_ceil() {
|
||||
assert_approx_eq!(1.0f128.ceil(), 1.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.3f128.ceil(), 2.0f128, TOL_PRECISE);
|
||||
|
|
@ -283,7 +305,9 @@ fn test_ceil() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_round() {
|
||||
assert_approx_eq!(2.5f128.round(), 3.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.0f128.round(), 1.0f128, TOL_PRECISE);
|
||||
|
|
@ -299,7 +323,9 @@ fn test_round() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_round_ties_even() {
|
||||
assert_approx_eq!(2.5f128.round_ties_even(), 2.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.0f128.round_ties_even(), 1.0f128, TOL_PRECISE);
|
||||
|
|
@ -315,7 +341,9 @@ fn test_round_ties_even() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_trunc() {
|
||||
assert_approx_eq!(1.0f128.trunc(), 1.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.3f128.trunc(), 1.0f128, TOL_PRECISE);
|
||||
|
|
@ -330,7 +358,9 @@ fn test_trunc() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_fract() {
|
||||
assert_approx_eq!(1.0f128.fract(), 0.0f128, TOL_PRECISE);
|
||||
assert_approx_eq!(1.3f128.fract(), 0.3f128, TOL_PRECISE);
|
||||
|
|
@ -345,7 +375,9 @@ fn test_fract() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_abs() {
|
||||
assert_eq!(f128::INFINITY.abs(), f128::INFINITY);
|
||||
assert_eq!(1f128.abs(), 1f128);
|
||||
|
|
@ -445,7 +477,9 @@ fn test_next_down() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_mul_add() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -462,7 +496,9 @@ fn test_mul_add() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_recip() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -484,7 +520,9 @@ fn test_recip() {
|
|||
// Many math functions allow for less accurate results, so the next tolerance up is used
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_powi() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -499,7 +537,9 @@ fn test_powi() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_powf() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -516,7 +556,9 @@ fn test_powf() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_sqrt_domain() {
|
||||
assert!(f128::NAN.sqrt().is_nan());
|
||||
assert!(f128::NEG_INFINITY.sqrt().is_nan());
|
||||
|
|
@ -528,7 +570,9 @@ fn test_sqrt_domain() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_exp() {
|
||||
assert_eq!(1.0, 0.0f128.exp());
|
||||
assert_approx_eq!(consts::E, 1.0f128.exp(), TOL);
|
||||
|
|
@ -543,7 +587,9 @@ fn test_exp() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_exp2() {
|
||||
assert_eq!(32.0, 5.0f128.exp2());
|
||||
assert_eq!(1.0, 0.0f128.exp2());
|
||||
|
|
@ -557,7 +603,9 @@ fn test_exp2() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_ln() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -573,7 +621,9 @@ fn test_ln() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_log() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -592,7 +642,9 @@ fn test_log() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_log2() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -609,7 +661,9 @@ fn test_log2() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_log10() {
|
||||
let nan: f128 = f128::NAN;
|
||||
let inf: f128 = f128::INFINITY;
|
||||
|
|
@ -659,7 +713,9 @@ fn test_to_radians() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_asinh() {
|
||||
// Lower accuracy results are allowed, use increased tolerances
|
||||
assert_eq!(0.0f128.asinh(), 0.0f128);
|
||||
|
|
@ -690,7 +746,9 @@ fn test_asinh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_acosh() {
|
||||
assert_eq!(1.0f128.acosh(), 0.0f128);
|
||||
assert!(0.999f128.acosh().is_nan());
|
||||
|
|
@ -709,7 +767,9 @@ fn test_acosh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_atanh() {
|
||||
assert_eq!(0.0f128.atanh(), 0.0f128);
|
||||
assert_eq!((-0.0f128).atanh(), -0.0f128);
|
||||
|
|
@ -729,7 +789,9 @@ fn test_atanh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_gamma() {
|
||||
// precision can differ among platforms
|
||||
assert_approx_eq!(1.0f128.gamma(), 1.0f128, TOL_IMPR);
|
||||
|
|
@ -750,7 +812,9 @@ fn test_gamma() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
fn test_ln_gamma() {
|
||||
assert_approx_eq!(1.0f128.ln_gamma().0, 0.0f128, TOL_IMPR);
|
||||
assert_eq!(1.0f128.ln_gamma().1, 1);
|
||||
|
|
@ -781,7 +845,9 @@ fn test_real_consts() {
|
|||
assert_approx_eq!(frac_1_pi, 1f128 / pi, TOL_PRECISE);
|
||||
assert_approx_eq!(frac_2_pi, 2f128 / pi, TOL_PRECISE);
|
||||
|
||||
#[cfg(reliable_f128_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
{
|
||||
let frac_2_sqrtpi: f128 = consts::FRAC_2_SQRT_PI;
|
||||
let sqrt2: f128 = consts::SQRT_2;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy
|
||||
#![cfg(reliable_f16)]
|
||||
#![cfg(not(bootstrap))]
|
||||
#![cfg(target_has_reliable_f16)]
|
||||
|
||||
use std::f16::consts;
|
||||
use std::num::FpCategory as Fp;
|
||||
|
|
@ -57,29 +58,40 @@ fn test_num_f16() {
|
|||
crate::test_num(10f16, 2f16);
|
||||
}
|
||||
|
||||
// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support
|
||||
// the intrinsics.
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_min_nan() {
|
||||
assert_eq!(f16::NAN.min(2.0), 2.0);
|
||||
assert_eq!(2.0f16.min(f16::NAN), 2.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_max_nan() {
|
||||
assert_eq!(f16::NAN.max(2.0), 2.0);
|
||||
assert_eq!(2.0f16.max(f16::NAN), 2.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_minimum() {
|
||||
assert!(f16::NAN.minimum(2.0).is_nan());
|
||||
assert!(2.0f16.minimum(f16::NAN).is_nan());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_maximum() {
|
||||
assert!(f16::NAN.maximum(2.0).is_nan());
|
||||
assert!(2.0f16.maximum(f16::NAN).is_nan());
|
||||
|
|
@ -236,7 +248,9 @@ fn test_classify() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_floor() {
|
||||
assert_approx_eq!(1.0f16.floor(), 1.0f16, TOL_0);
|
||||
assert_approx_eq!(1.3f16.floor(), 1.0f16, TOL_0);
|
||||
|
|
@ -251,7 +265,9 @@ fn test_floor() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_ceil() {
|
||||
assert_approx_eq!(1.0f16.ceil(), 1.0f16, TOL_0);
|
||||
assert_approx_eq!(1.3f16.ceil(), 2.0f16, TOL_0);
|
||||
|
|
@ -266,7 +282,9 @@ fn test_ceil() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_round() {
|
||||
assert_approx_eq!(2.5f16.round(), 3.0f16, TOL_0);
|
||||
assert_approx_eq!(1.0f16.round(), 1.0f16, TOL_0);
|
||||
|
|
@ -282,7 +300,9 @@ fn test_round() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_round_ties_even() {
|
||||
assert_approx_eq!(2.5f16.round_ties_even(), 2.0f16, TOL_0);
|
||||
assert_approx_eq!(1.0f16.round_ties_even(), 1.0f16, TOL_0);
|
||||
|
|
@ -298,7 +318,9 @@ fn test_round_ties_even() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_trunc() {
|
||||
assert_approx_eq!(1.0f16.trunc(), 1.0f16, TOL_0);
|
||||
assert_approx_eq!(1.3f16.trunc(), 1.0f16, TOL_0);
|
||||
|
|
@ -313,7 +335,9 @@ fn test_trunc() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_fract() {
|
||||
assert_approx_eq!(1.0f16.fract(), 0.0f16, TOL_0);
|
||||
assert_approx_eq!(1.3f16.fract(), 0.3f16, TOL_0);
|
||||
|
|
@ -328,7 +352,9 @@ fn test_fract() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_abs() {
|
||||
assert_eq!(f16::INFINITY.abs(), f16::INFINITY);
|
||||
assert_eq!(1f16.abs(), 1f16);
|
||||
|
|
@ -428,7 +454,9 @@ fn test_next_down() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_mul_add() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -445,7 +473,9 @@ fn test_mul_add() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_recip() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -461,7 +491,9 @@ fn test_recip() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_powi() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -476,7 +508,9 @@ fn test_powi() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_powf() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -493,7 +527,9 @@ fn test_powf() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_sqrt_domain() {
|
||||
assert!(f16::NAN.sqrt().is_nan());
|
||||
assert!(f16::NEG_INFINITY.sqrt().is_nan());
|
||||
|
|
@ -505,7 +541,9 @@ fn test_sqrt_domain() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_exp() {
|
||||
assert_eq!(1.0, 0.0f16.exp());
|
||||
assert_approx_eq!(2.718282, 1.0f16.exp(), TOL_0);
|
||||
|
|
@ -520,7 +558,9 @@ fn test_exp() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_exp2() {
|
||||
assert_eq!(32.0, 5.0f16.exp2());
|
||||
assert_eq!(1.0, 0.0f16.exp2());
|
||||
|
|
@ -534,7 +574,9 @@ fn test_exp2() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_ln() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -550,7 +592,9 @@ fn test_ln() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_log() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -569,7 +613,9 @@ fn test_log() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_log2() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -586,7 +632,9 @@ fn test_log2() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_log10() {
|
||||
let nan: f16 = f16::NAN;
|
||||
let inf: f16 = f16::INFINITY;
|
||||
|
|
@ -634,7 +682,9 @@ fn test_to_radians() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_asinh() {
|
||||
assert_eq!(0.0f16.asinh(), 0.0f16);
|
||||
assert_eq!((-0.0f16).asinh(), -0.0f16);
|
||||
|
|
@ -659,7 +709,9 @@ fn test_asinh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_acosh() {
|
||||
assert_eq!(1.0f16.acosh(), 0.0f16);
|
||||
assert!(0.999f16.acosh().is_nan());
|
||||
|
|
@ -678,7 +730,9 @@ fn test_acosh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_atanh() {
|
||||
assert_eq!(0.0f16.atanh(), 0.0f16);
|
||||
assert_eq!((-0.0f16).atanh(), -0.0f16);
|
||||
|
|
@ -698,7 +752,9 @@ fn test_atanh() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_gamma() {
|
||||
// precision can differ among platforms
|
||||
assert_approx_eq!(1.0f16.gamma(), 1.0f16, TOL_0);
|
||||
|
|
@ -719,7 +775,9 @@ fn test_gamma() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_ln_gamma() {
|
||||
assert_approx_eq!(1.0f16.ln_gamma().0, 0.0f16, TOL_0);
|
||||
assert_eq!(1.0f16.ln_gamma().1, 1);
|
||||
|
|
@ -752,7 +810,9 @@ fn test_real_consts() {
|
|||
assert_approx_eq!(frac_1_pi, 1f16 / pi, TOL_0);
|
||||
assert_approx_eq!(frac_2_pi, 2f16 / pi, TOL_0);
|
||||
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
{
|
||||
let frac_2_sqrtpi: f16 = consts::FRAC_2_SQRT_PI;
|
||||
let sqrt2: f16 = consts::SQRT_2;
|
||||
|
|
@ -813,7 +873,9 @@ fn test_clamp_max_is_nan() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(reliable_f16_math)]
|
||||
#[cfg(not(miri))]
|
||||
#[cfg(not(bootstrap))]
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
fn test_total_cmp() {
|
||||
use core::cmp::Ordering;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#![feature(f16, f128, float_algebraic, float_gamma, float_minimum_maximum)]
|
||||
#![cfg_attr(not(bootstrap), feature(cfg_target_has_reliable_f16_f128))]
|
||||
#![cfg_attr(not(bootstrap), expect(internal_features))] // for reliable_f16_f128
|
||||
|
||||
use std::fmt;
|
||||
use std::ops::{Add, Div, Mul, Rem, Sub};
|
||||
|
|
|
|||
8
tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_.stderr
Normal file
8
tests/ui/cfg/disallowed-cli-cfgs.reliable_f128_.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: unexpected `--cfg target_has_reliable_f128` flag
|
||||
|
|
||||
= note: config `target_has_reliable_f128` is only supposed to be controlled by `--target`
|
||||
= note: manually setting a built-in cfg can and does create incoherent behaviors
|
||||
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: unexpected `--cfg target_has_reliable_f128_math` flag
|
||||
|
|
||||
= note: config `target_has_reliable_f128_math` is only supposed to be controlled by `--target`
|
||||
= note: manually setting a built-in cfg can and does create incoherent behaviors
|
||||
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
8
tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_.stderr
Normal file
8
tests/ui/cfg/disallowed-cli-cfgs.reliable_f16_.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: unexpected `--cfg target_has_reliable_f16` flag
|
||||
|
|
||||
= note: config `target_has_reliable_f16` is only supposed to be controlled by `--target`
|
||||
= note: manually setting a built-in cfg can and does create incoherent behaviors
|
||||
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: unexpected `--cfg target_has_reliable_f16_math` flag
|
||||
|
|
||||
= note: config `target_has_reliable_f16_math` is only supposed to be controlled by `--target`
|
||||
= note: manually setting a built-in cfg can and does create incoherent behaviors
|
||||
= note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
//@ revisions: target_thread_local_ relocation_model_
|
||||
//@ revisions: fmt_debug_
|
||||
//@ revisions: emscripten_wasm_eh_
|
||||
//@ revisions: reliable_f16_ reliable_f16_math_ reliable_f128_ reliable_f128_math_
|
||||
|
||||
//@ [overflow_checks_]compile-flags: --cfg overflow_checks
|
||||
//@ [debug_assertions_]compile-flags: --cfg debug_assertions
|
||||
|
|
@ -35,6 +36,10 @@
|
|||
//@ [relocation_model_]compile-flags: --cfg relocation_model="a"
|
||||
//@ [fmt_debug_]compile-flags: --cfg fmt_debug="shallow"
|
||||
//@ [emscripten_wasm_eh_]compile-flags: --cfg emscripten_wasm_eh
|
||||
//@ [reliable_f16_]compile-flags: --cfg target_has_reliable_f16
|
||||
//@ [reliable_f16_math_]compile-flags: --cfg target_has_reliable_f16_math
|
||||
//@ [reliable_f128_]compile-flags: --cfg target_has_reliable_f128
|
||||
//@ [reliable_f128_math_]compile-flags: --cfg target_has_reliable_f128_math
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f16_math,target_has_reliable_f128,target_has_reliable_f128_math)
|
||||
|
||||
fn main() {
|
||||
cfg!(target_has_reliable_f16);
|
||||
//~^ ERROR `cfg(target_has_reliable_f16)` is experimental and subject to change
|
||||
cfg!(target_has_reliable_f16_math);
|
||||
//~^ ERROR `cfg(target_has_reliable_f16_math)` is experimental and subject to change
|
||||
cfg!(target_has_reliable_f128);
|
||||
//~^ ERROR `cfg(target_has_reliable_f128)` is experimental and subject to change
|
||||
cfg!(target_has_reliable_f128_math);
|
||||
//~^ ERROR `cfg(target_has_reliable_f128_math)` is experimental and subject to change
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
error[E0658]: `cfg(target_has_reliable_f16)` is experimental and subject to change
|
||||
--> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:4:10
|
||||
|
|
||||
LL | cfg!(target_has_reliable_f16);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(cfg_target_has_reliable_f16_f128)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `cfg(target_has_reliable_f16_math)` is experimental and subject to change
|
||||
--> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:6:10
|
||||
|
|
||||
LL | cfg!(target_has_reliable_f16_math);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(cfg_target_has_reliable_f16_f128)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `cfg(target_has_reliable_f128)` is experimental and subject to change
|
||||
--> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:8:10
|
||||
|
|
||||
LL | cfg!(target_has_reliable_f128);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(cfg_target_has_reliable_f16_f128)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `cfg(target_has_reliable_f128_math)` is experimental and subject to change
|
||||
--> $DIR/feature-gate-cfg-target-has-reliable-f16-f128.rs:10:10
|
||||
|
|
||||
LL | cfg!(target_has_reliable_f128_math);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(cfg_target_has_reliable_f16_f128)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
31
tests/ui/float/target-has-reliable-nightly-float.rs
Normal file
31
tests/ui/float/target-has-reliable-nightly-float.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//@ run-pass
|
||||
//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16,target_has_reliable_f16_math,target_has_reliable_f128,target_has_reliable_f128_math)
|
||||
// Verify that the feature gates and config work and are registered as known config
|
||||
// options.
|
||||
|
||||
#![deny(unexpected_cfgs)]
|
||||
#![feature(cfg_target_has_reliable_f16_f128)]
|
||||
|
||||
#[cfg(target_has_reliable_f16)]
|
||||
pub fn has_f16() {}
|
||||
|
||||
#[cfg(target_has_reliable_f16_math)]
|
||||
pub fn has_f16_math() {}
|
||||
|
||||
#[cfg(target_has_reliable_f128 )]
|
||||
pub fn has_f128() {}
|
||||
|
||||
#[cfg(target_has_reliable_f128_math)]
|
||||
pub fn has_f128_math() {}
|
||||
|
||||
fn main() {
|
||||
if cfg!(target_arch = "aarch64") && cfg!(target_os = "linux") {
|
||||
// Aarch64+Linux is one target that has support for all features, so use it to spot
|
||||
// check that the compiler does indeed enable these gates.
|
||||
|
||||
assert!(cfg!(target_has_reliable_f16));
|
||||
assert!(cfg!(target_has_reliable_f16_math));
|
||||
assert!(cfg!(target_has_reliable_f128));
|
||||
assert!(cfg!(target_has_reliable_f128_math));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue