miri: shims for erf & friends
This commit is contained in:
parent
b8f0ed37bd
commit
18b9edec09
3 changed files with 15 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(cell_update)]
|
||||
#![feature(float_gamma)]
|
||||
#![feature(float_erf)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(never_type)]
|
||||
#![feature(try_blocks)]
|
||||
|
|
|
|||
|
|
@ -742,6 +742,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
| "log1pf"
|
||||
| "expm1f"
|
||||
| "tgammaf"
|
||||
| "erff"
|
||||
| "erfcf"
|
||||
=> {
|
||||
let [f] = this.check_shim(abi, Conv::C , link_name, args)?;
|
||||
let f = this.read_scalar(f)?.to_f32()?;
|
||||
|
|
@ -759,6 +761,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"log1pf" => f_host.ln_1p(),
|
||||
"expm1f" => f_host.exp_m1(),
|
||||
"tgammaf" => f_host.gamma(),
|
||||
"erff" => f_host.erf(),
|
||||
"erfcf" => f_host.erfc(),
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = res.to_soft();
|
||||
|
|
@ -799,6 +803,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
| "log1p"
|
||||
| "expm1"
|
||||
| "tgamma"
|
||||
| "erf"
|
||||
| "erfc"
|
||||
=> {
|
||||
let [f] = this.check_shim(abi, Conv::C , link_name, args)?;
|
||||
let f = this.read_scalar(f)?.to_f64()?;
|
||||
|
|
@ -816,6 +822,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"log1p" => f_host.ln_1p(),
|
||||
"expm1" => f_host.exp_m1(),
|
||||
"tgamma" => f_host.gamma(),
|
||||
"erf" => f_host.erf(),
|
||||
"erfc" => f_host.erfc(),
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = res.to_soft();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(float_erf)]
|
||||
#![feature(float_gamma)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(f128)]
|
||||
|
|
@ -1076,6 +1077,11 @@ pub fn libm() {
|
|||
let (val, sign) = (-0.5f64).ln_gamma();
|
||||
assert_approx_eq!(val, (2.0 * f64::consts::PI.sqrt()).ln());
|
||||
assert_eq!(sign, -1);
|
||||
|
||||
assert_approx_eq!(1.0f32.erf(), 0.84270079294971486934122063508260926f32);
|
||||
assert_approx_eq!(1.0f64.erf(), 0.84270079294971486934122063508260926f64);
|
||||
assert_approx_eq!(1.0f32.erfc(), 0.15729920705028513065877936491739074f32);
|
||||
assert_approx_eq!(1.0f64.erfc(), 0.15729920705028513065877936491739074f64);
|
||||
}
|
||||
|
||||
fn test_fast() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue