[clang] [CIR] Upstream global initialization for VectorType (PR #137511)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 29 14:00:51 PDT 2025
================
@@ -215,6 +215,37 @@ def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", [TypedAttrInterface]>
}];
}
+//===----------------------------------------------------------------------===//
+// ConstVectorAttr
+//===----------------------------------------------------------------------===//
+
+def ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector",
+ [TypedAttrInterface]> {
+ let summary = "A constant vector from ArrayAttr";
+ let description = [{
+ A CIR vector attribute is an array of literals of the specified attribute
+ types.
+ }];
+
+ let parameters = (ins AttributeSelfTypeParameter<"">:$type,
+ "mlir::ArrayAttr":$elts);
+
+ // Define a custom builder for the type; that removes the need to pass in an
+ // MLIRContext instance, as it can be inferred from the `type`.
+ let builders = [
+ AttrBuilderWithInferredContext<(ins "cir::VectorType":$type,
+ "mlir::ArrayAttr":$elts), [{
+ return $_get(type.getContext(), type, elts);
+ }]>
+ ];
+
+ // Printing and parsing available in CIRAttrs.cpp
+ let hasCustomAssemblyFormat = 1;
----------------
AmrDeveloper wrote:
You are right, thats better, i think I can do it for ConstArrayAttr also on other PR
https://github.com/llvm/llvm-project/pull/137511
More information about the cfe-commits
mailing list