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