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的后端,每个维度自成体系,不同维度之间还有着对应的关系。后续也会写文章分析其中的关系。


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

查看所有标签

猜你喜欢:

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

数据结构与算法分析

数据结构与算法分析

韦斯(Mark Allen Weiss) / 机械工业出版社 / 2010-8 / 45.00元

《数据结构与算法分析:C语言描述》曾被评为20世纪顶尖的30部计算机著作之一,作者在数据结构和算法分析方面卓有建树,他的数据结构和算法分析的著作尤其畅销,并受到广泛好评,已被世界500余所大学选作教材。 在《数据结构与算法分析:C语言描述》中,作者精炼并强化了他对算法和数据结构方面创新的处理方法。通过C程序的实现,着重阐述了抽象数据类型的概念,并对算法的效率、性能和运行时间进行了分析。 ......一起来看看 《数据结构与算法分析》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具