Skip to content

Commit ae4b14b

Browse files
committed
update pr
1 parent b17c7b7 commit ae4b14b

File tree

25 files changed

+567
-41
lines changed

25 files changed

+567
-41
lines changed

mlir/include/mlir/Dialect/DLTI/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_subdirectory(TransformOps)
2+
add_subdirectory(Transforms)
23

34
add_mlir_dialect(DLTI dlti)
45
add_mlir_doc(DLTIAttrs DLTIDialect Dialects/ -gen-dialect-doc)

mlir/include/mlir/Dialect/DLTI/DLTIBase.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def DLTI_Dialect : Dialect {
3939
constexpr const static ::llvm::StringLiteral
4040
kTargetDeviceDescAttrName = "dlti.target_device_spec";
4141

42+
// Top-level attribute name for target information.
43+
constexpr const static ::llvm::StringLiteral
44+
kTargetDescAttrName = "dlti.target";
45+
4246
// Constants used in entries.
4347
constexpr const static ::llvm::StringLiteral
4448
kDataLayoutEndiannessKey = "dlti.endianness";

mlir/include/mlir/Dialect/DLTI/Traits.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ namespace impl {
1919
LogicalResult verifyHasDefaultDLTIDataLayoutTrait(Operation *op);
2020
DataLayoutSpecInterface getDataLayoutSpec(Operation *op);
2121
TargetSystemSpecInterface getTargetSystemSpec(Operation *op);
22+
TargetAttrInterface getTargetAttr(Operation *op);
23+
void setDataLayoutSpec(Operation *op, DataLayoutSpecInterface spec);
24+
void setTargetSystemSpec(Operation *op, TargetSystemSpecInterface spec);
25+
void setTargetAttr(Operation *op, TargetAttrInterface target);
2226
} // namespace impl
2327

2428
/// Trait to be used by operations willing to use the implementation of the
@@ -39,11 +43,27 @@ class HasDefaultDLTIDataLayout
3943
return impl::getDataLayoutSpec(this->getOperation());
4044
}
4145

46+
/// Sets the data layout specification.
47+
void setDataLayoutSpec(DataLayoutSpecInterface spec) {
48+
impl::setDataLayoutSpec(this->getOperation(), spec);
49+
}
4250
/// Returns the target system description specification as provided by DLTI
4351
/// dialect
4452
TargetSystemSpecInterface getTargetSystemSpec() {
4553
return impl::getTargetSystemSpec(this->getOperation());
4654
}
55+
/// Sets the target system description specification.
56+
void setTargetSystemSpec(TargetSystemSpecInterface spec) {
57+
impl::setTargetSystemSpec(this->getOperation(), spec);
58+
}
59+
/// Returns the target information as provided by DLTI dialect.
60+
TargetAttrInterface getTargetAttr() {
61+
return impl::getTargetAttr(this->getOperation());
62+
}
63+
/// Sets the target information.
64+
void setTargetAttr(TargetAttrInterface target) {
65+
impl::setTargetAttr(this->getOperation(), target);
66+
}
4767
};
4868
} // namespace mlir
4969

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(LLVM_TARGET_DEFINITIONS Passes.td)
2+
mlir_tablegen(Passes.h.inc -gen-pass-decls -name DLTI)
3+
mlir_tablegen(Passes.capi.h.inc -gen-pass-capi-header --prefix DLTI)
4+
mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix DLTI)
5+
add_public_tablegen_target(MLIRDLTIPassIncGen)
6+
7+
add_mlir_doc(Passes DLTIPasses ./ -gen-pass-doc)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===- Passes.h - Pass Entrypoints ------------------------------*- 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 header file defines prototypes that expose pass constructors.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_DIALECT_DLTI_TRANSFORMS_PASSES_H
14+
#define MLIR_DIALECT_DLTI_TRANSFORMS_PASSES_H
15+
16+
#include "mlir/Pass/Pass.h"
17+
18+
namespace mlir {
19+
#define GEN_PASS_DECL
20+
#include "mlir/Dialect/DLTI/Transforms/Passes.h.inc"
21+
22+
/// Generate the code for registering passes.
23+
#define GEN_PASS_REGISTRATION
24+
#include "mlir/Dialect/DLTI/Transforms/Passes.h.inc"
25+
26+
/// Sets the target specs using the target attached to the module.
27+
LogicalResult setTargetSpecsFromTarget(Operation *op);
28+
} // namespace mlir
29+
30+
#endif // MLIR_DIALECT_DLTI_TRANSFORMS_PASSES_H
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===-- Passes.td - DLTI pass definition file --------------*- 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+
#ifndef MLIR_DIALECT_DLTI_PASSES
10+
#define MLIR_DIALECT_DLTI_PASSES
11+
12+
include "mlir/Pass/PassBase.td"
13+
14+
def DltiSetTargetSpecsFromTarget: Pass<"dlti-set-target-specs", ""> {
15+
let summary = "Sets DLTI target specs using a target.";
16+
let description = [{
17+
This pass potentially sets the following DLTI target specs in the current
18+
operation:
19+
- The data layout.
20+
- The target system spec.
21+
22+
Example:
23+
24+
```mlir
25+
// Given the following input:
26+
builtin.module @module_1 attributes {dlti.target = #my.target} {...}
27+
// After applying the pass:
28+
builtin.module @module_1 attributes {
29+
dlti.target = #my.target,
30+
dlti.target_system_spec = #my.system_spec,
31+
dlti.dl_spec = #my.dl_spec
32+
} {...}
33+
```
34+
}];
35+
let dependentDialects = [
36+
"::mlir::DLTIDialect"
37+
];
38+
}
39+
40+
#endif // MLIR_DIALECT_DLTI_PASSES

