Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples? #432

Open
vivekascoder opened this issue Aug 15, 2023 · 6 comments
Open

More examples? #432

vivekascoder opened this issue Aug 15, 2023 · 6 comments

Comments

@vivekascoder
Copy link

Can we plz have more examples?

@EricLBuehler
Copy link
Contributor

EricLBuehler commented Aug 15, 2023

Perhaps links to projects that use Inkwell could be added? In my opinion, a real use case is the best example :)

@vivekascoder
Copy link
Author

True, that would be wonderful.

@Pat-Lafon
Copy link
Contributor

Can I shamelessly plug a mini-project of mine? https://github.com/sampsyo/bril/tree/main/bril-rs/brillvm Assuming you already have a frontend, it shows how to use the Inkwell bindings to compile your IR to LLVM or execute it via the jit.

Probably a bit on the simpler side for people more familiar with LLVM.

It does show off a few cool things:

  • how to use the stack to avoid needing SSA form
  • small examples of many of the builder operations in a clean manner
  • how to link in separately compiled rust code to build function calls(for printing)
  • some simple manipulation of basic blocks/pointers
  • How to get your runtime module to parse command line arguments ie argc/argv

Critiques appreciated!

@EricLBuehler
Copy link
Contributor

EricLBuehler commented Aug 31, 2023

@Pat-Lafon, that really looks interesting!

Currently, I am developing Kestrel, a programming language similar to Rust, with a rich type system and safety guarantees, but a different view on generics.
The major things Kestrel demonstrates with relation to Inkwell are:

  • Linking to C functions
  • Overflow handling
  • Examples of many of the Inkwell builder methods
  • Manipulation of basic blocks and branching
  • More to come, such as tagged enums, structs, generics, arrays and dynamic dispatch

However, I would also like to mention to the old Kestrel. It has the basic features of a programming language - and a trait-based type system. However, although it checks ownership and mutability and references, it is unsafe as it does not check lifetimes. This is what the "new" Kestrel seeks to solve. Regardless, the old Kestrel demonstrates:

  • Linking to C functions
  • Examples of many of the Inkwell builder methods
  • Manipulation of basic blocks and branching
  • Enums
  • Structs
  • Generics
  • Arrays
  • Dynamic dispatch

@TheDan64
Copy link
Owner

TheDan64 commented Sep 4, 2023

Happy to accept PRs to list more examples

@Dominilk
Copy link

self-plug: https://github.com/Dominilk/llvmbf

small llvm frontend for brainf*ck esoteric language

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

No branches or pull requests

5 participants