6 #include <gtest/gtest.h>
8 #include <llvm/IR/BasicBlock.h>
9 #include <llvm/IR/IRBuilder.h>
10 #include <llvm/IR/Module.h>
16 TEST(ViewTests, TestFMulAdd)
22 Module llvmModule(
"module", context);
25 auto doubleType = Type::getDoubleTy(context);
27 const auto functionArguments = std::vector<Type *>({ doubleType, doubleType, doubleType });
28 const auto functionType = FunctionType::get(doubleType, functionArguments,
false);
30 Function::Create(functionType, GlobalValue::ExternalLinkage,
"f", &llvmModule);
32 const auto basicBlock = BasicBlock::Create(context,
"basicBlock",
function);
34 IRBuilder builder(basicBlock);
35 const auto returnValue = builder.CreateIntrinsic(
38 {
function->getArg(0), function->getArg(1), function->getArg(2) });
39 builder.CreateRet(returnValue);
42 llvmModule.print(llvm::errs(),
nullptr);
46 print(*ipgModule, stdout);
50 const auto controlFlowGraph =
52 const auto basicBlock =
54 const auto fMulAdd = *std::next(basicBlock->rbegin(), 1);
55 EXPECT_TRUE(jlm::llvm::is<jlm::llvm::FMulAddIntrinsicOperation>(fMulAdd));
TEST(ViewTests, TestFMulAdd)
void print(const AggregationNode &n, const AnnotationMap &dm, FILE *out)
std::unique_ptr< InterProceduralGraphModule > ConvertLlvmModule(::llvm::Module &llvmModule)