Using this map we can look at the right and middle columns in the next image to see which operands are coalesced.
Alejandro Armenta's Blog
Compiler Engineer
Wednesday, August 6, 2025
Register Coalescing
Using this map we can look at the right and middle columns in the next image to see which operands are coalesced.
Thursday, July 24, 2025
Copy Propagation
I made an Optimizing Compiler for C. It has multiple passes for generating assembly code x86 architecture.
It is an Ahead of time Compiler.
I made the Intermediate Representation where optimizations are made. I convert the AST into Intermediate Representation then apply optimizations to the code.
This is an example of copy propagation:The call has the same arguments and the copy propagation pass knows about it, so it replaces arguments repectively.
If you want to look at the code:
Wednesday, June 25, 2025
Dynamic Memory Allocation
I made a Linux C Compiler. It is a software compiler, it compiles C code into GAS assembly language.
I followed ISO C17 standard to make the compiler following the rules of the standard.
I also followed system V ABI calling conventions. You can call other libraries compiled with other compilers and call them in your code.
I also followed Intel x64 ISA for writing assembly code.
It has dynamic memory allocation. You can use malloc, free, calloc, realloc in your programs and the compiler will handle void pointers and void types.
The compiler supports static memory allocation, automatic memory allocation and dynamic memory allocation.
I tested my compiler against C tests for making sure it works, the testing is incremental so it works with past tests as well.Wednesday, June 11, 2025
Testing my compiler against Test Suite of compiling C tests
I added Multidimensional Arrays in C and Pointers to my Compiler. I added Subscripting, pointer arithmetic, Derefencing and Addressing, Compound Initializers and Static Arrays.
I tested the Compiler against C tests for validating correct assembly code.The tests run from the beginning to the end, so every feature is tested and validated.
This is one of the tests of the compiler, pointer difference validation:
This is the final assembly language file, it is real x86 code and when it runs it produces correct results.
If you want to look at the code:
Friday, May 30, 2025
Code Generation of Floating point numbers
I made a Code Generator, The code generator supports floating point numbers.
I used SSE2 instructions for generating assembly code for instructions that use doubles.
It translates from the Intermediate Representation into assembly for x86 architectures.
I also kept System V Calling conventions. In this way I can call functions from the math.h library and they work.
The code generator supports type conversions between floating point numbers and integers.
If you want to look at the code:
Sunday, May 25, 2025
Type System Part 2
Tuesday, May 13, 2025
Type System
I added a Type System to my C Compiler. It has support for adding multiple types to the compiler and make static type checking.
I added support for long integer types.Type conversions between longs and ints, It converts implicit casts into explicit casts.
It annotates each expression with its corresponding return type and uses it to know the corresponding intermediate representation.
In the back end I added support for multiple operand sizes.
If you want to look at the code: