[Mlir-commits] [mlir] [mlir][llvm] support -new-struct-path-tbaa (PR #119698)
Tobias Gysi
llvmlistbot at llvm.org
Thu Feb 27 10:50:23 PST 2025
================
@@ -1084,8 +1084,79 @@ def LLVM_TBAATagAttr : LLVM_Attr<"TBAATag", "tbaa_tag"> {
let assemblyFormat = "`<` struct(params) `>`";
}
+def LLVM_TBAAStructFieldAttr : LLVM_Attr<"TBAAStructField", "tbaa_struct_field"> {
+ let parameters = (ins
+ "TBAANodeAttr":$typeDesc,
+ "int64_t":$offset,
+ "int64_t":$size
+ );
+ let assemblyFormat = "`<` struct(params) `>`";
+}
+
+
+def LLVM_TBAAStructFieldAttrArray : ArrayRefParameter<"TBAAStructFieldAttr"> {
+ let printer = [{
+ $_printer << '{';
+ llvm::interleaveComma($_self, $_printer, [&](TBAAStructFieldAttr attr) {
+ $_printer.printStrippedAttrOrType(attr);
+ });
+ $_printer << '}';
+ }];
+
+ let parser = [{
+ [&]() -> FailureOr<SmallVector<TBAAStructFieldAttr>> {
+ using Result = SmallVector<TBAAStructFieldAttr>;
+ if ($_parser.parseLBrace())
+ return failure();
+ FailureOr<Result> result = FieldParser<Result>::parse($_parser);
+ if (failed(result))
+ return failure();
+ if ($_parser.parseRBrace())
+ return failure();
+ return result;
+ }()
+ }];
+}
+
+def LLVM_TBAATypeNodeAttr : LLVM_Attr<"TBAATypeNode", "tbaa_type_node", [], "TBAANodeAttr"> {
+ let parameters = (ins
+ "TBAANodeAttr":$parent,
----------------
gysit wrote:
Makes sense.
If we want to verify this we have sort of two options:
1) we add a verifier to attribute that checks that parent is not a `TBAATypeDescriptorAttr`.
2) We implement a separate base class for the new TBBAA format which could be called `TBAAAccessNodeAttr` if we follow the naming scheme of the access tag. However, this also requires
a `TBAAAccessRootAttr` since an attribute can only inherit from one base class AFAIK.
I do not have a clear preference.
https://github.com/llvm/llvm-project/pull/119698
More information about the Mlir-commits
mailing list