Skip to content

Commit 8f9da1e

Browse files
authored
[mlir][ml_program] Add asm names for load (#70409)
1 parent 03485a0 commit 8f9da1e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include "mlir/Interfaces/CallInterfaces.td"
1616
include "mlir/Interfaces/ControlFlowInterfaces.td"
1717
include "mlir/Interfaces/SideEffectInterfaces.td"
1818
include "mlir/Interfaces/FunctionInterfaces.td"
19+
include "mlir/IR/OpAsmInterface.td"
1920
include "mlir/IR/RegionKindInterface.td"
2021
include "mlir/IR/SymbolInterfaces.td"
2122

@@ -153,6 +154,7 @@ def MLProgram_GlobalOp : MLProgram_Op<"global", [
153154
//===----------------------------------------------------------------------===//
154155

155156
def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
157+
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
156158
DeclareOpInterfaceMethods<SymbolUserOpInterface>
157159
]> {
158160
let summary = "Direct load of a mutable value from a global";
@@ -190,6 +192,13 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
190192
/// Gets the corresponding GlobalOp (or nullptr).
191193
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
192194
}];
195+
196+
let extraClassDefinition = [{
197+
void $cppClass::getAsmResultNames(
198+
function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
199+
setNameFn(getResult(), getGlobal().getLeafReference());
200+
}
201+
}];
193202
}
194203

195204
//===----------------------------------------------------------------------===//
@@ -198,6 +207,7 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
198207

199208
def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
200209
Pure,
210+
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
201211
DeclareOpInterfaceMethods<SymbolUserOpInterface>
202212
]> {
203213
let summary = "Direct load a constant value from a global";
@@ -229,6 +239,13 @@ def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
229239
/// Gets the corresponding GlobalOp (or nullptr).
230240
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
231241
}];
242+
243+
let extraClassDefinition = [{
244+
void $cppClass::getAsmResultNames(
245+
function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
246+
setNameFn(getResult(), getGlobal().getLeafReference());
247+
}
248+
}];
232249
}
233250

234251
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)