Skip to content

Commit

Permalink
[NFC][mlir][gpu] Make sym_name an inherent attr in GPUModuleOp (llvm#…
Browse files Browse the repository at this point in the history
…94918)

Make `sym_name` an inherent attr in GPUModuleOp so that it doesn't show
in the discardable attributes.
The change is safe as the attribute is always expected to be present.
  • Loading branch information
fabianmcg authored Jun 9, 2024
1 parent 77116bd commit 54373e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
def GPU_GPUModuleOp : GPU_Op<"module", [
DataLayoutOpInterface, HasDefaultDLTIDataLayout, IsolatedFromAbove,
SymbolTable, Symbol, SingleBlockImplicitTerminator<"ModuleEndOp">
]>, Arguments<(ins
]>, Arguments<(ins SymbolNameAttr:$sym_name,
OptionalAttr<GPUNonEmptyTargetArrayAttr>:$targets,
OptionalAttr<OffloadingTranslationAttr>:$offloadingHandler)> {
let summary = "A top level compilation unit containing code to be run on a GPU.";
Expand Down
7 changes: 3 additions & 4 deletions mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,12 +1730,11 @@ void GPUModuleOp::build(OpBuilder &builder, OperationState &result,
StringRef name, ArrayAttr targets,
Attribute offloadingHandler) {
ensureTerminator(*result.addRegion(), builder, result.location);
result.attributes.push_back(builder.getNamedAttr(
::mlir::SymbolTable::getSymbolAttrName(), builder.getStringAttr(name)));

Properties &props = result.getOrAddProperties<Properties>();
if (targets)
props.targets = targets;
props.setSymName(builder.getStringAttr(name));
props.offloadingHandler = offloadingHandler;
}

Expand All @@ -1751,11 +1750,11 @@ ParseResult GPUModuleOp::parse(OpAsmParser &parser, OperationState &result) {
StringAttr nameAttr;
ArrayAttr targetsAttr;

if (parser.parseSymbolName(nameAttr, mlir::SymbolTable::getSymbolAttrName(),
result.attributes))
if (parser.parseSymbolName(nameAttr))
return failure();

Properties &props = result.getOrAddProperties<Properties>();
props.setSymName(nameAttr);

// Parse the optional offloadingHandler
if (succeeded(parser.parseOptionalLess())) {
Expand Down

0 comments on commit 54373e0

Please sign in to comment.