Felix Angell

Read this first

A Brief And Brisk Overview of Compiler Architecture

Most compilers out there follow a particular architecture:

Preface

In this article I intend to dissect this architecture piece by piece in some detail.

Consider this article a supplement to the plethora of resources out there on compilers. It exists as a self contained resource to get your toes wet in the world of programming language design and implementation.

The audience for this article is someone who has very limited knowledge as to how a compiler works, i.e. you know that they compile into assembly at most. Though I do presume that the reader has a good understanding of data structures & algorithms.

It is by no means reflective of modern ‘production’ compilers with millions of lines of code! But rather a very brief/brisk ‘compilers for dummies’ resource to get an idea of what goes on in a compiler.

Introduction

Currently, I’m working on a programming language called...

Continue reading →


An introduction to LLVM in Go

Hacker News Dicussion
Article discussion on Hacker News

Introduction

LLVM is an infrastructure for creating compilers. It was initially created by Chris Lattner in 2000, and released in 2003. Since then it has evolved into an umbrella project that has a wide array of tools such as the LLVM Linker lld, LLVM Debugger lldb, and so on.

The banner feature of LLVM is its intermediate representation, commonly referred to as the LLVM IR. The idea of LLVM is that you can compile down to this IR, and then this IR can be JIT compiled, interpreted, or compiled into native assembly for the machine it’s running on. The primary target of this IR is compilers, in fact there are many compilers out there that use LLVM: clang and clang++ for C and C++ respectively, ldc2 for the D programming language, the Rust language, Swift, etc. There are even projects like emscripten, which can compile LLVM BC (LLVM...

Continue reading →


Virtual machine in C

Hacker News Dicussion
Article discussion on Hacker News

Introduction

Here’s the GitHub to show what we’ll be making. You can also compare your code to this repository in case you have any errors: GitHub Repository

I felt like writing an article about building your very own virtual machine in the C programming language. I love working on lower level applications e.g. compilers, interpreters, parsers, virtual machines, etc. So I thought I’d write this article as learning how virtual machines work is a great way to introduce yourself into the general realm of lower level programming!

Prerequisites & Notices

There are a few things that you need before we can continue:

  • GCC/Clang/.. — I’m using clang, but you can use any modern compiler;
  • Text Editor — I would suggest a text editor over an IDE (when writing C), I’ll be using Emacs;
  • Basic programming knowledge — Just the basics...

Continue reading →