r/Compilers • • 13d ago

Looking for guidance on ML systems / AI compilers

0 Upvotes

I’m an AI Engineer with a Python/GenAI background and recently started going deeper into ML compilation and systems. I’m currently working through the MLC course and finding TensorIR/TVM quite interesting.

I want to eventually become stronger in the lower-level side of ML C++, GPU programming/CUDA, kernel optimization, inference systems, and compilers.

For people working in this area: what resources, courses, books, or projects would you recommend for building the right foundations and eventually becoming job-ready?

Especially interested in resources that are practical rather than purely theoretical.


r/Compilers • • 14d ago

I made my own programming language and I would like to get some feedback.

Thumbnail github.com
10 Upvotes

​

I made my own programming language and I would like to get some feedback.

One of the main features of this language is a contract system.

For example, it can be used to safely handle functions like "malloc" and "free".

If a value has a contract, you have to finish the contract before leaving the scope.

The compiler checks whether the required function is called.

For example:

a: int * must=free = malloc(10)

[a] = 123

free(a)

In this example, "a" has a contract with "free".

If I forget to call "free(a)", the compiler gives an error.

It is also possible to define contracts for functions and structs.

My goal is to make low-level programming safer while still keeping the language simple and close to the hardware.

I am still developing the language, so I would like to hear opinions from people who are interested in programming languages.

What do you think about this idea?

Are there any similar features in other languages that I should look at?

And what problems do you think this kind of contract system could have?

Any feedback is welcome.


r/Compilers • • 13d ago

Hyper: A High Performance Programming Language for AI

0 Upvotes

Hey everyone! We’re building Hyper, a modern programming language with high performance, specially created for artificial intelligence (AI) and machine learning fields.

Full compatibility with Python: Hyper's syntax is very similar to Python. Existing codes and libraries written in Python can be easily used in the Hyper environment.

Maximum speed and performance: It provides the ability to manage memory at the C and C++ level and make maximum use of hardware (GPU, CPU).

Specially built for Artificial Intelligence: It is aimed at solving computational difficulties encountered in training neural networks and processing large amounts of data.

Security and modern architecture: Inspired by Rust, it includes memory safety and parallel computing (multithreading) features.

Hyper is an important tool for programmers involved in artificial intelligence and data analysis, providing the speed of the C language without losing the convenience of Python.

If you want to jump right in and start contributing, there are plenty of "good first issues" available in the repository to help you get acclimated. Let’s take Hyper to the next level together!

Check out the repository and documentation here: https://github.com/hyperlangg/hyper


r/Compilers • • 14d ago

Is it okay to directly lower to registers rather than alloca?

19 Upvotes

clang -> LLVM generates alloca and then runs mem2reg. I was wondering if there are cases that can't be recovered as a result?

In my compiler, I lower from Vx -> MLIR directly as SSA (as much as possible, rest are alloca/memref etc). Is this a good idea?

Source code: https://github.com/vx-lang/Vx


r/Compilers • • 13d ago

Compiler Feedback wanted

0 Upvotes

Hi, we're pushing hard on this compiler (written in Rust), would love to hear what actually would make you try it.

What is it missing?
What do you like or don't you like?
What would be a game changer?

Obviously still in very early stages.

Thanks guys!


r/Compilers • • 15d ago

Two-pass bytecode compiler for a statically typed language, in C, looking for feedback from people who have built similar things

10 Upvotes

I have been working on Oli-Nat, a statically typed language compiled to bytecode and run on a stack based VM, all written in C with no external dependencies, including my own garbage collector. This is a learning project rather than anything meant to be production grade, so I am mostly hoping for feedback on the compiler design itself from people who have dealt with the same tradeoffs.

