Path: blob/main/contrib/arm-optimized-routines/math/test/mathbench_wrappers.h
48254 views
/*1* Function wrappers for mathbench.2*3* Copyright (c) 2022-2024, Arm Limited.4* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception5*/67#if WANT_EXPERIMENTAL_MATH8static double9atan2_wrap (double x)10{11return atan2 (5.0, x);12}1314static float15atan2f_wrap (float x)16{17return atan2f (5.0f, x);18}1920static double21powi_wrap (double x)22{23return __builtin_powi (x, (int) round (x));24}25#endif /* WANT_EXPERIMENTAL_MATH. */2627#if __aarch64__ && __linux__2829__vpcs static float32x4_t30_Z_sincospif_wrap (float32x4_t x)31{32float s[4], c[4];33_ZGVnN4vl4l4_sincospif (x, s, c);34return vld1q_f32 (s) + vld1q_f32 (c);35}3637__vpcs static float64x2_t38_Z_sincospi_wrap (float64x2_t x)39{40double s[2], c[2];41_ZGVnN2vl8l8_sincospi (x, s, c);42return vld1q_f64 (s) + vld1q_f64 (c);43}4445__vpcs static float64x2_t46_Z_atan2_wrap (float64x2_t x)47{48return _ZGVnN2vv_atan2 (vdupq_n_f64 (5.0), x);49}5051__vpcs static float32x4_t52_Z_atan2f_wrap (float32x4_t x)53{54return _ZGVnN4vv_atan2f (vdupq_n_f32 (5.0f), x);55}5657__vpcs static float32x4_t58_Z_hypotf_wrap (float32x4_t x)59{60return _ZGVnN4vv_hypotf (vdupq_n_f32 (5.0f), x);61}6263__vpcs static float64x2_t64_Z_hypot_wrap (float64x2_t x)65{66return _ZGVnN2vv_hypot (vdupq_n_f64 (5.0), x);67}6869__vpcs static float32x4_t70xy_Z_powf (float32x4_t x)71{72return _ZGVnN4vv_powf (x, x);73}7475__vpcs static float32x4_t76x_Z_powf (float32x4_t x)77{78return _ZGVnN4vv_powf (x, vdupq_n_f32 (23.4));79}8081__vpcs static float32x4_t82y_Z_powf (float32x4_t x)83{84return _ZGVnN4vv_powf (vdupq_n_f32 (2.34), x);85}8687__vpcs static float64x2_t88xy_Z_pow (float64x2_t x)89{90return _ZGVnN2vv_pow (x, x);91}9293__vpcs static float64x2_t94x_Z_pow (float64x2_t x)95{96return _ZGVnN2vv_pow (x, vdupq_n_f64 (23.4));97}9899__vpcs static float64x2_t100y_Z_pow (float64x2_t x)101{102return _ZGVnN2vv_pow (vdupq_n_f64 (2.34), x);103}104105__vpcs static float32x4_t106_Z_modff_wrap (float32x4_t x)107{108float y[4];109float32x4_t ret = _ZGVnN4vl4_modff (x, y);110return ret + vld1q_f32 (y);111}112113__vpcs static float64x2_t114_Z_modf_wrap (float64x2_t x)115{116double y[2];117float64x2_t ret = _ZGVnN2vl8_modf (x, y);118return ret + vld1q_f64 (y);119}120121__vpcs static float32x4_t122_Z_sincosf_wrap (float32x4_t x)123{124float s[4], c[4];125_ZGVnN4vl4l4_sincosf (x, s, c);126return vld1q_f32 (s) + vld1q_f32 (c);127}128129__vpcs static float32x4_t130_Z_cexpif_wrap (float32x4_t x)131{132float32x4x2_t sc = _ZGVnN4v_cexpif (x);133return sc.val[0] + sc.val[1];134}135136__vpcs static float64x2_t137_Z_sincos_wrap (float64x2_t x)138{139double s[2], c[2];140_ZGVnN2vl8l8_sincos (x, s, c);141return vld1q_f64 (s) + vld1q_f64 (c);142}143144__vpcs static float64x2_t145_Z_cexpi_wrap (float64x2_t x)146{147float64x2x2_t sc = _ZGVnN2v_cexpi (x);148return sc.val[0] + sc.val[1];149}150151#endif152153#if WANT_SVE_TESTS154155static svfloat32_t156_Z_sv_atan2f_wrap (svfloat32_t x, svbool_t pg)157{158return _ZGVsMxvv_atan2f (x, svdup_f32 (5.0f), pg);159}160161static svfloat64_t162_Z_sv_atan2_wrap (svfloat64_t x, svbool_t pg)163{164return _ZGVsMxvv_atan2 (x, svdup_f64 (5.0), pg);165}166167static svfloat32_t168_Z_sv_hypotf_wrap (svfloat32_t x, svbool_t pg)169{170return _ZGVsMxvv_hypotf (x, svdup_f32 (5.0), pg);171}172173static svfloat64_t174_Z_sv_hypot_wrap (svfloat64_t x, svbool_t pg)175{176return _ZGVsMxvv_hypot (x, svdup_f64 (5.0), pg);177}178179static svfloat32_t180xy_Z_sv_powf (svfloat32_t x, svbool_t pg)181{182return _ZGVsMxvv_powf (x, x, pg);183}184185static svfloat32_t186x_Z_sv_powf (svfloat32_t x, svbool_t pg)187{188return _ZGVsMxvv_powf (x, svdup_f32 (23.4f), pg);189}190191static svfloat32_t192y_Z_sv_powf (svfloat32_t x, svbool_t pg)193{194return _ZGVsMxvv_powf (svdup_f32 (2.34f), x, pg);195}196197static svfloat64_t198xy_Z_sv_pow (svfloat64_t x, svbool_t pg)199{200return _ZGVsMxvv_pow (x, x, pg);201}202203static svfloat64_t204x_Z_sv_pow (svfloat64_t x, svbool_t pg)205{206return _ZGVsMxvv_pow (x, svdup_f64 (23.4), pg);207}208209static svfloat64_t210y_Z_sv_pow (svfloat64_t x, svbool_t pg)211{212return _ZGVsMxvv_pow (svdup_f64 (2.34), x, pg);213}214215static svfloat32_t216_Z_sv_sincospif_wrap (svfloat32_t x, svbool_t pg)217{218float s[svcntw ()], c[svcntw ()];219_ZGVsMxvl4l4_sincospif (x, s, c, pg);220return svadd_x (pg, svld1 (pg, s), svld1 (pg, c));221}222223static svfloat64_t224_Z_sv_sincospi_wrap (svfloat64_t x, svbool_t pg)225{226double s[svcntd ()], c[svcntd ()];227_ZGVsMxvl8l8_sincospi (x, s, c, pg);228return svadd_x (pg, svld1 (pg, s), svld1 (pg, c));229}230231static svfloat32_t232_Z_sv_modff_wrap (svfloat32_t x, svbool_t pg)233{234float i[svcntw ()];235svfloat32_t r = _ZGVsMxvl4_modff (x, i, pg);236return svadd_x (pg, r, svld1 (pg, i));237}238239static svfloat64_t240_Z_sv_modf_wrap (svfloat64_t x, svbool_t pg)241{242double i[svcntd ()];243svfloat64_t r = _ZGVsMxvl8_modf (x, i, pg);244return svadd_x (pg, r, svld1 (pg, i));245}246247static svfloat32_t248_Z_sv_sincosf_wrap (svfloat32_t x, svbool_t pg)249{250float s[svcntw ()], c[svcntw ()];251_ZGVsMxvl4l4_sincosf (x, s, c, pg);252return svadd_x (pg, svld1 (pg, s), svld1 (pg, s));253}254255static svfloat32_t256_Z_sv_cexpif_wrap (svfloat32_t x, svbool_t pg)257{258svfloat32x2_t sc = _ZGVsMxv_cexpif (x, pg);259return svadd_x (pg, svget2 (sc, 0), svget2 (sc, 1));260}261262static svfloat64_t263_Z_sv_sincos_wrap (svfloat64_t x, svbool_t pg)264{265double s[svcntd ()], c[svcntd ()];266_ZGVsMxvl8l8_sincos (x, s, c, pg);267return svadd_x (pg, svld1 (pg, s), svld1 (pg, s));268}269270static svfloat64_t271_Z_sv_cexpi_wrap (svfloat64_t x, svbool_t pg)272{273svfloat64x2_t sc = _ZGVsMxv_cexpi (x, pg);274return svadd_x (pg, svget2 (sc, 0), svget2 (sc, 1));275}276277# if WANT_EXPERIMENTAL_MATH278279static svfloat32_t280_Z_sv_powi_wrap (svfloat32_t x, svbool_t pg)281{282return _ZGVsMxvv_powi (x, svcvt_s32_f32_x (pg, x), pg);283}284285static svfloat64_t286_Z_sv_powk_wrap (svfloat64_t x, svbool_t pg)287{288return _ZGVsMxvv_powk (x, svcvt_s64_f64_x (pg, x), pg);289}290291# endif292293#endif294295#if __aarch64__296static float297sincospif_wrap (float x)298{299float s, c;300arm_math_sincospif (x, &s, &c);301return s + c;302}303304static double305sincospi_wrap (double x)306{307double s, c;308arm_math_sincospi (x, &s, &c);309return s + c;310}311#endif312313static double314xypow (double x)315{316return pow (x, x);317}318319static float320xypowf (float x)321{322return powf (x, x);323}324325static double326xpow (double x)327{328return pow (x, 23.4);329}330331static float332xpowf (float x)333{334return powf (x, 23.4f);335}336337static double338ypow (double x)339{340return pow (2.34, x);341}342343static float344ypowf (float x)345{346return powf (2.34f, x);347}348349static float350sincosf_wrap (float x)351{352float s, c;353sincosf (x, &s, &c);354return s + c;355}356357358