Skip to content

feat: Basic IR codegen - #11

Merged
Bli-AIk merged 24 commits into
mainfrom
feat-llvm-setup
Oct 16, 2025
Merged

feat: Basic IR codegen#11
Bli-AIk merged 24 commits into
mainfrom
feat-llvm-setup

Conversation

@Bli-AIk

@Bli-AIk Bli-AIk commented Oct 15, 2025

Copy link
Copy Markdown
Member

PR Type

Please check the type of this PR (you can select multiple)

  • 🐞 Bug fix
  • ✨ New feature
  • 📚 Documentation change
  • 🎨 Code style change (such as formatting, renaming)
  • ♻️ Refactoring
  • ⚡️ Performance improvement
  • 🧪 Adding or updating tests
  • 🤖 CI/CD (Changes to CI/CD configuration)
  • 📦 Other changes

Related Issue

  • N/A

What does this PR do?

The PR primarily focuses on introducing Just-In-Time (JIT) execution capabilities and updating the project dependency to LLVM 18.

  • Introduced JIT Execution: A new JITExecutor module was added to implement Just-In-Time compilation and execution, built on top of LLVM.
  • LLVM 18 Upgrade: The continuous integration (CI) workflow (ci.yml) was updated to install and use LLVM 18, and related dependencies were updated in Cargo.toml.
  • New Compilation Utilities: Helper functions like compile_and_execute_main and compile_and_execute_function were created to streamline the entire process of parsing, IR generation, module verification, and JIT execution for testing and library use.
  • CI Workflow Updates: The CI now installs LLVM 18 and includes a condition to skip testing on draft Pull Requests.

How to test?

  • N/A

Screenshots or Videos

N/A

Additional Information

N/A

Add comprehensive_test.rs and test.rs files with extensive test coverage.
Declare test modules in codegen.rs to organize test structure.
Add modulo operator implementation for both integer and floating-point types. Support mixed int/float operations through automatic type conversion. Improve return type handling for boolean values.
This commit standardizes error handling in  by refactoring long, chained error maps into more readable blocks. It also removes internal test modules to simplify the build structure.

* **IR Generation:** Refactors complex LLVM builder calls and conversions (like float/int/bool promotions, bitwise operations) to use dedicated code blocks, improving readability and maintainability of error messages.

* **Code Structure:** Removes  and  modules from , aligning with the typical Rust practice of placing tests directly within the module being tested or in a dedicated  directory.

* **Minor Cleanup:** Removes unused  variable assignment in .
…setup

# Conflicts:
#	src/codegen.rs
#	src/main.rs
@Bli-AIk
Bli-AIk requested a review from Copilot October 15, 2025 06:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements basic IR code generation functionality for the GML compiler, adding LLVM IR generation and JIT execution capabilities. The main purpose is to enable compilation and execution of GML code through LLVM infrastructure.

Key Changes:

  • Implements complete LLVM IR generation for GML language constructs including expressions, statements, functions, and control flow
  • Adds JIT execution engine for runtime code execution
  • Refactors project structure to separate compilation phases into dedicated handler modules

Reviewed Changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main.rs Complete refactor to use modular handlers for parsing, symbol table building, and code generation
src/codegen/ New module containing IR generator and JIT executor for LLVM-based compilation
src/handler/ New modular handler system separating concerns for file operations, parsing, output, symbol tables, and code generation
src/tests/ Comprehensive test suite with helper utilities and extensive codegen tests
src/utils/colorize.rs Remove unnecessary parentheses around function call
src/parser/ Module visibility changes and test reorganization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/tests/tests_helper.rs Outdated
@Bli-AIk Bli-AIk self-assigned this Oct 15, 2025
@Bli-AIk Bli-AIk added the enhancement New feature or request label Oct 15, 2025
@codecov

codecov Bot commented Oct 15, 2025

Copy link
Copy Markdown

The 'windows-latest' runner pre-installs a newer LLVM version (e.g., v20), causing the 'choco install llvm --version=18.1.8' step to fail.
Added '--allow-downgrade' to the Chocolatey command to force the installation of the required LLVM v18.1.8.
@Bli-AIk
Bli-AIk requested a review from Copilot October 16, 2025 02:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Bli-AIk
Bli-AIk merged commit 935e630 into main Oct 16, 2025
5 checks passed
@Bli-AIk
Bli-AIk deleted the feat-llvm-setup branch October 16, 2025 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants