Hacker News new | ask | show | jobs
Show HN: xocc – C compiler based on BSD license
39 points by steven_known 1918 days ago
Hello everybody,

I'm glad to announce the major release of xocc C compiler, 1.2.1, based on BSD license. xocc is a C compiler that based on XOC infrastructure, XGEN code generator and XOCFE C frontend. Both xocc, XOC, XGEN, and XOCFE are based on BSD license.

XOC provides multi-level IRs, flexibility, and the capability of representing almost all popular languages. There are mainly two level IRs used throughout all phases of the compilation. In addition to basic IR, XOC also provides IR builder, BB manipulating api, Control Flow Graph(CFG), IR lowering, Control Dependent Graph, Dominator Tree, Register SSA, Memory SSA, Agressive Flow Sensitive Alias Analysis, Flow Insensitive Alias Analysis, Agressive Field Sensitive Alias Analysis, Interprocedual Analysis Framework, Inliner, Dead Code Elimination, Copy Propagation, GCSE, GVN, and a lot of sophisticated control flow and peephole optimizations. Moveover, XOC does not use any std library, it provides all basic algorithm library such Vector, List, Map, Dense Bitset, Sparse Bitset, Graph, Mempool, Big-Integer, Linear Algebraic library, Linear Programming Solver, just read Manual.txt of XOC.

XGEN provides a retargetable machine code generator. For now, it could generate ARM, x86 code. XGEN provides IR2OR translator, Instruction Scheduling, Register Allocation, Instruction Packager, Assembly.

XOCFE is C frontend, it prints AST as output.

XOCC is a driver that composes XOCFE, AST2IR, XOC and XGEN into complete C compiler.

All features provided by XOCC, XOC, XGEN, XOCFE empower you developing any compiler and analysis tools.

Any feedback on the compiler and its components would be much appreciated!

To build xocc, see https://github.com/stevenknown/xgen for details.

Get them here: https://github.com/stevenknown/xgen https://github.com/stevenknown/xoc https://github.com/stevenknown/xocfe https://github.com/stevenknown/xpoly

Contact: steven.known@gmail.com

7 comments

Wow it's cool that Alibaba shared this. This is 300k lines and ten years of work. It has unit tests documenting optimizations it's able to do that LLVM can't. It looks like ARM support has been open sourced but not x86 yet. It'd be nice to see this included on clang.godbolt.org.
Thanks for your attention! XOC infrastructure has been widely used in many field. Recently, some famous AI chip design manufacturers has implemented DSL compiler of AI chip based on XOC. We hope the AI compiler will be open source soon.
The ARM code generation example seems to offload floating point as calls to a standard library rather than generating floating point instructions; is that the case?
I looked, and cannot find any documentation (other than a few comments in the source code).

Is there any documentation of the IR codes?

Also, what version of C does the C compiler implement, and are any GNU extensions implemented?

Sorry for the inconvenience caused by documents. There is Manual.txt under xoc/doc/ that describes key concepts to XOC IR, Var, MD, etc.We will do our best to supplement documents.
For now, xocc supports C99, but does not support GNU extensions yet.
xocc is a C compiler that based on XOC infrastructure, XGEN code generator and XOCFE C frontend. https://officess-setup.com
spammed link above.
Cool! How does it compare to GCC, Intels CC or LLVM? Are there any studies yet?
By some feedback of AI compiler performance tuner, the compiler based on XOC is 20% average faster than LLVM based.
Hi, Does Alibaba already use it? Lots of good stuff in it.
Sure, not only Alibaba, there are lots of applications of XOC. XOC has been used in Java AOT compiler, JavaScript AOT compiler and Type Inference Engine, VLIW/DSP compiler, etc. And XOC is also used in some teaching. For now, XOC is used as AI compiler to do optimization and code-generation for AI chip by some famous AI design manufacturers.
for curiosity, because I am a grad student working on AI accelerators, I just want to know why these AI manufacturers are going with XOC which is new to me instead of wide used toolchain like GCC or LLVM especially with the last one using MLIR .
Good question! In a simply word, GCC&LLVM compilers are good at traditional RISC-like hardware, namely, IR expected to be load/store/compute/branch, etc. More important is, these compilers do not allow user to add custom IR at will. AI chip operator evoloing rapidly, adding IR means the compiler needs to be overhauled. XOC is multi-level IR compiler, MLIR is not. MLIR open source later than XOC. Moreover, MLIR lack s of powerful optimizations.
Nice!
Have you considered submitting this to Show HN instead of Ask?

You can email hn@ycombinator.com and ask dang to change the title.

Changed now. Thanks!