Skip to content

Commit a388661

Browse files
committed
XXX
1 parent 7f27482 commit a388661

File tree

6 files changed

+85
-3
lines changed

6 files changed

+85
-3
lines changed

mlir/include/mlir/Dialect/MemRef/IR/MemRef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "mlir/Bytecode/BytecodeOpInterface.h"
1313
#include "mlir/Dialect/Arith/IR/Arith.h"
1414
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
15+
#include "mlir/IR/BuiltinEnums.h"
1516
#include "mlir/IR/Dialect.h"
1617
#include "mlir/Interfaces/CallInterfaces.h"
1718
#include "mlir/Interfaces/CastInterfaces.h"

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def AssumeAlignmentOp : MemRef_Op<"assume_alignment", [
154154
The `assume_alignment` operation takes a memref and an integer alignment
155155
value. It returns a new SSA value of the same memref type, but associated
156156
with the assumption that the underlying buffer is aligned to the given
157-
alignment.
157+
alignment.
158158

159159
If the buffer isn't aligned to the given alignment, its result is poison.
160160
This operation doesn't affect the semantics of a program where the
@@ -169,7 +169,7 @@ def AssumeAlignmentOp : MemRef_Op<"assume_alignment", [
169169
let assemblyFormat = "$memref `,` $alignment attr-dict `:` type($memref)";
170170
let extraClassDeclaration = [{
171171
MemRefType getType() { return ::llvm::cast<MemRefType>(getResult().getType()); }
172-
172+
173173
Value getViewSource() { return getMemref(); }
174174
}];
175175

@@ -1160,7 +1160,7 @@ def MemRef_GlobalOp : MemRef_Op<"global", [Symbol]> {
11601160
}];
11611161

11621162
let arguments = (ins SymbolNameAttr:$sym_name,
1163-
OptionalAttr<StrAttr>:$sym_visibility,
1163+
OptionalAttr<SymbolVisibilityAttr>:$sym_visibility,
11641164
MemRefTypeAttr:$type,
11651165
OptionalAttr<AnyAttr>:$initial_value,
11661166
UnitAttr:$constant,

mlir/include/mlir/IR/BuiltinAttributes.td

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define BUILTIN_ATTRIBUTES
1616

1717
include "mlir/IR/AttrTypeBase.td"
18+
include "mlir/IR/EnumAttr.td"
1819
include "mlir/IR/BuiltinDialect.td"
1920
include "mlir/IR/BuiltinAttributeInterfaces.td"
2021
include "mlir/IR/OpAsmInterface.td"
@@ -1202,6 +1203,47 @@ def Builtin_SymbolRefAttr : Builtin_Attr<"SymbolRef", "symbol_ref"> {
12021203
let skipDefaultBuilders = 1;
12031204
}
12041205

1206+
//===----------------------------------------------------------------------===//
1207+
// SymbolVisibilityAttr
1208+
//===----------------------------------------------------------------------===//
1209+
1210+
def Builtin_SymbolVisibilityAttr : I32EnumAttr<
1211+
"SymbolVisibility", "sym_visibility", [
1212+
I32EnumAttrCase<"Public", 0, "public">,
1213+
I32EnumAttrCase<"Private", 1, "private">,
1214+
I32EnumAttrCase<"Nested", 2, "nested">
1215+
]> {
1216+
let summary = "An Attribute representing the visibility of a symbol";
1217+
let description = [{
1218+
Syntax:
1219+
1220+
```
1221+
symbol-visibility-attribute ::= `public` | `private` | `nested`
1222+
```
1223+
1224+
The visibility of a symbol defines its structural reachability within the
1225+
IR. A symbol has one of the following visibilities:
1226+
1227+
- Public (Default): The symbol may be referenced from outside of the visible
1228+
IR. We cannot assume that all of the uses of this symbol are observable. If
1229+
the operation declares a symbol (as opposed to defining it), public
1230+
visibility is not allowed because symbol declarations are not intended to be
1231+
used from outside the visible IR.
1232+
1233+
- Private: The symbol may only be referenced from within the current symbol
1234+
table.
1235+
1236+
- Nested: The symbol may be referenced by operations outside of the current
1237+
symbol table, but not outside of the visible IR, as long as each symbol
1238+
table parent also defines a non-private symbol.
1239+
1240+
See [`Symbols And SymbolTables`](../SymbolsAndSymbolTables.md) for more
1241+
information.
1242+
}];
1243+
1244+
let cppNamespace = "mlir";
1245+
}
1246+
12051247
//===----------------------------------------------------------------------===//
12061248
// TypeAttr
12071249
//===----------------------------------------------------------------------===//
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef MLIR_IR_BUILTINENUMS_H
10+
#define MLIR_IR_BUILTINENUMS_H
11+
12+
//===----------------------------------------------------------------------===//
13+
// Tablegen Enums Declarations
14+
//===----------------------------------------------------------------------===//
15+
16+
namespace mlir {
17+
18+
#define GET_ENUM_ATTRDEF_CLASSES
19+
#include "mlir/IR/BuiltinAttributesEnums.h.inc"
20+
21+
} // namespace mlir
22+
23+
24+
#endif // MLIR_IR_BUILTIENUMS_H

mlir/include/mlir/IR/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ mlir_tablegen(BuiltinAttributes.h.inc -gen-attrdef-decls)
1616
mlir_tablegen(BuiltinAttributes.cpp.inc -gen-attrdef-defs)
1717
add_public_tablegen_target(MLIRBuiltinAttributesIncGen)
1818

19+
set(LLVM_TARGET_DEFINITIONS BuiltinAttributes.td)
20+
mlir_tablegen(BuiltinAttributesEnums.h.inc -gen-enum-decls)
21+
mlir_tablegen(BuiltinAttributesEnums.cpp.inc -gen-enum-defs)
22+
add_public_tablegen_target(MLIRBuiltinAttributesEnumsGen)
23+
1924
set(LLVM_TARGET_DEFINITIONS BuiltinAttributeInterfaces.td)
2025
mlir_tablegen(BuiltinAttributeInterfaces.h.inc -gen-attr-interface-decls)
2126
mlir_tablegen(BuiltinAttributeInterfaces.cpp.inc -gen-attr-interface-defs)

mlir/include/mlir/IR/CommonAttrConstraints.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,16 @@ def FlatSymbolRefArrayAttr :
683683
let constBuilderCall = ?;
684684
}
685685

686+
def SymbolVisibilityAttr : Attr<
687+
CPred<"::llvm::isa<::mlir::SymbolVisibilityAttr>($_self)">,
688+
"symbol visibility attribute"> {
689+
let storageType = [{ ::mlir::SymbolVisibilityAttr }];
690+
let returnType = [{ ::mlir::SymbolVisibilityAttr }];
691+
let valueType = NoneType;
692+
let constBuilderCall = "::mlir::SymbolVisibilityAttr::get($_builder.getContext(), $0)";
693+
let convertFromStorage = "$_self";
694+
}
695+
686696
//===----------------------------------------------------------------------===//
687697
// Derive attribute kinds
688698
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)