On 14/05/2008, at 5:05 PM, Erick Tryzelaar wrote:

> On Tue, May 13, 2008 at 11:48 PM, john skaller
> <[EMAIL PROTECTED]> wrote:
>> Yes, it will work easily. Just look at flx_gen.  We have to implement
>> each of the BEXE_* and BEXPR_* things in LLVM.
>>
>> Control flow is simple, if I recall:
>>
>>        BEXE_goto label
>>        BEXE_ifgoto (cond, label)
>>
>> are all you need.
>
> I've started hacking at it already :) Got any tips on how to break up
> complex expressions like "a*a + 2*a*b + b*b" into a series of
> temporary expressions?

Sure, there is already two routines which do that. In flx_inline or
round abouts there is a routine called "unravel" which does just that.

There is also a back end "unravel" routine which works on
C expressions.

Roughly the inliner:

Unravels expressions to 3 address form (SSA form),
then scans sequences of initialisations and re-ravels them
back to expressions by substitution of temporaries,
in the process doing common sub-expression elimination.

BE CAREFUL fiddling with this code because it is highly
tuned and very fragile. If you don't leave certain patterns intact,
the inliner can fail to recognize some optimisation opportunities.

Unraveling in the backend (C code) is much safer.

> One hack I was thinking of doing was to change
> Flx_egen.gen_expr to return a string list, where each item is one of
> the sub expressions. Then, modify Flx_gen.gen_exe to convert n-1
> arguments into temps, and the nth argument into whatever call it's
> being passed to.

There is something like this already, unravelling code.
but don't use strings unless you cant avoid it, use proper
algebraic structures.

In the inliner stage

        unravel e

returns a pair:

        inits, e'

where e' is the new expression, and inits is a list of initialisations
of the form

        tmp1 = e1
        tmp2 = e2
        ...

and where e1, e2 etc are themselves reduced to function calls like

        f a

where f, a are constants or variables (but no more complex than that).

--
john skaller
[EMAIL PROTECTED]





-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to