On 18/05/2008, at 3:34 AM, Erick Tryzelaar wrote:

> On Sat, May 17, 2008 at 3:36 AM, john skaller
> <[EMAIL PROTECTED]> wrote:
>> No, we do just this for C. You do it like this:
>>
>> fun sin: float -> float = "sin($1)"
>> requires header "extern float sin(float);";
>>
>> or for llvm I guess:
>>
>> fun sin: double -> double:
>> "call double @sin(double $1)"
>> requires header "declare double @sin(double)";
>
> Thats a little bit simpler. We could also just hide everything, and do
> something like this:
>
> fun add: double -* double > double: "add"
> fun sin: double -> double: "@sin"
>
> And do the declare if the string starts with @. That loses the ability
> to write arbitrary text.

Not if you change it to

        fun sin: double -> double :@ "sin";

i.e. special syntax which invokes an llvm specific extension.

> On the other hand, this would allow the
> compiler to do things like choose between a "call", a "tail call", or
> an "invoke" (which supports stack unwinding).
>
>> proc sin: lvalue[double] * double =
>> """
>> ld %x, $2  # load %x with argument 2
>> call double @sin(double %x)
>> st %r,$1  # store result to argument 1
>> """
>>
>> (using ld and st for load an store, and assuming result
>> is returned in register %r).
>
> True, but in many cases llvm can hide this away. LLvm uses load and
> store only when interacting explicitly with the stack or heap. For
> something like sin, you can just read and return the value directly.
> They've even got support now for returning multiple values. In the
> next release, I believe they're adding support for returning complex
> data like structures and arrays.

Why bother .. why not use C?

--
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