I've started a fork of felix to modify our compiler's backend to target llvm 
instead of c++. You can track it in the git repository 
[here](http://git.felix-lang.org/?p=felix/llvm-felix.git). 

For those unfamiliar with git, you can clone the repository by doing:

{{{
git clone http://git.felix-lang.org/r/felix/llvm-felix.git
}}}

Anyway, the support is very basic at the moment. But, it can turn this:

{{{
:::felix
#syntax <nugram.flxh>
open syntax felix;

type int = "i32";
fun add: int * int -> int = "add i32 $1, $2";
fun mul: int * int -> int = "mul i32 $1, $2";

body declare_exit = 'declare i32 [EMAIL PROTECTED](i32)';
proc exit: int = "call i32 [EMAIL PROTECTED](i32 $1)" requires declare_exit;

noinline fun foo (a:int, b:int) => a*a + 2*a*b + b*b;

var x = 1;
val y = 2;
val z = (foo (x, y)) + 3;
exit z;
}}}

Into this when run with `flxg test`:

{{{
:::llvm
declare i32 @exit(i32)
; ------------------------------
; C FUNC <8>: foo
define i32 @foo( i32 %a, i32 %b) {
entry:
      %_tmp30 = mul i32 %a, %a 
      %_tmp31 = mul i32 2, %a 
      %_tmp32 = mul i32 %_tmp31, %b 
      %_tmp33 = add i32 %_tmp30, %_tmp32 
      %_tmp34 = mul i32 %b, %b 
      %_tmp35 = add i32 %_tmp33, %_tmp34 
      ret i32 %_tmp35
}

; ------------------------------
; C PROC <15>: main
define i32 @main(i32 %argc, i8** %argv) {
entry:
      %x = bitcast i32 1 to i32
      %y = bitcast i32 2 to i32
      %_tmp36 = call i32 @foo(i32 %x, i32 %y)
      %z = add i32 %_tmp36, 3 
      call i32 @exit(i32 %z)
      ret i32 0
}
}}}

Which, when run with `cat test.ll | llvm-as - | llc - | gcc -x assembler -`, 
and you run `a.out`, it will exit with the status code `12`.

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