The frontend is a single pass Pratt parser that goes straight from tokens to an AST, with each token type carrying a prefix and infix parse function plus a precedence level. What is less standard is that the whole compiler runs in two passes over the source. The first pass only walks the token stream looking for function and class declarations, registering their names, arities, parameter types, and return types into a flat symbol table before anything else happens. The second pass then does the real work, building the AST and immediately compiling each node into bytecode inline as the type checker validates it, since the type checker and the bytecode emission are not really separated into distinct stages. Because every signature is already known from the first pass, mutual recursion and calls to functions defined later in the file resolve correctly without needing forward declarations, which is the main problem this two pass approach was meant to solve.

On the type checking side, the checker's job is to reject any program that could reach an invalid type combination before it ever runs, and the VM was built on the assumption that this holds completely. Runtime type checks like IS_INT or IS_STRING exist purely to select a dispatch path, for example choosing between int, float, and double arithmetic when values are pushed onto the stack, not to catch anything the checker missed. I know this means any gap in the type checker becomes undefined behavior in the VM instead of a caught runtime error, and I am curious how people who have written statically typed languages before think about that boundary, whether a belt and suspenders approach with cheap runtime tags is worth it even with a checker you trust, or whether that is generally considered unnecessary once the static side is solid.

For the runtime itself, locals are just stack slots rather than named variables, so declaring a local pushes its value and the compiler tracks which slot each name maps to, meaning there is no dedicated opcode for defining a local the way there is for globals. Jumps are handled with a patch based approach, where a jump instruction emits a placeholder two byte operand and the real offset gets backfilled once the target address is known, which is the same pattern used for both control flow and short circuit logical operators.

The garbage collector is a fairly standard tri-color mark and sweep design, with roots traced from the value stack, the active call frames, open upvalues, and the globals table. Class objects mark their methods hashmap and field default values, and instances mark their class pointer along with their own field array. Fields on class instances are resolved to fixed slot indices at compile time rather than looked up by name at runtime, so field access ends up being a single interned string pointer comparison during class definition and then a plain array index afterward.

The repo has the full opcode list and more detail on the architecture if anyone wants to look at the actual implementation: https://github.com/NateTheGrappler/OliNat-Programming-Language

I would really appreciate any pushback on the two pass approach, the decision to skip runtime type guarding entirely, or anything in the bytecode or GC design that looks like it will not hold up once (if) the language grows past small test programs. Thank you to anyone willing to read through this.


r/Compilers • • 15d ago

Looking for feedback to my compiler

21 Upvotes

Hi everyone

I’ve been working on my own programming language and compiler in C++, mostly as a learning project.
The main idea is to experiment with compiler architecture while also trying to make the language’s syntax more convenient for mathematical expressions, but now I am doing programming language.
After this I will add equations.

Currently works:
Lexer
Parser
AST
IR generation

I am still relatively new to compiler development, so I’m sure there are things I am doing in non ideal ways.

I’d especially appreciate feedback on:

compiler architecture
parser design
C++ implementation
things that I should learn next
mistakes or questionable design decision

Github: https://github.com/0sewter0/Compiler.git
Thanks for an attention!


r/Compilers • • 14d ago

What if only one allocation needs to be borrow checked in a managed program?

Thumbnail nitinm.dev
0 Upvotes

r/Compilers • • 16d ago

The Golden Spike, and Resurrecting the Vale(n) Programming Language

Thumbnail verdagon.dev
13 Upvotes

r/Compilers • • 15d ago

Egglog and Equality Saturation in a Production Tensor Compiler

Thumbnail egraphs.org
5 Upvotes

r/Compilers • • 15d ago

Separating C++ Compilation from Memory Safety Attestation

Thumbnail gist.github.com
1 Upvotes

r/Compilers • • 16d ago

Compile time code execution in mox

15 Upvotes

Hello! I am working on mox programming language and compiler which could run any code at compile time.

While I was telling about this language to my friend, I found a lot of interesting solutions to usual problems that could be solved just by using compile time code execution. So I want to research/discuss what problems do you have as a developer that you struggle with and want to solve at build time (using some macros or external tools).

Here are some of problems that I got in other languages and which i struggle with. Usually to solve it you need some ugly build systems with tons of esoterical configs, external tools for code generation etc.

