(本文是 http://llvm.org/releases/2.9/docs/LangRef.html 的阅读笔记,前作为《LLVM笔记(0):在一切开始之前》。)
- 一句话总结: LLVM is a Static Single Assignment (SSA) based representation that provides type safety, low-level operations, flexibility, and the capability of representing ‘all’ high-level languages cleanly. It is the common code representation used throughout all phases of the LLVM compilation strategy.
- LLVM语言有三种形式:in-memory compiler IR, on-disk bitcode representation, human readable assembly language representation。三种表现形式是等价的。
- LLVM语言的目标是:一方面 light-weight and low-level,另一方面expressive, typed, and extensible。
- “universal IR”
- Identifiers
- global: @开头
- local: %开头
- ‘;’开始注释
- High Level Structure
- Module
- llvm linker to combine
- global values: functions and global variables
- linkage types
- private, linker_private, linker_private_weak, linker_private_weak_def_auto
- internal, available_externally, linkonce, weak, common, appending, extern_weak
- linkonce_odr, weak_odr
- externally visible (default)
- Calling Conventions
- ccc: the C calling convention
- fastcc: the fast calling convention
- coldcc: the cold calling convention
- Visibility styles (for global variables and functions):
- default, hidden, protected
- Named types
- e.g. %mytype = type { %mytype*, i32 }
- Global variables
- many aspects can be controlled
- Functions
- definition and declaration
- definition contains a list of basic blocks, Control Flow Graph for the function
- each basic block optionally starts with a label, contains a list of instructions, and ends with a terminator instruction
- first basic block is special: 1. immediately executed on entrance; 2. not allowed to have predecessors
- Aliases
- Named Metadata: a collection of metadata
- Parameter Attributes
- zeroext, signext, inreg, byval, sret, noalias, nocapture, nest
- Garbage Collector Names
- Function Attributes
- …
- Module-Level Inline Assembly
- Data Layout
- target datalayout = “layout specification”
- Pointer Aliasing Rules
- memory access must be through pointers
- a pointer value is based on another pointer value according to the rules
- Volatile Memory Accesses
Post a Comment