| 研究生: |
蘇敬傑 Su, Jing-Jie |
|---|---|
| 論文名稱: |
基於LLVM架構的半自動編譯研究與實現 Research and Implementation of Semi-automatic Compilation Based on the LLVM Framework |
| 指導教授: |
周哲民
Jou, Jer-Min |
| 學位類別: |
碩士 Master |
| 系所名稱: |
電機資訊學院 - 電機工程學系 Department of Electrical Engineering |
| 論文出版年: | 2021 |
| 畢業學年度: | 109 |
| 語文別: | 中文 |
| 論文頁數: | 53 |
| 中文關鍵詞: | 編譯器 、RISC-V 、LLVM 、後端移植 、指令集 |
| 外文關鍵詞: | compiler, RISC-V, LLVM, back-end porting, instruction set |
| 相關次數: | 點閱:137 下載:0 |
| 分享至: |
| 查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報 |
如今,對嵌入式處理器的需求隨著應用的變化而有所不同,因此處理器架構需要相應地改變,或者需要擴展指令集架構(ISA)。採用RISC作為開源指令集架構的RISC-V處理器已經逐漸成為取代基於ARM處理器的選擇。自從引入LLVM後,它幾乎總是被用來開發新的架構或移植嵌入式系統的編譯器後端。隨著LLVM功能的不斷增加,如何提高編譯器後端的品質和模組化是值得探討的。
本文重點介紹了TableGen工具在LLVM後端架構中的應用,其對目標暫存器和目標指令集.td(target description)檔的描述,以及後端編譯器的構建過程,分析了後端代碼生成過程,並在構建過程中完成了對目標機器系統屬性的描述。由於每個目標架構中的暫存器和指令集的描述都使用了TableGen的語法和結構,在本文最後,可以在現有架構下增加擴展指令集。
最後,本文將以32位元整數RISC-V架構為例,實現暫存器、堆疊佈局、指令描述等;完成組合語言輸出,用模擬器測試,以保證編譯器的準確性。
Nowadays, the demand for embedded processors varies with the application, so the processor architecture needs to be changed accordingly, or the instruction set architecture (ISA) needs to be extended. The RISC-V processor, which uses RISC as the open source instruction set architecture, has gradually become the choice to replace the ARM-based processors. Since the introduction of LLVM, it is almost always used to develop a new architecture or to port the compiler backend of an embedded system. With the increasing functionality of LLVM, it is worthwhile to explore how to improve the quality and modularity of the compiler backend.
In this paper, we focus on the use of the TableGen tool in the LLVM backend architecture, its description of the target registers and the target instruction set file.td (target description), and the construction process of the backend compiler, analyzing the backend code generation process and completing the description of the properties of the target machine system during the construction process. Since the description of registers and instruction sets in each target architecture uses the syntax and structure of TableGen, after this paper, it is possible to add extended instruction sets under the existing architecture.
Finally, in this paper, we will use the 32-bit integer RISC-V architecture as an example to realize the register, stack layout, instruction description, etc.; we will complete the assembly language output and use the simulator to test it to ensure the accuracy of the compiler.
[1] Asanovic, Krste, and Andrew Waterman. "The RISC-V Instruction Set Manual." Privileged Architecture, Document Version 20190608-Priv-MSU-Ratified. Vol. 2. RISC-V Foundation, 2019.
[2] Chung-Shu, Chen. "Tutorial: Creating an LLVM Backend for the Cpu0 Architecture." 2021.
[3] Adve, Vikram, et al. "LLVA: A low-level virtual instruction set architecture." Proceedings. 36th Annual IEEE/ACM International Symposium on Microarchitecture, 2003. MICRO-36.. IEEE, 2003.
[4] Lattner, Chris, and Vikram Adve. "LLVM: A compilation framework for lifelong program analysis & transformation." International Symposium on Code Generation and Optimization, 2004. CGO 2004. IEEE, 2004.
[5] Lattner, Chris. "Introduction to the llvm compiler infrastructure." Itanium conference and expo. 2006.
[6] Lattner, Chris. "LLVM and Clang: Next generation compiler technology." The BSD conference. Vol. 5. 2008.
[7] Lattner, Chris. "Intro to the LLVM MC Project." 2010.
[8] Lopes, Bruno Cardoso, and Rafael Auler. Getting started with LLVM core libraries. Packt Publishing Ltd, 2014.
[9] Sarda, Suyog, and Mayur Pandey. LLVM Cookbook. Packt Publishing Ltd, 2015.
[10] "User Guides." User Guides - LLVM 13 Documentation. Web. 22 Sept. 2021.
[11] Cytron, Ron, et al. "Efficiently computing static single assignment form and the control dependence graph." ACM Transactions on Programming Languages and Systems (TOPLAS) 13.4 (1991): 451-490. 1991.
[12] Chang, Pokai. "The LLVM Compiler Infrastructure." 14 June 2017. Web. 22 Sept. 2021.
[13] 劉俊波。基於LLVM的編譯器移植中關鍵技術研究。中國南開大學。2012。
[14] 董峰。LLVM編譯系統結構分析與後端移植。上海交通大學。2007。
[15] 夏睿傑、陳躍躍、孫海燕、陽柳、王霽、廖坤、李燦。基於LLVM架構的Matrix2 DSP後端移植及其浮點數據比較指令的實現。第十八屆電腦工程與工藝年會暨第四屆微處理器技術論壇論文集。2014。