aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-25 17:52:39 +0000
committerChris Lattner <sabre@nondot.org>2007-10-25 17:52:39 +0000
commit861c7ca20b0027892430e8ba6b68f45a1f79889c (patch)
treece08efa6ef0168a827b452f69771d40735cd8908 /docs
parentc80bed47cb64ade3490a7ce5ec9ea7da69765820 (diff)
downloadexternal_llvm-861c7ca20b0027892430e8ba6b68f45a1f79889c.zip
external_llvm-861c7ca20b0027892430e8ba6b68f45a1f79889c.tar.gz
external_llvm-861c7ca20b0027892430e8ba6b68f45a1f79889c.tar.bz2
some minor edits, link to Passes.html, make one point
I forgot about yesterday. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43350 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/tutorial/LangImpl4.html27
1 files changed, 25 insertions, 2 deletions
diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html
index 1048f73..8661b62 100644
--- a/docs/tutorial/LangImpl4.html
+++ b/docs/tutorial/LangImpl4.html
@@ -252,8 +252,9 @@ entry:
add from the program.</p>
<p>LLVM provides a wide variety of optimizations that can be used in certain
-circumstances. Unfortunately we don't have a good centralized description of
-what every pass does, but you can check out the ones that <tt>llvm-gcc</tt> or
+circumstances. Some <a href="../Passes.html">documentation about the various
+passes</a> is available, but it isn't very complete. Another good source of
+ideas is to look at the passes that <tt>llvm-gcc</tt> or
<tt>llvm-ld</tt> run to get started. The "<tt>opt</tt>" tool allows you to
experiment with passes from the command line, so you can see if they do
anything.</p>
@@ -410,6 +411,7 @@ declare double @cos(double)
ready&gt; <b>sin(1.0);</b>
<em>Evaluated to 0.841471</em>
+
ready&gt; <b>def foo(x) sin(x)*sin(x) + cos(x)*cos(x);</b>
Read function definition:
define double @foo(double %x) {
@@ -444,6 +446,27 @@ tables, for example), allows you to dynamically decide on the fly based on the
function name, and even allows you to have the JIT abort itself if any lazy
compilation is attempted.</p>
+<p>One interesting application of this is that we can now extend the language
+by writing arbitrary C++ code to implement operations. For example, if we add:
+</p>
+
+<div class="doc_code">
+<pre>
+/// putchard - putchar that takes a double and returns 0.
+extern "C"
+double putchard(double X) {
+ putchar((char)X);
+ return 0;
+}
+</pre>
+</div>
+
+<p>Now we can produce simple output to the console by using things like:
+"<tt>extern putchard(x); putchard(120);</tt>", which prints a lowercase 'x' on
+the console (120 is the ascii code for 'x'). Similar code could be used to
+implement file I/O, console input, and many other capabilities in
+Kaleidoscope.</p>
+
<p>This completes the JIT and optimizer chapter of the Kaleidoscope tutorial. At
this point, we can compile a non-Turing-complete programming language, optimize
and JIT compile it in a user-driven way. Next up we'll look into <a