[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Basic register usage

From: Charles Lohr
Subject: [Tinycc-devel] Basic register usage
Date: Tue, 26 Sep 2017 19:59:30 -0400

In trying to write a target for TinyCC, I've noticed the rest of the engine seems to want to do a fair bit of register/stack management.  This is fine and dandy, but I am having a lot of difficulty understanding where the line between my target and the TCC register functions such as get_reg, gv, gv2, vpop, etc. 

Most notably, I don't understand how to interact with it, to indicate specific values are already in registers.  It seems the existing code can't assign registers externally.  Additionally, even when using i386 with fastcall, on ARM and even on C67 ... I think it's pushing the registers from the fastcall onto the stack just to get it to fit into the TCC paradigm. Is this true or did I misunderstand? 

A way around this would be to create a reg_classes which has little do do with my architecture's registers and only tell TCC about a few pretend registers.  On Xtensa, calls are similar to fastcalls, using registers a2-a7 for the first several parameters, and I could keep track of what registers hold what and just re-use them.

I don't understand the internal structure of how TCC tracks register utilization.  It seems only to look at reg_classes for some sort of friendly way of telling the target code to take things from the stack and put them into one of two registers (or two others if floating point is available). 

tl;dr questions:

Is there some way of hinting to TCC "hey, register X contains Y sym" What functions/data structures would I use in func_prolog to tell TCC about it?

If not, should I just tell TCC about 2-3 registers and do all register allocation myself in the load/store/gfunc_prolog/gfunc_epilog stuff?  Possibly using some sort of virtual register cache?

I would prefer not to have to think about it and do the first if at all posisble.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]