Skip to content

[mlir][ml_program] Add asm names for load #70409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/FunctionInterfaces.td"
include "mlir/IR/OpAsmInterface.td"
include "mlir/IR/RegionKindInterface.td"
include "mlir/IR/SymbolInterfaces.td"

Expand Down Expand Up @@ -153,6 +154,7 @@ def MLProgram_GlobalOp : MLProgram_Op<"global", [
//===----------------------------------------------------------------------===//

def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
DeclareOpInterfaceMethods<SymbolUserOpInterface>
]> {
let summary = "Direct load of a mutable value from a global";
Expand Down Expand Up @@ -190,6 +192,13 @@ def MLProgram_GlobalLoadOp : MLProgram_Op<"global_load", [
/// Gets the corresponding GlobalOp (or nullptr).
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
}];

let extraClassDefinition = [{
void $cppClass::getAsmResultNames(
function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
setNameFn(getResult(), getGlobal().getLeafReference());
}
}];
}

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

def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
Pure,
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
DeclareOpInterfaceMethods<SymbolUserOpInterface>
]> {
let summary = "Direct load a constant value from a global";
Expand Down Expand Up @@ -229,6 +239,13 @@ def MLProgram_GlobalLoadConstOp : MLProgram_Op<"global_load_const", [
/// Gets the corresponding GlobalOp (or nullptr).
GlobalOp getGlobalOp(SymbolTableCollection &symbolTable);
}];

let extraClassDefinition = [{
void $cppClass::getAsmResultNames(
function_ref<void(::mlir::Value, ::llvm::StringRef)> setNameFn) {
setNameFn(getResult(), getGlobal().getLeafReference());
}
}];
}

//===----------------------------------------------------------------------===//
Expand Down