Index: llvm/trunk/include/llvm/Analysis/VecFuncs.def =================================================================== --- llvm/trunk/include/llvm/Analysis/VecFuncs.def +++ llvm/trunk/include/llvm/Analysis/VecFuncs.def @@ -0,0 +1,173 @@ +//===-- VecFuncs.def - Library information -------------*- C++ -*-----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This .def file will create mappings from scalar math functions to vector +// functions along with their vectorization factor. The current support includes +// such mappings for Accelerate framework and SVML library. + +#if !(defined(TLI_DEFINE_VECFUNC)) +#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF) {SCAL, VEC, VF}, +#endif + +#if defined(TLI_DEFINE_ACCELERATE_VECFUNCS) +// Accelerate framework's Vector Functions + +// Floating-Point Arithmetic and Auxiliary Functions +TLI_DEFINE_VECFUNC("ceilf", "vceilf", 4) +TLI_DEFINE_VECFUNC("fabsf", "vfabsf", 4) +TLI_DEFINE_VECFUNC("llvm.fabs.f32", "vfabsf", 4) +TLI_DEFINE_VECFUNC("floorf", "vfloorf", 4) +TLI_DEFINE_VECFUNC("sqrtf", "vsqrtf", 4) +TLI_DEFINE_VECFUNC("llvm.sqrt.f32", "vsqrtf", 4) + +// Exponential and Logarithmic Functions +TLI_DEFINE_VECFUNC("expf", "vexpf", 4) +TLI_DEFINE_VECFUNC("llvm.exp.f32", "vexpf", 4) +TLI_DEFINE_VECFUNC("expm1f", "vexpm1f", 4) +TLI_DEFINE_VECFUNC("logf", "vlogf", 4) +TLI_DEFINE_VECFUNC("llvm.log.f32", "vlogf", 4) +TLI_DEFINE_VECFUNC("log1pf", "vlog1pf", 4) +TLI_DEFINE_VECFUNC("log10f", "vlog10f", 4) +TLI_DEFINE_VECFUNC("llvm.log10.f32", "vlog10f", 4) +TLI_DEFINE_VECFUNC("logbf", "vlogbf", 4) + +// Trigonometric Functions +TLI_DEFINE_VECFUNC("sinf", "vsinf", 4) +TLI_DEFINE_VECFUNC("llvm.sin.f32", "vsinf", 4) +TLI_DEFINE_VECFUNC("cosf", "vcosf", 4) +TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", 4) +TLI_DEFINE_VECFUNC("tanf", "vtanf", 4) +TLI_DEFINE_VECFUNC("asinf", "vasinf", 4) +TLI_DEFINE_VECFUNC("acosf", "vacosf", 4) +TLI_DEFINE_VECFUNC("atanf", "vatanf", 4) + +// Hyperbolic Functions +TLI_DEFINE_VECFUNC("sinhf", "vsinhf", 4) +TLI_DEFINE_VECFUNC("coshf", "vcoshf", 4) +TLI_DEFINE_VECFUNC("tanhf", "vtanhf", 4) +TLI_DEFINE_VECFUNC("asinhf", "vasinhf", 4) +TLI_DEFINE_VECFUNC("acoshf", "vacoshf", 4) +TLI_DEFINE_VECFUNC("atanhf", "vatanhf", 4) + + +#elif defined(TLI_DEFINE_SVML_VECFUNCS) +// Intel SVM library's Vector Functions + +TLI_DEFINE_VECFUNC("sin", "__svml_sin2", 2) +TLI_DEFINE_VECFUNC("sin", "__svml_sin4", 4) +TLI_DEFINE_VECFUNC("sin", "__svml_sin8", 8) + +TLI_DEFINE_VECFUNC("sinf", "__svml_sinf4", 4) +TLI_DEFINE_VECFUNC("sinf", "__svml_sinf8", 8) +TLI_DEFINE_VECFUNC("sinf", "__svml_sinf16", 16) + +TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin2", 2) +TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin4", 4) +TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin8", 8) + +TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf4", 4) +TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf8", 8) +TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf16", 16) + +TLI_DEFINE_VECFUNC("cos", "__svml_cos2", 2) +TLI_DEFINE_VECFUNC("cos", "__svml_cos4", 4) +TLI_DEFINE_VECFUNC("cos", "__svml_cos8", 8) + +TLI_DEFINE_VECFUNC("cosf", "__svml_cosf4", 4) +TLI_DEFINE_VECFUNC("cosf", "__svml_cosf8", 8) +TLI_DEFINE_VECFUNC("cosf", "__svml_cosf16", 16) + +TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos2", 2) +TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos4", 4) +TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos8", 8) + +TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf4", 4) +TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf8", 8) +TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf16", 16) + +TLI_DEFINE_VECFUNC("pow", "__svml_pow2", 2) +TLI_DEFINE_VECFUNC("pow", "__svml_pow4", 4) +TLI_DEFINE_VECFUNC("pow", "__svml_pow8", 8) + +TLI_DEFINE_VECFUNC("powf", "__svml_powf4", 4) +TLI_DEFINE_VECFUNC("powf", "__svml_powf8", 8) +TLI_DEFINE_VECFUNC("powf", "__svml_powf16", 16) + +TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow2", 2) +TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow4", 4) +TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow8", 8) + +TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf4", 4) +TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf8", 8) +TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf16", 16) + +TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow2", 2) +TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow4", 4) +TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow8", 8) + +TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf4", 4) +TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf8", 8) +TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf16", 16) + +TLI_DEFINE_VECFUNC("exp", "__svml_exp2", 2) +TLI_DEFINE_VECFUNC("exp", "__svml_exp4", 4) +TLI_DEFINE_VECFUNC("exp", "__svml_exp8", 8) + +TLI_DEFINE_VECFUNC("expf", "__svml_expf4", 4) +TLI_DEFINE_VECFUNC("expf", "__svml_expf8", 8) +TLI_DEFINE_VECFUNC("expf", "__svml_expf16", 16) + +TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp2", 2) +TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp4", 4) +TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp8", 8) + +TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf4", 4) +TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf8", 8) +TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf16", 16) + +TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp2", 2) +TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp4", 4) +TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp8", 8) + +TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf4", 4) +TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf8", 8) +TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf16", 16) + +TLI_DEFINE_VECFUNC("log", "__svml_log2", 2) +TLI_DEFINE_VECFUNC("log", "__svml_log4", 4) +TLI_DEFINE_VECFUNC("log", "__svml_log8", 8) + +TLI_DEFINE_VECFUNC("logf", "__svml_logf4", 4) +TLI_DEFINE_VECFUNC("logf", "__svml_logf8", 8) +TLI_DEFINE_VECFUNC("logf", "__svml_logf16", 16) + +TLI_DEFINE_VECFUNC("__log_finite", "__svml_log2", 2) +TLI_DEFINE_VECFUNC("__log_finite", "__svml_log4", 4) +TLI_DEFINE_VECFUNC("__log_finite", "__svml_log8", 8) + +TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf4", 4) +TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf8", 8) +TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf16", 16) + +TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log2", 2) +TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log4", 4) +TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log8", 8) + +TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf4", 4) +TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf8", 8) +TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf16", 16) + + +#else +#error "Must choose which vector library functions are to be defined." +#endif + +#undef TLI_DEFINE_VECFUNC +#undef TLI_DEFINE_ACCELERATE_VECFUNCS +#undef TLI_DEFINE_SVML_VECFUNCS + Index: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp +++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp @@ -1473,151 +1473,16 @@ switch (VecLib) { case Accelerate: { const VecDesc VecFuncs[] = { - // Floating-Point Arithmetic and Auxiliary Functions - {"ceilf", "vceilf", 4}, - {"fabsf", "vfabsf", 4}, - {"llvm.fabs.f32", "vfabsf", 4}, - {"floorf", "vfloorf", 4}, - {"sqrtf", "vsqrtf", 4}, - {"llvm.sqrt.f32", "vsqrtf", 4}, - - // Exponential and Logarithmic Functions - {"expf", "vexpf", 4}, - {"llvm.exp.f32", "vexpf", 4}, - {"expm1f", "vexpm1f", 4}, - {"logf", "vlogf", 4}, - {"llvm.log.f32", "vlogf", 4}, - {"log1pf", "vlog1pf", 4}, - {"log10f", "vlog10f", 4}, - {"llvm.log10.f32", "vlog10f", 4}, - {"logbf", "vlogbf", 4}, - - // Trigonometric Functions - {"sinf", "vsinf", 4}, - {"llvm.sin.f32", "vsinf", 4}, - {"cosf", "vcosf", 4}, - {"llvm.cos.f32", "vcosf", 4}, - {"tanf", "vtanf", 4}, - {"asinf", "vasinf", 4}, - {"acosf", "vacosf", 4}, - {"atanf", "vatanf", 4}, - - // Hyperbolic Functions - {"sinhf", "vsinhf", 4}, - {"coshf", "vcoshf", 4}, - {"tanhf", "vtanhf", 4}, - {"asinhf", "vasinhf", 4}, - {"acoshf", "vacoshf", 4}, - {"atanhf", "vatanhf", 4}, + #define TLI_DEFINE_ACCELERATE_VECFUNCS + #include "llvm/Analysis/VecFuncs.def" }; addVectorizableFunctions(VecFuncs); break; } case SVML: { const VecDesc VecFuncs[] = { - {"sin", "__svml_sin2", 2}, - {"sin", "__svml_sin4", 4}, - {"sin", "__svml_sin8", 8}, - - {"sinf", "__svml_sinf4", 4}, - {"sinf", "__svml_sinf8", 8}, - {"sinf", "__svml_sinf16", 16}, - - {"llvm.sin.f64", "__svml_sin2", 2}, - {"llvm.sin.f64", "__svml_sin4", 4}, - {"llvm.sin.f64", "__svml_sin8", 8}, - - {"llvm.sin.f32", "__svml_sinf4", 4}, - {"llvm.sin.f32", "__svml_sinf8", 8}, - {"llvm.sin.f32", "__svml_sinf16", 16}, - - {"cos", "__svml_cos2", 2}, - {"cos", "__svml_cos4", 4}, - {"cos", "__svml_cos8", 8}, - - {"cosf", "__svml_cosf4", 4}, - {"cosf", "__svml_cosf8", 8}, - {"cosf", "__svml_cosf16", 16}, - - {"llvm.cos.f64", "__svml_cos2", 2}, - {"llvm.cos.f64", "__svml_cos4", 4}, - {"llvm.cos.f64", "__svml_cos8", 8}, - - {"llvm.cos.f32", "__svml_cosf4", 4}, - {"llvm.cos.f32", "__svml_cosf8", 8}, - {"llvm.cos.f32", "__svml_cosf16", 16}, - - {"pow", "__svml_pow2", 2}, - {"pow", "__svml_pow4", 4}, - {"pow", "__svml_pow8", 8}, - - {"powf", "__svml_powf4", 4}, - {"powf", "__svml_powf8", 8}, - {"powf", "__svml_powf16", 16}, - - { "__pow_finite", "__svml_pow2", 2 }, - { "__pow_finite", "__svml_pow4", 4 }, - { "__pow_finite", "__svml_pow8", 8 }, - - { "__powf_finite", "__svml_powf4", 4 }, - { "__powf_finite", "__svml_powf8", 8 }, - { "__powf_finite", "__svml_powf16", 16 }, - - {"llvm.pow.f64", "__svml_pow2", 2}, - {"llvm.pow.f64", "__svml_pow4", 4}, - {"llvm.pow.f64", "__svml_pow8", 8}, - - {"llvm.pow.f32", "__svml_powf4", 4}, - {"llvm.pow.f32", "__svml_powf8", 8}, - {"llvm.pow.f32", "__svml_powf16", 16}, - - {"exp", "__svml_exp2", 2}, - {"exp", "__svml_exp4", 4}, - {"exp", "__svml_exp8", 8}, - - {"expf", "__svml_expf4", 4}, - {"expf", "__svml_expf8", 8}, - {"expf", "__svml_expf16", 16}, - - { "__exp_finite", "__svml_exp2", 2 }, - { "__exp_finite", "__svml_exp4", 4 }, - { "__exp_finite", "__svml_exp8", 8 }, - - { "__expf_finite", "__svml_expf4", 4 }, - { "__expf_finite", "__svml_expf8", 8 }, - { "__expf_finite", "__svml_expf16", 16 }, - - {"llvm.exp.f64", "__svml_exp2", 2}, - {"llvm.exp.f64", "__svml_exp4", 4}, - {"llvm.exp.f64", "__svml_exp8", 8}, - - {"llvm.exp.f32", "__svml_expf4", 4}, - {"llvm.exp.f32", "__svml_expf8", 8}, - {"llvm.exp.f32", "__svml_expf16", 16}, - - {"log", "__svml_log2", 2}, - {"log", "__svml_log4", 4}, - {"log", "__svml_log8", 8}, - - {"logf", "__svml_logf4", 4}, - {"logf", "__svml_logf8", 8}, - {"logf", "__svml_logf16", 16}, - - { "__log_finite", "__svml_log2", 2 }, - { "__log_finite", "__svml_log4", 4 }, - { "__log_finite", "__svml_log8", 8 }, - - { "__logf_finite", "__svml_logf4", 4 }, - { "__logf_finite", "__svml_logf8", 8 }, - { "__logf_finite", "__svml_logf16", 16 }, - - {"llvm.log.f64", "__svml_log2", 2}, - {"llvm.log.f64", "__svml_log4", 4}, - {"llvm.log.f64", "__svml_log8", 8}, - - {"llvm.log.f32", "__svml_logf4", 4}, - {"llvm.log.f32", "__svml_logf8", 8}, - {"llvm.log.f32", "__svml_logf16", 16}, + #define TLI_DEFINE_SVML_VECFUNCS + #include "llvm/Analysis/VecFuncs.def" }; addVectorizableFunctions(VecFuncs); break;