Porting LLVM
Current toolchain depends on llvm, the version is llvm-3.8.0-r267675. You can checkout the original llvm source code with following command:
svn co http://llvm.org/svn/llvm-project/llvm/trunk -r 267675 llvm-r267675
Depending libraries
Besides the llvm itself, the MaPU tool chain also rely on other tools as shown in following table:
tools | version | description | dir in LLVM |
---|---|---|---|
clang | 3.9.0-r267675 | The C/C++ frontend | $LLVM/tools |
lldb | r267675 | The Debugger | $LLVM/tools |
compiler-rt | r267675 | The runtime library for the compiler | $LLVM/projects |
The above depending libraries can be checkout with following command:
svn co http://llvm.org/svn/llvm-project/cfe/trunk -r 267675 clang-r267675
svn co http://llvm.org/svn/llvm-project/lldb/trunk -r 267675 lldb-r267675
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk -r 267675 compiler-rt-r267675
Adding the new target
We need to add a new target represent in LLVM so the tool can recongnize our architecture. Through the toolchain, we name our architecture mspu, which means maPU scalar processing unit. We then can specify our target in the command line:
llvm-mc -target mspu
We need to modify following files to make the targe effective:
- include/llvm/ADT/Triple.h: This is used for Autoconfig Detecting Triple.
- lib/Support/Triple.cpp: This is used for command line parsing target
- include/llvm/Support/ELF.h: Define the EM number for MaPU elf file.
- include/llvm/Object/ELFObjectFile.h: Return the correct object file type according to the EM
After modifying these files, the LLVM should recognize mspu architecture and generates mspu ELF files. Next we will add simple assembly instructons to the LLVM.