Updated documentation.

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@20 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2008-06-24 14:35:30 +00:00
commit 4c27a1c376
12 changed files with 920 additions and 45 deletions

View file

@ -5,7 +5,7 @@ llvm-py is just hatching. It needs your patches and suggestions to
grow up. Please contribute! All patches are welcome. Here are some links
to start hacking away:
`40`60~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`75`25~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Google code hosting, http://code.google.com/p/llvm-py/[http://code.google.com/p/llvm-py/]
Browse SVN, http://code.google.com/p/llvm-py/source/browse/[http://code.google.com/p/llvm-py/source/browse]
Issues tracker, http://code.google.com/p/llvm-py/issues/list[http://code.google.com/p/llvm-py/issues/list]
@ -24,6 +24,7 @@ Current Next Steps
------------------
- Wrap GenericValue, function call args for execution engine.
* done.
- Add APIs to read/write `.bc` and `.ll` files.
- Wrap `lto`.
- Add examples.

67
www/src/js/toc.js Normal file
View file

@ -0,0 +1,67 @@
/* Author: Mihai Bazon, September 2002
* http://students.infoiasi.ro/~mishoo
*
* Table Of Content generator
* Version: 0.4
*
* Feel free to use this script under the terms of the GNU General Public
* License, as long as you do not remove or alter this notice.
*/
/* modified by Troy D. Hanson, September 2006. License: GPL */
/* modified by Stuart Rackham, October 2006. License: GPL */
function getText(el) {
var text = "";
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
text += i.data;
else if (i.firstChild != null)
text += getText(i);
}
return text;
}
function TocEntry(el, text, toclevel) {
this.element = el;
this.text = text;
this.toclevel = toclevel;
}
function tocEntries(el, toclevels) {
var result = new Array;
var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
// Function that scans the DOM tree for header elements (the DOM2
// nodeIterator API would be a better technique but not supported by all
// browsers).
var iterate = function (el) {
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
var mo = re.exec(i.tagName)
if (mo)
result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
iterate(i);
}
}
}
iterate(el);
return result;
}
// This function does the work. toclevels = 1..4.
function generateToc(toclevels) {
var toc = document.getElementById("toc");
var entries = tocEntries(document.getElementsByTagName("body")[0], toclevels);
for (var i = 0; i < entries.length; ++i) {
var entry = entries[i];
if (entry.element.id == "")
entry.element.id = "toc" + i;
var a = document.createElement("a");
a.href = "#" + entry.element.id;
a.appendChild(document.createTextNode(entry.text));
var div = document.createElement("div");
div.appendChild(a);
div.className = "toclevel" + entry.toclevel;
toc.appendChild(div);
}
}

View file

@ -41,6 +41,14 @@ monospacedwords=(?u)\\?\basciidoc\(1\) (?u)\\?\ba2x\(1\)
<link rel="stylesheet" href="style/{theme={backend}}.css" type="text/css" />
<link rel="stylesheet" href="style/{theme={backend}}-quirks.css" type="text/css" />
<link rel="stylesheet" href="style/layout.css" type="text/css" />
ifdef::toc[]
<script type="text/javascript">
/*<![CDATA[*/
window.onload = function()\{generateToc({toclevels=2})\}
/*]]>*/
</script>
<script type="text/javascript" src="js/toc.js"></script>
endif::toc[]
<title>{doctitle} - llvm-py</title>
</head>
<body>
@ -58,14 +66,18 @@ monospacedwords=(?u)\\?\basciidoc\(1\) (?u)\\?\ba2x\(1\)
<div>&#187;<a href="contribute.html">Contribute</a></div>
<div>&#187;<a href="license.html">License</a></div>
<div>&#187;<a href="about.html">About</a></div>
<div id="page-source">&#187;<a href="http://www.python.org/">Python</a></div>
<div>&#187;<a href="http://llvm.org/">LLVM</a></div>
</td>
<td>
<div id="layout-content">
<div id="header">
<h1>{doctitle}</h1>
</div>
ifdef::toc[]
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
endif::toc[]
[footer]
<div id="footer">
@ -81,8 +93,6 @@ Last updated {localdate}.
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4519056-2");
pageTracker._initData();
pageTracker._trackPageview();

View file

