Index: include/clang/Basic/Builtins.def =================================================================== --- include/clang/Basic/Builtins.def +++ include/clang/Basic/Builtins.def @@ -197,6 +197,9 @@ BUILTIN(__builtin_exp2 , "dd" , "Fne") BUILTIN(__builtin_exp2f, "ff" , "Fne") BUILTIN(__builtin_exp2l, "LdLd", "Fne") +BUILTIN(__builtin_exp10 , "dd" , "Fne") +BUILTIN(__builtin_exp10f, "ff" , "Fne") +BUILTIN(__builtin_exp10l, "LdLd", "Fne") BUILTIN(__builtin_expm1 , "dd", "Fne") BUILTIN(__builtin_expm1f, "ff", "Fne") BUILTIN(__builtin_expm1l, "LdLd", "Fne") @@ -1147,6 +1150,10 @@ LIBBUILTIN(expm1f, "ff", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(expm1l, "LdLd", "fne", "math.h", ALL_LANGUAGES) +LIBBUILTIN(exp10, "dd", "fne", "math.h", ALL_LANGUAGES) +LIBBUILTIN(exp10f, "ff", "fne", "math.h", ALL_LANGUAGES) +LIBBUILTIN(exp10l, "LdLd", "fne", "math.h", ALL_LANGUAGES) + LIBBUILTIN(fdim, "ddd", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(fdimf, "fff", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(fdiml, "LdLdLd", "fne", "math.h", ALL_LANGUAGES) @@ -1380,10 +1387,6 @@ LIBBUILTIN(__tanpi, "dd", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(__tanpif, "ff", "fne", "math.h", ALL_LANGUAGES) -// Similarly, __exp10 is OS X only -LIBBUILTIN(__exp10, "dd", "fne", "math.h", ALL_LANGUAGES) -LIBBUILTIN(__exp10f, "ff", "fne", "math.h", ALL_LANGUAGES) - // Blocks runtime Builtin math library functions LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h", ALL_LANGUAGES) LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h", ALL_LANGUAGES) Index: include/clang/Basic/CodeGenOptions.h =================================================================== --- include/clang/Basic/CodeGenOptions.h +++ include/clang/Basic/CodeGenOptions.h @@ -53,7 +53,9 @@ enum VectorLibrary { NoLibrary, // Don't use any vector library. Accelerate, // Use the Accelerate framework. - SVML // Intel short vector math library. + SVML, // Intel short vector math library. + SLEEF // SLEEF - SIMD Library for Evaluating Elementary Functions. + // (Experimental). }; Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1407,7 +1407,7 @@ Group, Flags<[CC1Option]>, HelpText<"Disables an experimental new pass manager in LLVM.">; def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>, - HelpText<"Use the given vector functions library">, Values<"Accelerate,SVML,none">; + HelpText<"Use the given vector functions library">, Values<"Accelerate,SVML,SLEEF,none">; def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, Group, HelpText<"Disallow implicit conversions between vectors with a different number of elements or different element types">, Flags<[CC1Option]>; def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, Group, Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -352,6 +352,9 @@ case CodeGenOptions::SVML: TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML); break; + case CodeGenOptions::SLEEF: + TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SLEEF); + break; default: break; } Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -1598,6 +1598,62 @@ case Builtin::BI__builtin_copysignf128: return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::copysign)); + case Builtin::BIacos: + case Builtin::BIacosf: + case Builtin::BIacosl: + case Builtin::BI__builtin_acos: + case Builtin::BI__builtin_acosf: + case Builtin::BI__builtin_acosl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::acos)); + + case Builtin::BIacosh: + case Builtin::BIacoshf: + case Builtin::BIacoshl: + case Builtin::BI__builtin_acosh: + case Builtin::BI__builtin_acoshf: + case Builtin::BI__builtin_acoshl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::acosh)); + + case Builtin::BIasin: + case Builtin::BIasinf: + case Builtin::BIasinl: + case Builtin::BI__builtin_asin: + case Builtin::BI__builtin_asinf: + case Builtin::BI__builtin_asinl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::asin)); + + case Builtin::BIasinh: + case Builtin::BIasinhf: + case Builtin::BIasinhl: + case Builtin::BI__builtin_asinh: + case Builtin::BI__builtin_asinhf: + case Builtin::BI__builtin_asinhl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::asinh)); + + case Builtin::BIatan: + case Builtin::BIatanf: + case Builtin::BIatanl: + case Builtin::BI__builtin_atan: + case Builtin::BI__builtin_atanf: + case Builtin::BI__builtin_atanl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::atan)); + + case Builtin::BIatan2: + case Builtin::BIatan2f: + case Builtin::BIatan2l: + case Builtin::BI__builtin_atan2: + case Builtin::BI__builtin_atan2f: + case Builtin::BI__builtin_atan2l: + return RValue::get(emitBinaryBuiltin(*this, E, Intrinsic::atan2)); + + case Builtin::BIatanh: + case Builtin::BIatanhf: + case Builtin::BIatanhl: + case Builtin::BI__builtin_atanh: + case Builtin::BI__builtin_atanhf: + case Builtin::BI__builtin_atanhl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::atanh)); + case Builtin::BIcos: case Builtin::BIcosf: case Builtin::BIcosl: @@ -1606,6 +1662,14 @@ case Builtin::BI__builtin_cosl: return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::cos)); + case Builtin::BIcosh: + case Builtin::BIcoshf: + case Builtin::BIcoshl: + case Builtin::BI__builtin_cosh: + case Builtin::BI__builtin_coshf: + case Builtin::BI__builtin_coshl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::cosh)); + case Builtin::BIexp: case Builtin::BIexpf: case Builtin::BIexpl: @@ -1622,6 +1686,14 @@ case Builtin::BI__builtin_exp2l: return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp2)); + case Builtin::BIexp10: + case Builtin::BIexp10f: + case Builtin::BIexp10l: + case Builtin::BI__builtin_exp10: + case Builtin::BI__builtin_exp10f: + case Builtin::BI__builtin_exp10l: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10)); + case Builtin::BIfabs: case Builtin::BIfabsf: case Builtin::BIfabsl: @@ -1676,6 +1748,14 @@ return RValue::get(Builder.CreateFRem(Arg1, Arg2, "fmod")); } + case Builtin::BIlgamma: + case Builtin::BIlgammaf: + case Builtin::BIlgammal: + case Builtin::BI__builtin_lgamma: + case Builtin::BI__builtin_lgammaf: + case Builtin::BI__builtin_lgammal: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::lgamma)); + case Builtin::BIlog: case Builtin::BIlogf: case Builtin::BIlogl: @@ -1740,6 +1820,14 @@ case Builtin::BI__builtin_sinl: return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::sin)); + case Builtin::BIsinh: + case Builtin::BIsinhf: + case Builtin::BIsinhl: + case Builtin::BI__builtin_sinh: + case Builtin::BI__builtin_sinhf: + case Builtin::BI__builtin_sinhl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::sinh)); + case Builtin::BIsqrt: case Builtin::BIsqrtf: case Builtin::BIsqrtl: @@ -1748,6 +1836,30 @@ case Builtin::BI__builtin_sqrtl: return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::sqrt)); + case Builtin::BItan: + case Builtin::BItanf: + case Builtin::BItanl: + case Builtin::BI__builtin_tan: + case Builtin::BI__builtin_tanf: + case Builtin::BI__builtin_tanl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::tan)); + + case Builtin::BItanh: + case Builtin::BItanhf: + case Builtin::BItanhl: + case Builtin::BI__builtin_tanh: + case Builtin::BI__builtin_tanhf: + case Builtin::BI__builtin_tanhl: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::tanh)); + + case Builtin::BItgamma: + case Builtin::BItgammaf: + case Builtin::BItgammal: + case Builtin::BI__builtin_tgamma: + case Builtin::BI__builtin_tgammaf: + case Builtin::BI__builtin_tgammal: + return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::tgamma)); + case Builtin::BItrunc: case Builtin::BItruncf: case Builtin::BItruncl: Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -668,9 +668,21 @@ StringRef Name = A->getValue(); if (Name == "Accelerate") Opts.setVecLib(CodeGenOptions::Accelerate); - else if (Name == "SVML") - Opts.setVecLib(CodeGenOptions::SVML); - else if (Name == "none") + else if (Name == "SVML") { + if (Triple.getArch() == llvm::Triple::x86 || + Triple.getArch() == llvm::Triple::x86_64) + Opts.setVecLib(CodeGenOptions::SVML); + else + Diags.Report(diag::err_drv_unsupported_opt_for_target) + << Name << Triple.getArchName(); + } else if (Name == "SLEEF") { + if (Triple.getArch() == llvm::Triple::aarch64 || + Triple.getArch() == llvm::Triple::aarch64_be) + Opts.setVecLib(CodeGenOptions::SLEEF); + else + Diags.Report(diag::err_drv_unsupported_opt_for_target) + << Name << Triple.getArchName(); + } else if (Name == "none") Opts.setVecLib(CodeGenOptions::NoLibrary); else Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name;