目录

 

Introduction to Machine Descriptions

1.Influences on Machine Descriptions

2.Organization of GCC MD

3. Machine Descriptions的基本结构

(1)指定目标指令语义

​(2)General Move Instruction

(3)Relationship Between .md, .c, and.h Files

(4)GCC中的翻译顺序

(5)Retargetability Mechanism of GCC

Spim移植示例

(1)Retargeting GCC to Spim

(2)Registering Spim with GCC Build Process

Step 1

Step 2

(3)Building a Cross-Compiler for Spim

(4) Level 0 of Spim Machine Descriptions


Introduction to Machine Descriptions

1.Influences on Machine Descriptions

GCC后端移植适配

2.Organization of GCC MD

GCC要知道目标处理器的指令、特征、目标汇编码的特征。以及目标平台需要执行的特定的优化,例如窥孔优化、指令调度。

  1. GCC MD的文件结构
  1. <target>.h: A set of C macros that describe
    • 目标寄存器()集和特征
    • 系统软件详细信息:汇编程序格式、可执行文件格式等。
  2. <target>.md: Target instructions described using MD constructs.
  3. <target>.c: Optional, but usually required.
    • 实现特定目标代码的函数

3. Machine Descriptions的基本结构

GCC后端移植适配

RTL是一种目标特异性IR

GIMPLE →non strict RTL →strict RTL→(操作符匹配+粗操作数匹配,改进操作数匹配)→Unique target ASM string.

考虑生成GIMPLE节点的RTL表达式,有两种构造: define insndefine expand

(1)指定目标指令语义

GCC后端移植适配

GCC后端移植适配

GCC后端移植适配(2)General Move Instruction

GCC后端移植适配

这个定义可以生成所有组合的数据移动模式,甚至是Mem→Mem都是偶可能的。我们还需要一种机制来生成更多受限的数据移动RTX实例.

GCC后端移植适配

(3)Relationship Between <target>.md, <target>.c, and<target>.h Files

寄存器类约束在<target>中使用。md文件

GCC后端移植适配

    这里z是在REG_CLASS_FROM_LETTER_P中定义的约束字符。使用的是寄存器$ 0。

Register类定义在<target>.h文件中

GCC后端移植适配

寄存器类的检查在<target>.c文件中实现

GCC后端移植适配

(4)GCC中的翻译顺序

GCC后端移植适配

         machine descriptions什么时候会用到?

         在构建过程中当gcc编译程序时,会参考从机器描述中收集到的信息

(5)Retargetability Mechanism of GCC

GCC后端移植适配

GCC通过读取机器描述并生成自定义机器描述的后端来实现可重定向性

机器描述受以下因素影响:

HLLsGCC体系结构,以及目标、主机和构建系统的属性

编写机器描述需要:指定C宏、目标指令和任何所需的支持功能

•define insndefine expand用于将GIMPLE表示转换为RTL

 

Spim移植示例

  1. spim is mips simulator developed by James Larus
  2. I RISC machine
  3. I Assembly level simulator: No need of assembler, linkers, or libraries

GCC后端移植适配

(1)Retargeting GCC to Spim

Registering spim target with GCC build process

Making machine description files available

Building the compiler

(2)Registering Spim with GCC Build Process

Step 1

GCC后端移植适配GCC后端移植适配

Step 2

GCC后端移植适配GCC后端移植适配

GCC后端移植适配

(3)Building a Cross-Compiler for Spim

         普通的交叉编译器构建过程尝试使用生成的cc1将模拟库(LIBGCC)编译为可执行文件,并使用汇编器、链接器和归档器。

GCC后端移植适配

GCC后端移植适配

 

(4) Level 0 of Spim Machine Descriptions

 

相关文章:

猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-04-04
相关资源
相似解决方案