Closed axic closed 5 years ago
Can you expand on the pt.2 ?
Could have a small C/C++ snippet which calls getRegisteredNames
and generates a Rust file with for example an enum from the names received:
pub enum OptimisationPasses {
Untee,
Vacuum,
// ...
}
That's really interesting approach.
Or to be quick, we could do a regex on src/passes/pass.cpp
:
registerPass\("([^"]+)", "([^"]+)", [^)]+\);
Hm that's tempting... But we need to make sure that we don't require any new dependencies (i.e. we don't want to require grep
to be installed).
From https://github.com/pepyakin/binaryen-rs/pull/22#discussion_r245003965.
Binaryen has optimisation passes which have a name and a description, both are strings. The list of names (keys) can be retrieved via
std::vector<std::string> PassRegistry::getRegisteredNames()
and the descriptions viastd::string PassRegistry::getPassDescription(std::string name)
.Would be nice if we could design a dynamic API exposing this to Rust.
Two alternatives: 1) hardcode them in Rust (such as a
enum
as suggested by @pepyakin, where though the description could still be dynamic) 2) generate Rust code at compile time