TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Explaining my fast 6502 code generator

217 pointsby pubbyabout 2 years ago

10 comments

nstbaylessabout 2 years ago
I may have misunderstood, but I believe step 1 (eliding loads) is simply a cache scheduling problem. The optimal solution is the greedy "furthest in the future" eviction policy.
评论 #35299127 未加载
评论 #35299383 未加载
commandlinefanabout 2 years ago
&gt; my compiler generates faster code than GCC, LLVM, and every other compiler I compared it to<p>GCC and LLVM can target the 6502?!?
评论 #35294745 未加载
评论 #35294885 未加载
userbinatorabout 2 years ago
I&#x27;d like to see this same technique applied to x86, and what the performance is like without the &quot;illegal instructions&quot; (omitting them from generation would probably be trivial). It&#x27;s relatively well known that one of the ways Asm programmers can beat compilers is on instruction selection, and that&#x27;s what this technique seems to excel at.
ecpottingerabout 2 years ago
This does far more than I did back in my PET and then Amiga days, but one thing I did was write a multi-pass compiler. Each pass at first found ways to make the come better (usually smaller so it ran faster). Even simple code I wrote could see a 10-20% improvement.<p>Of-course, this is because the original code was quick and dirty. I wonder what improvement modern compilers could have added.
评论 #35297069 未加载
deterministicabout 2 years ago
Excellent read. I am a pro compiler developer and I learned quite a few things from the article.
thechaoabout 2 years ago
This is a Massalin superoptimizer.
评论 #35295097 未加载
Scaevolusabout 2 years ago
Does this code generator spill to zero-page? Do you have to do anything special for allocations there?
评论 #35296836 未加载
billyjobobabout 2 years ago
All the other compilers in the comparison are C compilers, right? Whereas this compiler is compiling its own home made language? So not sure how the comparison can be valid.
评论 #35296255 未加载
评论 #35296396 未加载
评论 #35301105 未加载
turboboosterabout 2 years ago
Can this make games for NES?
ajrossabout 2 years ago
Bookmarked this to read about optimizers, because it looks great.<p>That said, I clicked on the link because it had &quot;6502&quot; in the title. And... this isn&#x27;t very interesting as a retrocomputing activity. To be blunt: there&#x27;s absolutely no way in hell a compiler architecture like that is ever going to be self-hosting in 64k of memory space.
评论 #35296364 未加载
评论 #35296012 未加载
评论 #35296995 未加载