Skip to content

feat: add LLVM IR codegen for StructDefStmt and tests#201

Open
m-akhil-reddy wants to merge 7 commits intoarxlang:mainfrom
m-akhil-reddy:feat/issue-143
Open

feat: add LLVM IR codegen for StructDefStmt and tests#201
m-akhil-reddy wants to merge 7 commits intoarxlang:mainfrom
m-akhil-reddy:feat/issue-143

Conversation

@m-akhil-reddy
Copy link
Contributor

Notes

  • This repository uses an AI bot for reviews. Keep your PR in Draft while
    you work. When you’re ready for a review, change the status to Ready for
    review
    to trigger a new review round. If you make additional changes and
    don’t want to trigger the bot, switch the PR back to Draft.
  • AI-bot comments may not always be accurate. Please review them critically and
    share your feedback; it helps us improve the tool.
  • Avoid changing code that is unrelated to your proposal. Keep your PR as short
    as possible to increase the chances of a timely review. Large PRs may not be
    reviewed and may be closed.
  • Don’t add unnecessary comments. Your code should be readable and
    self-documenting
    (guidance).
  • Don’t change core features without prior discussion with the community. Use
    our Discord to discuss ideas, blockers, or issues
    (https://discord.gg/Nu4MdGj9jB).
  • Do not include secrets (API keys, tokens, passwords), credentials, or
    sensitive data/PII in code, configs, logs, screenshots, or commit history. If
    something leaks, rotate the credentials immediately, invalidate the old key,
    and note it in the PR so maintainers can assist.
  • Do not commit large binaries or generated artifacts. If large datasets are
    needed for tests, prefer small fixtures or programmatic downloads declared in
    makim.yaml (e.g., a task that fetches data at test time). If a large binary is
    unavoidable, discuss first and consider Git LFS.

Pull Request description

#143

How to test these changes

  • ...

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling.
  • The code is well commented, especially in the parts that contain more
    complexity.
  • New and old tests passed locally.

Additional information

Reviewer's checklist

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved .

@yuvimittal
Copy link
Member

@m-akhil-reddy , i thought you were working on @omsherikar branch, wasnt it? or this is the branch you both will be working on with, so i can close one PR

@yuvimittal yuvimittal closed this Mar 6, 2026
@yuvimittal yuvimittal reopened this Mar 6, 2026
@m-akhil-reddy
Copy link
Contributor Author

@yuvimittal , i am wrking in the new branch. i think you can close the other PR.

@m-akhil-reddy
Copy link
Contributor Author

m-akhil-reddy commented Mar 6, 2026

Hi @yuvimittal , i have made PR for the issue #143 and can please review it , suggest me any changes if needed.

Approach :-

  • Added support for translating astx.StructDefStmt into an LLVM identified struct type.
  • Introduced two structures in LLVMLiteIRVisitor:
    struct_types – stores created LLVM identified struct types.
    struct_defs – stores struct definitions from the AST.
  • Implemented a visit(self, node: astx.StructDefStmt) method to:
    create an LLVM identified struct type for the struct name
    translate attribute types from AST types to LLVM types
    set the struct body with the translated field types
    store the struct type for later use during code generation

Testing :-

  • Added a new test: tests/test_struct_definition.py.
  • The test defines a struct:-
    struct Point { x: int32, y: int32 }
  • The struct definition is included in a simple program with a main function returning 0.
  • The test verifies that the module builds successfully and that the struct definition does not break execution.

@yuvimittal
Copy link
Member

@m-akhil-reddy , can we have one more test or it will reduce test coverage, rest looks good to me, good work!

@m-akhil-reddy
Copy link
Contributor Author

@yuvimittal , Thank you for the feedback.

I have added an additional test case for a struct with a single field to improve test coverage.
I also rebased the branch on the latest main to keep the history clean.

Could you please review the changes and if you accept it then i can work on #152 #159 issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants