[Mlir-commits] [mlir] [mlir][EmitC]Allow Fields to have initial values (PR #151437)
Jaden Angella
llvmlistbot at llvm.org
Thu Jul 31 15:54:33 PDT 2025
================
@@ -1398,6 +1398,45 @@ void FileOp::build(OpBuilder &builder, OperationState &state, StringRef id) {
//===----------------------------------------------------------------------===//
// FieldOp
//===----------------------------------------------------------------------===//
+static void printEmitCFieldOpTypeAndInitialValue(OpAsmPrinter &p, FieldOp op,
+ TypeAttr type,
+ Attribute initialValue) {
+ p << type;
+ if (initialValue) {
+ p << " = ";
+ p.printAttributeWithoutType(initialValue);
+ }
+}
+
+static Type getInitializerTypeForField(Type type) {
+ if (auto array = llvm::dyn_cast<ArrayType>(type))
+ return RankedTensorType::get(array.getShape(), array.getElementType());
----------------
Jaddyen wrote:
I suppose this is convention since this is directly from how we have it in `GlobalOp`. And we have this:https://mlir.llvm.org/docs/Dialects/EmitC/#pointertype:~:text=If%20tensors%20are%20used%2C%20C%2B%2B%20is%20generated
https://github.com/llvm/llvm-project/pull/151437
More information about the Mlir-commits
mailing list