[llvm] [TLI] Add getLibFunc in TLI API that accepts an Instruction. (PR #75919)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 03:36:34 PST 2023


================
@@ -1149,6 +1149,22 @@ bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
   return isValidProtoForLibFunc(*FDecl.getFunctionType(), F, *M);
 }
 
+bool TargetLibraryInfoImpl::getLibFunc(const Instruction &I, LibFunc &F) const {
+  if (I.getOpcode() != Instruction::FRem)
+    return false;
+
+  Type *ScalarTy = I.getType()->getScalarType();
+  if (ScalarTy->isDoubleTy())
+    F = LibFunc_fmod;
+  else if (ScalarTy->isFloatTy())
+    F = LibFunc_fmodf;
+  else if (ScalarTy->isFP128Ty())
+    F = LibFunc_fmodl;
----------------
paulwalker-arm wrote:

This is not strictly speaking true because the choice of what underlying LLVM type is used to represent a long double is target specific.  I think it's safer to drop this code.

https://github.com/llvm/llvm-project/pull/75919


More information about the llvm-commits mailing list