Created by: HugoPhi
This pull request introduces several significant changes to improve code organization, functionality, and debugging capabilities. The most notable updates include the consolidation of IR-related structures into tca_ir.h, the addition of LLVM IR generation functionality, and enhancements to debugging options. Below is a categorized summary of the key changes:
Code Organization and Refactoring
- Consolidated IR-related definitions (
Type,Operand,Instruction,Function, etc.) into a new file,tca_ir.h, replacing the previous scattered definitions in multiple files (ir.h,ir_function.h,ir_instruction.h,ir_operand.h,ir_operator.h,ir_program.h). This simplifies the structure and improves maintainability. - Updated all references to the old IR-related files to use the new
tca_ir.hacross multiple files (generator.h,ast.h,semantic.h,syntax.h,token.h,ir_executor.h,ir_reader.h). [1] [2] [3] [4] [5] [6] [7]
LLVM IR Generation
- Introduced a new
LLVMIRGeneratorclass intca2llvm.hto handle the conversion of TCA IR to LLVM IR. This includes functionality for type conversion, instruction translation, and module generation. - Added support for generating LLVM IR in the
main.cppfile, including a new command-line flag--llvm-irto enable this feature. The generated IR is output to a.llfile. [1] [2] [3] [4] [5]
Debugging Enhancements
- Added new debugging macros (
DEBUG_EXEC_BRIEF,DEBUG_EXEC_DETAIL,DEBUG_HYM_SEE_VAR2OFFSET_TABLE,DEBUG_TCA_2_LLVM) todebug.hfor more granular control of debug output during execution and IR conversion processes.
Cleanup and Removal of Deprecated Code
- Removed outdated and unused IR-related files (
ir.h,ir_function.h,ir_instruction.h,ir_operand.h,ir_operator.h,ir_program.h). These files were replaced by the newtca_ir.h. [1] [2] [3] [4] [5] [6] - Removed redundant debug output in
src/backend/generator.cppto streamline register allocation logic.
Miscellaneous Improvements
- Added a helper function in
main.cppto check if a file contains specific code snippets, with optimizations for early exit and reduced memory usage.
These changes collectively improve the project's structure, functionality, and usability, paving the way for more efficient development and debugging workflows.