当前位置:网站首页>LLVM TargetPassConfig
LLVM TargetPassConfig
2022-06-24 20:15:00 【Huo的藏经阁】
TargetPassConfig
TargetPassConfig类是LLVM 后端添加pass入口,LLVM 框架将整个后端依次划分为指令选择、指令调度,寄存器分配等几个阶段,,如下图:

其中每个阶段包含有一个或者多个pass,LLVM后端一个重要的处理就是兼容性和模块化,为了对这些后端所加的pass进行管理,LLVM后端对上述几个比较重要的阶段封装成接口,而每个接口基本代表一个 重要阶段,每个target可以根据需要添加所需要pass,
TargetPassConfig该类为codegen中各个阶段提供了各个接口,提供主要接口如下:
接口 | 说明 |
addISelPasses | 添加所有必须的从llvm IR转成生成MI的pass |
addIRPasses | 添加对llvm IR->IR的优化pass |
addPassesToHandleExceptions | 添加较低级别的各种异常pass,这些pass主要处理CodeGen中产生的各种异常 |
addCodeGenPrepare | 在LLVM IR这个级别中添加CodeGen前准备的pass,这些pass此时还只处理IR,因此需要在addPassesToHandleExceptions之前添加 |
addISelPrepare | 添加指令选择前的一些优化IR的pass,这个阶段也处于IR阶段,还未转换成DAG,主要优化IR |
addInstSelector | 添加指令选择器selector以及必要pass |
addIRTranslator | 添加IR转换成机器码相关pass,调用关系时addIRTranslatoràaddInstSelector |
addMachinePasses | 添加一套CodeGen标准所需要的pass |
addMachineSSAOptimization | SSA优化所需要添加pass |
addPreRegAlloc/addPostRegAlloc | 分别是寄存器分配前/后所需要添加pass |
addFastRegAlloc | 快速分配寄存器所需要添加pass |
addPassesToGenerateCode
addPassesToGenerateCode函数为添加CodeGen Pass总入口:
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
static TargetPassConfig *
addPassesToGenerateCode(LLVMTargetMachine &TM, PassManagerBase &PM,
bool DisableVerify,
MachineModuleInfoWrapperPass &MMIWP) {
// Targets may override createPassConfig to provide a target-specific
// subclass.
TargetPassConfig *PassConfig = TM.createPassConfig(PM);
// Set PassConfig options provided by TargetMachine.
PassConfig->setDisableVerify(DisableVerify);
PM.add(PassConfig);
PM.add(&MMIWP);
if (PassConfig->addISelPasses())
return nullptr;
PassConfig->addMachinePasses();
PassConfig->setInitialized();
return PassConfig;
}
- createPassConfig :根据PM 创建对应target 的 TargetPassConfig ,每个target都会基于该类,对阶段中重要接口重新实现以实现添加独有pass,而不会影响其他target
- PassConfig->addISelPasses:添加指令选择阶段中所需要的pass 总入口
- PassConfig->addMachinePasses(): 指令由IR 转换成机器码之后,所添加的pass,包括寄存器分配,以及机器码级别优化pass等
AMDGPU TargetPassConfig
新写一个后端时,一个重要内容就是实现该target 所需要的添加pass, 以AMDGPU为例TargetPassConfig继承关系如下:

- AMDGPUPassConfig: 是所有AMDGPU后端所必须要添加的pass
- GCNPassConfig和 R600PassConfig分别针对的是GCN 和R600 平台。
边栏推荐
- 108页(4万字)未来公寓智能化设计平台项目方案建议书2022版
- 2022 simulated 100 questions of safety officer-c certificate examination and online simulated examination
- 图书馆管理系统代码源码(php+css+js+mysql) 完整的代码源码
- [micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
- Jar package merging using Apache ant
- Registration method of native method in JNI
- adb shell getevent
- 2022年危险化学品经营单位安全管理人员考试试题及模拟考试
- QT (35) - operate excel qxlsx qaxobject
- 我想问一下兴业证券怎么开户?通过链接办理股票开户安全吗
猜你喜欢

傳輸層 以字節為單比特的滑動窗口技術

Rich text tables, lists, pictures

Practical operation notes - notebook plus memory and ash cleaning

Wallpaper applet wechat applet

图书馆管理系统代码源码(php+css+js+mysql) 完整的代码源码

Text editor for QT project practice - Episode 10

Custom animation (simulated win10 loading animation)

How to reduce the font size of custom controls (optimize the round dot progress bar)

Using tcp/udp tools to debug the yeelight ribbon

【Redis实现秒杀业务②】超卖问题的解决方案
随机推荐
最新QQ微信域名防红PHP程序源码+强制跳转打开
2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作
51 single chip microcomputer multi computer communication
腾讯云国际云服务器网络访问丢包问题解决办法
2022 melting welding and thermal cutting recurrent training question bank simulated examination platform operation
【Redis实现秒杀业务④】一人一单,不可重复购买
Tiktok wallpaper applet v1.0.2 function, new arrival function
EVM简略
Infotnews | is the development of domestic NFT limited to digital collections?
Helm chart warehouse operation
2021-09-12
Xcode预览(Preview)显示List视图内容的一个Bug及解决
Usage of assert
Add information on the left and add parts on the right of the status bar
生成订单30分钟未支付,则自动取消,该怎么实现?
QT (35) - operate excel qxlsx qaxobject
Only positive integers can be entered in the text box
ros(25):rqt_ image_ View reports an error unable to load plugin for transport 'compressed', error string
VNC viewer remote connection raspberry pie without display
智能合约安全审计入门篇 —— delegatecall (2)