LLVM每日谈之四十七 LLVM后端文档解析

栏目: 服务器 · 编程工具 · 发布时间: 6年前

内容简介:去年在HelloLLVM杭州站的活动中,我做了一个分享:LLVM官方提供了两个关于后端的官方文档:1、

去年在HelloLLVM杭州站的活动中,我做了一个分享: LLVM后端简介 。主要是从LLVM后端的几大环节上展开,简单介绍了LLVM后端。在新的芯片和指令集大火的今天,为LLVM添加一个新的后端,也成了大家比较关注的热点。

LLVM官方提供了两个关于后端的官方文档:

1、 The LLVM Target-Independent Code Generator

2、 Writing an LLVM Backend

阅读2之前要求阅读1。将这两个文档参照起来读,基本上可以获取新建后端所需要的各类信息。这两个文档从三个层面解析了后端的架构,将后端从代码组织、执行环节和建立步骤都讲的很清楚。我们在这里就一起看看这三个层面:

1、后端的六大部分

  • Target description classes : abstract target description interfaces (代码地址:include/llvm/Target/)
  • Marchine code description classes : classes used to repesent the code being generated for a target (代码地址:include/llvm/CodeGen/)
  • The "MC" Layer : use to represent and process code at the raw machine code level
  • Target-independent code generation algorithms  (代码地址:lib/CodeGen)
  • Implementations of the abstract description interfaces for particular targets  (代码地址: lib/Target)
  • The target-independent JIT components  (代码地址:lib/ExecutionEngine/JIT)

2、后端的七大环节

  • Instruction Selection
  • Scheduling and Formation
  • SSA-based Machine Code Optimizations
  • Register Allocation
  • Prolog/Epilog Code Insertion
  • Late Machine Code Optimizations
  • Code Emission

3、建立新后端的七大步骤

  • Create a subclass of the TargetMachine class that describes characteristics of your target machine.
  • Describe the register set of the target.
  • Describe the instruction set of the target.
  • Describe the selection and conversion of the LLVM IR from a Directed Acyclic Graph (DAG) representation of instructions to native target-specific instructions.
  • Write code for an assembly printer that converts LLVM IR to a GAS format for your target machine.
  • Optionally, add support for subtargets.
  • Optionally, add JIT support and create a machine code emitter (subclass of TargetJITInfo) that is used to emit binary code directly into memory.

这三个层面是从不同的维度去审视LLVM的后端,每个维度自成体系,不同维度之间还有着对应的关系。后续也会写文章分析其中的关系。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

以奋斗者为本

以奋斗者为本

黄卫伟 / 中信出版社 / 2014-11-1 / 68.00元

《以奋斗者为本:华为公司人力资源管理纲要》传承于《华为公司基本法》,华为管理层25年人力资源管理思想精髓,5年整理,华为公司内训教材,首次大公开!作为华为公司内部培训教材,原汁原味,是继《华为基本法》之后华为的标志性著作,对国内外企业管理者&研究者具有高度的研究及借鉴价值。《以奋斗者为本:华为公司人力资源管理纲要》由华为公司首席管理科学家主编,华为高管及顾问参与编著,华为管理层25年实践,权威出品......一起来看看 《以奋斗者为本》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具