On 16/09/2009, at 5:34 PM, Erick Tryzelaar wrote:

> Just got basic conditional branching working. With this code:

>
>  Unfortunately, branching only works inside functions.

Why is that unfortunate? Code only lives inside functions.

In the C generator there's a hack to allow gcc to do "long jumps"
across functions.

However this is needed only because gcc is pretty brain dead
handling large functions. Ideally Felix (and other C code generators)
would generate all code as a single massive function, since this then
allow unrestricted flow control. Unfortunately this can't be done since
gcc can't handle it so we have to generate multiple small functions and
then hack long jumps.

Procedural jumps can also be done by a fiddling the spaghetti stack
and then doing a return to the driver code, which then "resumes" the
target function which itself starts off with a switch (or computed  
goto).
Clearly this is less efficient than a direct jump. Oh well.. the real  
problem
is that C can't handle control exchange. Ideally you'd have a function  
with
multiple entry points and do a tail call to one of those points (which  
is
equivalent to a jump).

LLVM probably doesn't have this restriction since it is an assembler
and should be able to assemble a whole program as a single function
without any problem.

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to