<span style="font-family:SimSun;">Hi all,</span><span style="font-family:SimSun;"><br>
</span><br>
<span style="font-family:SimSun;">We are proposing the integration of a new backend targeting the LoongArch ISA.</span><br>
<br>
<span style="font-family:SimSun;">1. LoongArch intro</span><br>
<span style="font-family:SimSun;">LoongArch is a RISC style ISA which is independently designed by Loongson</span><br>
<span style="font-family:SimSun;">Technology in China. It is divided into two versions, the 32-bit version (LA32)</span><br>
<span style="font-family:SimSun;">and the 64-bit version (LA64). LA64 applications have application-level</span><br>
<span style="font-family:SimSun;">backward binary compatibility with LA32 applications. LoongArch is composed of</span><br>
<span style="font-family:SimSun;">a basic part (Loongson Base) and an expanded part. The expansion part includes</span><br>
<span style="font-family:SimSun;">Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD</span><br>
<span style="font-family:SimSun;">EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX).</span><br>
<br>
<span style="font-family:SimSun;">Currently the LA464 processor core supports LoongArch ISA and the Loongson</span><br>
<span style="font-family:SimSun;">3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit</span><br>
<span style="font-family:SimSun;">high-performance processor core. It can be used as a single core for high-end</span><br>
<span style="font-family:SimSun;">embedded and desktop applications, or as a basic processor core to form an</span><br>
<span style="font-family:SimSun;">on-chip multi-core system for server and high-performance machine applications.</span><br>
<br>
<span style="font-family:SimSun;">2. Conform to the policy</span><br>
<span style="font-family:SimSun;">According to https://llvm.org/docs/DeveloperPolicy.html#adding-a-new-target</span><br>
<span style="font-family:SimSun;">a) Of couse it will be an experimental target at first.</span><br>
<span style="font-family:SimSun;">b) I'd like to be the code owner of this target.</span><br>
<span style="font-family:SimSun;">c) There is an active community behind the target: https://github.com/loongson</span><br>
<span style="font-family:SimSun;">   And we will provide builbot support.</span><br>
<span style="font-family:SimSun;">d) Documentations:</span><br>
<span style="font-family:SimSun;"> - ISA:</span><br>
<span style="font-family:SimSun;">   https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html</span><br>
<span style="font-family:SimSun;"> - ABI:</span><br>
<span style="font-family:SimSun;">   https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html</span><br>
<span style="font-family:SimSun;"> - More docs can be found at:</span><br>
<span style="font-family:SimSun;">   https://loongson.github.io/LoongArch-Documentation/README-EN.html</span><br>
<br>
<span style="font-family:SimSun;">3. Status</span><br>
<span style="font-family:SimSun;">We started to implement an out-of-tree LoongArch LLVM port since last year</span><br>
<span style="font-family:SimSun;">based on llvm-8/11 and posted it to https://github.com/loongson/llvm-project</span><br>
<span style="font-family:SimSun;">last month. This port also adds supports to clang front-end and we finally pass</span><br>
<span style="font-family:SimSun;">100% llvm-test-suite in O0/1/2/3 optimization levels. But in this port there</span><br>
<span style="font-family:SimSun;">are a few issues we must handle to get it upstreamed.</span><br>
<span style="font-family:SimSun;"> - The codebase is too old that means we may use some out-of-date interfaces.</span><br>
<span style="font-family:SimSun;"> - The test coverage is not broad enough.</span><br>
<span style="font-family:SimSun;"> - Coding standard is not met.</span><br>
<span style="font-family:SimSun;">So we decide to refactor this port base on llvm trunk and integrate to upstream</span><br>
<span style="font-family:SimSun;">incrementally. This approach of small, incremental patches is somewhat similar</span><br>
<span style="font-family:SimSun;">to what has been or is being done with many other backends like RISC-V, CSKY</span><br>
<span style="font-family:SimSun;">and VE.</span><br>
<br>
<span style="font-family:SimSun;">The current status is that we have completed a series of 5 patches adding</span><br>
<span style="font-family:SimSun;">triple, ELF machine, basic interger instructions and registers definition. We</span><br>
<span style="font-family:SimSun;">will submit them for review later. Any comments are welcome and please do let</span><br>
<span style="font-family:SimSun;">me know if you'd like to be added as a reviewer to future patches.</span><br>
<br>
<span style="font-family:SimSun;">A rough development roadmap:</span><br>
<span style="font-family:SimSun;"> - MC layer</span><br>
<span style="font-family:SimSun;"> - CodeGen for Loongson Base</span><br>
<span style="font-family:SimSun;"> - CodeGen for ISA extensions, including LSX and LASX</span><br>
<span style="font-family:SimSun;"> - Support clang</span><br>
<span style="font-family:SimSun;"> - Support other sub-projects</span><br>
<br>
<span style="font-family:SimSun;">Best regards,</span><br>
<span style="font-family:SimSun;">Weining Lu</span><br>
<span style="font-family:SimSun;">-------------------------------------------------------------------------------</span><br>
<span style="font-family:SimSun;">Loongson Technology Corporation Limited</span><br>
<span style="font-family:SimSun;">Building No.2, Loongson Industrial Park, Zhongguancun Environmental Protection</span><br>
<span style="font-family:SimSun;">Park, Haidian District, Beijing</span><br><br><br><i style="font-variant-numeric: normal; font-variant-east-asian: normal; widows: 1; font-family: 宋体, Tahoma; font-size: 14px; line-height: 16.8px;"><font color="#c0c0c0"><span style="font-size: 10pt; font-family: 宋体;">本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部</span><span style="font-size: 10pt; font-family: 宋体;">分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。</span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif;"> <br>This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it. </span></font></i>