refactor: decompose llvm_codegen into functional modules #262
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.
This PR restructures the LLVM code generation backend by breaking down the monolithic
llvm_codegen.rsfile into a modular directory structure. This change aims to improve code maintainability, clarify the responsibilities of different codegen components, and simplify future extensions to the Wave compiler backend.Key Changes
1. Modular Directory Structure
The single
llvm_codegen.rsfile has been replaced by thellvm_temporary/llvm_codegen/module with the following sub-components:mod.rs: The main entry point that re-exports public API functions.ir.rs: Contains the core AST traversal logic and the primarygenerate_irfunction.address.rs: Specialized logic for memory address calculation (generate_address_ir).types.rs: Manages type conversion logic (wave_type_to_llvm_type) and theVariableInfostructure.consts.rs: Handles the creation of LLVM constant values (create_llvm_const_value).format.rs: Bridging logic for Wave format strings to C-styleprintf/scanfformats.legacy.rs: Preserves legacy functions for backward compatibility withTokenType.2. Signature Updates & Refactoring
wave_format_to_cto accept an LLVMContextreference. This is necessary for accurate floating-point type checking during format string generation.gen_print_format_irwithinstatement/io.rsto pass the requiredcontextto the updated formatting functions.3. Cleanup
front/llvm_temporary/src/llvm_temporary/llvm_codegen.rsfile.Impact