[clang] [CIR] Upstream global initialization for VectorType (PR #137511)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 28 15:51:02 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;
----------------
bcardosolopes wrote:
Have you tried to use a tablegen based asm fmt? The incubator impl is a bit outdated here - I don't see any real constraints these days blocking such approach.
https://github.com/llvm/llvm-project/pull/137511
More information about the cfe-commits
mailing list