|
From: | Fabrice Bellard |
Subject: | [Tinycc-devel] Re: tcc stack |
Date: | Thu, 06 Feb 2003 22:46:44 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.1) Gecko/20020828 |
Xanthakis Stelios wrote:
Hello Fabrice I was looking at tcc output and found this: In the sample code int foo (int x) { if (x) { char p[1000]; ... } else { char p [1000]; ... } {/* brackets here for a purpose !*/ char p[1000]; ... } } tcc will allocate (sub SP) 3000 bytes of local storage. It seems that all the declarations of a function are added to compute the total stack that's needed. Of course this is not very important, since most function are not like the example above (and especially recursive ones). On the other hand it's an easy one to fix.
Yes, I did that only to save code space and complexity when TCC source code had a size smaller than 2048 bytes :-) If you have a patch a can include it - otherwise you'll have to wait a next release...
Also. I've been looking into the way tcc handles early terminations && and ||. Is your choice to use eax eventually? Because if you are willing to use temporary space for the result (0 or 1), you can go the gcc way which has a jump less. tmp=1 test x jnz L1 test y jnz L1tmp 0 L1:for x||y.
It seems interesting, but maybe difficult to generate with a single pass. If a separate pass is added to optimize jumps targets then it will be doable (I think such a pass would have a very small compilation time cost and would greatly improve tcc code size and performance).
Fabrice.
[Prev in Thread] | Current Thread | [Next in Thread] |