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

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

内容简介:去年在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-8-1 / 35

马化腾自述:我的互联网思维》讲述了些人说移动互联网就是加了“移动”两个字,互联网十几年了,移动互联网应该是个延伸。我的感受是,移动互联网远远不只是一个延伸,甚至是一个颠覆。互联网是一个开放交融、瞬息万变的大生态,企业作为互联网生态里面的物种,需要像自然界的生物一样,各个方面都具有与生态系统汇接、和谐、共生的特性。开放和分享并不是一个宣传口号,也不是一个简单的概念。开放很多时候被看作一种姿态,但是我......一起来看看 《马化腾自述-我的互联网思维》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具