@@ -16,6 +16,7 @@ include "mlir/Interfaces/CallInterfaces.td"
16
16
include "mlir/Interfaces/ControlFlowInterfaces.td"
17
17
include "mlir/Interfaces/SideEffectInterfaces.td"
18
18
include "mlir/Interfaces/FunctionInterfaces.td"
19
+ include "mlir/IR/OpAsmInterface.td"
19
20
include "mlir/IR/RegionKindInterface.td"
20
21
include "mlir/IR/SymbolInterfaces.td"
21
22
@@ -153,6 +154,7 @@ def MLProgram_GlobalOp : MLProgram_Op<"global", [
153
154
//===----------------------------------------------------------------------===//
154
155
155
156
def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
157
+ DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
156
158
DeclareOpInterfaceMethods<SymbolUserOpInterface>
157
159
]> {
158
160
let summary = "Direct load of a mutable value from a global";
@@ -190,6 +192,13 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
190
192
/// Gets the corresponding GlobalOp (or nullptr).
191
193
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
192
194
}];
195
+
196
+ let extraClassDefinition = [{
197
+ void $cppClass::getAsmResultNames(
198
+ function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
199
+ setNameFn(getResult(), getGlobal().getLeafReference());
200
+ }
201
+ }];
193
202
}
194
203
195
204
//===----------------------------------------------------------------------===//
@@ -198,6 +207,7 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
198
207
199
208
def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
200
209
Pure,
210
+ DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
201
211
DeclareOpInterfaceMethods<SymbolUserOpInterface>
202
212
]> {
203
213
let summary = "Direct load a constant value from a global";
@@ -229,6 +239,13 @@ def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
229
239
/// Gets the corresponding GlobalOp (or nullptr).
230
240
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
231
241
}];
242
+
243
+ let extraClassDefinition = [{
244
+ void $cppClass::getAsmResultNames(
245
+ function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
246
+ setNameFn(getResult(), getGlobal().getLeafReference());
247
+ }
248
+ }];
232
249
}
233
250
234
251
//===----------------------------------------------------------------------===//
0 commit comments