caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Documentation of the OCaml Lambda Intermediate Language
@ 2011-04-07 20:37 Arthur Peters
  2011-04-08 11:26 ` John Carr
  2011-04-09 14:54 ` Vincent Aravantinos
  0 siblings, 2 replies; 3+ messages in thread
From: Arthur Peters @ 2011-04-07 20:37 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 953 bytes --]

I am digging into the lambda language (as printed by -dlambda and as
represented by the types in bytecomp/lambda.ml). And it mostly makes sense
however I still have a constant stream of questions. So I was wondering: Is
there any internal documentation for the lambda IL?

The specific questions on my mind at the moment are:
1. How are types represented in the lambda IL? (they seem to be implicit but
it's not clear) This is especially an issue with polymorphic primitives like
"field" and "apply".
2. What do each of the operation (primitive and lambda) mean? What do they
do and what types to they imply (if that's handled that way)?

Just for some background I am a grad student in a compilers course and I am
looking to build a simple LLVM code generator that takes lambda and output
LLVM bytecode (allowing it to use all the fun JIT and optimization, etc
features of LLVM). Out of curiosity has this been attempted before?

Thanks a lot!
-Arthur

[-- Attachment #2: Type: text/html, Size: 1062 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Documentation of the OCaml Lambda Intermediate Language
  2011-04-07 20:37 [Caml-list] Documentation of the OCaml Lambda Intermediate Language Arthur Peters
@ 2011-04-08 11:26 ` John Carr
  2011-04-09 14:54 ` Vincent Aravantinos
  1 sibling, 0 replies; 3+ messages in thread
From: John Carr @ 2011-04-08 11:26 UTC (permalink / raw)
  To: Arthur Peters; +Cc: caml-list


>1. How are types represented in the lambda IL? (they seem to be implicit but
>it's not clear) This is especially an issue with polymorphic primitives like
>"field" and "apply".

They are implicit.  See "type erasure."  The type checker ensures
that no IL function operates on a value with the wrong type.

Given

	let f x = 3 lsl !x

the compiler generates

	(function x/1031 (lsl 3 (field 0 x/1031)))

It is impossible, if the type system is sound, for x/1031 to be
anything other than a pointer to a block and for the value in
field 0 of that block to be anything other than an integer.

The implementation depends on pointers and integers being the same size.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Documentation of the OCaml Lambda Intermediate Language
  2011-04-07 20:37 [Caml-list] Documentation of the OCaml Lambda Intermediate Language Arthur Peters
  2011-04-08 11:26 ` John Carr
@ 2011-04-09 14:54 ` Vincent Aravantinos
  1 sibling, 0 replies; 3+ messages in thread
From: Vincent Aravantinos @ 2011-04-09 14:54 UTC (permalink / raw)
  To: Arthur Peters; +Cc: caml-list

Hi,

Le 7 avr. 11 à 22:37, Arthur Peters a écrit :

> I am looking to build a simple LLVM code generator that takes lambda  
> and output LLVM bytecode (allowing it to use all the fun JIT and  
> optimization, etc features of LLVM). Out of curiosity has this been  
> attempted before?

The question of LLVM and ocaml has been raised quite a few times, see  
e.g.:

<http://groups.google.com/group/fa.caml/browse_thread/thread/284aff5210b4390e/8d62c4114f640e3e?lnk=gst&q=llvm#8d62c4114f640e3e 
 >
<http://groups.google.com/group/fa.caml/browse_thread/thread/6aff6222b6f0cdb8/6c21a4e75713ca22?lnk=gst&q=llvm#6c21a4e75713ca22 
 >

and more generally:

<http://groups.google.com/group/fa.caml/search?group=fa.caml&q=llvm>

Cheers,
V.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-09 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-07 20:37 [Caml-list] Documentation of the OCaml Lambda Intermediate Language Arthur Peters
2011-04-08 11:26 ` John Carr
2011-04-09 14:54 ` Vincent Aravantinos

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