caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Ocamlopt x86-32 and SSE2
Date: Mon, 11 May 2009 14:47:04 +0100	[thread overview]
Message-ID: <200905111447.05040.jon@ffconsultancy.com> (raw)
In-Reply-To: <90823c940905110143k2380b9e2r2ba0a79e6ff8d59e@mail.gmail.com>

On Monday 11 May 2009 09:43:59 Dmitry Bely wrote:
> So it's just pie in the sky. No working implementation has been
> demonstrated since then.

The file "test/CodeGen/Generic/GC/simple_ocaml.ll" in the LLVM 2.5 source 
distribution contains the following test code for the OCaml-compatible 
frametable emitter:

  %struct.obj = type { i8*, %struct.obj* }
  
  define %struct.obj* @fun(%struct.obj* %head) gc "ocaml" {
  entry:
          %gcroot.0 = alloca i8*
          %gcroot.1 = alloca i8*
          
          call void @llvm.gcroot(i8** %gcroot.0, i8* null)
          call void @llvm.gcroot(i8** %gcroot.1, i8* null)
          
          %local.0 = bitcast i8** %gcroot.0 to %struct.obj**
          %local.1 = bitcast i8** %gcroot.1 to %struct.obj**
  
          store %struct.obj* %head, %struct.obj** %local.0
          br label %bb.loop
  bb.loop:
          %t0 = load %struct.obj** %local.0
          %t1 = getelementptr %struct.obj* %t0, i32 0, i32 1
          %t2 = bitcast %struct.obj* %t0 to i8*
          %t3 = bitcast %struct.obj** %t1 to i8**
          %t4 = call i8* @llvm.gcread(i8* %t2, i8** %t3)
          %t5 = bitcast i8* %t4 to %struct.obj*
          %t6 = icmp eq %struct.obj* %t5, null
          br i1 %t6, label %bb.loop, label %bb.end
  bb.end:
          %t7 = malloc %struct.obj
          store %struct.obj* %t7, %struct.obj** %local.1
          %t8 = bitcast %struct.obj* %t7 to i8*
          %t9 = load %struct.obj** %local.0
          %t10 = getelementptr %struct.obj* %t9, i32 0, i32 1
          %t11 = bitcast %struct.obj* %t9 to i8*
          %t12 = bitcast %struct.obj** %t10 to i8**
          call void @llvm.gcwrite(i8* %t8, i8* %t11, i8** %t12)
          ret %struct.obj* %t7
  }
  
  declare void @llvm.gcroot(i8** %value, i8* %tag)
  declare void @llvm.gcwrite(i8* %value, i8* %obj, i8** %field)
  declare i8* @llvm.gcread(i8* %obj, i8** %field)

Compiling this with:

  llvm-as <simple_ocaml.ll | llc

gives:

          .file	"<stdin>"
          .text
          .globl	caml<stdin>__code_begin
  caml<stdin>__code_begin:
          .data
          .globl	caml<stdin>__data_begin
  caml<stdin>__data_begin:
  
          .text
          .align	16
          .globl	fun
          .type	fun,@function
  fun:
  .Leh_func_begin1:
  .Llabel1:
          subl	$12, %esp
          movl	$0, 8(%esp)
          movl	$0, 4(%esp)
          movl	16(%esp), %eax
          movl	%eax, 8(%esp)
          .align	16
  .LBB1_1:	# bb.loop
          movl	8(%esp), %eax
          cmpl	$0, 4(%eax)
          je	.LBB1_1	# bb.loop
  .LBB1_2:	# bb.end
          movl	$8, (%esp)
          call	malloc
  .Llabel2:
          movl	%eax, 4(%esp)
          movl	8(%esp), %ecx
          movl	%eax, 4(%ecx)
          addl	$12, %esp
          ret
          .size	fun, .-fun
  .Leh_func_end1:
          .section	.eh_frame,"aw",@progbits
  .LEH_frame0:
  .Lsection_eh_frame:
  .Leh_frame_common:
          .long	.Leh_frame_common_end-.Leh_frame_common_begin
  .Leh_frame_common_begin:
          .long	0x0
          .byte	0x1
          .asciz	"zR"
          .uleb128	1
          .sleb128	-4
          .byte	0x8
          .uleb128	1
          .byte	0x1B
          .byte	0xC
          .uleb128	4
          .uleb128	4
          .byte	0x88
          .uleb128	1
          .align	4
  .Leh_frame_common_end:
  
  .Lfun.eh:
          .long	.Leh_frame_end1-.Leh_frame_begin1
  .Leh_frame_begin1:
          .long	.Leh_frame_begin1-.Leh_frame_common
          .long	.Leh_func_begin1-.
          .long	.Leh_func_end1-.Leh_func_begin1
          .uleb128	0
          .byte	0xE
          .uleb128	16
          .byte	0x4
          .long	.Llabel1-.Leh_func_begin1
          .byte	0xD
          .uleb128	4
          .align	4
  .Leh_frame_end1:
  
          .text
          .globl	caml<stdin>__code_end
  caml<stdin>__code_end:
          .data
          .globl	caml<stdin>__data_end
  caml<stdin>__data_end:
          .long	0
          .globl	caml<stdin>__frametable
  caml<stdin>__frametable:
          # live roots for fun
          .long	.Llabel2
          .short	0xC
          .short	0x2
          .word	8
          .word	4
          .align	4
          .section	.note.GNU-stack,"",@progbits

So perhaps it is worth a look.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


  reply	other threads:[~2009-05-11 13:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090509100004.353ADBC5C@yquem.inria.fr>
2009-05-09 11:38 ` CUOQ Pascal
2009-05-10  1:52   ` [Caml-list] " Goswin von Brederlow
2009-05-10  2:16     ` Seo Sanghyeon
2009-05-10  3:50       ` Jon Harrop
2009-05-11  8:05         ` Dmitry Bely
2009-05-11  9:26           ` Jon Harrop
2009-05-11  8:43             ` Dmitry Bely
2009-05-11 13:47               ` Jon Harrop [this message]
2009-05-11  9:12             ` Andrey Riabushenko
2009-05-10  8:56     ` CUOQ Pascal
2009-05-10 14:47       ` [Caml-list] " Richard Jones
2009-05-10 19:25     ` Florian Weimer
     [not found] <20090511043120.976EBBC67@yquem.inria.fr>
2009-05-11  7:10 ` Pascal Cuoq
2009-05-12  9:37   ` [Caml-list] " Xavier Leroy
2009-05-12 12:40     ` Richard Jones
2009-05-13 22:30     ` Florian Weimer
2009-04-28 19:36 Ocamlopt code generator question Dmitry Bely
2009-05-05  9:24 ` [Caml-list] " Xavier Leroy
2009-05-05  9:41   ` Dmitry Bely
2009-05-08 10:21     ` [Caml-list] Ocamlopt x86-32 and SSE2 Xavier Leroy
2009-05-10 11:04       ` David MENTRE
2009-05-11  2:43         ` Jon Harrop
2009-05-10 23:12       ` Matteo Frigo
2009-05-11  2:45         ` Jon Harrop
2009-05-11  7:55       ` Dmitry Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200905111447.05040.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).