mlir/include/mlir/Dialect/GPU/IR/GPUOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,8 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
13881388
}
13891389

13901390
def GPU_GPUModuleOp : GPU_Op<"module", [
1391-
IsolatedFromAbove, DataLayoutOpInterface, HasDefaultDLTIDataLayout,
1391+
IsolatedFromAbove,
1392+
DeclareOpInterfaceMethods<DataLayoutOpInterface, ["getTargetAttr", "setTargetAttr"]>,
13921393
NoRegionArguments, SymbolTable, Symbol] # GraphRegionNoTerminator.traits> {
13931394
let summary = "A top level compilation unit containing code to be run on a GPU.";
13941395
let description = [{

mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,9 +3247,7 @@ def NVVM_Tcgen05StOp : NVVM_Op<"tcgen05.st"> {
32473247
// NVVM target attribute.
32483248
//===----------------------------------------------------------------------===//
32493249

3250-
def NVVM_TargettAttr : NVVM_Attr<"NVVMTarget", "target", [
3251-
DeclareAttrInterfaceMethods<TargetInfoAttrInterface>
3252-
]> {
3250+
def NVVM_TargettAttr : NVVM_Attr<"NVVMTarget", "target"> {
32533251
let description = [{
32543252
GPU target attribute for controlling compilation of NVIDIA targets. All
32553253
parameters decay into default values if not present.

mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,7 @@ def ROCDL_CvtSrFp8F32Op :
11171117
// ROCDL target attribute.
11181118
//===----------------------------------------------------------------------===//
11191119

1120-
def ROCDL_TargettAttr : ROCDL_Attr<"ROCDLTarget", "target", [
1121-
DeclareAttrInterfaceMethods<TargetInfoAttrInterface>
1122-
]> {
1120+
def ROCDL_TargettAttr : ROCDL_Attr<"ROCDLTarget", "target"> {
11231121
let description = [{
11241122
ROCDL target attribute for controlling compilation of AMDGPU targets. All
11251123
parameters decay into default values if not present.

mlir/include/mlir/InitAllPasses.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "mlir/Dialect/Async/Passes.h"
2424
#include "mlir/Dialect/Bufferization/Pipelines/Passes.h"
2525
#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
26+
#include "mlir/Dialect/DLTI/Transforms/Passes.h"
2627
#include "mlir/Dialect/EmitC/Transforms/Passes.h"
2728
#include "mlir/Dialect/Func/Transforms/Passes.h"
2829
#include "mlir/Dialect/GPU/Pipelines/Passes.h"
@@ -75,6 +76,7 @@ inline void registerAllPasses() {
7576
bufferization::registerBufferizationPasses();
7677
func::registerFuncPasses();
7778
registerGPUPasses();
79+
registerDLTIPasses();
7880
registerLinalgPasses();
7981
registerNVGPUPasses();
8082
registerSparseTensorPasses();

0 commit comments

Comments
 (0)