Support decrementing indices in DSLX for loop
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
DSLX loops are constrained to incrementing indices. For loop traversal, the developer may need to reverse their array prior and after the loop statement.
Example:
```
Array = Reverse(Array)
Array = Incrementing For loop
Array = Reverse(Array)
```
A reverse function for each array may be needed. Example of a reverse function:
```
const SIZE= uint32_t:8;
fn reverse_array(array: int64_t[SIZE]) ->
int64_t[STREAM_LENGTH_SIZE] {
for (i, new_array): (uint32_t, int64_t[SIZE])
in range(uint32_t:0, SIZE/uint32_t:2) {
let first: int64_t = array[i];
let second: int64_t = array[SIZE- i - uint32_t:1];
let array = update(array, SIZE- i - uint32_t:1, first);
update(array, i, second)
}(array)
}
```
There are two solutions. A reverse function in std lib or enable decrementing traversal.
Related to https://github.com/google/xls/issues/634, the DSLX loops must start from 0 and increment.
Contributor guide
Assessment
This issue has not been assessed yet.