Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a160a7

Browse filesBrowse files
[mlir][MLProgram][NFC] Migrate to OpAsmAttrInterface for ASM alias generation
1 parent 6fbe491 commit 9a160a7
Copy full SHA for 9a160a7

File tree

Expand file treeCollapse file tree

2 files changed

+13
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-9
lines changed

‎mlir/include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.td

Copy file name to clipboardExpand all lines: mlir/include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.td
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
include "mlir/IR/AttrTypeBase.td"
1313
include "mlir/IR/BuiltinAttributeInterfaces.td"
14+
include "mlir/IR/OpAsmInterface.td"
1415
include "mlir/Dialect/MLProgram/IR/MLProgramBase.td"
1516

1617
// Base class for MLProgram dialect attributes.
@@ -23,7 +24,7 @@ class MLProgram_Attr<string name, list<Trait> traits = []>
2324
// ExternAttr
2425
//===----------------------------------------------------------------------===//
2526

26-
def MLProgram_ExternAttr : MLProgram_Attr<"Extern", [TypedAttrInterface]> {
27+
def MLProgram_ExternAttr : MLProgram_Attr<"Extern", [TypedAttrInterface, OpAsmAttrInterface]> {
2728
let summary = "Value used for a global signalling external resolution";
2829
let description = [{
2930
When used as the value for a GlobalOp, this indicates that the actual
@@ -40,6 +41,17 @@ def MLProgram_ExternAttr : MLProgram_Attr<"Extern", [TypedAttrInterface]> {
4041
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
4142
let mnemonic = "extern";
4243
let assemblyFormat = "";
44+
45+
let extraClassDeclaration = [{
46+
//===------------------------------------------------------------------===//
47+
// OpAsmAttrInterface Methods
48+
//===------------------------------------------------------------------===//
49+
50+
::mlir::OpAsmAliasResult getAlias(::llvm::raw_ostream &os) const {
51+
os << "}] # mnemonic # [{";
52+
return ::mlir::OpAsmAliasResult::OverridableAlias;
53+
}
54+
}];
4355
}
4456

4557
#endif // MLPROGRAM_ATTRIBUTES

‎mlir/lib/Dialect/MLProgram/IR/MLProgramDialect.cpp

Copy file name to clipboardExpand all lines: mlir/lib/Dialect/MLProgram/IR/MLProgramDialect.cpp
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ struct MLProgramInlinerInterface : public DialectInlinerInterface {
3939

4040
struct MLProgramOpAsmDialectInterface : public OpAsmDialectInterface {
4141
using OpAsmDialectInterface::OpAsmDialectInterface;
42-
43-
AliasResult getAlias(Attribute attr, raw_ostream &os) const override {
44-
if (llvm::isa<ExternAttr>(attr)) {
45-
os << "extern";
46-
return AliasResult::OverridableAlias;
47-
}
48-
return AliasResult::NoAlias;
49-
}
5042
};
5143
} // namespace
5244

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.