20 LogicalResult mlir::LLVMImportInterface::convertUnregisteredIntrinsic(
22 LLVM::ModuleImport &moduleImport) {
23 StringRef intrinName = inst->getCalledFunction()->getName();
29 llvmOpBundles.reserve(inst->getNumOperandBundles());
30 for (
unsigned i = 0; i < inst->getNumOperandBundles(); ++i)
31 llvmOpBundles.push_back(inst->getOperandBundleAt(i));
35 if (
failed(moduleImport.convertIntrinsicArguments(
36 llvmOperands, llvmOpBundles,
false,
41 Type resultType = moduleImport.convertType(inst->getType());
42 auto op = CallIntrinsicOp::create(
43 builder, moduleImport.translateLoc(inst->getDebugLoc()),
46 ValueRange{mlirOperands}, FastmathFlagsAttr{});
48 moduleImport.setFastmathFlagsAttr(inst, op);
49 moduleImport.convertArgAndResultAttrs(inst, op);
52 unsigned numRes = op.getNumResults();
54 moduleImport.mapValue(inst) = op.getResult(0);
56 moduleImport.mapNoResultOp(inst);
59 "expected at most one result from target intrinsic call");
72 assert(intrinId != llvm::Intrinsic::not_intrinsic);
79 dialect = intrinsicToDialect.lookup(intrinId);
84 return convertUnregisteredIntrinsic(builder, inst, moduleImport);
88 assert(iface &&
"expected to find a dialect interface");
MLIRContext * getContext() const
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
Base class for dialect interfaces used to import LLVM IR.
virtual LogicalResult convertIntrinsic(OpBuilder &builder, llvm::CallInst *inst, LLVM::ModuleImport &moduleImport) const
Hook for derived dialect interfaces to implement the import of intrinsics into MLIR.
LogicalResult convertIntrinsic(OpBuilder &builder, llvm::CallInst *inst, LLVM::ModuleImport &moduleImport) const
Converts the LLVM intrinsic to an MLIR operation if a conversion exists.
Module import implementation class that provides methods to import globals and functions from an LLVM...
bool useUnregisteredIntrinsicsOnly() const
Whether the importer should try to convert all intrinsics to llvm.call_intrinsic instead of dialect s...
This class helps build Operations.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...