1 //===- Async.h - MLIR Async dialect -----------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file defines the async dialect that is used for modeling asynchronous 10 // execution. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef MLIR_DIALECT_ASYNC_IR_ASYNC_H 15 #define MLIR_DIALECT_ASYNC_IR_ASYNC_H 16 17 #include "mlir/IR/Builders.h" 18 #include "mlir/IR/BuiltinTypes.h" 19 #include "mlir/IR/Dialect.h" 20 #include "mlir/IR/OpDefinition.h" 21 #include "mlir/IR/OpImplementation.h" 22 #include "mlir/Interfaces/ControlFlowInterfaces.h" 23 #include "mlir/Interfaces/SideEffectInterfaces.h" 24 25 namespace mlir { 26 namespace async { 27 28 namespace detail { 29 struct ValueTypeStorage; 30 } // namespace detail 31 32 /// The token type to represent asynchronous operation completion. 33 class TokenType : public Type::TypeBase<TokenType, Type, TypeStorage> { 34 public: 35 using Base::Base; 36 }; 37 38 /// The value type to represent values returned from asynchronous operations. 39 class ValueType 40 : public Type::TypeBase<ValueType, Type, detail::ValueTypeStorage> { 41 public: 42 using Base::Base; 43 44 /// Get or create an async ValueType with the provided value type. 45 static ValueType get(Type valueType); 46 47 Type getValueType(); 48 }; 49 50 /// The group type to represent async tokens or values grouped together. 51 class GroupType : public Type::TypeBase<GroupType, Type, TypeStorage> { 52 public: 53 using Base::Base; 54 }; 55 56 // -------------------------------------------------------------------------- // 57 // Helper functions of Async dialect transformations. 58 // -------------------------------------------------------------------------- // 59 60 /// Returns true if the type is reference counted. All async dialect types are 61 /// reference counted at runtime. isRefCounted(Type type)62inline bool isRefCounted(Type type) { 63 return type.isa<TokenType, ValueType, GroupType>(); 64 } 65 66 } // namespace async 67 } // namespace mlir 68 69 #define GET_OP_CLASSES 70 #include "mlir/Dialect/Async/IR/AsyncOps.h.inc" 71 72 #include "mlir/Dialect/Async/IR/AsyncOpsDialect.h.inc" 73 74 #endif // MLIR_DIALECT_ASYNC_IR_ASYNC_H 75