Topi Kettunen


Sila Dev Log: New Beginning in LLVM

Posted on 12th of November 2024 | 350 words
Plug: Follow the Sila development here.

Behind the scenes, I’ve continued to develop Sila quite a bit, but unfortunately, it seems that some of the design – or better lack of – choices I made during the early initial development has started show their flaws. So, I’ve decided to go back to drawing board to do some of the design flaws better this time. Also, with a new/old language.

Originally, I wanted to start writing this compiler in Common Lisp mainly due to the reason of just purely liking the language. And nothing has changed in that front and I still love working with it. I’ve just run into a situation, where I happen to need quite a bit of C++ and also LLVM. So this naturally got me thinking that maybe I should look into just rewriting my compiler in those. Another reason was the fact that I just recently got a new Apple Silicon machine and most of the compiler was written for x86-64. So now I would need to write a new backend for aarch64, which is why LLVM started to look like a feasible choice.

Of course – at least in my opinion – going back to C++ from Common Lisp is in many ways a step back. I love utilising Common Lisp’s dynamic nature pretty thoroughly and especially when working as a solo developer, it offers great perks. Due to this, I played around with the idea of just generating LLVM IR from Common Lisp without using the LLVM API directly, but then decided to go with the C++ API route, mainly since I just wanted to refresh some memories of C++ and also at least by doing that, I get exposed to the LLVM API completely. Which I find beneficial, especially when trying diving into LLVM more.

Decisions to start over are never easy, but often necessary for progress. By doing this, I tend to address some of the shortcomings of the initial design. But also since I’m going with LLVM, I can also focus on some of the more interesting – to me – problems in the compiler construction.

NB: If you want to read earlier posts of this dev log, head over here.