This commit is contained in:
xlauko 2025-06-19 21:58:47 +02:00
parent 7f27482a32
commit a388661092
No known key found for this signature in database
6 changed files with 85 additions and 3 deletions

View File

@ -12,6 +12,7 @@
#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
#include "mlir/IR/BuiltinEnums.h"
#include "mlir/IR/Dialect.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/CastInterfaces.h"

View File

@ -1160,7 +1160,7 @@ def MemRef_GlobalOp : MemRef_Op<"global", [Symbol]> {
}];
let arguments = (ins SymbolNameAttr:$sym_name,
OptionalAttr<StrAttr>:$sym_visibility,
OptionalAttr<SymbolVisibilityAttr>:$sym_visibility,
MemRefTypeAttr:$type,
OptionalAttr<AnyAttr>:$initial_value,
UnitAttr:$constant,

View File

@ -15,6 +15,7 @@
#define BUILTIN_ATTRIBUTES
include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/EnumAttr.td"
include "mlir/IR/BuiltinDialect.td"
include "mlir/IR/BuiltinAttributeInterfaces.td"
include "mlir/IR/OpAsmInterface.td"
@ -1202,6 +1203,47 @@ def Builtin_SymbolRefAttr : Builtin_Attr<"SymbolRef", "symbol_ref"> {
let skipDefaultBuilders = 1;
}
//===----------------------------------------------------------------------===//
// SymbolVisibilityAttr
//===----------------------------------------------------------------------===//
def Builtin_SymbolVisibilityAttr : I32EnumAttr<
"SymbolVisibility", "sym_visibility", [
I32EnumAttrCase<"Public", 0, "public">,
I32EnumAttrCase<"Private", 1, "private">,
I32EnumAttrCase<"Nested", 2, "nested">
]> {
let summary = "An Attribute representing the visibility of a symbol";
let description = [{
Syntax:
```
symbol-visibility-attribute ::= `public` | `private` | `nested`
```
The visibility of a symbol defines its structural reachability within the
IR. A symbol has one of the following visibilities:
- Public (Default): The symbol may be referenced from outside of the visible
IR. We cannot assume that all of the uses of this symbol are observable. If
the operation declares a symbol (as opposed to defining it), public
visibility is not allowed because symbol declarations are not intended to be
used from outside the visible IR.
- Private: The symbol may only be referenced from within the current symbol
table.
- Nested: The symbol may be referenced by operations outside of the current
symbol table, but not outside of the visible IR, as long as each symbol
table parent also defines a non-private symbol.
See [`Symbols And SymbolTables`](../SymbolsAndSymbolTables.md) for more
information.
}];
let cppNamespace = "mlir";
}
//===----------------------------------------------------------------------===//
// TypeAttr
//===----------------------------------------------------------------------===//

View File

@ -0,0 +1,24 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_IR_BUILTINENUMS_H
#define MLIR_IR_BUILTINENUMS_H
//===----------------------------------------------------------------------===//
// Tablegen Enums Declarations
//===----------------------------------------------------------------------===//
namespace mlir {
#define GET_ENUM_ATTRDEF_CLASSES
#include "mlir/IR/BuiltinAttributesEnums.h.inc"
} // namespace mlir
#endif // MLIR_IR_BUILTIENUMS_H

View File

@ -16,6 +16,11 @@ mlir_tablegen(BuiltinAttributes.h.inc -gen-attrdef-decls)
mlir_tablegen(BuiltinAttributes.cpp.inc -gen-attrdef-defs)
add_public_tablegen_target(MLIRBuiltinAttributesIncGen)
set(LLVM_TARGET_DEFINITIONS BuiltinAttributes.td)
mlir_tablegen(BuiltinAttributesEnums.h.inc -gen-enum-decls)
mlir_tablegen(BuiltinAttributesEnums.cpp.inc -gen-enum-defs)
add_public_tablegen_target(MLIRBuiltinAttributesEnumsGen)
set(LLVM_TARGET_DEFINITIONS BuiltinAttributeInterfaces.td)
mlir_tablegen(BuiltinAttributeInterfaces.h.inc -gen-attr-interface-decls)
mlir_tablegen(BuiltinAttributeInterfaces.cpp.inc -gen-attr-interface-defs)

View File

@ -683,6 +683,16 @@ def FlatSymbolRefArrayAttr :
let constBuilderCall = ?;
}
def SymbolVisibilityAttr : Attr<
CPred<"::llvm::isa<::mlir::SymbolVisibilityAttr>($_self)">,
"symbol visibility attribute"> {
let storageType = [{ ::mlir::SymbolVisibilityAttr }];
let returnType = [{ ::mlir::SymbolVisibilityAttr }];
let valueType = NoneType;
let constBuilderCall = "::mlir::SymbolVisibilityAttr::get($_builder.getContext(), $0)";
let convertFromStorage = "$_self";
}
//===----------------------------------------------------------------------===//
// Derive attribute kinds
//===----------------------------------------------------------------------===//