#define NVGPU
include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/OpBase.td"
def NVGPU_Dialect : Dialect {
let useDefaultTypePrinterParser = 1;
}
-/// Device-side synchronization token.
-def NVGPU_DeviceAsyncToken : DialectType<
- NVGPU_Dialect, CPred<"$_self.isa<::mlir::nvgpu::DeviceAsyncTokenType>()">,
- "device async token type">,
- BuildableType<
- "mlir::nvgpu::DeviceAsyncTokenType::get($_builder.getContext())">;
+//===----------------------------------------------------------------------===//
+// NVGPU Type Definitions
+//===----------------------------------------------------------------------===//
+
+class NVGPU_Type<string name, string typeMnemonic,
+ list<Trait> traits = []> : TypeDef<NVGPU_Dialect, name, traits> {
+ let mnemonic = typeMnemonic;
+}
+def NVGPU_DeviceAsyncToken : NVGPU_Type<"DeviceAsyncToken",
+ "device.async.token", []> {
+ let summary = "device async token type";
+ let description = [{
+ `nvgpu.device.async.token` is a type returned by an asynchronous operation
+ that runs on the GPU (device). It is used to establish an SSA-based link
+ between the async operation (e.g. DeviceAsyncCopy) and operations that
+ group or synchronize the async operations (e.g. DeviceAsyncCreateGroupOp,
+ DeviceAsyncWaitOp).
+ }];
+}
//===----------------------------------------------------------------------===//
-// NVGPU Op definitions
+// NVGPU Op Definitions
//===----------------------------------------------------------------------===//
class NVGPU_Op<string mnemonic, list<Trait> traits = []> :
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
-namespace mlir {
-namespace nvgpu {
-
-/// Device-side token storage type. There is only one type of device-side token.
-class DeviceAsyncTokenType
- : public Type::TypeBase<DeviceAsyncTokenType, Type, TypeStorage> {
-public:
- // Used for generic hooks in TypeBase.
- using Base::Base;
-};
-
-} // namespace nvgpu
-} // namespace mlir
+#define GET_TYPEDEF_CLASSES
+#include "mlir/Dialect/NVGPU/IR/NVGPUTypes.h.inc"
#include "mlir/Dialect/NVGPU/IR/NVGPUDialect.h.inc"
using namespace mlir;
using namespace mlir::nvgpu;
-#include "mlir/Dialect/NVGPU/IR/NVGPUDialect.cpp.inc"
-
void nvgpu::NVGPUDialect::initialize() {
- addTypes<DeviceAsyncTokenType>();
+ addTypes<
+#define GET_TYPEDEF_LIST
+#include "mlir/Dialect/NVGPU/IR/NVGPUTypes.cpp.inc"
+ >();
addOperations<
#define GET_OP_LIST
#include "mlir/Dialect/NVGPU/IR/NVGPU.cpp.inc"
>();
}
-Type NVGPUDialect::parseType(DialectAsmParser &parser) const {
- // Parse the main keyword for the type.
- StringRef keyword;
- if (parser.parseKeyword(&keyword))
- return Type();
- MLIRContext *context = getContext();
- // Handle 'device async token' types.
- if (keyword == "device.async.token")
- return DeviceAsyncTokenType::get(context);
-
- parser.emitError(parser.getNameLoc(), "unknown nvgpu type: " + keyword);
- return Type();
-}
-
-void NVGPUDialect::printType(Type type, DialectAsmPrinter &os) const {
- TypeSwitch<Type>(type)
- .Case<DeviceAsyncTokenType>([&](Type) { os << "device.async.token"; })
- .Default([](Type) { llvm_unreachable("unexpected 'nvgpu' type kind"); });
-}
//===----------------------------------------------------------------------===//
// NVGPU_DeviceAsyncCopyOp
//===----------------------------------------------------------------------===//
return success();
}
+//===----------------------------------------------------------------------===//
+// TableGen'd dialect, type, and op definitions
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/NVGPU/IR/NVGPUDialect.cpp.inc"
+
#define GET_OP_CLASSES
#include "mlir/Dialect/NVGPU/IR/NVGPU.cpp.inc"
+
+#define GET_TYPEDEF_CLASSES
+#include "mlir/Dialect/NVGPU/IR/NVGPUTypes.cpp.inc"