Sunday, September 25, 2011
(本文是 http://llvm.org/releases/2.9/docs/LangRef.html 的阅读笔记,前作为《LLVM笔记(1):LLVM的语言(上)》。)
- Type System
- Type Classifications
- integer: i1, i2, i3, … i8, … i16, … i32, … i64
- floating point: float, double, x86_fp80, fp128, ppc_fp128
- first class: integer, floating point, pointer, vector, structure, array, label, metadata.
- primitive: label, void, integer, floating point, x86mmx, metadata.
- derived: array, function, pointer, structure, packed structure, vector, opaque.
- Array type
- Function Type
- Structure Type
- Packed Structure Type
- Pointer Type
- Vector Type
- Opaque Type: represents unknown type
- Type Up-references
- needed by the asmprinter for printing out cyclic types
- Constants
- Simple Constants
- Boolean(true, false)
- Integer(e.g. 42)
- Floating point(3.14 or 6.02E+23 or
double 0x432ff973cafa8000
(IEEE))
- Null pointer (null)
- Complex Constants
- Structure constants
- { i32 4, float 17.0, i32* @G }
- @G = external global i32
- Array constants
- [ i32 42, i32 11, i32 74 ]
- Vector constants
- [ i32 42, i32 11, i32 74 ]
- Zero initialization
- Metadata node
- metadata !{ i32 0, metadata !”test” }
- Global Variable and Function Addresses
- Undefined Values
- The string ‘undef’ can be used anywhere a constant is expected, and indicates that the user of the value may receive an unspecified bit-pattern.
- Trap Values
- Addresses of Basic Blocks
- blockaddress(@function, %block)
- Constant Expressions
- trunc, zext, sext, fptrunc, fpext, fptoui, fptosi, uitofp, sitofp, ptrtoint, inttoptr, bitcast
- getelementptr, select, icmp, fcmp, extractelement, insertelement, shufflevector, extractvalue, insertvalue
- OPCODE
- Other Values
- Inline Assembler Expressions
- Inline Asm Metadata
- Metadata Nodes and Metadata Strings
- Intrinsic Global Variables
- The ‘llvm.used’ Global Variable
- The @llvm.used global is an array with i8* element type which has appending linkage.
- The ‘llvm.compiler.used’ Global Variable
- The ‘llvm.global_ctors’ Global Variable
- The ‘llvm.global_dtors’ Global Variable
Wednesday, September 21, 2011
(本文是 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。
- Identifiers
- ‘;’开始注释
- 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
Wednesday, September 21, 2011
下载地址在 http://love-oriented.com/pack/pack2beta1.pdf
全文各章语言均有更新,更新最大的章节是 3.4,提供了多重背包可行性问题的一种简明的O(VN)解法。
本文IOIFORUM首发,欢迎转载,但请保留出处。
Monday, September 19, 2011
(本文是 http://llvm.org/releases/2.9/docs/GettingStarted.html 的阅读笔记。)
- LLVM的安装包分为三部分,LLVM工具包,LLVM-GCC,测试集。
- 自己编译LLVM三者都需要,但在主流平台上都有编译好的binary。
- 讲了LLVM的安装,没发现什么特别需要注意的。
- LLVM的目录结构
- llvm/examples: 很多有用的代码示例
- llvm/include
- llvm/include/llvm LLVM头文件
- llvm/include/llvm/Support 支持LLVM工具的头文件,但不和LLVM的功能密切相关
- llvm/include/llvm/Config configure脚本生成的头文件,主要是Unix/C中标准头文件的包装。
- llvm/lib 大部分的源代码都在这里,LLVM中几乎所有的代码都以库的形式存在
- llvm/lib/VMCore/
- llvm/lib/AsmParser/
- llvm/lib/BitCode/
- llvm/lib/Analysis/
- llvm/lib/Transforms/
- llvm/lib/Target/
- llvm/lib/CodeGen/
- llvm/lib/Debugger/
- llvm/lib/ExecutionEngine/
- llvm/lib/Support/
- llvm/lib/System/
- llvm/projects 并非LLVM一部分,但与LLVM共同发布的项目
- llvm/runtime 需要LLVM-GCC编译
- llvm/test
- llvm/tools 各种使用LLVM命令行工具
- llvm/utils 帮助开发LLVM的命令行工具
Friday, September 16, 2011
《寻寻觅觅 道阻且长》是《动态规划的思考艺术》的一部分,《背包问题九讲》的续作,讲解了动态规划中的寻路(path-finding)问题。

目前的完成状态如上图所示(只完成了目录的框架的一部分),现诚征我每写完一节即可第一时间看到的试读者。需要的人数非常少,且要求比较高,请谨慎申请。要求如下:
- 和我以前就认识。也就是说,在你申请之前我就听说过你的名字或网名,和我在三次元中见过面更佳。
- 能为我的文章提出建设性批评意见。这一条不好考核,目前的考察方法是:请针对《背包问题九讲》alpha1版本尽最大努力提出您的建设性意见,我会根据意见的有价值程度进行评估。
- 能尽保密义务。我会每天一次将最新草稿发送给试读者,但试读者必须保证不发送给任何其它人。