-
Notifications
You must be signed in to change notification settings - Fork 148
LLVM Basics
LLVM is an umbrella project that hosts and develops a set of close-knit low-level tool chain components (e.g., assemblers, compilers, debuggers, etc.)
LLVM is mostly used as a common infrastructure to implement a broad variety of statically and runtime compiled languages (e.g., the family of languages supported by GCC, Java, .NET, Python, Ruby, Scheme, Haskell, D). It has also replaced a broad variety of special purpose compilers, such as the run-time specialization engine in Apple's OpenGL stack and the image processing library in Adobe's After Effects product. Finally LLVM has also been used to create a broad variety of new products, perhaps the best known of which is the OpenCL GPU programming language and runtime.
Intermediate Representation (IR) is the most important aspect of LLVM design, which is the form it uses to represent code in the compiler. LLVM IR is designed to host mid-level analyses and transformations that you find in the optimizer section of a compiler.
Here is a simple example of a .ll (IR file Extension):
; ModuleID = 'main.cpp'
source_filename = "main.cpp"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noinline norecurse nounwind optnone uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 32, i32* %1, align 4
%3 = load i32, i32* %1, align 4
%4 = add nsw i32 %3, 1
store i32 %4, i32* %2, align 4
ret i32 0
}
which corresponds to this simple code example:
int main() {
int i = 32;
int j = i+1;
}
The shell instalation of LLVM can be find here => LLVM instalation..
you can refer to the following mentioned links for more information:
https://llvm.org/docs/LangRef.html
http://llvm.org/docs/GettingStarted.html
http://llvm.org/docs/ProgrammersManual.html
- Home
- Reference Material
- Getting Started:
- Building PhASAR
- Using PhASAR with Docker
- A few uses of PhASAR
- Coding Conventions
- Contributing to PhASAR
- Errors and bug reporting
- Update to Newer LLVM Versions
- OS Support
- FAQ