google / google/xls

cpp_transpiler should emit an array of all DSLX enum members

Open
#1,603 0 comments 0 reactions 0 assignees View on GitHub
enhancement 🧦 sox
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

The generated C++ library for DSLX is great! But it's unfortunate that C++ doesn't allow iterating over enum classes. However, since we generate the code, it'd be great to provide this in the generated C++ for the converted DSLX enum definitions. I think proto enums have something similar?

One use case: Run every case of this enum through some C++ test.

### Current best alternative workaround (limit 100 words)

Manually reference each enum member, possibly missing some.

### Your view of the "best case XLS enhancement" (limit 100 words)

We should generate an array like `kAllFoos` in addition to `enum class Foo`. @meheff pointed to some similar generated code for ops here:

https://github.com/google/xls/blob/9a266ca4e37b75b07891d2895fecaa95922a8ea6/xls/ir/op.h#L34-L46

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.