Added generated docs to svn.
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@7 8d1e9007-1d4e-0410-b67e-1979fd6579aa
68
www/web/about.html
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>About - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>About</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<div class="admonitionblock">
|
||||
<table><tr>
|
||||
<td class="icon">
|
||||
<img src="./images/icons/note.png" alt="Note" />
|
||||
</td>
|
||||
<td class="content">
|
||||
<div class="title"><em>llvm-py</em> Mission Statement</div>
|
||||
<p>Provide a simple, consistent and well-documented suite of APIs that
|
||||
exposes just enough of LLVM to write a compiler/VM in Python.</p>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<p><em>llvm-py</em> is developed by Mahadevan R, in his spare time, without being
|
||||
paid for it. He can be reached at <em>mdevan.foobar .at. gmail.com</em>, on the
|
||||
llvm-dev mailing list and irc.oftc.net#llvm (mdevan).</p>
|
||||
<p>These web pages were generated using the nifty tool
|
||||
<a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
63
www/web/contribute.html
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>Contribute - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>Contribute</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p><em>llvm-py</em> is just hatching. It needs your patches and suggestions to
|
||||
grow up. Please contribute! All patches are welcome.</p>
|
||||
<p>The <em>llvm-py</em> code is hosted on a google code project by the same name,
|
||||
<a href="http://code.google.com/p/llvm-py/">here</a>. It provides the SVN repository
|
||||
and a <a href="http://code.google.com/p/llvm-py/issues/list">bug tracker</a>. The
|
||||
latest code can be checked out from SVN like so:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ svn checkout http://llvm-py.googlecode.com/svn/trunk/ llvm-py</tt></pre>
|
||||
</div></div>
|
||||
<p>You can browse the source online at:
|
||||
<a href="http://code.google.com/p/llvm-py/source/browse">http://code.google.com/p/llvm-py/source/browse</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
260
www/web/download.html
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>Download and Setup - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>Download and Setup</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p>The latest release is 0.2, released xx-Jun-2008 (full <a href="#changelog">Changelog</a>
|
||||
below).</p>
|
||||
<p>Download it here:</p>
|
||||
<div class="tableblock">
|
||||
<table rules="all"
|
||||
frame="border"
|
||||
cellspacing="0" cellpadding="4">
|
||||
<col width="200" />
|
||||
<col width="200" />
|
||||
<col width="200" />
|
||||
<col width="200" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">
|
||||
Release
|
||||
</th>
|
||||
<th align="left">
|
||||
Date
|
||||
</th>
|
||||
<th align="left">
|
||||
Package
|
||||
</th>
|
||||
<th align="left">
|
||||
Mirror
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr>
|
||||
<td align="left">
|
||||
0.2
|
||||
</td>
|
||||
<td align="left">
|
||||
xx-Jun-2008
|
||||
</td>
|
||||
<td align="left">
|
||||
<a href="http://llvm-py.googlecode.com/files/llvm-py-0.2.tar.bz2">llvm-py-0.2.tar.bz2</a>
|
||||
</td>
|
||||
<td align="left">
|
||||
<a href="llvm-py-0.2.tar.bz2">llvm-py-0.2.tar.bz2</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
0.1
|
||||
</td>
|
||||
<td align="left">
|
||||
20-May-2008
|
||||
</td>
|
||||
<td align="left">
|
||||
<a href="http://llvm-py.googlecode.com/files/llvm-py-0.1.tar.bz2">llvm-py-0.1.tar.bz2</a>
|
||||
</td>
|
||||
<td align="left">
|
||||
<a href="llvm-py-0.1.tar.bz2">llvm-py-0.1.tar.bz2</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Bleeding Edge</h2>
|
||||
<div class="sectionbody">
|
||||
<p>The latest code can be checked out from SVN thusly:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ svn checkout http://llvm-py.googlecode.com/svn/trunk/ llvm-py</tt></pre>
|
||||
</div></div>
|
||||
<p>Happy hacking, and please send in your patches.</p>
|
||||
</div>
|
||||
<h2>Setting Up</h2>
|
||||
<div class="sectionbody">
|
||||
<p>Follow these steps to get <em>llvm-py</em> up and running:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
<a href="#uninstall">Uninstall</a> any previous version of <em>llvm-py</em>.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Get and build LLVM.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Optionally, install it.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Get the latest release (see above) of <em>llvm-py</em> and untar it:
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ wget http://link/llvm-py-0.2.tar.bz2
|
||||
$ tar jxvf llvm-py-0.2.tar.bz2</tt></pre>
|
||||
</div></div>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
If you've installed LLVM, setup <em>llvm-py</em> like this:
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ cd llvm-py-0.2
|
||||
$ sudo python setup.py install</tt></pre>
|
||||
</div></div>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
If you haven't installed LLVM, locate the executable <tt>llvm-config</tt>
|
||||
under your LLVM build directory (should be something like
|
||||
<tt>/home/mdevan/llvm/Release/bin/llvm-config</tt>) and pass this to setup.py:
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ cd llvm-py-0.2
|
||||
$ sudo python setup.py install --llvm-config=/path/to/llvm-config</tt></pre>
|
||||
</div></div>
|
||||
<p>That's it!</p>
|
||||
<div class="title">Notes:</div><ul>
|
||||
<li>
|
||||
<p>
|
||||
<em>setup.py</em> is a standard Python distutils script. See the Python
|
||||
documentation regarding
|
||||
<a href="http://docs.python.org/inst/inst.html">Installing Python Modules</a> and
|
||||
<a href="http://docs.python.org/dist/dist.html">Distributing Python Modules</a> for
|
||||
more information on such scripts.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
To build the debug version, build with the <tt>-g</tt> flag and the debug
|
||||
version of llvm-config:
|
||||
</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ python setup.py build -g --llvm-config=/path/to/Debug/bin/llvm-config
|
||||
$ sudo python setup.py install</tt></pre>
|
||||
</div></div>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Debug binaries are <em>huge</em>! (65 MB+)
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
If --llvm-config is not specified, <tt>setup.py</tt> looks for
|
||||
<tt>llvm-config</tt> in the <tt>PATH</tt>, which will succeed if LLVM is installed.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2><a id="uninstall"></a>Uninstall</h2>
|
||||
<div class="sectionbody">
|
||||
<p>To get rid of llvm-py completely, if you wish to do so:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt># rm -rf /usr/lib/python2.5/site-packages/llvm
|
||||
# rm -f /usr/lib/python2.5/site-packages/llvm_py-0.1.egg-info</tt></pre>
|
||||
</div></div>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
You need to be root to do this.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Paths are for debian-based systems, in other distros it might be different.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Note that there is a version number in the egg file name.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2><a id="changelog"></a>Changelog</h2>
|
||||
<div class="sectionbody">
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>0.1, 10-May-2008:
|
||||
|
||||
* Initial release.
|
||||
|
||||
|
||||
0.2, ongoing:
|
||||
|
||||
* Independent package, need not be unpacked into llvm/bindings
|
||||
* Modules can be dumped to a string
|
||||
* Modules can be verified
|
||||
* Module.global_variables, Module.functions, Function.args,
|
||||
Function.basic_blocks and BasicBlock.instructions are
|
||||
now proper iterators (generators in fact) than plain lists
|
||||
|
||||
* MemoryBuffer is done
|
||||
* TypeHandle is done
|
||||
* Unit tester added (but doesn't do much for now)
|
||||
</tt></pre>
|
||||
</div></div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
114
www/web/examples.html
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>Examples - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>Examples</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p>Here's an example:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content"><!-- Generator: GNU source-highlight 2.4
|
||||
by Lorenzo Bettini
|
||||
http://www.lorenzobettini.it
|
||||
http://www.gnu.org/software/src-highlite -->
|
||||
<pre><tt><span style="font-style: italic"><span style="color: #9A1900">#!/usr/bin/env python</span></span>
|
||||
|
||||
<span style="font-weight: bold"><span style="color: #000080">from</span></span> llvm<span style="color: #990000">.</span>core <span style="font-weight: bold"><span style="color: #000080">import</span></span> <span style="color: #990000">*</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900">## create a module</span></span>
|
||||
module <span style="color: #990000">=</span> <span style="color: #009900">Module</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">new</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"my_module"</span><span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900">## create a function type taking two doubles and returning a (32-bit) integer</span></span>
|
||||
ty<span style="color: #009900">_</span>double <span style="color: #990000">=</span> <span style="color: #009900">Type</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">double</span></span><span style="color: #990000">()</span>
|
||||
ty<span style="color: #009900">_</span>int <span style="color: #990000">=</span> <span style="color: #009900">Type</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">int</span></span><span style="color: #990000">()</span>
|
||||
ty<span style="color: #009900">_</span>func <span style="color: #990000">=</span> <span style="color: #009900">Type</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span> ty<span style="color: #009900">_</span>int<span style="color: #990000">,</span> <span style="color: #990000">[</span> ty<span style="color: #009900">_</span>double<span style="color: #990000">,</span> ty<span style="color: #009900">_</span>double <span style="color: #990000">]</span> <span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900">## create a function of this type</span></span>
|
||||
func <span style="color: #990000">=</span> <span style="color: #009900">Function</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">new</span></span><span style="color: #990000">(</span> module<span style="color: #990000">,</span> ty<span style="color: #009900">_</span>func<span style="color: #990000">,</span> <span style="color: #FF0000">"foobar"</span> <span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># name function args</span></span>
|
||||
func<span style="color: #990000">.</span>args<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">].</span>name <span style="color: #990000">=</span> <span style="color: #FF0000">"arg1"</span>
|
||||
func<span style="color: #990000">.</span>args<span style="color: #990000">[</span><span style="color: #993399">1</span><span style="color: #990000">].</span>name <span style="color: #990000">=</span> <span style="color: #FF0000">"arg2"</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900">## implement the function</span></span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># add a basic block</span></span>
|
||||
entry <span style="color: #990000">=</span> func<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">append_basic_block</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"entry"</span><span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># create an llvm::IRBuilder</span></span>
|
||||
builder <span style="color: #990000">=</span> <span style="color: #009900">Builder</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">new</span></span><span style="color: #990000">()</span>
|
||||
builder<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">position_at_end</span></span><span style="color: #990000">(</span>entry<span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># add two args into tmp1</span></span>
|
||||
tmp1 <span style="color: #990000">=</span> builder<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">add</span></span><span style="color: #990000">(</span>func<span style="color: #990000">.</span>args<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">],</span> func<span style="color: #990000">.</span>args<span style="color: #990000">[</span><span style="color: #993399">1</span><span style="color: #990000">],</span> <span style="color: #FF0000">"tmp1"</span><span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># sub `1' from that</span></span>
|
||||
one <span style="color: #990000">=</span> <span style="color: #009900">Constant</span><span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">real</span></span><span style="color: #990000">(</span> ty<span style="color: #009900">_</span>double<span style="color: #990000">,</span> <span style="color: #993399">1.0</span> <span style="color: #990000">)</span>
|
||||
tmp2 <span style="color: #990000">=</span> builder<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">sub</span></span><span style="color: #990000">(</span>tmp1<span style="color: #990000">,</span> one<span style="color: #990000">,</span> <span style="color: #FF0000">"tmp2"</span><span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># convert to integer</span></span>
|
||||
tmp3 <span style="color: #990000">=</span> builder<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">fptoui</span></span><span style="color: #990000">(</span>tmp2<span style="color: #990000">,</span> ty<span style="color: #009900">_</span>int<span style="color: #990000">,</span> <span style="color: #FF0000">"tmp3"</span><span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># return it</span></span>
|
||||
builder<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">ret</span></span><span style="color: #990000">(</span>tmp3<span style="color: #990000">)</span>
|
||||
|
||||
<span style="font-style: italic"><span style="color: #9A1900"># dump the module to see the llvm "assembly" code</span></span>
|
||||
<span style="font-weight: bold"><span style="color: #0000FF">print</span></span> module
|
||||
</tt></pre></div></div>
|
||||
<p>which gives this output:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>; ModuleID = 'my_module'
|
||||
|
||||
define i32 @foobar(double %arg1, double %arg2) {
|
||||
entry:
|
||||
%temp1 = add double %arg1, %arg2 ; <double> [#uses=1]
|
||||
%temp2 = sub double %temp1, 1.000000e+00 ; <double> [#uses=1]
|
||||
%temp3 = fptoui double %temp2 to i32 ; <i32> [#uses=1]
|
||||
ret i32 %temp3
|
||||
}</tt></pre>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
BIN
www/web/images/icons/callouts/1.png
Normal file
|
After Width: | Height: | Size: 329 B |
BIN
www/web/images/icons/callouts/10.png
Normal file
|
After Width: | Height: | Size: 361 B |
BIN
www/web/images/icons/callouts/11.png
Normal file
|
After Width: | Height: | Size: 565 B |
BIN
www/web/images/icons/callouts/12.png
Normal file
|
After Width: | Height: | Size: 617 B |
BIN
www/web/images/icons/callouts/13.png
Normal file
|
After Width: | Height: | Size: 623 B |
BIN
www/web/images/icons/callouts/14.png
Normal file
|
After Width: | Height: | Size: 411 B |
BIN
www/web/images/icons/callouts/15.png
Normal file
|
After Width: | Height: | Size: 640 B |
BIN
www/web/images/icons/callouts/2.png
Normal file
|
After Width: | Height: | Size: 353 B |
BIN
www/web/images/icons/callouts/3.png
Normal file
|
After Width: | Height: | Size: 350 B |
BIN
www/web/images/icons/callouts/4.png
Normal file
|
After Width: | Height: | Size: 345 B |
BIN
www/web/images/icons/callouts/5.png
Normal file
|
After Width: | Height: | Size: 348 B |
BIN
www/web/images/icons/callouts/6.png
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
www/web/images/icons/callouts/7.png
Normal file
|
After Width: | Height: | Size: 344 B |
BIN
www/web/images/icons/callouts/8.png
Normal file
|
After Width: | Height: | Size: 357 B |
BIN
www/web/images/icons/callouts/9.png
Normal file
|
After Width: | Height: | Size: 357 B |
BIN
www/web/images/icons/caution.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
www/web/images/icons/example.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
www/web/images/icons/home.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
www/web/images/icons/important.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
www/web/images/icons/next.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
www/web/images/icons/note.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
www/web/images/icons/prev.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
www/web/images/icons/tip.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
www/web/images/icons/up.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
www/web/images/icons/warning.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
75
www/web/index.html
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>llvm-py: Python Bindings for LLVM - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>llvm-py: Python Bindings for LLVM</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p><em>llvm-py</em> provides <a href="http://www.python.org/">Python</a> bindings for
|
||||
<a href="http://llvm.org/">LLVM</a>. It currently provides APIs to build the in-memory IR
|
||||
(intermediate representation) and to dump it. Execution engine and related APIs
|
||||
should appear soon.</p>
|
||||
<p><em>llvm-py</em> is a set of Python-based and C-based Python modules. It makes use of
|
||||
llvm-c, the C binding for LLVM. It is based on the latest SVN version of LLVM
|
||||
(and will not work on 2.2). It has been tested only with Python 2.5, although
|
||||
it should be usable with 2.4 also. I've built and tested it only on Linux/i386
|
||||
machines.</p>
|
||||
<p>Download links, setup help and changelog are on the
|
||||
<a href="download.html">download</a> page.</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2>News</h2>
|
||||
<div class="sectionbody">
|
||||
<dl>
|
||||
<dt>
|
||||
20-May-2008
|
||||
</dt>
|
||||
<dd>
|
||||
<p>
|
||||
0.1 released.
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
87
www/web/license.html
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>License - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>License</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p><em>llvm-py</em> is distributed under the
|
||||
<a href="http://www.opensource.org/licenses/bsd-license.php">new BSD license</a>.
|
||||
This is similar to LLVM's license. You should be able to use <em>llvm-py</em>
|
||||
where-ever and how-ever you're able to use LLVM itself.</p>
|
||||
<p>The license text is present in the
|
||||
<a href="http://code.google.com/p/llvm-py/source/browse/trunk/LICENSE">LICENSE</a>
|
||||
file in the distribution, and is reproduced here:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>Copyright (c) 2008, Mahadevan R All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Mahadevan R, llvm-py nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</tt></pre>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
67
www/web/style/layout.css
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
body {
|
||||
background-color: white;
|
||||
margin: 1%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
#layout-banner {
|
||||
background-color: #73a0c5;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
text-align: left;
|
||||
padding: 0.8em 20px;
|
||||
}
|
||||
|
||||
#layout-title {
|
||||
font-family: monospace;
|
||||
font-size: 3.5em;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.2em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#layout-description {
|
||||
font-size: 1.2em;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
#layout-menu {
|
||||
background-color: #f4f4f4;
|
||||
border-right: 3px solid #eeeeee;
|
||||
padding-top: 0.8em;
|
||||
padding-left: 20px;
|
||||
padding-right: 0.8em;
|
||||
font-size: 1.1em;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
#layout-menu a {
|
||||
line-height: 2em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
#layout-menu a:link, #layout-menu a:visited, #layout-menu a:hover {
|
||||
color: #527bbd;
|
||||
text-decoration: none;
|
||||
}
|
||||
#layout-menu a:hover {
|
||||
color: navy;
|
||||
text-decoration: none;
|
||||
}
|
||||
#layout-menu #page-source {
|
||||
border-top: 2px solid silver;
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
#layout-content {
|
||||
margin-left: 1.0em;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
@media print {
|
||||
#layout-banner { display: none; }
|
||||
#layout-menu { display: none; }
|
||||
}
|
||||
18
www/web/style/xhtml11-manpage.css
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* Overrides for manpage documents */
|
||||
h1 {
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
border-top: 2px solid silver;
|
||||
border-bottom: 2px solid silver;
|
||||
}
|
||||
h2 {
|
||||
border-style: none;
|
||||
}
|
||||
div.sectionbody {
|
||||
margin-left: 5%;
|
||||
}
|
||||
|
||||
@media print {
|
||||
div#toc { display: none; }
|
||||
}
|
||||
|
||||
40
www/web/style/xhtml11-quirks.css
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* Workarounds for IE6's broken and incomplete CSS2. */
|
||||
|
||||
div.sidebar-content {
|
||||
background: #ffffee;
|
||||
border: 1px solid silver;
|
||||
padding: 0.5em;
|
||||
}
|
||||
div.sidebar-title, div.image-title {
|
||||
color: #527bbd;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
margin-top: 0.0em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
div.listingblock div.content {
|
||||
border: 1px solid silver;
|
||||
background: #f4f4f4;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.quoteblock-content {
|
||||
padding-left: 2.0em;
|
||||
}
|
||||
|
||||
div.exampleblock-content {
|
||||
border-left: 2px solid silver;
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
/* IE6 sets dynamically generated links as visited. */
|
||||
div#toc a:visited { color: blue; }
|
||||
|
||||
/* Because IE6 child selector is broken. */
|
||||
div.olist2 ol {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
div.olist2 div.olist ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
276
www/web/style/xhtml11.css
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
/* Debug borders */
|
||||
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
|
||||
/*
|
||||
border: 1px solid red;
|
||||
*/
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 1em 5% 1em 5%;
|
||||
}
|
||||
|
||||
a {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:visited {
|
||||
color: fuchsia;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
color: navy;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
color: #083194;
|
||||
}
|
||||
|
||||
tt {
|
||||
color: navy;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #527bbd;
|
||||
font-family: sans-serif;
|
||||
margin-top: 1.2em;
|
||||
margin-bottom: 0.5em;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
border-bottom: 2px solid silver;
|
||||
}
|
||||
h2 {
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
h3 {
|
||||
float: left;
|
||||
}
|
||||
h3 + * {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
div.sectionbody {
|
||||
font-family: serif;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 1px solid silver;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
ul, ol, li > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
span#author {
|
||||
color: #527bbd;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
span#email {
|
||||
}
|
||||
span#revision {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div#footer {
|
||||
font-family: sans-serif;
|
||||
font-size: small;
|
||||
border-top: 2px solid silver;
|
||||
padding-top: 0.5em;
|
||||
margin-top: 4.0em;
|
||||
}
|
||||
div#footer-text {
|
||||
float: left;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
div#footer-badges {
|
||||
float: right;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
div#preamble,
|
||||
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
|
||||
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
|
||||
div.admonitionblock {
|
||||
margin-right: 10%;
|
||||
margin-top: 1.5em;
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
div.admonitionblock {
|
||||
margin-top: 2.5em;
|
||||
margin-bottom: 2.5em;
|
||||
}
|
||||
|
||||
div.content { /* Block element content. */
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Block element titles. */
|
||||
div.title, caption.title {
|
||||
color: #527bbd;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
margin-top: 1.0em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
div.title + * {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
td div.title:first-child {
|
||||
margin-top: 0.0em;
|
||||
}
|
||||
div.content div.title:first-child {
|
||||
margin-top: 0.0em;
|
||||
}
|
||||
div.content + div.title {
|
||||
margin-top: 0.0em;
|
||||
}
|
||||
|
||||
div.sidebarblock > div.content {
|
||||
background: #ffffee;
|
||||
border: 1px solid silver;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.listingblock {
|
||||
margin-right: 0%;
|
||||
}
|
||||
div.listingblock > div.content {
|
||||
border: 1px solid silver;
|
||||
background: #f4f4f4;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.quoteblock > div.content {
|
||||
padding-left: 2.0em;
|
||||
}
|
||||
|
||||
div.attribution {
|
||||
text-align: right;
|
||||
}
|
||||
div.verseblock + div.attribution {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.admonitionblock .icon {
|
||||
vertical-align: top;
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
color: #527bbd;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
div.admonitionblock td.content {
|
||||
padding-left: 0.5em;
|
||||
border-left: 2px solid silver;
|
||||
}
|
||||
|
||||
div.exampleblock > div.content {
|
||||
border-left: 2px solid silver;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.verseblock div.content {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
div.imageblock div.content { padding-left: 0; }
|
||||
div.imageblock img { border: 1px solid silver; }
|
||||
span.image img { border-style: none; }
|
||||
|
||||
dl {
|
||||
margin-top: 0.8em;
|
||||
margin-bottom: 0.8em;
|
||||
}
|
||||
dt {
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0;
|
||||
font-style: normal;
|
||||
}
|
||||
dd > *:first-child {
|
||||
margin-top: 0.1em;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
list-style-position: outside;
|
||||
}
|
||||
div.olist > ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
div.olist2 > ol {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
div.tableblock > table {
|
||||
border: 3px solid #527bbd;
|
||||
}
|
||||
thead {
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
tfoot {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.hlist {
|
||||
margin-top: 0.8em;
|
||||
margin-bottom: 0.8em;
|
||||
}
|
||||
div.hlist td {
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
td.hlist1 {
|
||||
vertical-align: top;
|
||||
font-style: normal;
|
||||
padding-right: 0.8em;
|
||||
}
|
||||
td.hlist2 {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
@media print {
|
||||
div#footer-badges { display: none; }
|
||||
}
|
||||
|
||||
div#toctitle {
|
||||
color: #527bbd;
|
||||
font-family: sans-serif;
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
margin-top: 1.0em;
|
||||
margin-bottom: 0.1em;
|
||||
}
|
||||
|
||||
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
div.toclevel2 {
|
||||
margin-left: 2em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
div.toclevel3 {
|
||||
margin-left: 4em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
div.toclevel4 {
|
||||
margin-left: 6em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
357
www/web/userguide.html
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="generator" content="AsciiDoc 8.2.2" />
|
||||
<meta name="description" content="Text based document generation" />
|
||||
<meta name="keywords" content="text to HTML, text to DocBook, text to XML, AsciiDoc" />
|
||||
<link rel="stylesheet" href="style/xhtml11.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/xhtml11-quirks.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style/layout.css" type="text/css" />
|
||||
<title>llvm-py User Guide - llvm-py</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout-banner">
|
||||
<div id="layout-title">llvm-py</div>
|
||||
<div id="layout-description">Python Bindings for LLVM</div>
|
||||
</div>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td id="layout-menu">
|
||||
<div>»<a href="index.html">Home</a></div>
|
||||
<div>»<a href="examples.html">Examples</a></div>
|
||||
<div>»<a href="download.html">Download</a></div>
|
||||
<div>»<a href="userguide.html">User Guide</a></div>
|
||||
<div>»<a href="contribute.html">Contribute</a></div>
|
||||
<div>»<a href="license.html">License</a></div>
|
||||
<div>»<a href="about.html">About</a></div>
|
||||
<div id="page-source">»<a href="http://www.python.org/">Python</a></div>
|
||||
<div>»<a href="http://llvm.org/">LLVM</a></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="layout-content">
|
||||
<div id="header">
|
||||
<h1>llvm-py User Guide</h1>
|
||||
</div>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<p><em>llvm-py</em> provides Python bindings for LLVM. This document explains how
|
||||
you can setup and use it. A working knowledge of Python and a basic idea
|
||||
of LLVM is assumed.</p>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Introduction</h2>
|
||||
<div class="sectionbody">
|
||||
<p><a href="http://www.llvm.org/">LLVM</a> (Low-Level Virtual Machine) provides enough
|
||||
infrastructure to use it as the backend for your compiled, or
|
||||
JIT-compiled language. It provides extensive optimization support, and
|
||||
static and dynamic (JIT) backends for many platforms. See the website at
|
||||
<a href="http://www.llvm.org/">http://www.llvm.org/</a> to discover more.</p>
|
||||
<p>Python bindings for LLVM provides a gentler learning curve for working
|
||||
with the LLVM APIs. It should also prove easier to create working
|
||||
prototypes and experimental languages using this medium.</p>
|
||||
<div class="title">License</div>
|
||||
<p>Both LLVM and <em>llvm-py</em> are distributed under (different) permissive
|
||||
open source licenses. <em>llvm-py</em> uses the
|
||||
<a href="http://opensource.org/licenses/bsd-license.php">new BSD license</a>. More
|
||||
information is available <a href="license.html">here</a>.</p>
|
||||
<div class="title">Platforms</div>
|
||||
<p>Currently, <em>llvm-py</em> has been built and tested only on Linux/x86. However,
|
||||
it should be trivial to build it on other unices. Windows is not
|
||||
supported, for a variety of reasons.</p>
|
||||
<div class="title">Versions</div>
|
||||
<p>As of now, <em>llvm-py</em> requires the latest SVN version of LLVM. It will
|
||||
not work with version 2.2 of LLVM. However, 2.3 should be release soon,
|
||||
and <em>llvm-py</em> should work with stock 2.3 LLVM.</p>
|
||||
<p><em>llvm-py</em> has been built and tested with Python 2.5. It should work with
|
||||
Python 2.4, with minimal changes, if any.</p>
|
||||
</div>
|
||||
<h2>Installation</h2>
|
||||
<div class="sectionbody">
|
||||
<p><em>llvm-py</em> is distributed as a source tarball. You'll need to build and
|
||||
install it before it can be used. At least the following will be
|
||||
required for this:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
compilers, both gcc and g++
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Python itself
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Python development files (headers and libraries)
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
LLVM, either installed or built
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>On debian-based systems, the first three can be installed with the
|
||||
command `sudo apt-get install gcc g++ python python-dev'. Note that
|
||||
ubuntu repository has an old version of llvm (1.8) which will not work
|
||||
with <em>llvm-py</em>.</p>
|
||||
<h3>llvm-config</h3>
|
||||
<p>Inorder to build llvm-py, it's build script needs to know from where to
|
||||
invoke the llvm helper program, <tt>llvm-config</tt>. If you've installed LLVM,
|
||||
then this will be available in your <tt>PATH</tt>, and nothing further needs to
|
||||
be done. If you've built LLVM yourself, or for any reason <tt>llvm-config</tt>
|
||||
is not in your <tt>PATH</tt>, you'll need to pass the full path of
|
||||
<tt>llvm-config</tt> to the build script.</p>
|
||||
<h3>Steps</h3>
|
||||
<p>The commands illustrated below assume that the LLVM source is available
|
||||
under <tt>/home/mdevan/llvm</tt>. If you've a previous version of llvm-py
|
||||
installed, you must remove it first, as described
|
||||
<a href="#uninstall">below</a>.</p>
|
||||
<p>If you have <tt>llvm-config</tt> in your path, you can build and install
|
||||
llvm-py this way:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ tar jxvf llvm-py-0.2.tar.bz2
|
||||
$ cd llvm-py-0.2
|
||||
$ sudo python setup.py install</tt></pre>
|
||||
</div></div>
|
||||
<p>If you need to tell the build script where <tt>llvm-config</tt> is, do it this
|
||||
way:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ tar jxvf llvm-py-0.2.tar.bz2
|
||||
$ cd llvm-py-0.2
|
||||
$ sudo python setup.py install --llvm-config=/home/mdevan/llvm/Release/bin/llvm-config</tt></pre>
|
||||
</div></div>
|
||||
<p>To build a debug version of llvm-py, that links against the debug
|
||||
libraries of LLVM, use this:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>$ tar jxvf llvm-py-0.2.tar.bz2
|
||||
$ cd llvm-py-0.2
|
||||
$ python setup.py build -g --llvm-config=/home/mdevan/llvm/Debug/bin/llvm-config
|
||||
$ sudo python setup.py install -g --llvm-config=/home/mdevan/llvm/Debug/bin/llvm-config</tt></pre>
|
||||
</div></div>
|
||||
<p>Be warned that debug binaries will be huge (65MB+) !</p>
|
||||
<h3><a id="uninstall"></a>Uninstall</h3>
|
||||
<p>To get rid of llvm-py completely, if you wish to do so:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt># rm -rf /usr/lib/python2.5/site-packages/llvm
|
||||
# rm -f /usr/lib/python2.5/site-packages/llvm_py-0.1.egg-info</tt></pre>
|
||||
</div></div>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
You need to be root to do this.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Paths are for debian-based systems, in other distros it might be different.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
Note that there are version numbers (both Python's and llvm-py's)
|
||||
which you might need to change to suit your system.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2>The Concepts</h2>
|
||||
<div class="sectionbody">
|
||||
<p>This section explains a few concepts related to LLVM.</p>
|
||||
<h3>Intermediate Representation</h3>
|
||||
<p>The intermediate representation, or IR for short, is an in-memory data
|
||||
structure that represents executable code. The IR data structures allow
|
||||
for creation of types, constants, functions, function arguments,
|
||||
instructions, global variables and so on. For example, to create a
|
||||
function <em>sum</em> that takes two integers and returns their sum, we need to
|
||||
follow these steps:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
create an integer type <em>ti</em> of required bitwidth
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
create a function type <em>tf</em> which takes two <em>ti</em> -s and returns
|
||||
another <em>ti</em>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
create a function of type <em>tf</em> named <em>sum</em>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
add a <em>basic block</em> to the function
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
using a helper object called an <em>instruction builder</em>, add two
|
||||
instructions into the basic block:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
<p>
|
||||
an instruction to add the two arguments and store the result into
|
||||
a temporary variable
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
a return instruction to return the value of the temporary variable
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul>
|
||||
<p>(A basic block is a block of instructions.)</p>
|
||||
<p>LLVM has it's own instruction set; the instructions used above (<tt>add</tt>
|
||||
and <tt>ret</tt>) are from this set. The LLVM instructions are at a higher
|
||||
level than the usual assembly language; for example there are
|
||||
instructions related to variable argument handling, exception handling,
|
||||
and garbage collection. These allow high-level languages to be
|
||||
represented cleanly in the IR.</p>
|
||||
<p>The full set of instructions are:</p>
|
||||
<p>TODO</p>
|
||||
<h3>SSA Form and PHI Nodes</h3>
|
||||
<p>All LLVM instructions are represented in the <em>Static Single Assignment</em>
|
||||
(SSA) form. Essentially, this means that any variable can be assigned to
|
||||
only once. Such a representation facilitates better optimization, among
|
||||
other benefits.</p>
|
||||
<p>A consequence of single assignment are PHI (Φ) nodes. These
|
||||
are required when a variable can be assigned a different value based on
|
||||
the path of control flow. For example, the value of <tt>b</tt> at the end of
|
||||
execution of the snippet below:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>a = 1;
|
||||
if (v < 10)
|
||||
a = 2;
|
||||
b = a;</tt></pre>
|
||||
</div></div>
|
||||
<p>cannot be determined statically. The value of <em>2</em> cannot be assigned to
|
||||
the <em>original</em> <tt>a</tt>, since <tt>a</tt> can be assigned to only once. There are
|
||||
two <tt>a</tt> 's in there, and the last assignment has to choose between which
|
||||
version to pick. This is accomplished by adding a PHI node:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt>a1 = 1;
|
||||
if (v < 10)
|
||||
a2 = 2;
|
||||
b = PHI(a1, a2);</tt></pre>
|
||||
</div></div>
|
||||
<p>The PHI node selects <tt>a1</tt> or <tt>a2</tt>, depending on where the control
|
||||
reached the PHI node. The argument <tt>a1</tt> of the PHI node is associated
|
||||
with the block <tt>"a1 = 1;"</tt> and <tt>a2</tt> with the block <tt>"a2 = 2;"</tt>.</p>
|
||||
<p>PHI nodes have to be explicitly created in the LLVM IR. The LLVM
|
||||
instruction set therefore has an instruction called <em>phi</em>.</p>
|
||||
<h3>LLVM Assembly Language</h3>
|
||||
<p>The LLVM IR can be represented offline in two formats
|
||||
- a textual, human-readable form, similar to assembly language, called
|
||||
the LLVM assembly language (files with .ll extension) (XXX ?)
|
||||
- a binary form, called the LLVM bitcode (files with .bc extension)
|
||||
All three formats (the in-memory IR, the LLVM assembly language and the
|
||||
LLVM bitcode) represent the <em>same</em> information. Each format can be
|
||||
converted into the other two formats (using LLVM APIs).</p>
|
||||
<p>The <a href="http://www.llvm.org/demo/">LLVM demo page</a> lets you type in C or C++
|
||||
code, converts it into LLVM IR and outputs the IR as LLVM assembly
|
||||
language code.</p>
|
||||
<p>Here's a function in C, that calculates the sum of the first <em>n</em>
|
||||
fibonacci numbers:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content"><!-- Generator: GNU source-highlight 2.4
|
||||
by Lorenzo Bettini
|
||||
http://www.lorenzobettini.it
|
||||
http://www.gnu.org/software/src-highlite -->
|
||||
<pre><tt><span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">fibsum</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> n<span style="color: #990000">)</span>
|
||||
<span style="color: #FF0000">{</span>
|
||||
<span style="color: #FF0000">}</span>
|
||||
</tt></pre></div></div>
|
||||
<p>And here's the corresponding LLVM assembly listing, as provided by the
|
||||
demo page:</p>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre><tt></tt></pre>
|
||||
</div></div>
|
||||
<p>Note the … TODO …</p>
|
||||
<p>The <a href="http://www.llvm.org/docs/LangRef.html">LLVM Language Reference</a>
|
||||
defines the LLVM assembly language including the entire instruction set.</p>
|
||||
<h3>Modules</h3>
|
||||
<p>Modules, in the LLVM IR, are similar to a single <em>C</em> language source
|
||||
file (.c file). A module contains:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
functions (declarations and definitions)
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
global variables and constants
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
global type aliases (typedef-s)
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Modules are top-level containers; all executable code representation is
|
||||
contained within modules.</p>
|
||||
<h3>Optimization and Passes</h3>
|
||||
<p>LLVM provides quite a few optimization algorithms that work on the IR.
|
||||
These algorithms are organized as <em>passes</em>. Each pass does something
|
||||
specific, like combining redundant instructions. Passes need not always
|
||||
optimize the IR, it can also do other operations like inserting
|
||||
instrumentation code, or analysing the IR (the result of which can be
|
||||
used by passes that do optimizations) or even printing call graphs.</p>
|
||||
<p>This LLVM <a href="http://www.llvm.org/docs/Passes.html">documentation page</a>
|
||||
describes all the available passes, and what they do.</p>
|
||||
<p>LLVM does not automatically choose to run any passes, anytime. Passes
|
||||
have to be explicitly selected and run on each module. This gives you
|
||||
the flexibility to choose transformations and optimizations that are
|
||||
most suitable for the code in the module.</p>
|
||||
<p>There is a LLVM binary called <a href="http://www.llvm.org/cmds/opt.html">opt</a>,
|
||||
which lets you run passes on bitcode files from the command line. You
|
||||
can write your own passes (in C/C++, as a shared library). This can be
|
||||
loaded and executed by <tt>opt</tt>. (Although <em>llvm-py</em> does not allow you to
|
||||
write your own passes, it does allow you to navigate the entire IR at
|
||||
any stage, and perform any transforms on it as you like.)</p>
|
||||
<p>Passes are run using a <em>pass manager</em>. For our purposes, there are two</p>
|
||||
<h3>Execution Engine</h3>
|
||||
<p>TODO</p>
|
||||
<h3>BitCode</h3>
|
||||
<p>TODO</p>
|
||||
<h3>llvm-gcc</h3>
|
||||
<p>TODO</p>
|
||||
</div>
|
||||
<h2>The <em>llvm-py</em> Package</h2>
|
||||
<div class="sectionbody">
|
||||
<p>modules overview: llvm, llvm.core, llvm.ee, llvm.passes</p>
|
||||
<p>importing modules</p>
|
||||
<p>core:</p>
|
||||
<p>types</p>
|
||||
<p>constants</p>
|
||||
<p>values</p>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Web pages © Mahadevan R. Generated with <a href="http://www.methods.co.nz/asciidoc/">asciidoc</a>.
|
||||
Last updated 09-Jun-2008.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||