【LLVM】《Getting Started with LLVM Core Libararies》读书笔记——写一个PASS
来源:互联网 发布:山东省农产品出口数据 编辑:程序博客网 时间:2024/06/05 20:20
【Building and running your new pass with the LLVM build system】
1.“We name our pass FnArgCnt and place it under the LLVM source code tree:”
给PASS命名为FnArgCnt,并用以下命令将PASS文件放到LLVM_SRC_ROOT/lib/Transforms/FnArgCnt目录下:
$ cd <llvm_source_tree>
$ mkdir lib/Transforms/FnArgCnt
$ cd lib/Transforms/FnArgCnt
2.写cpp文件,其中需要注意的部分:
(1)“The ID is determined internally by LLVM to identify a pass, and it can be declared with any value: char FnArgCnt::ID = 0;”
ID用于定义PASS,可以用任意值声明。(如果用同一个值声明两个不同的PASS会如何?)
(2)“static RegisterPass<FnArgCnt> X("fnargcnt", "Function Argument Count Pass", false, false);”
“The first argument, fnargcnt , is the name used by the opt tool to identify the pass, whereas the second argument contains its extended name. The third argument tells us whether the pass changes the current CFG, and the last returns true only if it implements an analysis pass.”
第一个参数:被opt tool使用的定义PASS的名字
第二个参数:扩展名
第三个参数:是否会改变现有的CFG
第四个参数:是否实现的是一个分析PASS
3.“To compile and install the pass, we need a Makefile within the same directory of the source code. Different from our previous projects, we are not building a standalone tool anymore, and this Makefile is integrated in the LLVM build system. Since it relies on the LLVM main Makefile, which implements a great deal of rules, its contents are considerably simpler than a standalone Makefile. Refer to the following code:”
要编译和install这个PASS,需要使Makefile和源代码在同一个文件目录下。这个Makefile集成在LLVM系统中,所以我们不再建立一个独立的工具。因为它依赖于LLVM的main Makefile。Makefile内容如下:
# Makefile for FnArgCnt pass
# Path to top level of LLVM hierarchy
LEVEL = ../../..
# Name of the library to build
LIBRARYNAME = LLVMFnArgCnt
# Make the shared library become a loadable module so the tools can
# dlopen/dlsym on the resulting library.
LOADABLE_MODULE = 1
# Include the makefile implementation stuff
include $(LEVEL)/Makefile.common
- 【LLVM】《Getting Started with LLVM Core Libararies》读书笔记——写一个PASS
- 【LLVM】《Getting Started with LLVM Core Libararies》读书笔记——IR和几个重要的类
- Getting Started with LLVM Core Libraries阅读笔记
- LLVM每日谈之十九 LLVM的第一本系统的书<Getting Started with LLVM Core Libraries>
- Getting Started with the LLVM System
- LLVM pass manager debugging
- LLVM Pass 初探
- CMake LLVM Pass配置
- 【LLVM】MyHello Pass
- 建立一个maze游戏(Getting.Started.with.Unity 读书笔记二)
- 2 Getting Comfortable with Xcode 4 and the LLVM Compiler
- LLVM
- LLVM
- llvm
- LLVM
- LLVM
- LLVM
- LLVM
- 漫画:什么是单例模式?(整合版)
- 十进制转换成字符串
- vue单页应用之创建和运行
- 基于Drools决策表的通用规则集设计
- Android 还可以走多久?
- 【LLVM】《Getting Started with LLVM Core Libararies》读书笔记——写一个PASS
- u-boot与linux下网卡MAC地址的更改
- Java多线程编程总结
- 让webstorm支持arcgis api 的代码提示
- C++网络(三)用Socket API建立简易TCP服务端、客户端
- JVM实用参数(三)打印所有XX参数及值
- DeBug能力
- 技术工程师的能力与目标(转)
- Cookie