LLVM + Eclipse?

So, suppose I wanted to create an Eclipse plugin that could read an LLVM bitcode file. What would be the best way to bridge between the Java and C++ worlds? I thought about calling llvm-dis as a subprocess and then parsing the output, but that seems fragile to me. I’d rather deal with the API level if possible.

Hi Talin,

You'd still have to use Java to create the plugin and, unless you
write a new llvm-dis in Java, there no way you get a clean API.

AFAICS, What you can do is re-write llvm-dis (it's just a small cpp
file) but using JNI calls rather than the main(), and use that from
your plugin.

What are your goals with this plugin? It'd be nice to edit the IR,
send it to the back-end or JIT, compile it back to C and re-edit, for
code that is hard to optimize. But just visualizing the code would be
good enough, especially if you can select the optimization levels
seamlessly or even have three panels, one with each level to compare
(maybe using Eclipse's diff utility).

Looking forward to use the plugin! :wink:

cheers,
--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm

   

So, suppose I wanted to create an Eclipse plugin that could read an LLVM
bitcode file. What would be the best way to bridge between the Java and C++
worlds? I thought about calling llvm-dis as a subprocess and then parsing
the output, but that seems fragile to me. I'd rather deal with the API level
if possible.
     

Hi Talin,

You'd still have to use Java to create the plugin and, unless you
write a new llvm-dis in Java, there no way you get a clean API.

AFAICS, What you can do is re-write llvm-dis (it's just a small cpp
file) but using JNI calls rather than the main(), and use that from
your plugin.

What are your goals with this plugin? It'd be nice to edit the IR,
send it to the back-end or JIT, compile it back to C and re-edit, for
code that is hard to optimize. But just visualizing the code would be
good enough, especially if you can select the optimization levels
seamlessly or even have three panels, one with each level to compare
(maybe using Eclipse's diff utility).
   

Well, all I really want is some sort of tree-view of the global variables and functions, so that I can verify that my code generator is correct. Right now it's really hard to read the output of llvm-dis, especially the source-level debugging stuff.

(Another, perhaps easier option would be to simply write a pretty-printer mode for llvm-dis.)

That's tricky. The printout is hard-coded in "print()" methods all
over the place...

--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm