mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
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
This commit is contained in:
parent
89a354d7fa
commit
7271423a99
@ -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> <b>sin(1.0);</b>
|
||||
<em>Evaluated to 0.841471</em>
|
||||
|
||||
ready> <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
|
||||
|
Loading…
Reference in New Issue
Block a user