@@ -56,6 +56,30 @@ static ArrayRef<unsigned> getSupportedIntrinsicsImpl() {
5656 return convertibleIntrinsics;
5757}
5858
59+ // / Converts the LLVM intrinsic to an MLIR LLVM dialect operation if a
60+ // / conversion exits. Returns failure otherwise.
61+ static LogicalResult convertIntrinsicImpl (OpBuilder &odsBuilder,
62+ llvm::CallInst *inst,
63+ LLVM::ModuleImport &moduleImport) {
64+ llvm::Intrinsic::ID intrinsicID = inst->getIntrinsicID ();
65+
66+ // Check if the intrinsic is convertible to an MLIR dialect counterpart and
67+ // copy the arguments to an an LLVM operands array reference for conversion.
68+ if (isConvertibleIntrinsic (intrinsicID)) {
69+ SmallVector<llvm::Value *> args (inst->args ());
70+ ArrayRef<llvm::Value *> llvmOperands (args);
71+
72+ SmallVector<llvm::OperandBundleUse> llvmOpBundles;
73+ llvmOpBundles.reserve (inst->getNumOperandBundles ());
74+ for (unsigned i = 0 ; i < inst->getNumOperandBundles (); ++i)
75+ llvmOpBundles.push_back (inst->getOperandBundleAt (i));
76+
77+ #include " mlir/Dialect/LLVMIR/LLVMIntrinsicFromLLVMIRConversions.inc"
78+ }
79+
80+ return failure ();
81+ }
82+
5983// / Converts the LLVM intrinsic to a generic LLVM intrinsic call using
6084// / llvm.intrinsic_call. Returns failure otherwise.
6185static LogicalResult
@@ -98,32 +122,6 @@ convertUnregisteredIntrinsicImpl(OpBuilder &odsBuilder, llvm::CallInst *inst,
98122 return success ();
99123}
100124
101- // / Converts the LLVM intrinsic to an MLIR LLVM dialect operation if a
102- // / conversion exits. Returns failure otherwise.
103- static LogicalResult convertIntrinsicImpl (OpBuilder &odsBuilder,
104- llvm::CallInst *inst,
105- LLVM::ModuleImport &moduleImport) {
106- llvm::Intrinsic::ID intrinsicID = inst->getIntrinsicID ();
107-
108- // Check if the intrinsic is convertible to an MLIR dialect counterpart and
109- // copy the arguments to an an LLVM operands array reference for conversion.
110- if (isConvertibleIntrinsic (intrinsicID)) {
111- SmallVector<llvm::Value *> args (inst->args ());
112- ArrayRef<llvm::Value *> llvmOperands (args);
113-
114- SmallVector<llvm::OperandBundleUse> llvmOpBundles;
115- llvmOpBundles.reserve (inst->getNumOperandBundles ());
116- for (unsigned i = 0 ; i < inst->getNumOperandBundles (); ++i)
117- llvmOpBundles.push_back (inst->getOperandBundleAt (i));
118-
119- #include " mlir/Dialect/LLVMIR/LLVMIntrinsicFromLLVMIRConversions.inc"
120- } else if (intrinsicID != llvm::Intrinsic::not_intrinsic) {
121- return convertUnregisteredIntrinsicImpl (odsBuilder, inst, moduleImport);
122- }
123-
124- return failure ();
125- }
126-
127125// / Returns the list of LLVM IR metadata kinds that are convertible to MLIR LLVM
128126// / dialect attributes.
129127static ArrayRef<unsigned > getSupportedMetadataImpl (llvm::LLVMContext &context) {
@@ -411,6 +409,14 @@ static LogicalResult setIntelReqdSubGroupSizeAttr(Builder &builder,
411409 return success ();
412410}
413411
412+ namespace mlir {
413+ // Generate llvm.call_intrinsic when no supporting dialect available.
414+ LogicalResult LLVMImportInterface::convertUnregisteredIntrinsic (
415+ OpBuilder &builder, llvm::CallInst *inst,
416+ LLVM::ModuleImport &moduleImport) const {
417+ return convertUnregisteredIntrinsicImpl (builder, inst, moduleImport);
418+ }
419+ } // namespace mlir
414420namespace {
415421
416422// / Implementation of the dialect interface that converts operations belonging
@@ -466,9 +472,6 @@ class LLVMDialectLLVMIRImportInterface : public LLVMImportDialectInterface {
466472 return getSupportedIntrinsicsImpl ();
467473 }
468474
469- // / Cnvertible to generic llvm.call_intrinsic.
470- bool getUnregisteredIntrinsics () const final { return true ; }
471-
472475 // / Returns the list of LLVM IR metadata kinds that are convertible to MLIR
473476 // / LLVM dialect attributes.
474477 ArrayRef<unsigned >
0 commit comments