编译器后端移植是目前嵌入式系统研究的重要领域,如何快速实现编译器后端移植仍然是嵌入式系统研究的热点。采用新的编译器架构LLVM,移植NiosⅡ处理器来分析LLVM快速后端移植架构。使用LLVM后端移植架构的TableGen描述NiosⅡ体系结构例如指令、寄存器等,使用完备LLVM C++函数库实现复杂或特殊的操作。TableGen与C++函数库互相配合,最终实现LLVM架构对NiosⅡ后端的支持。实验结果表明与GCC编译器后端移植方法相比,基于LLVM架构的编译器后端移植方法的工作量减少了64.2%~83.9%,大大节省后端移植时间。
Compiler backend porting is an important field for present research on embedded systems.How to fastly implement compiler backend porting is still a hot topic in the study on embedded systems.The paper uses a new compiler infrastructure,LLVM,by transplanting NiosⅡ processor to analyze LLVM fast backend porting infrastructure.It uses LLVM backend porting infrastructure's TableGen to describe NiosⅡ architecture with instructions and registers etc.It uses the complete C+ + function library to implement complex or special operations.The support by LLVM infrastructure for NiosⅡ backend is finally realized by the cooperation between TableGen and C+ + function library.Experiment results indicate that,compared to GCC compiler backend porting method,the LLVM-infrastructure-based compiler backend porting method reduces the workload by 64.2%~83.9% and significantly saves the backend porting time.