Rust Code generation#21
Open
loic-fejoz wants to merge 3 commits into
Open
Conversation
Experiments the use of a macro to support multiple Futamura projection, like for Runtime and CodeGeneration.
- Introduced FsdrBackend trait to decouple flowgraph construction from execution. - Created fsdr-cli-macros crate with #[fsdr_instantiate] attribute to ensure a "One Source of Truth" for both runtime and codegen modes. - Refactored all ~40 block converters to be generic over the backend, enabling behavioral parity between interpretation and compilation. - Implemented CodegenBackend to emit optimized Rust source code with pre-computed data (like filter taps) baked in as literals. - Added a --generate <filepath> CLI flag to the csdr and grc commands. - Added integration tests in tests/codegen.rs and updated developer documentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a Rust Code Generation feature to fsdr-cli, enabling any DSP flowgraph (from csdr commands or .grc files) to be exported as a standalone, Rust source file.
The implementation follows the Futamura projection concept: the flowgraph is partially evaluated, complex parameters (like FIR taps) are pre-computed, and the resulting physical data is baked directly into the generated code as literals. This eliminates runtime overhead for graph construction and parameter resolution.
Key Changes
generating both runtime and codegen versions of a block's constructor.
Usage Example
Export an optimized standalone Rust program from a complex pipeline
fsdr-cli csdr --generate src/my_dsp_app.rs convert_u8_f ! shift_addition_cc 0.01 ! fmdemod_quadri_cf ! dump_fVerification