================
@@ -4592,9 +4608,20 @@ def CIR_ArrayCtor : CIR_Op<"array.ctor"> {
         $_state.addOperands(ValueRange{addr});
         $_builder.createBlock(r);
         regionBuilder($_builder, $_state.location);
+    }]>,
+    // Dynamic form: addr is ptr<T>, num_elements is the runtime count.
+    OpBuilder<(ins "mlir::Value":$addr, "mlir::Value":$num_elements,
+      "llvm::function_ref<void(mlir::OpBuilder &, 
mlir::Location)>":$regionBuilder), [{
+        assert(regionBuilder && "builder callback expected");
----------------
erichkeane wrote:

What should we do if `num_elements` ends up being a constant?  I wonder if we 
should either auto-const-fold here (to convert this to the other form if we can 
figure out the type?), or have a transform for it? 

Consider:

```
void foo() {
int N = 5;
int arr[N]; // Technically non-constant/a VLA, but we could 'promote' this in 
CIR since we know the size.
}
```

https://github.com/llvm/llvm-project/pull/190656
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to