KickC Optimizing C-Compiler now supports NES

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

tepples
Posts: 21971
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: KickC Optimizing C-Compiler now supports NES

Post by tepples » Thu Jun 18, 2020 1:32 pm

Does it offer something with static's speed and auto's space reuse that uses the call graph to let functions share a variable's space if the compiler can determine that they will never be in the call stack at once? I've proposed this sort of arrangement for 6502 assembly, and compilers for modern 8-bit microcontroller ISAs appear to support what Microchip calls a "compiled stack."

JesperGravgaard
Posts: 9
Joined: Fri Jul 05, 2019 1:41 pm

Re: KickC Optimizing C-Compiler now supports NES

Post by JesperGravgaard » Thu Jun 18, 2020 2:30 pm

tepples wrote:
Thu Jun 18, 2020 1:32 pm
Does it offer something with static's speed and auto's space reuse that uses the call graph to let functions share a variable's space if the compiler can determine that they will never be in the call stack at once? I've proposed this sort of arrangement for 6502 assembly, and compilers for modern 8-bit microcontroller ISAs appear to support what Microchip calls a "compiled stack."
The majority of short-lived variables can be handled directly in registers (and thus are never stored in memory). Short lived variables that have to be stored in memory tries to reuse the same zero page addresses when possible.

KickC performs variable live range analysis based on single-static assignment form of the code. This allows the compiler to reuse the same storage for multiple variables as long as they are never alive at the same time. It also tries to reuse the same storage for variables that "meet" at a single assigment), eg. if the variable a is last used in the assignment b=a+7 then it will try to reuse the same storage for a and b.

You can read a paper describing the algorithm that KickC uses for allocating variables to storage here: http://compilers.cs.ucla.edu/fernando/p ... t_tech.pdf

User avatar
Nikku4211
Posts: 26
Joined: Sun Dec 15, 2019 1:28 pm
Location: Bronx, New York
Contact:

Re: KickC Optimizing C-Compiler now supports NES

Post by Nikku4211 » Sat Jun 27, 2020 10:58 am

Do you plan to add SNES support, too? I don't care if PVSNESLib exists.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.

Post Reply