25 #include "llvm/ADT/TypeSwitch.h"
28 #define GEN_PASS_DEF_CONVERTASYNCTOLLVMPASS
29 #include "mlir/Conversion/Passes.h.inc"
32 #define DEBUG_TYPE "convert-async-to-llvm"
41 static constexpr
const char *
kAddRef =
"mlirAsyncRuntimeAddRef";
42 static constexpr
const char *
kDropRef =
"mlirAsyncRuntimeDropRef";
43 static constexpr
const char *
kCreateToken =
"mlirAsyncRuntimeCreateToken";
44 static constexpr
const char *
kCreateValue =
"mlirAsyncRuntimeCreateValue";
45 static constexpr
const char *
kCreateGroup =
"mlirAsyncRuntimeCreateGroup";
46 static constexpr
const char *
kEmplaceToken =
"mlirAsyncRuntimeEmplaceToken";
47 static constexpr
const char *
kEmplaceValue =
"mlirAsyncRuntimeEmplaceValue";
48 static constexpr
const char *
kSetTokenError =
"mlirAsyncRuntimeSetTokenError";
49 static constexpr
const char *
kSetValueError =
"mlirAsyncRuntimeSetValueError";
50 static constexpr
const char *
kIsTokenError =
"mlirAsyncRuntimeIsTokenError";
51 static constexpr
const char *
kIsValueError =
"mlirAsyncRuntimeIsValueError";
52 static constexpr
const char *
kIsGroupError =
"mlirAsyncRuntimeIsGroupError";
53 static constexpr
const char *
kAwaitToken =
"mlirAsyncRuntimeAwaitToken";
54 static constexpr
const char *
kAwaitValue =
"mlirAsyncRuntimeAwaitValue";
55 static constexpr
const char *
kAwaitGroup =
"mlirAsyncRuntimeAwaitAllInGroup";
56 static constexpr
const char *
kExecute =
"mlirAsyncRuntimeExecute";
58 "mlirAsyncRuntimeGetValueStorage";
60 "mlirAsyncRuntimeAddTokenToGroup";
62 "mlirAsyncRuntimeAwaitTokenAndExecute";
64 "mlirAsyncRuntimeAwaitValueAndExecute";
66 "mlirAsyncRuntimeAwaitAllInGroupAndExecute";
68 "mlirAsyncRuntimGetNumWorkerThreads";
78 static LLVM::LLVMPointerType opaquePointerType(
MLIRContext *ctx) {
82 static LLVM::LLVMTokenType tokenType(
MLIRContext *ctx) {
86 static FunctionType addOrDropRefFunctionType(
MLIRContext *ctx) {
87 auto ref = opaquePointerType(ctx);
92 static FunctionType createTokenFunctionType(
MLIRContext *ctx) {
96 static FunctionType createValueFunctionType(
MLIRContext *ctx) {
98 auto value = opaquePointerType(ctx);
102 static FunctionType createGroupFunctionType(
MLIRContext *ctx) {
107 static FunctionType getValueStorageFunctionType(
MLIRContext *ctx) {
108 auto ptrType = opaquePointerType(ctx);
112 static FunctionType emplaceTokenFunctionType(
MLIRContext *ctx) {
116 static FunctionType emplaceValueFunctionType(
MLIRContext *ctx) {
117 auto value = opaquePointerType(ctx);
121 static FunctionType setTokenErrorFunctionType(
MLIRContext *ctx) {
125 static FunctionType setValueErrorFunctionType(
MLIRContext *ctx) {
126 auto value = opaquePointerType(ctx);
130 static FunctionType isTokenErrorFunctionType(
MLIRContext *ctx) {
135 static FunctionType isValueErrorFunctionType(
MLIRContext *ctx) {
136 auto value = opaquePointerType(ctx);
141 static FunctionType isGroupErrorFunctionType(
MLIRContext *ctx) {
146 static FunctionType awaitTokenFunctionType(
MLIRContext *ctx) {
150 static FunctionType awaitValueFunctionType(
MLIRContext *ctx) {
151 auto value = opaquePointerType(ctx);
155 static FunctionType awaitGroupFunctionType(
MLIRContext *ctx) {
159 static FunctionType executeFunctionType(
MLIRContext *ctx) {
160 auto ptrType = opaquePointerType(ctx);
164 static FunctionType addTokenToGroupFunctionType(
MLIRContext *ctx) {
170 static FunctionType awaitTokenAndExecuteFunctionType(
MLIRContext *ctx) {
171 auto ptrType = opaquePointerType(ctx);
175 static FunctionType awaitValueAndExecuteFunctionType(
MLIRContext *ctx) {
176 auto ptrType = opaquePointerType(ctx);
180 static FunctionType awaitAllAndExecuteFunctionType(
MLIRContext *ctx) {
181 auto ptrType = opaquePointerType(ctx);
185 static FunctionType getNumWorkerThreads(
MLIRContext *ctx) {
192 auto ptrType = opaquePointerType(ctx);
203 auto addFuncDecl = [&](StringRef name, FunctionType type) {
204 if (module.lookupSymbol(name))
206 builder.create<func::FuncOp>(name, type).setPrivate();
210 addFuncDecl(
kAddRef, AsyncAPI::addOrDropRefFunctionType(ctx));
211 addFuncDecl(
kDropRef, AsyncAPI::addOrDropRefFunctionType(ctx));
212 addFuncDecl(
kCreateToken, AsyncAPI::createTokenFunctionType(ctx));
213 addFuncDecl(
kCreateValue, AsyncAPI::createValueFunctionType(ctx));
214 addFuncDecl(
kCreateGroup, AsyncAPI::createGroupFunctionType(ctx));
215 addFuncDecl(
kEmplaceToken, AsyncAPI::emplaceTokenFunctionType(ctx));
216 addFuncDecl(
kEmplaceValue, AsyncAPI::emplaceValueFunctionType(ctx));
217 addFuncDecl(
kSetTokenError, AsyncAPI::setTokenErrorFunctionType(ctx));
218 addFuncDecl(
kSetValueError, AsyncAPI::setValueErrorFunctionType(ctx));
219 addFuncDecl(
kIsTokenError, AsyncAPI::isTokenErrorFunctionType(ctx));
220 addFuncDecl(
kIsValueError, AsyncAPI::isValueErrorFunctionType(ctx));
221 addFuncDecl(
kIsGroupError, AsyncAPI::isGroupErrorFunctionType(ctx));
222 addFuncDecl(
kAwaitToken, AsyncAPI::awaitTokenFunctionType(ctx));
223 addFuncDecl(
kAwaitValue, AsyncAPI::awaitValueFunctionType(ctx));
224 addFuncDecl(
kAwaitGroup, AsyncAPI::awaitGroupFunctionType(ctx));
225 addFuncDecl(
kExecute, AsyncAPI::executeFunctionType(ctx));
229 AsyncAPI::awaitTokenAndExecuteFunctionType(ctx));
231 AsyncAPI::awaitValueAndExecuteFunctionType(ctx));
233 AsyncAPI::awaitAllAndExecuteFunctionType(ctx));
241 static constexpr
const char *
kResume =
"__resume";
247 if (module.lookupSymbol(
kResume))
251 auto loc = module.getLoc();
255 Type ptrType = AsyncAPI::opaquePointerType(ctx);
257 auto resumeOp = moduleBuilder.create<LLVM::LLVMFuncOp>(
259 resumeOp.setPrivate();
261 auto *block = resumeOp.addEntryBlock(moduleBuilder);
264 blockBuilder.create<LLVM::CoroResumeOp>(resumeOp.getArgument(0));
265 blockBuilder.create<LLVM::ReturnOp>(
ValueRange());
278 addConversion([](
Type type) {
return type; });
279 addConversion([](
Type type) {
return convertAsyncTypes(type); });
285 auto cast = builder.
create<UnrealizedConversionCastOp>(loc, type, inputs);
289 addSourceMaterialization(addUnrealizedCast);
290 addTargetMaterialization(addUnrealizedCast);
293 static std::optional<Type> convertAsyncTypes(
Type type) {
294 if (isa<TokenType, GroupType, ValueType>(type))
295 return AsyncAPI::opaquePointerType(type.
getContext());
297 if (isa<CoroIdType, CoroStateType>(type))
298 return AsyncAPI::tokenType(type.
getContext());
299 if (isa<CoroHandleType>(type))
300 return AsyncAPI::opaquePointerType(type.
getContext());
309 template <
typename SourceOp>
315 AsyncOpConversionPattern(
const AsyncRuntimeTypeConverter &typeConverter,
317 : Base(typeConverter, context) {}
320 const AsyncRuntimeTypeConverter *getTypeConverter()
const {
321 return static_cast<const AsyncRuntimeTypeConverter *
>(
322 Base::getTypeConverter());
333 class CoroIdOpConversion :
public AsyncOpConversionPattern<CoroIdOp> {
335 using AsyncOpConversionPattern::AsyncOpConversionPattern;
338 matchAndRewrite(CoroIdOp op, OpAdaptor adaptor,
340 auto token = AsyncAPI::tokenType(op->getContext());
341 auto ptrType = AsyncAPI::opaquePointerType(op->getContext());
342 auto loc = op->getLoc();
347 auto nullPtr = rewriter.
create<LLVM::ZeroOp>(loc, ptrType);
351 op, token,
ValueRange({constZero, nullPtr, nullPtr, nullPtr}));
363 class CoroBeginOpConversion :
public AsyncOpConversionPattern<CoroBeginOp> {
365 using AsyncOpConversionPattern::AsyncOpConversionPattern;
368 matchAndRewrite(CoroBeginOp op, OpAdaptor adaptor,
370 auto ptrType = AsyncAPI::opaquePointerType(op->getContext());
371 auto loc = op->getLoc();
383 auto makeConstant = [&](uint64_t c) {
384 return rewriter.
create<LLVM::ConstantOp>(op->getLoc(),
387 coroSize = rewriter.
create<LLVM::AddOp>(op->getLoc(), coroSize, coroAlign);
389 rewriter.
create<LLVM::SubOp>(op->getLoc(), coroSize, makeConstant(1));
391 rewriter.
create<LLVM::SubOp>(op->getLoc(), makeConstant(0), coroAlign);
393 rewriter.
create<LLVM::AndOp>(op->getLoc(), coroSize, negCoroAlign);
397 rewriter, op->getParentOfType<ModuleOp>(), rewriter.
getI64Type());
398 if (failed(allocFuncOp))
400 auto coroAlloc = rewriter.
create<LLVM::CallOp>(
401 loc, allocFuncOp.value(),
ValueRange{coroAlign, coroSize});
404 auto coroId = CoroBeginOpAdaptor(adaptor.getOperands()).getId();
406 op, ptrType,
ValueRange({coroId, coroAlloc.getResult()}));
418 class CoroFreeOpConversion :
public AsyncOpConversionPattern<CoroFreeOp> {
420 using AsyncOpConversionPattern::AsyncOpConversionPattern;
423 matchAndRewrite(CoroFreeOp op, OpAdaptor adaptor,
425 auto ptrType = AsyncAPI::opaquePointerType(op->getContext());
426 auto loc = op->getLoc();
430 rewriter.
create<LLVM::CoroFreeOp>(loc, ptrType, adaptor.getOperands());
435 if (failed(freeFuncOp))
455 matchAndRewrite(CoroEndOp op, OpAdaptor adaptor,
458 auto constFalse = rewriter.
create<LLVM::ConstantOp>(
460 auto noneToken = rewriter.
create<LLVM::NoneTokenOp>(op->getLoc());
463 auto coroHdl = adaptor.getHandle();
464 rewriter.
create<LLVM::CoroEndOp>(
466 ValueRange({coroHdl, constFalse, noneToken}));
484 matchAndRewrite(CoroSaveOp op, OpAdaptor adaptor,
488 op, AsyncAPI::tokenType(op->getContext()), adaptor.getOperands());
530 matchAndRewrite(CoroSuspendOp op, OpAdaptor adaptor,
534 auto loc = op->getLoc();
537 auto constFalse = rewriter.
create<LLVM::ConstantOp>(
541 auto coroState = adaptor.getState();
542 auto coroSuspend = rewriter.
create<LLVM::CoroSuspendOp>(
543 loc, i8,
ValueRange({coroState, constFalse}));
552 op.getCleanupDest()};
554 op, rewriter.
create<LLVM::SExtOp>(loc, i32, coroSuspend.getResult()),
580 matchAndRewrite(RuntimeCreateOp op, OpAdaptor adaptor,
583 Type resultType = op->getResultTypes()[0];
586 if (isa<TokenType>(resultType)) {
593 if (
auto value = dyn_cast<ValueType>(resultType)) {
595 auto sizeOf = [&](ValueType valueType) ->
Value {
599 auto storedType = converter->
convertType(valueType.getValueType());
600 auto storagePtrType =
601 AsyncAPI::opaquePointerType(rewriter.
getContext());
605 auto nullPtr = rewriter.
create<LLVM::ZeroOp>(loc, storagePtrType);
607 rewriter.
create<LLVM::GEPOp>(loc, storagePtrType, storedType,
609 return rewriter.
create<LLVM::PtrToIntOp>(loc, i64, gep);
628 class RuntimeCreateGroupOpLowering
634 matchAndRewrite(RuntimeCreateGroupOp op, OpAdaptor adaptor,
637 Type resultType = op.getResult().getType();
641 adaptor.getOperands());
652 class RuntimeSetAvailableOpLowering
658 matchAndRewrite(RuntimeSetAvailableOp op, OpAdaptor adaptor,
660 StringRef apiFuncName =
666 adaptor.getOperands());
678 class RuntimeSetErrorOpLowering
684 matchAndRewrite(RuntimeSetErrorOp op, OpAdaptor adaptor,
686 StringRef apiFuncName =
692 adaptor.getOperands());
709 matchAndRewrite(RuntimeIsErrorOp op, OpAdaptor adaptor,
711 StringRef apiFuncName =
718 op, apiFuncName, rewriter.
getI1Type(), adaptor.getOperands());
734 matchAndRewrite(RuntimeAwaitOp op, OpAdaptor adaptor,
736 StringRef apiFuncName =
743 adaptor.getOperands());
756 class RuntimeAwaitAndResumeOpLowering
757 :
public AsyncOpConversionPattern<RuntimeAwaitAndResumeOp> {
759 using AsyncOpConversionPattern::AsyncOpConversionPattern;
762 matchAndRewrite(RuntimeAwaitAndResumeOp op, OpAdaptor adaptor,
764 StringRef apiFuncName =
770 Value operand = adaptor.getOperand();
771 Value handle = adaptor.getHandle();
775 auto resumePtr = rewriter.
create<LLVM::AddressOfOp>(
776 op->getLoc(), AsyncAPI::opaquePointerType(rewriter.
getContext()),
779 rewriter.
create<func::CallOp>(
781 ValueRange({operand, handle, resumePtr.getRes()}));
794 class RuntimeResumeOpLowering
795 :
public AsyncOpConversionPattern<RuntimeResumeOp> {
797 using AsyncOpConversionPattern::AsyncOpConversionPattern;
800 matchAndRewrite(RuntimeResumeOp op, OpAdaptor adaptor,
804 auto resumePtr = rewriter.
create<LLVM::AddressOfOp>(
805 op->getLoc(), AsyncAPI::opaquePointerType(rewriter.
getContext()),
809 auto coroHdl = adaptor.getHandle();
828 matchAndRewrite(RuntimeStoreOp op, OpAdaptor adaptor,
833 auto ptrType = AsyncAPI::opaquePointerType(rewriter.
getContext());
834 auto storage = adaptor.getStorage();
835 auto storagePtr = rewriter.
create<func::CallOp>(
839 auto valueType = op.getValue().getType();
840 auto llvmValueType = getTypeConverter()->convertType(valueType);
843 op,
"failed to convert stored value type to LLVM type");
845 Value castedStoragePtr = storagePtr.getResult(0);
847 auto value = adaptor.getValue();
848 rewriter.
create<LLVM::StoreOp>(loc, value, castedStoragePtr);
868 matchAndRewrite(RuntimeLoadOp op, OpAdaptor adaptor,
873 auto ptrType = AsyncAPI::opaquePointerType(rewriter.
getContext());
874 auto storage = adaptor.getStorage();
875 auto storagePtr = rewriter.
create<func::CallOp>(
880 auto llvmValueType = getTypeConverter()->convertType(valueType);
883 op,
"failed to convert loaded value type to LLVM type");
885 Value castedStoragePtr = storagePtr.getResult(0);
901 class RuntimeAddToGroupOpLowering
907 matchAndRewrite(RuntimeAddToGroupOp op, OpAdaptor adaptor,
910 if (!isa<TokenType>(op.getOperand().getType()))
928 class RuntimeNumWorkerThreadsOpLowering
934 matchAndRewrite(RuntimeNumWorkerThreadsOp op, OpAdaptor adaptor,
952 template <
typename RefCountingOp>
955 explicit RefCountingOpLowering(
const TypeConverter &converter,
958 apiFunctionName(apiFunctionName) {}
961 matchAndRewrite(RefCountingOp op,
typename RefCountingOp::Adaptor adaptor,
963 auto count = rewriter.
create<arith::ConstantOp>(
975 StringRef apiFunctionName;
978 class RuntimeAddRefOpLowering :
public RefCountingOpLowering<RuntimeAddRefOp> {
980 explicit RuntimeAddRefOpLowering(
const TypeConverter &converter,
982 : RefCountingOpLowering(converter, ctx,
kAddRef) {}
985 class RuntimeDropRefOpLowering
986 :
public RefCountingOpLowering<RuntimeDropRefOp> {
988 explicit RuntimeDropRefOpLowering(
const TypeConverter &converter,
990 : RefCountingOpLowering(converter, ctx,
kDropRef) {}
1004 matchAndRewrite(func::ReturnOp op, OpAdaptor adaptor,
1015 struct ConvertAsyncToLLVMPass
1016 :
public impl::ConvertAsyncToLLVMPassBase<ConvertAsyncToLLVMPass> {
1019 void runOnOperation()
override;
1023 void ConvertAsyncToLLVMPass::runOnOperation() {
1024 ModuleOp module = getOperation();
1038 AsyncRuntimeTypeConverter converter(
options);
1044 llvmConverter.addConversion([&](
Type type) {
1045 return AsyncRuntimeTypeConverter::convertAsyncTypes(type);
1049 populateFunctionOpInterfaceTypeConversionPattern<func::FuncOp>(
patterns,
1054 patterns.add<ReturnOpOpConversion>(converter, ctx);
1057 patterns.add<RuntimeSetAvailableOpLowering, RuntimeSetErrorOpLowering,
1058 RuntimeIsErrorOpLowering, RuntimeAwaitOpLowering,
1059 RuntimeAwaitAndResumeOpLowering, RuntimeResumeOpLowering,
1060 RuntimeAddToGroupOpLowering, RuntimeNumWorkerThreadsOpLowering,
1061 RuntimeAddRefOpLowering, RuntimeDropRefOpLowering>(converter,
1066 patterns.add<RuntimeCreateOpLowering, RuntimeCreateGroupOpLowering,
1067 RuntimeStoreOpLowering, RuntimeLoadOpLowering>(llvmConverter);
1071 .add<CoroIdOpConversion, CoroBeginOpConversion, CoroFreeOpConversion,
1072 CoroEndOpConversion, CoroSaveOpConversion, CoroSuspendOpConversion>(
1076 target.addLegalOp<arith::ConstantOp, func::ConstantOp,
1077 UnrealizedConversionCastOp>();
1078 target.addLegalDialect<LLVM::LLVMDialect>();
1082 target.addIllegalDialect<AsyncDialect>();
1085 target.addDynamicallyLegalOp<func::FuncOp>([&](func::FuncOp op) {
1086 return converter.isSignatureLegal(op.getFunctionType());
1088 target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
1089 return converter.isLegal(op.getOperandTypes());
1091 target.addDynamicallyLegalOp<func::CallOp>([&](func::CallOp op) {
1092 return converter.isSignatureLegal(op.getCalleeType());
1096 signalPassFailure();
1108 matchAndRewrite(ExecuteOp op, OpAdaptor adaptor,
1113 newOp.getRegion().end());
1116 newOp->setOperands(adaptor.getOperands());
1119 for (
auto result : newOp.getResults())
1120 result.setType(typeConverter->convertType(result.getType()));
1122 rewriter.
replaceOp(op, newOp.getResults());
1132 matchAndRewrite(AwaitOp op, OpAdaptor adaptor,
1144 matchAndRewrite(async::YieldOp op, OpAdaptor adaptor,
1155 typeConverter.
addConversion([&](TokenType type) {
return type; });
1161 patterns.add<ConvertExecuteOpTypes, ConvertAwaitOpTypes, ConvertYieldOpTypes>(
1162 typeConverter,
patterns.getContext());
static constexpr const char * kAwaitValueAndExecute
static constexpr const char * kCreateValue
static constexpr const char * kCreateGroup
static constexpr const char * kCreateToken
static constexpr const char * kEmplaceValue
static void addResumeFunction(ModuleOp module)
A function that takes a coroutine handle and calls a llvm.coro.resume intrinsics.
static constexpr const char * kEmplaceToken
static void addAsyncRuntimeApiDeclarations(ModuleOp module)
Adds Async Runtime C API declarations to the module.
static constexpr const char * kResume
static constexpr const char * kAddRef
static constexpr const char * kAwaitTokenAndExecute
static constexpr const char * kAwaitValue
static constexpr const char * kSetTokenError
static constexpr const char * kExecute
static constexpr const char * kAddTokenToGroup
static constexpr const char * kIsGroupError
static constexpr const char * kSetValueError
static constexpr const char * kIsTokenError
static constexpr const char * kAwaitGroup
static constexpr const char * kAwaitAllAndExecute
static constexpr const char * kGetNumWorkerThreads
static constexpr const char * kDropRef
static constexpr const char * kIsValueError
static constexpr const char * kAwaitToken
static constexpr const char * kGetValueStorage
static llvm::ManagedStatic< PassManagerOptions > options
IntegerAttr getI64IntegerAttr(int64_t value)
IntegerType getIntegerType(unsigned width)
BoolAttr getBoolAttr(bool value)
MLIRContext * getContext() const
This class implements a pattern rewriter for use with ConversionPatterns.
void replaceOp(Operation *op, ValueRange newValues) override
Replace the given operation with the new values.
FailureOr< Block * > convertRegionTypes(Region *region, const TypeConverter &converter, TypeConverter::SignatureConversion *entryConversion=nullptr)
Apply a signature conversion to each block in the given region.
void eraseOp(Operation *op) override
PatternRewriter hook for erasing a dead operation.
This class describes a specific conversion target.
void addDynamicallyLegalOp(OperationName op, const DynamicLegalityCallbackFn &callback)
Register the given operation as dynamically legal and set the dynamic legalization callback to the on...
Utility class for operation conversions targeting the LLVM dialect that match exactly one source oper...
ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1)
static ImplicitLocOpBuilder atBlockEnd(Location loc, Block *block, Listener *listener=nullptr)
Create a builder and set the insertion point to after the last operation in the block but still insid...
Conversion from types to the LLVM IR dialect.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Options to control the LLVM lowering.
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Operation * cloneWithoutRegions(Operation &op, IRMapping &mapper)
Creates a deep copy of this operation but keep the operation regions empty.
OpConversionPattern is a wrapper around ConversionPattern that allows for matching and rewriting agai...
OpConversionPattern(MLIRContext *context, PatternBenefit benefit=1)
Operation is the basic unit of execution within MLIR.
Value getOperand(unsigned idx)
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
void addConversion(FnT &&callback)
Register a conversion function.
bool isLegal(Type type) const
Return true if the given type is legal for this type converter, i.e.
LogicalResult convertType(Type t, SmallVectorImpl< Type > &results) const
Convert the given type.
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...
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
Location getLoc() const
Return the location of this value.
FailureOr< LLVM::LLVMFuncOp > lookupOrCreateFreeFn(OpBuilder &b, Operation *moduleOp, SymbolTableCollection *symbolTables=nullptr)
FailureOr< LLVM::LLVMFuncOp > lookupOrCreateAlignedAllocFn(OpBuilder &b, Operation *moduleOp, Type indexType, SymbolTableCollection *symbolTables=nullptr)
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
void populateAsyncStructuralTypeConversionsAndLegality(TypeConverter &typeConverter, RewritePatternSet &patterns, ConversionTarget &target)
Populates patterns for async structural type conversions.
void populateCallOpTypeConversionPattern(RewritePatternSet &patterns, const TypeConverter &converter)
Add a pattern to the given pattern list to convert the operand and result types of a CallOp with the ...
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Below we define several entry points for operation conversion.