arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.18353cs.AR
收藏

利用 LLVM 编译器为 RISC-V 处理器支持自定义指令

Supporting Custom Instructions with the LLVM Compiler for RISC-V Processor

Eymen Ünay, Bora İnan, Emrecan Yiğit

AI总结:

本文研究如何通过修改 LLVM 的 RISC-V 后端为自定义指令提供编译支持,将支持过程分为 Assembler 与模式匹配两部分,并重点分析模式匹配的实现方法及合适的修改阶段。

摘要:

随着带有自定义指令的硬件加速器的兴起,迫切需要能够支持这些加速器的自定义编译器后端。本研究对 LLVM 及其 RISC-V 后端进行了详细分析,并通过案例研究对上述转换过程提供了端到端的概述。我们讨论指出,指令设计应当同时考虑硬件和软件设计空间。必要的编译器修改可能意味着该指令设计不佳,需要重新考虑。我们讨论认为,RISC-V 标准扩展提供了可作为指令设计者参考的典范指令。在本研究中,向编译器添加自定义指令的过程被分为两部分:Assembler 支持和模式匹配支持。如果没有模式匹配支持,传统软件需要为加速器手动编写内联汇编,这种方式不具备可扩展性。虽然无论指令语义如何,添加 Assembler 支持都相对简单,但模式匹配支持则恰恰相反。模式匹配支持以及选择正确的修改阶段,需要了解编译器内部的转换过程。本研究深入探讨了模式匹配,并提出了多种解决模式匹配支持问题的方法。文中讨论指出,根据模式的复杂程度,与指令选择阶段相比,在更高层次的转换(例如 IR 层)上进行修改可能更具可维护性。

英文摘要:

The rise of hardware accelerators with custom instructions necessitates custom compiler backends supporting these accelerators. This study provides detailed analyses of LLVM and its RISC-V backend, supplemented with case studies providing end-to-end overview of the mentioned transformations. We discuss that instruction design should consider both hardware and software design space. The necessary compiler modifications may mean that the instruction is not well designed and need to be reconsidered. We discuss that RISC-V standard extensions provide exemplary instructions that can guide instruction designers. In this study, the process of adding a custom instruction to compiler is split into two parts as Assembler support and pattern matching support. Without pattern matching support, conventional software requires manual entries of inline Assembly for the accelerator which is not scalable. While it is trivial to add Assembler support regardless of the instruction semantics, pattern matching support is on the contrary. Pattern matching support and choosing the right stage for the modification, requires the knowledge of the internal transformations in the compiler. This study delves deep into pattern matching and presents multiple ways to approach the problem of pattern matching support. It is discussed that depending on the pattern's complexity, higher level transformations, e.g. IR level, can be more maintainable compared to Instruction Selection phase.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