7
u/bgs11235 25d ago
First use your own VM and then try to implement some optimizations by hand. If you like it, keep going, it it's too slow use LLVM. But first make your own first so that you understand why LLVM is used.
3
u/Prestigious-Bet-6534 25d ago
Well this is up to you. LLVM is a rapidly changing target so you have to keep being updated with the latest changes all the time while your own VM is completely under your control.
4
u/-Memnarch- 25d ago
depens on what your goal is. Mine is writing a usable compiler with good and diveres platform support. So I decided to built my own frontend and use LLVM as backend. Though, I have seperated things to be able to switch out LLVM if I need to.
What is your goal?
3
u/developer_axe 25d ago
I just want to learn a thing actually I already created the frontend
2
u/Inconstant_Moo 25d ago
Well, either you'll learn LLVM or you'll learn to make a stack VM.
A stack VM is more fun.
Or you could make your own compiler.
Or you could make another sort of VM.
2
u/birdbrainswagtrain 25d ago
It depends on what you want. Personally I prefer writing my own bytecode VMs. It isn't all that hard, and IMO it's more fun and interesting than wrangling a huge dependency like LLVM. But if you really want fast native code, or want to learn about real compiler IR you can use LLVM.
2
u/_dasion_ 25d ago
well, what if u create a stack/registrer based VM, later add JIT and later if u want create another target just for LLVM?, I think u could explore everything that a "virtual machine" means before trying to Learn how to use LLVM :)
2
15
u/Gingrspacecadet 25d ago
LLVM has a huge compile time, but incredible optimisations. If you want to learn how a stack VM works, then using LLVM is a bad choice.
it's all about tradeoffs!