| C*Core is an embedded processor developed by Su Zhou China-Core, Inc., which isbased on M*Core from Motorola. But so far, C*Core uses GCC backend for M*Coredeveloped10years ago, and is devoid of itself compiler tool chain that may take fulladvantages of C*Core, and thus restrict their applications and developments. With efficientcompiling, modular and re-usable characteristics, LLVM is an emerging compilerinfrastructure began at the University of Illinois, which may become a substitute for GCC.This thesis focused on LLVM backend porting for C*Core, in order to enhance recentlyinefficient support from GCC. First, the thesis analyzed LLVM IR and backend tool sets, anddiscussed TableGen-based target description methods and LLVM backend code generationprocedure. Then C*Core target was described by TableGen under thorough analysis of itsarchitecture and ABI. By adopting DAG construction and transformation methods providedby LLVM infrasturcture, DAG match pattern for C*Core Instructions was designed, andtherefore finally implemented instruction selection from LLVM IR to C*Core. Meanwhile,oriented to conditional execution instructions and C*Core-specific instructions, severaloptimizations techniques, such as peephole optimizations, were presented for a better codequality. Experimental results show that, not only LLVM backend for C*Core proposed by thisthesis mapped most C*Core instructions, but also beat GCC for M*Core in many cases. |