LLVMs

LLVM

https://www.infoworld.com/article/2261861/what-is-llvm-the-power-behind-swift-rust-clang-and-more.html

LLVM is a compiler framework for programmatically generating machine-native code.

Intro

Developers use it to roll out new languages and enhance existing ones.

The development landscape is ripe with new languages and improvements on existing ones. Mozilla’s Rust, Apple’s Swift, Kotlin from JetBrains, and the experimental Python variant Mojo (and many others) offer developers a wide range of choices for speed, safety, convenience, portability, and power.

The arrival of new tools for building languages—specifically, compilers—is a big factor in this abundance. And chief among compilers is LLVM, an open source project originally developed by Swift language creator Chris Lattner at the University of Illinois.

LLVM makes it easier to not only create new languages but enhance the development of existing ones. It provides tools for automating many of the most thankless parts of creating a new language: developing a compiler, porting the outputted code to multiple platforms and architectures, generating architecture-specific optimizations such as vectorization, and writing code to handle common language metaphors like exceptions. Its liberal licensing means LLVM can be freely reused as a software component or deployed as a service.

What is LLVM?

At heart, LLVM is a library for programmatically creating machine-native code. A developer uses the API to generate instructions in a format called an intermediate representation, or IR. LLVM can then compile the IR into a standalone binary or perform a JIT (just-in-time) compilation on the code to run in the context of another program, such as an interpreter or runtime for the language.

How programming languages uses LLVM

The most common use case for LLVM is as an ahead-of-time (AOT) language compiler. For example, the Clang project ahead-of-time compiles C and C++ to native binaries.

Just-in-time compiling with LLVM

Some situations require generating code on the fly at runtime, rather than compiling it ahead of time.


Links to this note