LLVM

llvm学习日记十:llvm后端概览

2019-11-27  本文已影响0人  鸣人的大哥

参考书:《Getting Started with LLVM Core Libraries》

一、概览图:

整体概述:IR在翻译成目标代码时,图中白色方框Passes表示进一步优化,灰色方框表示翻译过程中的各个阶段。


image.png

二、使用LLC

llc是我们后端使用的主要工具

// 生成汇编
$ llc sum.bc -o sum.s
// 生成obj文件
$ llc sum.bc -filetype=obj -o sum.o
// 指定后端架构
$ llc -march=mips -filetype=obj sum.bc -o sum.o

三、了解后端代码结构

后端实现分散在LLVM源码树的不同的目录,主要的库在lib目录和子目录(CodeGen, MC, TableGen, and Target)

四、了解后端库

llc只有一小部分非共享代码tools/llc/llc.cpp,它的大多数功能实现都是可重用的库。

• AsmParser.a: This library contains code to parse assembly text and implement an assembler
• AsmPrinter.a: This library contains code to print assembly language and implement a backend that generates assembly files
• CodeGen.a: This library contains the code generation algorithms
• MC.a: This library contains the MCInst class and related ones and is used to
represent the program in the lowest level that LLVM allows
• MCDisassembler.a: This library contains the code to implement a
disassembler that reads object code and decodes bytes to MCInst objects
• MCJIT.a: This library contains the implementation for the just-in-time code
generator
• MCParser.a: This library contains the interface to the MCAsmParser class and is used to implement a component that parses assembly text and performs part of the work of an assembler
• SelectionDAG.a: This library contains SelectionDAG and related classes
• Target.a: This library contains the interfaces that allow the target-independent algorithms to solicit target-dependent functionality, although this functionality per se is implemented in other libraries
(the target-dependent ones)

上一篇下一篇

猜你喜欢

热点阅读