From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id C83B2BBAF for ; Wed, 24 Jun 2009 14:14:39 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEADG1QUrUnwdkbmdsb2JhbACCIJZODQgLCREGuRCECwU X-IronPort-AV: E=Sophos;i="4.42,282,1243807200"; d="scan'208";a="31848307" Received: from relay.pcl-ipout02.plus.net ([212.159.7.100]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Jun 2009 14:14:39 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQFAKi1QUrUnw6S/2dsb2JhbACCINAchAsF Received: from ptb-relay02.plus.net ([212.159.14.146]) by relay.pcl-ipout02.plus.net with ESMTP; 24 Jun 2009 13:14:39 +0100 Received: from [87.115.147.64] (helo=leper.local) by ptb-relay02.plus.net with esmtp (Exim) id 1MJRN8-0004xf-Ns for caml-list@yquem.inria.fr; Wed, 24 Jun 2009 13:14:38 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: New HLVM examples! Date: Wed, 24 Jun 2009 14:23:27 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906241423.27628.jon@ffconsultancy.com> X-Plusnet-Relay: 05f6f61b020978b4ce41687716bb76e8 X-Spam: no; 0.01; compiler:01 compiler:01 ocaml:01 ocaml-like:01 ocaml:01 native-code:01 2009:98 2.0:98 2.0:98 1.5:98 1.0:98 60%:98 frog:98 char:01 char:01 The HLVM project now includes two examples: a calculator and a tiny compiler: http://forge.ocamlcore.org/projects/hlvm/ The design and implementation of the compiler are described in detail in the latest OCaml Journal article: http://ocamlnews.blogspot.com/2009/06/compiler-development-part-1.html The compiler can execute the following OCaml-like program to print the Mandelbrot set: # let rec pixel((n, zr, zi, cr, ci) : int * float * float * float * float) : unit = if n = 65536 then print_char ' ' else if zr * zr + zi * zi >= 4.0 then print_char '.' else pixel(n+1, zr * zr - zi * zi + cr, 2.0 * zr * zi + ci, cr, ci);; # let rec row((i, j, n) : int * int * int) : unit = if i>n then () else begin let cr = 2.0 * float_of_int i / float_of_int n - 1.5 in let ci = 2.0 * float_of_int j / float_of_int n - 1.0 in pixel(0, 0.0, 0.0, cr, ci); row(i+1, j, n) end;; # let rec col((j, n) : int * int) : unit = if j>n then () else begin row(0, j, n); print_char '\n'; col(j+1, n) end;; # let rec mandelbrot(n : int) : unit = col(0, n);; # mandelbrot 77;; In particular, our compiler runs this program interactively 50x faster than the OCaml top-level and 60% faster than native-code compiled OCaml! Check out HLVM's SVN repository including these examples with: svn checkout svn://svn.forge.ocamlcore.org/svnroot/hlvm -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e