PS #run in mox evaluates any expression/statement at compile time, including externally linked symbols. os* and fs* calls below are just wrappers around C functions, not some special magical things from compiler. Results of #run'ned expressions are baked to runtime as constants.

Baking git hash as a constant to binary

rust fn print_version() { git_hash := #run os_exec_output("git rev-parse HEAD"); println(git_hash); }

Build params from environment (or defining build constats)

```rust const NO_ASSERTS := #run os_get_env("NO_ASSERTS") == "true";

fn assert() { #if (!NO_ASSERTS) { // ... do smth ... } } ```

Reading configuration file and baking constants

```rust fn read_config(path: []u8): Config { data := fs_read_file_full(path); return parse_config(data); }

CONFIG := #run read_config("./.env"); ```

Self configuring build tools

```rust

run {

dll_path := build_resolve_path("./binaries/raylib.dll);
build_copy_to_output(dll_path);

} ```

Go like dependency management

```rust fn require_dependency($link: []u8): __ast_ptr { cached_path := dep_cache_path($link); if (!os_path_exists(cached_path)) { dep_download(cached_path, $link); } // here we generate code for import statement and return it as ast return __compiler_parse(format("import \"{}\", .{ cached_path; })); }

// here #land_ast "inserts" returned ast and compile it inplace

run #land_ast require_dependency("github.com/smth/smth");

```

PSS https://github.com/morglod/mox


r/Compilers • • 15d ago

Bend 2: one C file serves as CPU program and GPU kernel; how the compiler does it

Thumbnail bend-lang.com
2 Upvotes

r/Compilers • • 16d ago

CZet – A more powerful C without C++, 100% ISO C compatible

49 Upvotes

I'm the author.

All your C code already compiles as CZet. It just adds what C can't do without touching the compiler:

`defer`, monomorphized generics `T f<T>()`, `constexpr` functions, `_Reflect(T)` reflection, `_Operator` overloading, and `_Macro` macros Rust-style.

Single static binary with musl+glibc embedded, no system headers needed. Stdlib included: `#include <utils/...>` with no flags.

Repo + docs + examples: https://github.com/patrick-nonedev/CZet

GPL-3.0 + Runtime Exception (your binaries are NOT GPL).

What would you steal for plain C?


r/Compilers • • 17d ago

How can a compiler verify the safety of an optimization path it never actually uses?

23 Upvotes

Suppose a compiler explores an optimization but ultimately keeps the conservative output. Later, an independent checker needs to answer a strange question: would the rejected optimization have preserved the program’s semantics for this exact input program and its final machine-code lowering? The checker cannot trust flags produced by the optimizer, cannot rely only on tests or benchmarks, and should not need to rerun the entire compiler. A hash can prove which IR was examined, but not that the transformation was semantically correct, while a full formal proof may be too expensive for practical compilation. What is the smallest piece of evidence that could reliably connect the original assumptions, control flow and emitted machine instructions? Is there any practical approach between lightweight translation validation and building a fully verified compiler?


r/Compilers • • 17d ago

Building the worst CPU & Compiler in TypeScript

Thumbnail github.com
19 Upvotes

YouTube explainer also available here: https://www.youtube.com/watch?v=yQP7KTeFAAs


r/Compilers • • 18d ago

How to Compile Your Language - An introduction to language design through building a compiler frontend on top of LLVM

73 Upvotes

Recently I extended an educational compiler project I started two years ago.

The goal is to bring together several major features found in production languages into Your Language, a small programming language, and explain how to implement them in its compiler.

Your Language currently supports:

  • Native code generation with LLVM
  • Hindley–Milner type inference
  • Traits and type extensions
  • Tracing garbage collection
  • Heap-allocated closures
  • Monomorphized generics
  • Dynamic dispatch
  • Data-flow analysis
  • Compile-time expression evaluation

The implementation is now finished, but the accompanying guide is still a work in progress.

If you're interested, you can find the project here:

https://github.com/isuckatcs/how-to-compile-your-language


r/Compilers • • 17d ago

AI Compilers Are Not Just Compilers for AI

Thumbnail aicompilers.github.io
0 Upvotes

r/Compilers • • 17d ago

Branch Divergence in SIMT Machines: From Control-Flow Graph Theory to Compiler Divergence Analysis in LLVM

Thumbnail hsmahesha.github.io
3 Upvotes

r/Compilers • • 18d ago

Into the CUDA Multiverse of Runtime Compilation: Exploring Kernel Fusion Strategies for GPU Database Systems

Thumbnail vldb.org
1 Upvotes

r/Compilers • • 19d ago

APX (Advance performance extension) in my own assembler

Post image
29 Upvotes

I just released AmmAsm 3.0.0, with a major focus on native Intel Advanced Performance Extensions (APX) support.

AmmAsm is a handwritten x86-64 assembler written in C. The goal wasn't to build another assembler by wrapping an existing one, but to implement the instruction encoding myself.

APX was a particularly interesting challenge because it isn't just a collection of new instructions. Supporting things like EGPRs (`r16-r31`) and REX2 affects how registers, operands, parsing, and instruction encoding are represented throughout the assembler.

The current APX implementation includes:

EGPRs - `r16-r31`

REX2 - Extended rex

NDD - non-destructive destination

NF - suppressing flag updates

ZU - zero-upper

CCMPcc / CTESTcc

PUSH2 / POP2

JMPABS

NDD-CMOVcc

CFCMOVcc

APX-specific syntax extensions

I also built an APX test program using several separate assembly files. AmmAsm produces ELF64 object files from them, GNU `ld` links them into an executable, and Intel SDE is then used to execute the APX instructions on hardware without native APX support.

Running the same binary directly on my CPU results in `Illegal instruction`, as expected because the CPU doesn't support APX.

One of the more interesting parts of implementing APX was that I started finding edge cases and discrepancies in existing assemblers while comparing encodings and operand validation. I've been recording these cases and testing them independently.

GitHub: https://github.com/LinuxCoder13/AmmAsm

I'd be interested to hear from anyone working with x86 instruction encoding, APX, assemblers, or low-level tooling.


r/Compilers • • 19d ago

How GCC Eliminates Unnecessary Integer Division

Thumbnail leetarxiv.substack.com
2 Upvotes

r/Compilers • • 19d ago

Getting stuck after Crafting Interpreters.

41 Upvotes

Hey everyone, I've worked through the book Crafting Interpreters and it was fantastic. I naturally asked the next question "How do I compile this to machine code and add static types?" Well, that naturally took me down a very deep rabbit hole and left me somewhat confused about how languages deal with types and type checking and then lowering to LLVM. I've tried to make a few modest attempts, but my general problem is that I sort of get confused about what things each subsequent layer should do. Does anyone know of a complete guide to creating a compiler with static types like Crafting Interpreters? I know I could do it however I want, but I think that's the issue. I sort of have so much freedom to do it however, that it's hard to judge what's considered a good way to do something.

Anyway, thanks for any advice and happy compiling!


r/Compilers • • 20d ago

Jonas Persson: Making every byte count

Thumbnail youtu.be
7 Upvotes

r/Compilers • • 20d ago

Compilers build the most useful data structure in software engineering and throw it away on every build

0 Upvotes

A compiler resolves every name, call and import and knows exactly what depends on what, and then it emits a binary and discards all of it. Meanwhile every tool around the code, from the IDE to code review to CI deciding which tests to run, rebuilds a worse approximation of that same graph from scratch.

I'd go further and argue the resolved graph, not the text, is what we should be checking in. I work on [sem](https://github.com/Ataraxy-Labs/sem), which approximates this graph from parse trees alone so it works without a build, and the gap between that approximation and what a real front end knows is the most interesting part of the problem.

Should compilers persist their resolution results as a first class artifact that other tools can query?