Index: docs/LangRef.rst =================================================================== --- docs/LangRef.rst +++ docs/LangRef.rst @@ -10058,12 +10058,7 @@ Overview: """"""""" -The '``llvm.sqrt``' intrinsics return the sqrt of the specified operand, -returning the same value as the libm '``sqrt``' functions would. Unlike -``sqrt`` in libm, however, ``llvm.sqrt`` has undefined behavior for -negative numbers other than -0.0 (which allows for better optimization, -because there is no need to worry about errno being set). -``llvm.sqrt(-0.0)`` is defined to return -0.0 like IEEE sqrt. +The '``llvm.sqrt``' intrinsics return the square root of the operand. Arguments: """""""""" @@ -10074,8 +10069,8 @@ Semantics: """""""""" -This function returns the sqrt of the specified operand if it is a -nonnegative floating point number. +This is equivalent to the IEEE 754 ``squareRoot()`` function. It has no +side-effects. '``llvm.powi.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10147,9 +10142,8 @@ Semantics: """""""""" -This function returns the sine of the specified operand, returning the -same values as the libm ``sin`` functions would, and handles error -conditions in the same way. +This is equivalent to the IEEE 754 ``sin()`` function. It has no +side-effects. '``llvm.cos.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10183,9 +10177,8 @@ Semantics: """""""""" -This function returns the cosine of the specified operand, returning the -same values as the libm ``cos`` functions would, and handles error -conditions in the same way. +This is equivalent to the IEEE 754 ``cos()`` function. It has no +side-effects. '``llvm.pow.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10220,9 +10213,8 @@ Semantics: """""""""" -This function returns the first value raised to the second power, -returning the same values as the libm ``pow`` functions would, and -handles error conditions in the same way. +This is equivalent to the IEEE 754 ``pow()`` function. It has no +side-effects. '``llvm.exp.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10256,8 +10248,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``exp`` functions -would, and handles error conditions in the same way. +This is equivalent to the IEEE 754 ``exp()`` function. It has no +side-effects. '``llvm.exp2.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10291,8 +10283,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``exp2`` functions -would, and handles error conditions in the same way. +This is equivalent to the IEEE 754 ``exp2()`` function. It has no +side-effects. '``llvm.log.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10326,8 +10318,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``log`` functions -would, and handles error conditions in the same way. +This is equivalent to the IEEE 754 ``log()`` function. It has no +side-effects. '``llvm.log10.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10361,8 +10353,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``log10`` functions -would, and handles error conditions in the same way. +This is equivalent to the IEEE 754 ``log10()`` function. It has no +side-effects. '``llvm.log2.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10396,8 +10388,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``log2`` functions -would, and handles error conditions in the same way. +This is equivalent to the IEEE 754 ``log2()`` function. It has no +side-effects. '``llvm.fma.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10432,8 +10424,8 @@ Semantics: """""""""" -This function returns the same values as the libm ``fma`` functions -would, and does not set errno. +This is equivalent to the IEEE 754 ``fma()`` function. It has no +side-effects. '``llvm.fabs.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Triple.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" @@ -1922,6 +1923,9 @@ // and leave the Hi part unset. SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node, bool isSigned) { + if (!TLI.getLibcallName(LC)) + report_fatal_error("No implementation available for libcall " + utostr(LC)); + TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; for (const SDValue &Op : Node->op_values()) { @@ -1973,6 +1977,9 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, EVT RetVT, const SDValue *Ops, unsigned NumOps, bool isSigned, const SDLoc &dl) { + if (!TLI.getLibcallName(LC)) + report_fatal_error("No implementation available for libcall " + utostr(LC)); + TargetLowering::ArgListTy Args; Args.reserve(NumOps); Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6398,27 +6398,6 @@ if (visitBinaryFloatCall(I, ISD::FMAXNUM)) return; break; - case LibFunc::sin: - case LibFunc::sinf: - case LibFunc::sinl: - if (visitUnaryFloatCall(I, ISD::FSIN)) - return; - break; - case LibFunc::cos: - case LibFunc::cosf: - case LibFunc::cosl: - if (visitUnaryFloatCall(I, ISD::FCOS)) - return; - break; - case LibFunc::sqrt: - case LibFunc::sqrtf: - case LibFunc::sqrtl: - case LibFunc::sqrt_finite: - case LibFunc::sqrtf_finite: - case LibFunc::sqrtl_finite: - if (visitUnaryFloatCall(I, ISD::FSQRT)) - return; - break; case LibFunc::floor: case LibFunc::floorf: case LibFunc::floorl: @@ -6455,18 +6434,6 @@ if (visitUnaryFloatCall(I, ISD::FTRUNC)) return; break; - case LibFunc::log2: - case LibFunc::log2f: - case LibFunc::log2l: - if (visitUnaryFloatCall(I, ISD::FLOG2)) - return; - break; - case LibFunc::exp2: - case LibFunc::exp2f: - case LibFunc::exp2l: - if (visitUnaryFloatCall(I, ISD::FEXP2)) - return; - break; case LibFunc::memcmp: if (visitMemCmpCall(I)) return; Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp =================================================================== --- lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -14,6 +14,7 @@ #include "llvm/Target/TargetLowering.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/CallingConvLower.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" @@ -132,6 +133,8 @@ if (LC == RTLIB::UNKNOWN_LIBCALL) report_fatal_error("Unsupported library call operation!"); + if (!getLibcallName(LC)) + report_fatal_error("No implementation available for libcall " + utostr(LC)); SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC), getPointerTy(DAG.getDataLayout())); Index: lib/CodeGen/TargetLoweringBase.cpp =================================================================== --- lib/CodeGen/TargetLoweringBase.cpp +++ lib/CodeGen/TargetLoweringBase.cpp @@ -130,11 +130,6 @@ Names[RTLIB::DIV_F80] = "__divxf3"; Names[RTLIB::DIV_F128] = "__divtf3"; Names[RTLIB::DIV_PPCF128] = "__gcc_qdiv"; - Names[RTLIB::REM_F32] = "fmodf"; - Names[RTLIB::REM_F64] = "fmod"; - Names[RTLIB::REM_F80] = "fmodl"; - Names[RTLIB::REM_F128] = "fmodl"; - Names[RTLIB::REM_PPCF128] = "fmodl"; Names[RTLIB::FMA_F32] = "fmaf"; Names[RTLIB::FMA_F64] = "fma"; Names[RTLIB::FMA_F80] = "fmal"; @@ -145,51 +140,6 @@ Names[RTLIB::POWI_F80] = "__powixf2"; Names[RTLIB::POWI_F128] = "__powitf2"; Names[RTLIB::POWI_PPCF128] = "__powitf2"; - Names[RTLIB::SQRT_F32] = "sqrtf"; - Names[RTLIB::SQRT_F64] = "sqrt"; - Names[RTLIB::SQRT_F80] = "sqrtl"; - Names[RTLIB::SQRT_F128] = "sqrtl"; - Names[RTLIB::SQRT_PPCF128] = "sqrtl"; - Names[RTLIB::LOG_F32] = "logf"; - Names[RTLIB::LOG_F64] = "log"; - Names[RTLIB::LOG_F80] = "logl"; - Names[RTLIB::LOG_F128] = "logl"; - Names[RTLIB::LOG_PPCF128] = "logl"; - Names[RTLIB::LOG2_F32] = "log2f"; - Names[RTLIB::LOG2_F64] = "log2"; - Names[RTLIB::LOG2_F80] = "log2l"; - Names[RTLIB::LOG2_F128] = "log2l"; - Names[RTLIB::LOG2_PPCF128] = "log2l"; - Names[RTLIB::LOG10_F32] = "log10f"; - Names[RTLIB::LOG10_F64] = "log10"; - Names[RTLIB::LOG10_F80] = "log10l"; - Names[RTLIB::LOG10_F128] = "log10l"; - Names[RTLIB::LOG10_PPCF128] = "log10l"; - Names[RTLIB::EXP_F32] = "expf"; - Names[RTLIB::EXP_F64] = "exp"; - Names[RTLIB::EXP_F80] = "expl"; - Names[RTLIB::EXP_F128] = "expl"; - Names[RTLIB::EXP_PPCF128] = "expl"; - Names[RTLIB::EXP2_F32] = "exp2f"; - Names[RTLIB::EXP2_F64] = "exp2"; - Names[RTLIB::EXP2_F80] = "exp2l"; - Names[RTLIB::EXP2_F128] = "exp2l"; - Names[RTLIB::EXP2_PPCF128] = "exp2l"; - Names[RTLIB::SIN_F32] = "sinf"; - Names[RTLIB::SIN_F64] = "sin"; - Names[RTLIB::SIN_F80] = "sinl"; - Names[RTLIB::SIN_F128] = "sinl"; - Names[RTLIB::SIN_PPCF128] = "sinl"; - Names[RTLIB::COS_F32] = "cosf"; - Names[RTLIB::COS_F64] = "cos"; - Names[RTLIB::COS_F80] = "cosl"; - Names[RTLIB::COS_F128] = "cosl"; - Names[RTLIB::COS_PPCF128] = "cosl"; - Names[RTLIB::POW_F32] = "powf"; - Names[RTLIB::POW_F64] = "pow"; - Names[RTLIB::POW_F80] = "powl"; - Names[RTLIB::POW_F128] = "powl"; - Names[RTLIB::POW_PPCF128] = "powl"; Names[RTLIB::CEIL_F32] = "ceilf"; Names[RTLIB::CEIL_F64] = "ceil"; Names[RTLIB::CEIL_F80] = "ceill"; @@ -487,14 +437,6 @@ Names[RTLIB::ATOMIC_FETCH_NAND_8] = "__atomic_fetch_nand_8"; Names[RTLIB::ATOMIC_FETCH_NAND_16] = "__atomic_fetch_nand_16"; - if (TT.isGNUEnvironment()) { - Names[RTLIB::SINCOS_F32] = "sincosf"; - Names[RTLIB::SINCOS_F64] = "sincos"; - Names[RTLIB::SINCOS_F80] = "sincosl"; - Names[RTLIB::SINCOS_F128] = "sincosl"; - Names[RTLIB::SINCOS_PPCF128] = "sincosl"; - } - if (!TT.isOSOpenBSD()) { Names[RTLIB::STACKPROTECTOR_CHECK_FAIL] = "__stack_chk_fail"; } Index: lib/Target/AArch64/AArch64FastISel.cpp =================================================================== --- lib/Target/AArch64/AArch64FastISel.cpp +++ lib/Target/AArch64/AArch64FastISel.cpp @@ -131,7 +131,6 @@ bool selectMul(const Instruction *I); bool selectShift(const Instruction *I); bool selectBitCast(const Instruction *I); - bool selectFRem(const Instruction *I); bool selectSDiv(const Instruction *I); bool selectGetElementPtr(const Instruction *I); bool selectAtomicCmpXchg(const AtomicCmpXchgInst *I); @@ -4740,44 +4739,6 @@ return true; } -bool AArch64FastISel::selectFRem(const Instruction *I) { - MVT RetVT; - if (!isTypeLegal(I->getType(), RetVT)) - return false; - - RTLIB::Libcall LC; - switch (RetVT.SimpleTy) { - default: - return false; - case MVT::f32: - LC = RTLIB::REM_F32; - break; - case MVT::f64: - LC = RTLIB::REM_F64; - break; - } - - ArgListTy Args; - Args.reserve(I->getNumOperands()); - - // Populate the argument list. - for (auto &Arg : I->operands()) { - ArgListEntry Entry; - Entry.Val = Arg; - Entry.Ty = Arg->getType(); - Args.push_back(Entry); - } - - CallLoweringInfo CLI; - MCContext &Ctx = MF->getContext(); - CLI.setCallee(DL, Ctx, TLI.getLibcallCallingConv(LC), I->getType(), - TLI.getLibcallName(LC), std::move(Args)); - if (!lowerCallTo(CLI)) - return false; - updateValueMap(I, CLI.ResultReg); - return true; -} - bool AArch64FastISel::selectSDiv(const Instruction *I) { MVT VT; if (!isTypeLegal(I->getType(), VT)) @@ -5077,8 +5038,6 @@ return selectSelect(I); case Instruction::Ret: return selectRet(I); - case Instruction::FRem: - return selectFRem(I); case Instruction::GetElementPtr: return selectGetElementPtr(I); case Instruction::AtomicCmpXchg: