Top 1,000 Features Creators Resources Extensions Blog Explorer CSV Download
GitHub icon


< >

LLVM IR is an open source intermediate representation language created in 2003.

#70on PLDB 21Years Old 1kRepos

Try now: Riju · TIO

The LLVM compiler infrastructure project is a "collection of modular and reusable compiler and toolchain technologies" used to develop compiler front ends and back ends. LLVM is written in C++ and is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. Originally implemented for C and C++, the language-agnostic design of LLVM has since spawned a wide variety of front ends: languages with compilers that use LLVM include ActionScript, Ada, C#, Common Lisp, Crystal, D, Delphi, Fortran, OpenGL Shading Language, Halide, Haskell, Java bytecode, Julia, Lua, Objective-C, Pony, Python, R, Ruby, Rust, CUDA, Scala, Swift, and Xojo. Read more on Wikipedia...

Example from Compiler Explorer:
define i32 @square(i32) local_unnamed_addr #0 { %2 = mul nsw i32 %0, %0 ret i32 %2 }
Example from Riju:
@.str = private unnamed_addr constant [13 x i8] c"Hello, world!" declare i32 @puts(i8* nocapture) nounwind define i32 @main() { %cast210 = getelementptr [13 x i8],[13 x i8]* @.str, i64 0, i64 0 call i32 @puts(i8* %cast210) ret i32 0 }
Example from hello-world:
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" @.str = internal constant [12 x i8] c"Hello World\00" ; puts from libc declare i32 @puts(i8*) define i32 @main(...) { call i32 @puts(i8* getelementptr([12 x i8]* @.str, i32 0, i32 0)) ret i32 0 }
Example from Wikipedia:
@.str = internal constant [14 x i8] c"hello, world\0A\00" declare i32 @printf(i8*, ...) define i32 @main(i32 %argc, i8** %argv) nounwind { entry: %tmp1 = getelementptr [14 x i8], [14 x i8]* @.str, i32 0, i32 0 %tmp2 = call i32 (i8*, ...) @printf( i8* %tmp1 ) nounwind ret i32 0 }

Language features

Feature Supported Token Example
; A comment
Line Comments ;
; A comment
Semantic Indentation X

View source

- Build the next great programming language · About · Acknowledgements · Published by Breck's Lab