3 ms·
That’s true, but I don’t think they do to the extent that is needed to generate good Z80 or 6502 code. They won’t move local variables to global locations, for
by Someone 6y ago
That’s true, but I don’t think they do to the extent that is needed to generate good Z80 or 6502 code. They won’t move local variables to global locations, for example. That often is essential on 6502 because of the limited stack space.
I also doubt they’ll use status flags to return data from functions. Such micro-optimizations just aren’t that useful on heavily pipelined CPUs with zillions of registers.
But yes, a link-time optimizer would work, but it would have to be built for these architectures, not, as in gcc’s or LLVM’s case, for the intermediate language.
Edit: for stuff that I don’t see a traditional link time optimizer do, look at CHRGET and CHRGOT in http://unusedino.de/ec64/technical/project64/mapping_c64.html http://unusedino.de/ec64/technical/project64/mapping_c64.htm....
Semi-equivalent C code (leaving out returning info in the status flags) is:
void * addr;
void * CHRGOT() { return addr; }
void * CHRGET() { while(shouldSkip(++addr)); return addr;}
The assembly code uses self-modifying code for speed, and makes CHRGET fall-through into CHRGOT, adding an unnecessary while-loop to CHRGOT.
Also, there’s the choice as to what flags to use for returning info.