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/Bytecode/BytecodeOpInterface.h" |
18 | #include "mlir/Dialect/Async/IR/AsyncTypes.h" |
19 | #include "mlir/IR/Builders.h" |
20 | #include "mlir/IR/BuiltinTypes.h" |
21 | #include "mlir/IR/Dialect.h" |
22 | #include "mlir/IR/OpImplementation.h" |
23 | #include "mlir/IR/PatternMatch.h" |
24 | #include "mlir/IR/SymbolTable.h" |
25 | #include "mlir/Interfaces/CallInterfaces.h" |
26 | #include "mlir/Interfaces/ControlFlowInterfaces.h" |
27 | #include "mlir/Interfaces/FunctionInterfaces.h" |
28 | #include "mlir/Interfaces/InferTypeOpInterface.h" |
29 | #include "mlir/Interfaces/SideEffectInterfaces.h" |
30 | |
31 | //===----------------------------------------------------------------------===// |
32 | // Async Dialect |
33 | //===----------------------------------------------------------------------===// |
34 | |
35 | #include "mlir/Dialect/Async/IR/AsyncOpsDialect.h.inc" |
36 | |
37 | //===----------------------------------------------------------------------===// |
38 | // Async Dialect Operations |
39 | //===----------------------------------------------------------------------===// |
40 | |
41 | #define GET_OP_CLASSES |
42 | #include "mlir/Dialect/Async/IR/AsyncOps.h.inc" |
43 | |
44 | //===----------------------------------------------------------------------===// |
45 | // Helper functions of Async dialect transformations. |
46 | //===----------------------------------------------------------------------===// |
47 | |
48 | namespace mlir { |
49 | namespace async { |
50 | |
51 | /// Returns true if the type is reference counted at runtime. |
52 | inline bool isRefCounted(Type type) { |
53 | return isa<TokenType, ValueType, GroupType>(type); |
54 | } |
55 | |
56 | } // namespace async |
57 | } // namespace mlir |
58 | |
59 | namespace llvm { |
60 | |
61 | /// Allow stealing the low bits of async::FuncOp. |
62 | template <> |
63 | struct PointerLikeTypeTraits<mlir::async::FuncOp> { |
64 | static inline void *getAsVoidPointer(mlir::async::FuncOp val) { |
65 | return const_cast<void *>(val.getAsOpaquePointer()); |
66 | } |
67 | static inline mlir::async::FuncOp getFromVoidPointer(void *p) { |
68 | return mlir::async::FuncOp::getFromOpaquePointer(p); |
69 | } |
70 | static constexpr int numLowBitsAvailable = 3; |
71 | }; |
72 | } // namespace llvm |
73 | |
74 | #endif // MLIR_DIALECT_ASYNC_IR_ASYNC_H |
75 | |