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

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

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


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

查看所有标签

猜你喜欢:

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

统计思维

统计思维

[美] Allen B. Downey / 金迎 / 人民邮电出版社 / 2015-9 / 49.00元

现实工作中,人们常常需要用数据说话。可是,数据自己不会说话,需要人对它进行分析和挖掘才能找到有价值的信息。概率统计是数据分析的通用语言,是大数据时代预测未来的根基。如果你有编程背景,就能以概率和统计学为工具,将数据转化为有用的信息和知识,让数据说话。本书介绍了如何借助计算而非数学方法,使用Python语言对数据进行统计分析。 通过书中有趣的案例,你可以学到探索性数据分析的整个过程,从数据收集......一起来看看 《统计思维》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具