Yasser is developing "Tilde," a new compiler infrastructure designed as a simpler, more modular alternative to LLVM. Frustrated with LLVM's complexity and monolithic nature, he's building Tilde with a focus on ease of use, extensibility, and better diagnostics. The project is in its early stages, currently capable of compiling a subset of C and targeting x86-64 Linux. Key differentiating features include a novel intermediate representation (IR) designed for efficient analysis and transformation, a pipeline architecture that facilitates experimentation and customization, and a commitment to clear documentation and a welcoming community. While performance isn't the primary focus initially, the long-term goal is to be competitive with LLVM.
Yasser, the author, introduces "Tilde," their personal project aimed at creating a from-scratch alternative to the LLVM compiler infrastructure. Driven by a desire to learn more about compilers and explore different design decisions, they embarked on this ambitious undertaking. Tilde isn't intended to replace or compete with LLVM, but rather serves as an educational exercise and a platform for experimentation.
The post details the current state of Tilde, which is still in its early stages. It currently supports a minimal subset of the C language, focusing on basic integer arithmetic, function calls, global and local variables, and control flow constructs like if
statements and for
loops. The author explicitly mentions the omission of more complex features like structures, floating-point numbers, and pointers, emphasizing the project's nascent nature.
The compilation process in Tilde is outlined, starting with parsing the input C code into an Abstract Syntax Tree (AST). This AST is then transformed into a simpler, three-address code intermediate representation (IR). From this IR, Tilde generates assembly code for the x86-64 architecture. The author details the register allocation strategy, which currently uses a simple, non-optimized approach. Specifically, Tilde assigns a new register for every variable, leading to suboptimal code generation but simplifying the implementation. Future optimizations are planned, but not yet implemented.
The author emphasizes their choice of Zig as the implementation language for Tilde, highlighting Zig's self-hosting capabilities and control over memory management as key factors. This allows for easier debugging and a more streamlined development process compared to using C or C++.
The post concludes with a discussion of future plans for Tilde. These include expanding the supported C features, implementing better register allocation, incorporating optimizations like constant folding and dead code elimination, and exploring alternative backend targets beyond x86-64. The author expresses excitement about the project's potential and invites feedback from the community. The overall tone suggests a passion for compiler design and a commitment to the ongoing development of Tilde, albeit as a personal learning endeavor rather than a production-ready tool.
Summary of Comments ( 41 )
https://news.ycombinator.com/item?id=42782872
Hacker News users discuss the author's approach to building a compiler, "Tilde," positioned as an LLVM alternative. Several commenters express skepticism about the project's practicality and scope, questioning the rationale behind reinventing LLVM, especially given its maturity and extensive community. Some doubt the performance claims and suggest benchmarks are needed. Others appreciate the author's ambition and the technical details shared, seeing value in exploring alternative compiler designs even if Tilde doesn't replace LLVM. A few users offer constructive feedback on specific aspects of the compiler's architecture and potential improvements. The overall sentiment leans towards cautious interest with a dose of pragmatism regarding the challenges of competing with an established project like LLVM.
The Hacker News thread for "Tilde, My LLVM Alternative" contains a moderate number of comments, many of which delve into technical details and offer informed perspectives on the project. While there's enthusiasm for the ambition and potential of a simpler compiler backend, there's also a healthy dose of skepticism and pragmatic analysis of the challenges involved.
Several commenters acknowledge the complexity of LLVM and the potential benefits of a simpler, more approachable alternative, particularly for educational purposes or niche use cases. Some express interest in following the project's development and appreciate the author's willingness to tackle such a complex undertaking.
However, many comments also highlight the significant hurdles faced by such a project. The sheer size and maturity of LLVM, coupled with its extensive community and tooling, are seen as major advantages that Tilde would struggle to replicate. Some commenters question whether the performance gains touted by the author are realistically achievable or sustainable in the long run. Concerns are raised about the potential for fragmentation within the compiler ecosystem and the difficulty of attracting a sufficient developer community to support and maintain a new backend.
A few compelling comments include:
Overall, the comments reflect a cautious but intrigued response to the "Tilde" project. While acknowledging the author's ambition and the potential value of a simplified compiler backend, the discussion reveals a strong awareness of the significant challenges involved and the importance of carefully considering the project's goals and scope.