@@ -80,48 +80,6 @@ static LogicalResult convertIntrinsicImpl(OpBuilder &odsBuilder,
8080 return failure ();
8181}
8282
83- // / Converts the LLVM intrinsic to a generic LLVM intrinsic call using
84- // / llvm.intrinsic_call. Returns failure otherwise.
85- static LogicalResult
86- convertUnregisteredIntrinsicImpl (OpBuilder &odsBuilder, llvm::CallInst *inst,
87- LLVM::ModuleImport &moduleImport) {
88- StringRef intrinName = inst->getCalledFunction ()->getName ();
89-
90- SmallVector<llvm::Value *> args (inst->args ());
91- ArrayRef<llvm::Value *> llvmOperands (args);
92-
93- SmallVector<llvm::OperandBundleUse> llvmOpBundles;
94- llvmOpBundles.reserve (inst->getNumOperandBundles ());
95- for (unsigned i = 0 ; i < inst->getNumOperandBundles (); ++i)
96- llvmOpBundles.push_back (inst->getOperandBundleAt (i));
97-
98- SmallVector<Value> mlirOperands;
99- SmallVector<NamedAttribute> mlirAttrs;
100- if (failed (moduleImport.convertIntrinsicArguments (
101- llvmOperands, llvmOpBundles, false , {}, {}, mlirOperands, mlirAttrs)))
102- return failure ();
103-
104- Type results = moduleImport.convertType (inst->getType ());
105- auto op = odsBuilder.create <::mlir::LLVM::CallIntrinsicOp>(
106- moduleImport.translateLoc (inst->getDebugLoc ()), results,
107- StringAttr::get (odsBuilder.getContext (), intrinName),
108- ValueRange{mlirOperands}, FastmathFlagsAttr{});
109-
110- moduleImport.setFastmathFlagsAttr (inst, op);
111-
112- // Update importer tracking of results.
113- unsigned numRes = op.getNumResults ();
114- if (numRes == 1 )
115- moduleImport.mapValue (inst) = op.getResult (0 );
116- else if (numRes == 0 )
117- moduleImport.mapNoResultOp (inst);
118- else
119- return op.emitError (
120- " expected at most one result from target intrinsic call" );
121-
122- return success ();
123- }
124-
12583// / Returns the list of LLVM IR metadata kinds that are convertible to MLIR LLVM
12684// / dialect attributes.
12785static ArrayRef<unsigned > getSupportedMetadataImpl (llvm::LLVMContext &context) {
@@ -411,8 +369,42 @@ static LogicalResult setIntelReqdSubGroupSizeAttr(Builder &builder,
411369
412370LogicalResult mlir::LLVMImportInterface::convertUnregisteredIntrinsic (
413371 OpBuilder &builder, llvm::CallInst *inst,
414- LLVM::ModuleImport &moduleImport) const {
415- return convertUnregisteredIntrinsicImpl (builder, inst, moduleImport);
372+ LLVM::ModuleImport &moduleImport) {
373+ StringRef intrinName = inst->getCalledFunction ()->getName ();
374+
375+ SmallVector<llvm::Value *> args (inst->args ());
376+ ArrayRef<llvm::Value *> llvmOperands (args);
377+
378+ SmallVector<llvm::OperandBundleUse> llvmOpBundles;
379+ llvmOpBundles.reserve (inst->getNumOperandBundles ());
380+ for (unsigned i = 0 ; i < inst->getNumOperandBundles (); ++i)
381+ llvmOpBundles.push_back (inst->getOperandBundleAt (i));
382+
383+ SmallVector<Value> mlirOperands;
384+ SmallVector<NamedAttribute> mlirAttrs;
385+ if (failed (moduleImport.convertIntrinsicArguments (
386+ llvmOperands, llvmOpBundles, false , {}, {}, mlirOperands, mlirAttrs)))
387+ return failure ();
388+
389+ Type results = moduleImport.convertType (inst->getType ());
390+ auto op = builder.create <::mlir::LLVM::CallIntrinsicOp>(
391+ moduleImport.translateLoc (inst->getDebugLoc ()), results,
392+ StringAttr::get (builder.getContext (), intrinName),
393+ ValueRange{mlirOperands}, FastmathFlagsAttr{});
394+
395+ moduleImport.setFastmathFlagsAttr (inst, op);
396+
397+ // Update importer tracking of results.
398+ unsigned numRes = op.getNumResults ();
399+ if (numRes == 1 )
400+ moduleImport.mapValue (inst) = op.getResult (0 );
401+ else if (numRes == 0 )
402+ moduleImport.mapNoResultOp (inst);
403+ else
404+ return op.emitError (
405+ " expected at most one result from target intrinsic call" );
406+
407+ return success ();
416408}
417409namespace {
418410
0 commit comments