1//===- AsyncBase.td ----------------------------------------*- tablegen -*-===//
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// Base definitions for the `async` dialect.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef ASYNC_BASE_TD
14#define ASYNC_BASE_TD
15
16include "mlir/IR/OpBase.td"
17
18//===----------------------------------------------------------------------===//
19// Async dialect definitions
20//===----------------------------------------------------------------------===//
21
22def AsyncDialect : Dialect {
23  let name = "async";
24
25  let summary = "Types and operations for async dialect";
26  let description = [{
27    This dialect contains operations for modeling asynchronous execution.
28  }];
29
30  let cppNamespace = "::mlir::async";
31}
32
33def Async_TokenType : DialectType<AsyncDialect,
34    CPred<"$_self.isa<::mlir::async::TokenType>()">, "token type">,
35    BuildableType<"$_builder.getType<::mlir::async::TokenType>()"> {
36  let typeDescription = [{
37    `async.token` is a type returned by asynchronous operations, and it becomes
38    `ready` when the asynchronous operations that created it is completed.
39  }];
40}
41
42class Async_ValueType<Type type>
43    : DialectType<AsyncDialect,
44        And<[
45          CPred<"$_self.isa<::mlir::async::ValueType>()">,
46          SubstLeaves<"$_self",
47                      "$_self.cast<::mlir::async::ValueType>().getValueType()",
48                      type.predicate>
49       ]>, "async value type with " # type.description # " underlying type"> {
50  let typeDescription = [{
51    `async.value` represents a value returned by asynchronous operations,
52    which may or may not be available currently, but will be available at some
53    point in the future.
54  }];
55
56  Type valueType = type;
57}
58
59def Async_GroupType : DialectType<AsyncDialect,
60    CPred<"$_self.isa<::mlir::async::GroupType>()">, "group type">,
61    BuildableType<"$_builder.getType<::mlir::async::GroupType>()"> {
62  let typeDescription = [{
63    `async.group` represent a set of async tokens or values and allows to
64    execute async operations on all of them together (e.g. wait for the
65    completion of all/any of them).
66  }];
67}
68
69def Async_AnyValueType : DialectType<AsyncDialect,
70                           CPred<"$_self.isa<::mlir::async::ValueType>()">,
71                                 "async value type">;
72
73def Async_AnyValueOrTokenType : AnyTypeOf<[Async_AnyValueType,
74                                           Async_TokenType]>;
75
76def Async_AnyAsyncType : AnyTypeOf<[Async_AnyValueType,
77                                    Async_TokenType,
78                                    Async_GroupType]>;
79
80#endif // ASYNC_BASE_TD
81