[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-dev
Subject:    [LLVMdev] Ocaml bindings (and ExecutionEngine)
From:       Gordon Henriksen <gordonhenriksen () mac ! com>
Date:       2007-10-19 17:23:24
Message-ID: 4B93491E-6D2F-4E31-891A-8B91A4DCECFD () mac ! com
[Download RAW message or body]

On Oct 19, 2007, at 11:51, Jan Rehders wrote:

> this looks very promising. Do you have any plans to add bindings  
> for the use of an ExecutionEngine, especially  
> recompileAndRelinkFunction?

I'd considered it on the basis that others may find it useful, but I  
have no immediate need for it.

Patches are welcome. Binding a method is trivial:
     http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of- 
Mon-20071001/054282.html

And even binding a new library is straightforward:

1. Add C bindings for the desired functionality. (Strictly speaking,  
this is optional.)
     http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/ 
Analysis.h?view=markup&pathrev=42707
     http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ 
Analysis.cpp?view=markup&pathrev=42707

2. Copy up a bindings project.
     http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/ 
analysis/?pathrev=42707
     http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/ 
Makefile?r1=42707&r2=42706&pathrev=42707

3. And add tests for it.
     http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/ 
Ocaml/analysis.ml?view=markup&pathrev=42707

> I've build an interactive toplevel implemented in OCaml and I have  
> to pull of some stunts to be able to change the definition of a  
> function. (emit a .ll file containing the code, looking up the  
> function and calling removeBody, then reading the .ll file back in  
> using ParseAssemblyString). I noticed that functions are  
> represented as an llvalue which makes turning it into a Function*  
> unsafe if I'm correct?

Yes, llvalues are very weakly typed. If assertions are enabled in the  
LLVM build, then any misuses will be caught by the 'wrap' and  
'unwrap' helpers in the C bindings.

— Gordon


[Attachment #3 (unknown)]

<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; "><div><div>On Oct 19, 2007, at 11:51, Jan \
Rehders wrote:</div><br class="Apple-interchange-newline"><blockquote \
type="cite"><div>this looks very promising. Do you have any plans to add bindings for \
the use of an ExecutionEngine, especially \
recompileAndRelinkFunction?</div></blockquote><div><br \
class="webkit-block-placeholder"></div><div>I'd considered it on the basis that \
others may find it useful, but I have no immediate need for it.</div><div><br \
class="webkit-block-placeholder"></div><div>Patches are welcome. Binding a method is \
trivial:</div><div>    <a \
href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071001/054282.html \
">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071001/054282.html</a></div><div><br \
class="webkit-block-placeholder"></div><div>And even binding a new library is \
straightforward:</div><div><br class="webkit-block-placeholder"></div><div>1. Add C \
bindings for the desired functionality. (Strictly speaking, this is \
optional.)</div><div>    <a \
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Analysis.h?view=ma \
rkup&amp;pathrev=42707">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Analysis.h?view=markup&amp;pathrev=42707</a></div><div> \
<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?view \
=markup&amp;pathrev=42707">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Analysis.cpp?view=markup&amp;pathrev=42707</a></div><div><br \
class="webkit-block-placeholder"></div><div>2. Copy up a bindings \
project.</div><div><div>    <a \
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/?pathrev= \
42707">http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/?pathrev=42707</a></div><div> \
<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/Makefile?r1=427 \
07&amp;r2=42706&amp;pathrev=42707">http://llvm.org/viewvc/llvm-project/llvm/trunk/bind \
ings/ocaml/Makefile?r1=42707&amp;r2=42706&amp;pathrev=42707</a></div><br></div><div>3. \
And add tests for it.</div><div>    <a \
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/analysis.ml?v \
iew=markup&amp;pathrev=42707">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/analysis.ml?view=markup&amp;pathrev=42707</a></div><div><br \
class="webkit-block-placeholder"></div><blockquote type="cite"><div>I've build an \
interactive toplevel implemented in OCaml and I have to pull of some stunts to be \
able to change the definition of a function. (emit a .ll file containing the code, \
looking up the function and calling removeBody, then reading the .ll file back in \
using ParseAssemblyString). I noticed that functions are represented as an llvalue \
which makes turning it into a Function* unsafe if I'm \
correct?</div></blockquote><div><br class="webkit-block-placeholder"></div><div>Yes, \
llvalues are very weakly typed. If assertions are enabled in the LLVM build, then any \
misuses will be caught by the 'wrap' and 'unwrap' helpers in the C \
bindings.</div></div><div><span class="Apple-style-span" style="border-collapse: \
separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; \
font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; \
letter-spacing: normal; line-height: normal; text-align: auto; \
-khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: \
auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: \
0px; "><span class="Apple-style-span" style="border-collapse: separate; \
border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: \
12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: \
normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: \
none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: \
2; white-space: normal; widows: 2; word-spacing: 0px; "><span \
class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; \
color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; \
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: \
normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; \
-apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; \
widows: 2; word-spacing: 0px; "><span class="Apple-style-span" \
style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); \
font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; \
font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; \
-khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: \
auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: \
0px; "><span class="Apple-style-span" style="border-collapse: separate; \
border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: \
12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: \
normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: \
none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: \
2; white-space: normal; widows: 2; word-spacing: 0px; "><span \
class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; \
color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; \
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: \
normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; \
-apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; \
widows: 2; word-spacing: 0px; "><div><br class="khtml-block-placeholder"></div>— \
Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></span> \
</div><br></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic