阅读文档
这就是LLVM的编程指引,相对来说这个文档没那么长,但是里面的东西很重要,希望在阅读的过程中认真阅读。同时,涉及到C++部分的知识,如果有不清楚的,要自己主动的把那些知识补充学习一下。在阅读这个文档的过程中,可以去LLVM的源码中找一些实际的代码,参照着看一下,效果会更好。可以从http://androidxref.com/ 在线浏览和搜索代码,这个网站是在线浏览搜索Android源码的,LLVM的源码就在http://androidxref.com/4.2.2_r1/xref/external/llvm/ 这里,可以从这里搜索、跳转,都很方便。
isa<>, cast<> dyn_cast<>
Passing strings(StringRef and TWine)
DEBUG() macro and -debug
Statistic class and -stats
Viewing graphs while debugging code
Data Structure(Sequential String-like Set-like Map-like BitVector-like)
helpful hints
所有的加法变减法
简便方法一:1
2
3
4
5Because the Instruction class subclasses the User class, its operands can be accessed in the same way as for other Users (with the getOperand()/getNumOperands() and op_begin()/op_end() methods).
the llvm/Instruction.def file. This file contains some meta-data about the various different types of instructions in LLVM. It describes the enum values that are used as opcodes (for example Instruction::Add and Instruction::Sub)
ReplaceInstWithInst直接将加法变减法
复杂方法二:
1 | //找到加法指令(和GetInst中找到PHI跳转指令是一样的) |