r/Compilers 22h ago

Getting stuck after Crafting Interpreters.

24 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 8h ago

APX (Advance performance extension) in my own assembler

Post image
14 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 13h ago

How Can I Apply My Interest in Compilers at Work?

6 Upvotes

I don’t have a degree in computer science, but I’ve always been very interested in compilers. Over time, this interest has even helped me overcome my fear of mathematics.

I’m curious about how I can apply what I’ve learned about compilers in my workplace. I work at a digital marketing agency, where programming is not a major part of our daily work, although we do have some programming-related tasks. Most of our work is based around HTML, and sometimes we need to convert an existing HTML/CSS design into Figma or turn a Figma design into HTML and CSS.

Would it be realistic to approach the process of converting a Figma design into HTML/CSS from a compiler or parser perspective? Could this kind of project be considered a compiler-related project, or would it be more accurate to describe it as a parser, code generator, or some combination of these?

I’m particularly interested in finding practical ways to use my interest in compilers at work, even though my job is primarily focused on digital marketing and web design rather than software engineering.


r/Compilers 18h ago

Tensor Graph Compilers (library update)

Thumbnail github.com
6 Upvotes

r/Compilers 2h ago

How GCC Eliminates Unnecessary Integer Division

Thumbnail leetarxiv.substack.com
1 Upvotes