48 llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
49 Operation *intrOp, llvm::StringRef intrinsicName) {
50 llvm::Type *resTy =
nullptr;
51 unsigned numResults = intrOp->getNumResults();
53 resTy = moduleTranslation.convertType(*(intrOp->getResultTypes().begin()));
54 else if (numResults > 1) {
55 SmallVector<llvm::Type *> resTys;
56 for (
auto ty : intrOp->getResultTypes())
57 resTys.push_back(moduleTranslation.convertType(ty));
58 resTy = llvm::StructType::get(builder.getContext(), resTys);
60 auto operands = moduleTranslation.lookupValues(intrOp->getOperands());
61 SmallVector<llvm::Type *> types;
62 for (
auto op : operands)
63 types.push_back(op->getType());
64 llvm::Module *
module = builder.GetInsertBlock()->getModule();
65 llvm::Function *llvmIntr =
66 getNamedIntrinsicDeclaration(module, intrinsicName, resTy, types);
67 return builder.CreateCall(llvmIntr, operands);