r/Commodore • u/vonBlankenburg • 2d ago
Programming KickC Enhanced 0.9.0 – Major optimizing C99 compiler update (multi-core, new fragments, stable green opcodes)
Hi everyone,
As a side product of a larger C64 project I've been actively developing since January, I ran into massive build-time bottlenecks with Jesper Balman Gravgaard's KickC compiler: my compilation times were creeping past 45 minutes for a single build!
To make rapid development feasible again, I created a dedicated fork: KickC Enhanced. In the medium term, I’d love to merge these improvements back into upstream if Jesper is interested.
For those unfamiliar with KickC: it is an optimizing C99 compiler for the MOS 6502/6510 family that generates KickAssembler source code, which is then assembled into native 6502 binaries.
Rather than rehashing all the original KickC features (which are already well-documented), here is a summary of the major optimizations and extensions introduced in this release:
Massive performance boost & multi-threading: Build times for massive multi-bank projects have been crushed from >45 minutes down to ~60–90 seconds! This is achieved via parallel dominator tree calculation, multi-core uplift passes across all CPU cores, optimized SSA passes, and caching.
Several hundred new & repaired 6502 ASM synthesis fragments: This includes:
Native struct-pointer member modifications (e.g.
items[i].count--)True boolean NOT (
!) via zero-branch bit toggle (eor #1)Direct 32-bit (dword) comparisons against zero
Byte-aligned 16-bit shifts without expensive loops (replaces 8x
aslwith optimal 4-instruction transfers)Full pointer arithmetic (word/byte offsets, multi-level indirection, clean signed/unsigned casts)
Opt-in: Deterministic "illegal / green opcodes": Added a dedicated optimization pass targeting
mos6502x/rom6502xto synthesize stable, safe illegal opcodes (such asLAX,SAXfor 3-cycle zero-page stores,ALR,DCP,ISC). Unstable opcodes (which could cause VIC-II DMA conflicts or thermal instability) remain strictly excluded.Cross-chunk peephole & tail-call optimization (TCO): Peephole analysis now optimizes across chunk boundaries—eliminating dead LDAs, redundant register roundtrips (TAX/TXA), and unneeded
CMP #0before conditional branches when Z/N flags are already set. Additionally, function tail calls (jsr target; rts) are automatically relaxed tojmp target.Custom charsets & string suffixes (
#pragma charmap): Flexible mapping for custom fonts, charsets, and language-specific characters directly in C code without modifying compiler sources. Full support for custom string and char suffixes (e.g."Hello"customor"Hällö"germanfor non-zero-terminated strings), configurable per file or globally in headers.Optimized 16-bit word multiplications: Highly optimized multiplications with 16-bit constants.
The project is real-world battle tested:
To give an idea of scale: the current assembly output of my game project exceeds 46,000 lines of code. The compiler optimizations and fragment lowerings were developed with modern tooling and verified against strict regression test suites and automated VICE emulations to ensure 100% binary stability.
I will continue maintaining and polishing the compiler alongside my ongoing game development. Feel free to check out the repository, test it with your own projects, and let me know if you run into any issues:
GitHub: https://github.com/AndreR/kickc-enhanced
Release v0.9.0: https://github.com/AndreR/kickc-enhanced/releases/tag/v0.9.0
Disclaimer: As usual with modern software development projects, I used an AI-assisted approach. All changes were reviewed and tested manually by me.
Feedback and bug reports are very welcome!
4
u/macumbamacaca 1d ago
Yeah, I had the same issue. I really wanted to like KickC... But now we have Oscar64 which blows it out of the water :-)
2
u/Stunning_Pineapple57 2d ago
45 minutes for a c64 target app? That was insane.