diff options
Diffstat (limited to 'llvm/unittests/Analysis/TargetLibraryInfoTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp index 292b5ca..34b06fe 100644 --- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp +++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -621,3 +621,38 @@ TEST_F(TargetLibraryInfoTest, ValidProto) { EXPECT_TRUE(isLibFunc(F, LF)); } } + +namespace { + +/// Creates TLI for AArch64 and uses it to get the LibFunc names for the given +/// Instruction opcode and Type. +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)); + } + + /// Returns the TLI function name for the given \p Opcode and type \p Ty. + StringRef getScalarName(unsigned int Opcode, Type *Ty) { + LibFunc Func; + if (!TLI->getLibFunc(Opcode, Ty, Func)) + return ""; + return TLI->getName(Func); + } +}; +} // end anonymous namespace + +TEST_F(TLITestAarch64, TestFrem) { + EXPECT_EQ(getScalarName(Instruction::FRem, Type::getDoubleTy(Ctx)), "fmod"); + EXPECT_EQ(getScalarName(Instruction::FRem, Type::getFloatTy(Ctx)), "fmodf"); +}
\ No newline at end of file |