@ -1,7 +1,8 @@
llvm-py User Guide
===================
NOTE: This document is updated constantly. Check back often.
NOTE: This document is updated frequently (last updated on {localdate}).
Check back often.
llvm-py provides Python bindings for LLVM. This document explains how
you can setup and use it. A working knowledge of Python and a basic idea
@ -899,6 +900,118 @@ r1 = Constant.real(tr, "3.141592") # create from a string
r2 = Constant.real(tr, 1.61803399) # create from a Python float
source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following constructors (static methods) can be used to create
constants:
[frame="all",grid="all"]
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Constructor Method, What It Creates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`null(ty)`, A null value (all zeros) of type `ty`
`all_ones(ty)`, All 1's value of type `ty`
`undef(ty)`, An ``undefined'' value of type `ty`
"`int(ty, value)`", "Integer of type `ty`, with value `value` (a Python int or long)"
"`int_signextend(ty, value)`", Integer of signed type `ty` (use for signed types)
"`real(ty, value)`", "Floating point value of type `ty`, with value `value` (a Python float)"
"`stringz(value)`", "A null-terminated string. `value` is a Python string"
"`string(value)`", "As `string(ty)`, but not null terminated"
"`array(ty, consts)`", "Array of type `ty`, initialized with `consts` (an iterable yielding `Constant` objects of the appropriate type)"
"`struct(ty, consts)`", "Struct (unpacked) of type `ty`, initialized with `consts` (an iterable yielding `Constant` objects of the appropriate type)"
"`packed_struct(ty, consts)`", "As `struct(ty, consts)` but packed"
"`vector(consts)`", "Vector, initialized with `consts` (an iterable yielding `Constant` objects of the appropriate type)"
"`sizeof(ty)`", "Constant value representing the sizeof the type `ty`"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following operations are available:
[frame="all",grid="all"]
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Method, Operation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`k.neg()`, "negation, same as `0 - k`"
`k.not_()`, "1's complement of `k`. Note trailing underscore."
`k.add(k2)`, "`k + k2`"
`k.sub(k2)`, "`k - k2`"
`k.mul(k2)`, "`k * k2`"
`k.udiv(k2)`, "Quotient of unsigned division of `k` with `k2`"
`k.sdiv(k2)`, "Quotient of signed division of `k` with `k2`"
`k.fdiv(k2)`, "Quotient of floating point division of `k` with `k2`"
`k.urem(k2)`, "Reminder of unsigned division of `k` with `k2`"
`k.srem(k2)`, "Reminder of signed division of `k` with `k2`"
`k.frem(k2)`, "Reminder of floating point division of `k` with `k2`"
`k.and_(k2)`, "Bitwise and of `k` and `k2`. Note trailing underscore."
`k.or_(k2)`, "Bitwise or of `k` and `k2`. Note trailing underscore."
`k.xor(k2)`, "Bitwise exclusive-or of `k` and `k2`."
"`k.icmp(ipred, k2)`", "Compare `k` with `k2` using the predicate `ipred`. See table link:#ipred[below] for list of predicates for integer operands."
"`k.fcmp(rpred, k2)`", "Compare `k` with `k2` using the predicate `rpred`. See table link:#rpred[below] for list of predicates for real operands."
shl, TODO
lshr, TODO
ashr, TODO
gep, TODO
trunc, TODO
sext, TODO
zext, TODO
fptrunc, TODO
fpext, TODO
uitofp, TODO
sitofp, TODO
fptoui, TODO
fptosi, TODO
ptrtoint, TODO
inttoptr, TODO
bitcast, TODO
select, TODO
extract_element, TODO
insert_element, TODO
shuffle_vector, TODO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[[ipred]]
Predicates for use with `icmp` instruction are listed below. All
of these are integer constants defined in the `llvm.core` module.
[frame="all",grid="all"]
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Value, Meaning
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`IPRED_EQ`, Equality
`IPRED_NE`, Inequality
`IPRED_UGT`, Unsigned greater than
`IPRED_UGE`, Unsigned greater than or equal
`IPRED_ULT`, Unsigned less than
`IPRED_ULE`, Unsigned less than or equal
`IPRED_SGT`, Signed greater than
`IPRED_SGE`, Signed greater than or equal
`IPRED_SLT`, Signed less than
`IPRED_SLE`, Signed less than or equal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[[rpred]]
Predicates for use with `fcmp` instruction are listed below. All
of these are integer constants defined in the `llvm.core` module.
[frame="all",grid="all"]
`25`75~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Value, Meaning
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`RPRED_FALSE`,
`RPRED_OEQ`,
`RPRED_OGT`,
`RPRED_OGE`,
`RPRED_OLT`,
`RPRED_OLE`,
`RPRED_ONE`,
`RPRED_ORD`,
`RPRED_UNO`,
`RPRED_UEQ`,
`RPRED_UGT`,
`RPRED_UGE`,
`RPRED_ULT`,
`RPRED_ULE`,
`RPRED_UNE`,
`RPRED_TRUE `,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeHandle (llvm.core)