[Mlir-commits] [mlir] [MLIR][GEN] Add GEN dialect (PR #88734)
Mehdi Amini
llvmlistbot at llvm.org
Mon Apr 15 08:07:26 PDT 2024
================
@@ -0,0 +1,132 @@
+//===-- GENOps.td - GEN IR dialect op definition file ------*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This is the GEN IR operation definition file.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef GEN_OPS
+#define GEN_OPS
+
+include "mlir/Dialect/GEN/IR/GENDialect.td"
+include "mlir/Dialect/GEN/IR/GENAttrDefs.td"
+include "mlir/IR/OpBase.td"
+include "mlir/IR/EnumAttr.td"
+include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/IR/OpAsmInterface.td"
+
+//===----------------------------------------------------------------------===//
+// GEN op definitions
+//===----------------------------------------------------------------------===//
+
+class GEN_Op<string mnemonic, list<Trait> traits = []> :
+ Op<GEN_Dialect, mnemonic, traits>;
+
+class GENOpTrait<string name, list<Trait> traits = [],
+ code extraOpDeclaration = [{}],
+ code extraOpDefinition = [{}]>
+ : NativeOpTrait<name, traits, extraOpDeclaration, extraOpDefinition> {
+ let cppNamespace = "::mlir::OpTrait::GEN";
+}
+
+//===----------------------------------------------------------------------===//
+// ND-Range Operations
+//===----------------------------------------------------------------------===//
+
+def GEN3DNDRange : GENOpTrait<"GEN3DNDRange">;
+
+class GEN_3DNDRangeOp<string mnemonic, list<Trait> traits = []>
+ : GEN_Op<mnemonic, [GEN3DNDRange, Pure] # traits>,
+ Arguments<(ins I32:$dim)>,
+ Results<(outs Index:$res)> {
+ let assemblyFormat = "$dim attr-dict";
+}
+
+def GEN_LocalIdOp : GEN_3DNDRangeOp<"local_id"> {
+ let summary = "Query a work-item's local id.";
+ let description = [{
+ Query the work-item's position in its work-group, i.e., its local id, in a
+ given dimension.
+ ```mlir
+ %local_id = gen.local_id %dim
+ ```
+ }];
+}
+
+def GEN_WorkGroupIdOp : GEN_3DNDRangeOp<"work_group_id"> {
+ let summary = "Query the id of a work-item's work-group.";
+ let description = [{
+ Query the id of a work-item's work-group in a given dimension.
+ ```mlir
+ %work_group_id = gen.work_group_id %dim
+ ```
+ }];
+}
+
+def GEN_WorkGroupSizeOp : GEN_3DNDRangeOp<"work_group_size"> {
+ let summary = "Query the work-group size.";
+ let description = [{
+ Query the work-item's work-group size in a given dimension.
----------------
joker-eph wrote:
Please beef up the description for each operations.
For example what are the possible values for dim? What happens if it is out-of-bound?
https://github.com/llvm/llvm-project/pull/88734
More information about the Mlir-commits
mailing list