Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp_transpiler should emit an array of all DSLX enum members #1603

Open
mikex-oss opened this issue Sep 12, 2024 · 0 comments
Open

cpp_transpiler should emit an array of all DSLX enum members #1603

mikex-oss opened this issue Sep 12, 2024 · 0 comments
Labels
enhancement New feature or request 🧦 sox

Comments

@mikex-oss
Copy link
Collaborator

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:

xls/xls/ir/op.h

Lines 34 to 46 in 9a266ca

// Enumerates the operator for nodes in the IR.
enum class Op : int8_t {
#define MAKE_ENUM(name, a, b, c) name,
XLS_FOR_EACH_OP_TYPE(MAKE_ENUM)
#undef MAKE_ENUM
};
// List of all the operators for nodes in the IR.
constexpr auto kAllOps = std::to_array<Op>({
#define MAKE_ENUM_REF(name, a, b, c) Op::name,
XLS_FOR_EACH_OP_TYPE(MAKE_ENUM_REF)
#undef MAKE_ENUM_REF
});

@mikex-oss mikex-oss added enhancement New feature or request 🧦 sox labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🧦 sox
Projects
Status: No status
Development

No branches or pull requests

1 participant