[llvm] [TLI] Add getLibFunc that accepts an Opcode and scalar Type. (PR #75919)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 08:48:37 PST 2023


================
@@ -621,3 +621,42 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
     EXPECT_TRUE(isLibFunc(F, LF));
   }
 }
+
+namespace {
+
+/// Creates TLI for AArch64 and uses it to get the LibFunc names for the FRem
+/// Instruction.
+class TLITestAarch64 : public ::testing::Test {
+private:
+  const Triple TargetTriple;
+
+protected:
+  LLVMContext Ctx;
+  std::unique_ptr<TargetLibraryInfoImpl> TLII;
+  std::unique_ptr<TargetLibraryInfo> TLI;
+
+  /// Create TLI for AArch64
+  TLITestAarch64() : TargetTriple(Triple("aarch64-unknown-linux-gnu")) {
+    TLII = std::make_unique<TargetLibraryInfoImpl>(
+        TargetLibraryInfoImpl(TargetTriple));
+    TLI = std::make_unique<TargetLibraryInfo>(TargetLibraryInfo(*TLII));
+  }
+
+  /// Creates an FRem Instruction of Type \p Ty, and uses it to get the TLI
+  /// function name.
+  StringRef getFremScalarName(Type *Ty) {
+    Value *V = Constant::getNullValue(Ty);
+    Instruction *FRem = BinaryOperator::Create(Instruction::FRem, V, V);
----------------
paulwalker-arm wrote:

With the new interface you don't need to create the instruction anymore because you can just pass in `Instruction::FRem` and `Ty`.

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


More information about the llvm-commits mailing list