[LLVMdev] MOS6502 target

John Criswell jtcriswel at gmail.com
Thu Jul 3 11:21:11 PDT 2014


On 7/2/14, 9:44 PM, Bruce Hoult wrote:
> I've considered doing this as well :-) As an exercise to learn the 
> LLVM back end as much as anything.
>
> It probably makes sense to allocate 8 or 16 pairs of zero page 
> locations as virtual 16 bit registers and make 32 bit operations 
> available only as library routines/intrinsics.

One interesting problem with doing that is determining which zero page 
locations are free for use on the target machine.  The Apple II ROM, for 
example, reserves many of these locations for its own use. Other 
machines may reserve different locations within the zero page.

>
> What would be *really* helpful would be if LLVM had a way to detect 
> that certain functions and sets of functions (probably >90% of the 
> program) are NOT recursive and statically allocate fixed zero page 
> and/or high memory locations for their local variables.

A typical callgraph analysis run within libLTO can be used (along with 
Tarjan's algorithm) to find SCCs in the callgraph.  The default 
callgraph implementation within LLVM is extremely conservative with 
function pointers and external code, so for some programs, the results 
may not be good.

Alternatively, one could use the DSA analysis within the poolalloc 
project to get a better callgraph.  There's even code within SAFECode to 
find SCCs, although I don't recall off-hand which pass it is and whether 
it's active in the default compilation.

Regards,

John Criswell (who fondly remembers assembly programming on his Apple //c)




More information about the llvm-dev mailing list