llvm / llvm/circt

[Moore] Missing conversions to open array types

Open
#11,027 4 comments 0 reactions 1 assignee Claimed by @ovdiiuv View on GitHub
good first issue Moore
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Removing the `moore.conversion` op in #11024 has revealed two related gaps in converting between fixed-size and dynamically-sized array types: a fixed-size unpacked array (e.g. an array literal) assigned to a dynamic array has no conversion path, and a plain packed bit vector passed as the actual argument to a DPI import whose formal parameter is a packed open array has no conversion path either.

```systemverilog
string strArr[] = { "hello", "sad", "world" };
```
```
error: unsupported conversion from '!moore.uarray<3 x string>' to '!moore.open_uarray'
```

```systemverilog
import "DPI-C" function void packed_bits_fn(input bit [] data);
bit [7:0] pdata;
packed_bits_fn(pdata);
```
```
error: unsupported conversion from '!moore.i8' to '!moore.open_array'
```

For the first case, there's no op to build an open unpacked array from element values or from a fixed-size array value — `OpenUArrayCreateOp` only allocates an array of a given size (`new[N]`). Queues have an analogous, working conversion (`QueueFromUnpackedArrayOp`) that a dynamic-array equivalent could follow.

For the second case, MooreToCore's DPI open-array cast support only recognizes array-typed sources, not a plain packed bit vector, and `OpenArrayType`/`OpenUnpackedArrayType` lower to opaque LLVM pointers with no static width, so there's no bitcast to fall back on. A real fix needs to materialize a properly-sized open-array value from the packed operand (allocate and populate it), not just reinterpret bits. This is essentially #11025.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.