mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Updated the documentation to reflect changes in the Makefiles for building
projects. Fixed some small grammatical errors. Using Netscape Composer seems to have added stuff that makes the page look exactly the same. Bah! Curse my laziness! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a277ca84e0
commit
8df90e0c8d
@ -1,477 +1,468 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Getting Started with LLVM System</title>
|
<title>Getting Started with LLVM System</title>
|
||||||
</head>
|
</head>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
<body bgcolor=white>
|
<center>
|
||||||
<center><h1>Getting Started with the LLVM System<br><font size=3>By: <a
|
<h1>Getting Started with the LLVM System<br>
|
||||||
href="mailto:gshi1@uiuc.edu">Guochun Shi</a>,
|
<font size="3">By: <a href="mailto:gshi1@uiuc.edu">Guochun Shi</a>, <a
|
||||||
<a href="mailto:sabre@nondot.org">Chris Lattner</a> and
|
href="mailto:sabre@nondot.org">Chris Lattner</a> and <a
|
||||||
<a href="http://www.cs.uiuc.edu/~vadve">Vikram Adve</a>
|
href="http://www.cs.uiuc.edu/%7Evadve">Vikram Adve</a> </font></h1>
|
||||||
</font></h1></center>
|
</center>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
<!--=====================================================================-->
|
<h2><a name="Contents">Contents</a></h2>
|
||||||
<h2><a name="Contents">Contents</a></h2>
|
<!--=====================================================================-->
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#overview">Overview</a>
|
<li><a href="#overview">Overview</a> </li>
|
||||||
<li><a href="#starting">Getting started with LLVM</a>
|
<li><a href="#starting">Getting started with LLVM</a>
|
||||||
<ol>
|
|
||||||
<li><a href="#quickstart">Getting started quickly (a summary)</a>
|
|
||||||
<li><a href="#checkout">Checkout LLVM from CVS</a>
|
|
||||||
<li><a href="#terminology">Terminology and Notation</tt></a>
|
|
||||||
<li><a href="#objfiles">The location for object files</tt></a>
|
|
||||||
<li><a href="#config">Local Configuration Options</tt></a>
|
|
||||||
<li><a href="#environment">Setting up your environment</a>
|
|
||||||
<li><a href="#compile">Compiling the source code</a>
|
|
||||||
</ol>
|
|
||||||
<li><a href="#layout">Program layout</a>
|
|
||||||
<ol>
|
|
||||||
<li><a href="#cvsdir">CVS directories</a>
|
|
||||||
<li><a href="#dd"><tt>Depend</tt>, <tt>Debug</tt>, &
|
|
||||||
<tt>Release</tt> directories</a></li>
|
|
||||||
<li><a href="#include"><tt>llvm/include</tt></a>
|
|
||||||
<li><a href="#lib"><tt>llvm/lib</tt></a>
|
|
||||||
<li><a href="#test"><tt>llvm/test</tt></a>
|
|
||||||
<li><a href="#tools"><tt>llvm/tools</tt></a>
|
|
||||||
</ol>
|
|
||||||
<li><a href="#tutorial">An example using the LLVM tool chain</a>
|
|
||||||
<li><a href="#links">Links</a>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<!--=====================================================================-->
|
|
||||||
<center>
|
|
||||||
<h2><a name="overview"><b>Overview</b></a></h2>
|
|
||||||
</center>
|
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
<p>The <a href"starting">next section</a> of this guide is meant to get
|
|
||||||
you up and running with LLVM, and to give you some basic information about
|
|
||||||
the LLVM environment. The <a href"#quickstart">first subsection</a> gives
|
|
||||||
a short summary for those who are already familiar with the system and
|
|
||||||
want to get started as quickly as possible.
|
|
||||||
|
|
||||||
<p>The later sections of this guide describe the <a
|
|
||||||
href"#layout">general layout</a> of the the LLVM source-tree, a <a
|
|
||||||
href="#tutorial">simple example</a> using the LLVM tool chain, and <a
|
|
||||||
href="#links">links</a> to find more information about LLVM or to get
|
|
||||||
help via e-mail.
|
|
||||||
|
|
||||||
<!--=====================================================================-->
|
|
||||||
<center>
|
|
||||||
<h2><a name="starting"><b>Getting Started</b></a></h2>
|
|
||||||
</center>
|
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
|
|
||||||
<!--=====================================================================-->
|
|
||||||
<h3><a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a></h3>
|
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
Here's the short story for getting up and running quickly with LLVM:
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Find the path to the CVS repository containing LLVM (we'll call this <i>CVSROOTDIR</i>).
|
<li><a href="#quickstart">Getting started quickly (a summary)</a>
|
||||||
<li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
|
</li>
|
||||||
<li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt>
|
<li><a href="#checkout">Checkout LLVM from CVS</a> </li>
|
||||||
<li><tt>cd llvm</tt>
|
<li><a href="#terminology">Terminology and Notation</a> </li>
|
||||||
<li>Edit <tt>Makefile.config</tt> to set local paths. This includes
|
<li><a href="#objfiles">The location for object files</a> </li>
|
||||||
setting the install location of the C frontend, and the various paths
|
<li><a href="#config">Local Configuration Options</a> </li>
|
||||||
to the C and C++ compilers used to build LLVM itself.
|
<li><a href="#environment">Setting up your environment</a>
|
||||||
<li>Set your LLVM_LIB_SEARCH_PATH environment variable.
|
</li>
|
||||||
<li><tt>gmake -k |& tee gnumake.out
|
<li><a href="#compile">Compiling the source code</a> </li>
|
||||||
# this is csh or tcsh syntax</tt>
|
|
||||||
</ol>
|
</ol>
|
||||||
|
</li>
|
||||||
|
<li><a href="#layout">Program layout</a>
|
||||||
|
<ol>
|
||||||
|
<li><a href="#cvsdir">CVS directories</a> </li>
|
||||||
|
<li><a href="#dd"><tt>Depend</tt>, <tt>Debug</tt>, &
|
||||||
|
<tt>Release</tt> directories</a></li>
|
||||||
|
<li><a href="#include"><tt>llvm/include</tt></a> </li>
|
||||||
|
<li><a href="#lib"><tt>llvm/lib</tt></a> </li>
|
||||||
|
<li><a href="#test"><tt>llvm/test</tt></a> </li>
|
||||||
|
<li><a href="#tools"><tt>llvm/tools</tt></a> </li>
|
||||||
|
</ol>
|
||||||
|
</li>
|
||||||
|
<li><a href="#tutorial">An example using the LLVM tool chain</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#links">Links</a> </li>
|
||||||
|
</ul>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
<p>See <a href="#environment">Setting up your environment</a> on tips to
|
<center>
|
||||||
simplify working with the LLVM front-end and compiled tools. See the
|
<h2><a name="overview"><b>Overview</b></a></h2>
|
||||||
other sub-sections below for other useful details in working with LLVM,
|
</center>
|
||||||
or go straight to <a href="#layout">Program Layout</a> to learn about the
|
<!--=====================================================================-->
|
||||||
layout of the source code tree.
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<p>The <a href="" starting="">next section</a> of this guide is meant to
|
||||||
<h3><a name="terminology">Terminology and Notation</a></h3>
|
get you up and running with LLVM, and to give you some basic information
|
||||||
<!------------------------------------------------------------------------->
|
about the LLVM environment. The <a href="" #quickstart="">first subsection</a>
|
||||||
|
gives a short summary for those who are already familiar with the system
|
||||||
|
and want to get started as quickly as possible. </p>
|
||||||
|
<p>The later sections of this guide describe the <a href="" #layout="">general
|
||||||
|
layout</a> of the LLVM source-tree, a <a href="#tutorial">simple example</a>
|
||||||
|
using the LLVM tool chain, and <a href="#links">links</a> to find more information
|
||||||
|
about LLVM or to get help via e-mail. <!--=====================================================================-->
|
||||||
|
</p>
|
||||||
|
<center>
|
||||||
|
<h2><a name="starting"><b>Getting Started</b></a></h2>
|
||||||
|
</center>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
<p>Through this manual, the following names are used to denote paths
|
<h3><a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a></h3>
|
||||||
specific to the local system and working environment. <i>These are not
|
<!--=====================================================================-->
|
||||||
environment variables you need to set, but just strings used in the rest
|
Here's the short story for getting up and running quickly with LLVM:
|
||||||
of this document below.</i>. In any of the examples below, simply replace
|
|
||||||
|
<ol>
|
||||||
|
<li>Find the path to the CVS repository containing LLVM (we'll call
|
||||||
|
this <i>CVSROOTDIR</i>). </li>
|
||||||
|
<li><tt>cd <i>where-you-want-llvm-to-live</i></tt> </li>
|
||||||
|
<li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt> </li>
|
||||||
|
<li><tt>cd llvm</tt> </li>
|
||||||
|
<li>Edit <tt>Makefile.config</tt> to set local paths. This includes
|
||||||
|
setting the install location of the C frontend and the various paths
|
||||||
|
to the C and C++ compilers used to build LLVM itself. </li>
|
||||||
|
<li>Set your LLVM_LIB_SEARCH_PATH environment variable. </li>
|
||||||
|
<li><tt>gmake -k |& tee gnumake.out # this is
|
||||||
|
csh or tcsh syntax</tt> </li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<p>See <a href="#environment">Setting up your environment</a> on tips to
|
||||||
|
simplify working with the LLVM front-end and compiled tools. See the
|
||||||
|
other sub-sections below for other useful details in working with LLVM,
|
||||||
|
or go straight to <a href="#layout">Program Layout</a> to learn about
|
||||||
|
the layout of the source code tree. <!------------------------------------------------------------------------->
|
||||||
|
</p>
|
||||||
|
<h3><a name="terminology">Terminology and Notation</a></h3>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
<p>Through this manual, the following names are used to denote paths
|
||||||
|
specific to the local system and working environment. <i>These are not
|
||||||
|
environment variables you need to set, but just strings used in the rest
|
||||||
|
of this document below</i>. In any of the examples below, simply replace
|
||||||
each of these names with the appropriate pathname on your local system.
|
each of these names with the appropriate pathname on your local system.
|
||||||
All these paths are absolute:</p>
|
All these paths are absolute:</p>
|
||||||
<ul>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<ul>
|
||||||
<h3><a name="checkout">Checkout LLVM from CVS</a></h3>
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
|
|
||||||
<p>Before checking out the source code, you will need to know the path to
|
</ul>
|
||||||
CVS repository containing LLVM source code (we'll call this
|
<!------------------------------------------------------------------------->
|
||||||
<i>CVSROOTDIR</i> below). Ask the person responsible for your local LLVM
|
|
||||||
installation to give you this path.
|
|
||||||
|
|
||||||
<p>To get a fresh copy of the entire source code, all you
|
<h3><a name="checkout">Checkout LLVM from CVS</a></h3>
|
||||||
need to do is check it out from CVS as follows:
|
<!------------------------------------------------------------------------->
|
||||||
<ul>
|
|
||||||
<li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
|
|
||||||
<li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt></p>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>This will create an '<tt>llvm</tt>' directory in the current
|
<p>Before checking out the source code, you will need to know the path to
|
||||||
directory and fully populate it with the LLVM source code, Makefiles,
|
the CVS repository containing LLVM source code (we'll call this <i>CVSROOTDIR</i>
|
||||||
test directories, and local copies of documentation files.</p>
|
below). Ask the person responsible for your local LLVM installation
|
||||||
|
to give you this path. </p>
|
||||||
|
<p>To get a fresh copy of the entire source code, all you need to do
|
||||||
|
is check it out from CVS as follows: </p>
|
||||||
|
<ul>
|
||||||
|
<li><tt>cd <i>where-you-want-llvm-to-live</i></tt> </li>
|
||||||
|
<li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt>
|
||||||
|
<p></p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<p>This will create an '<tt>llvm</tt>' directory in the current directory
|
||||||
<h3><a name="config">Local Configuration Options</a></h3>
|
and fully populate it with the LLVM source code, Makefiles, test directories,
|
||||||
<!------------------------------------------------------------------------->
|
and local copies of documentation files.</p>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<p>The file <tt>llvm/Makefile.config</tt>
|
<h3><a name="config">Local Configuration Options</a></h3>
|
||||||
defines the following path variables,
|
<!------------------------------------------------------------------------->
|
||||||
which are specific to a particular installation of LLVM.
|
|
||||||
These should need to be modified only once after checking out a copy
|
|
||||||
of LLVM (if the default values do not already match your system):
|
|
||||||
|
|
||||||
<ul>
|
<p>The file <tt>llvm/Makefile.config</tt> defines the following path
|
||||||
<p><li><i>CXX</i> = Path to C++ compiler to use.
|
variables which are specific to a particular installation of LLVM.
|
||||||
<p><li><i>LLVM_OBJ_DIR</i> = Path to the llvm directory where
|
These should need to be modified only once after checking out a copy
|
||||||
object files should be placed.
|
of LLVM (if the default values do not already match your system):
|
||||||
(See the Section on <a href=#objfiles>
|
</p>
|
||||||
The location for LLVM object files</a>
|
<ul>
|
||||||
for more information.)
|
|
||||||
<p><li><i>LLVMGCCDIR</i> = Path to the location of the LLVM front-end
|
|
||||||
binaries and associated libraries.
|
|
||||||
<p><li><i>PURIFY</i> = Path to the purify program.
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
In addition to settings in this file, you must set a
|
<p></p>
|
||||||
<tt>LLVM_LIB_SEARCH_PATH</tt> environment variable in your startup scripts.
|
<li><i>CXX</i> = Path to C++ compiler to use.
|
||||||
This environment variable is used to locate "system" libraries like
|
<p></p>
|
||||||
"<tt>-lc</tt>" and "<tt>-lm</tt>" when linking. This variable should be set
|
</li>
|
||||||
to the absolute path for the bytecode-libs subdirectory of the C front-end
|
<li><i>OBJ_ROOT</i> = Path to the llvm directory where object files
|
||||||
install. For example,
|
should be placed. (See the Section on <a href="#objfiles"> The
|
||||||
<tt>/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs</tt> for the X86
|
location for LLVM object files</a> for more information.)
|
||||||
version of the C front-end, on our research machines.<p>
|
<p></p>
|
||||||
|
</li>
|
||||||
|
<li><i>LLVMGCCDIR</i> = Path to the location of the LLVM front-end
|
||||||
|
binaries and associated libraries.
|
||||||
|
<p></p>
|
||||||
|
</li>
|
||||||
|
<li><i>PURIFY</i> = Path to the purify program. </li>
|
||||||
|
</ul>
|
||||||
|
In addition to settings in this file, you must set a <tt>LLVM_LIB_SEARCH_PATH</tt>
|
||||||
|
environment variable in your startup scripts. This environment variable
|
||||||
|
is used to locate "system" libraries like "<tt>-lc</tt>" and "<tt>-lm</tt>"
|
||||||
|
when linking. This variable should be set to the absolute path for the
|
||||||
|
bytecode-libs subdirectory of the C front-end install. For example,
|
||||||
|
<tt>/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs</tt> is used
|
||||||
|
for the X86 version of the C front-end on our research machines.
|
||||||
|
<p> <!------------------------------------------------------------------------->
|
||||||
|
</p>
|
||||||
|
<h3><a name="objfiles">The location for LLVM object files</a></h3>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<p>The LLVM make system sends most output files generated during the build
|
||||||
<h3><a name="objfiles">The location for LLVM object files</a></h3>
|
into the directory defined by the variable OBJ_ROOT in <tt>llvm/Makefile.config</tt>.
|
||||||
<!------------------------------------------------------------------------->
|
This can be either just your normal LLVM source tree or some other directory
|
||||||
|
writable by you. You may wish to put object files on a different filesystem
|
||||||
|
either to keep them from being backed up or to speed up local builds.
|
||||||
|
</p>
|
||||||
|
<p>If you do not wish to use a different location for object files (i.e.
|
||||||
|
building into the source tree directly), just set this variable to ".".</p>
|
||||||
|
<p> <!------------------------------------------------------------------------->
|
||||||
|
</p>
|
||||||
|
<h3><a name="environment">Setting up your environment</a></h3>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
<i>NOTE: This step is optional but will set up your environment so you
|
||||||
|
can use the compiled LLVM tools with as little hassle as possible.</i>)
|
||||||
|
|
||||||
<p>The LLVM make system sends most output files generated during the build
|
<p>Add the following lines to your <tt>.cshrc</tt> (or the corresponding
|
||||||
into the directory defined by the variable LLVM_OBJ_DIR in
|
lines to your <tt>.profile</tt> if you use a bourne shell derivative).
|
||||||
<tt>llvm/Makefile.config</tt>. This can be either just your normal LLVM
|
</p>
|
||||||
source tree or some other directory writable by you. You may wish to put
|
<pre> # Make the C front end easy to use...<br> alias llvmgcc <i>LLVMGCCDIR</i><tt>/bin/llvm-gcc</tt>
|
||||||
object files on a different filesystem either to keep them from being backed
|
|
||||||
up or to speed up local builds.
|
|
||||||
|
|
||||||
<p>If you do not wish to use a different location for object files (building
|
|
||||||
into the source tree directly), just set this variable to ".".<p>
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
<h3><a name="environment">Setting up your environment</a></h3>
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
|
|
||||||
<i>NOTE: This step is optional but will set up your environment so you
|
|
||||||
can use the compiled LLVM tools with as little hassle as
|
|
||||||
possible.</i>)
|
|
||||||
|
|
||||||
<p>Add the following lines to your <tt>.cshrc</tt> (or the corresponding
|
|
||||||
lines to your <tt>.profile</tt> if you use a bourne shell derivative).
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
# Make the C front end easy to use...
|
|
||||||
alias llvmgcc <i>LLVMGCCDIR</i><tt>/bin/llvm-gcc</tt>
|
|
||||||
|
|
||||||
# Make the LLVM tools easy to use...
|
# Make the LLVM tools easy to use...
|
||||||
setenv PATH <i>LLVM_OBJ_DIR</i>/llvm/tools/Debug:${PATH}
|
setenv PATH <i>OBJ_ROOT</i>/llvm/tools/Debug:${PATH}<br> </pre>
|
||||||
</pre>
|
The <tt>llvmgcc</tt> alias is useful because the C compiler is not
|
||||||
The <tt>llvmgcc</tt> alias is useful because the C compiler is not
|
included in the CVS tree you just checked out.
|
||||||
included in the CVS tree you just checked out.
|
<p>The other <a href="#tools">LLVM tools</a> are part of the LLVM source
|
||||||
|
base and are built when compiling LLVM. They will be built into the
|
||||||
|
<tt><i>OBJ_ROOT</i>/tools/Debug</tt> directory.</p>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<p>The other <a href="#tools">LLVM tools</a> are part of the LLVM
|
<h3><a name="compile">Compiling the source code</a></h3>
|
||||||
source base, and built when compiling LLVM. They will be built into the
|
<!------------------------------------------------------------------------->
|
||||||
<tt><i>LLVM_OBJ_DIR</i>/tools/Debug</tt> directory.</p>
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<p>Every directory in the LLVM source tree includes a <tt>Makefile</tt> to
|
||||||
<h3><a name="compile">Compiling the source code</a></h3>
|
build it and any subdirectories that it contains. These makefiles require
|
||||||
<!------------------------------------------------------------------------->
|
GNU Make (<tt>gmake)</tt> instead of <tt>make</tt> to build them, but
|
||||||
|
can otherwise be used freely. To build the entire LLVM system, just
|
||||||
|
enter the top level <tt>llvm</tt> directory and type <tt>gmake</tt>.
|
||||||
|
A few minutes later you will hopefully have a freshly compiled toolchain
|
||||||
|
waiting for you in <tt><i>OBJ_ROOT</i></tt><tt>/llvm/tools/Debug</tt>.
|
||||||
|
If you want to look at the libraries that were compiled, look in <tt><i>OBJ_ROOT</i></tt><tt>/llvm/lib/Debug</tt>.</p>
|
||||||
|
If you get an error about the <tt>/localhome</tt> directory, chances
|
||||||
|
are good that something has been misconfigured. Follow the instructions
|
||||||
|
in the section about <a href="#environment">Setting Up Your Environment.</a>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
<p>Every directory in the LLVM source tree includes a <tt>Makefile</tt> to
|
<center>
|
||||||
build it, and any subdirectories that it contains. These makefiles require
|
<h2><a name="layout"><b>Program Layout</b></a></h2>
|
||||||
that you use <tt>gmake</tt>, instead of <tt>make</tt> to build them, but can
|
</center>
|
||||||
otherwise be used freely. To build the entire LLVM system, just enter the
|
<!--=====================================================================-->
|
||||||
top level <tt>llvm</tt> directory and type <tt>gmake</tt>. A few minutes
|
|
||||||
later you will hopefully have a freshly compiled toolchain waiting for you
|
|
||||||
in <tt>llvm/tools/Debug</tt>. If you want to look at the libraries that
|
|
||||||
were compiled, look in <tt>llvm/lib/Debug</tt>.</p>
|
|
||||||
|
|
||||||
If you get an error talking about a <tt>/localhome</tt> directory, follow
|
<p>One useful source of infomation about the LLVM sourcebase is the LLVM
|
||||||
the instructions in the section about <a href="#environment">Setting Up Your
|
<a href="http://www.doxygen.org">doxygen</a> documentation, available at
|
||||||
Environment.</a>
|
<tt><a href="http://llvm.cs.uiuc.edu/doxygen/">http://llvm.cs.uiuc.edu/doxygen/</a></tt>.
|
||||||
|
The following is a brief introduction to code layout:</p>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
<h3><a name="cvsdir"><tt>CVS</tt> directories</a></h3>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
Every directory checked out of CVS will contain a <tt>CVS</tt> directory;
|
||||||
|
for the most part, these can just be ignored. <!------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
<h3><a name="ddr"><tt>Depend</tt>, <tt>Debug</tt>, & <tt>Release</tt>
|
||||||
<!--=====================================================================-->
|
|
||||||
<center>
|
|
||||||
<h2><a name="layout"><b>Program Layout</b></a></h2>
|
|
||||||
</center>
|
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
<p>One useful source of infomation about the LLVM sourcebase is the LLVM <a
|
|
||||||
href="http://www.doxygen.org">doxygen</a> documentation, available at <tt><a
|
|
||||||
href="http://llvm.cs.uiuc.edu/doxygen/">http://llvm.cs.uiuc.edu/doxygen/</a></tt>. The
|
|
||||||
following is a brief introduction to code layout:</p>
|
|
||||||
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
<h3><a name="cvsdir"><tt>CVS</tt> directories</a></h3>
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
|
|
||||||
Every directory checked out of CVS will contain a <tt>CVS</tt> directory,
|
|
||||||
for the most part these can just be ignored.
|
|
||||||
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
<h3><a name="ddr"><tt>Depend</tt>, <tt>Debug</tt>, & <tt>Release</tt>
|
|
||||||
directories</a></h3>
|
directories</a></h3>
|
||||||
<!------------------------------------------------------------------------->
|
<!------------------------------------------------------------------------->
|
||||||
|
If you are building with the "<tt>OBJ_ROOT=.</tt>" option enabled in
|
||||||
If you are building with the "<tt>BUILD_ROOT=.</tt>" option enabled in the
|
the <tt>Makefile.config</tt> file, most source directories will contain
|
||||||
<tt>Makefile.common</tt> file, most source directories will contain two
|
two directories, <tt>Depend</tt> and <tt>Debug</tt>. The <tt>Depend</tt>
|
||||||
directories, <tt>Depend</tt> and <tt>Debug</tt>. The <tt>Depend</tt>
|
directory contains automatically generated dependance files which are
|
||||||
directory contains automatically generated dependance files which are used
|
used during compilation to make sure that source files get rebuilt if
|
||||||
during compilation to make sure that source files get rebuilt if a header
|
a header file they use is modified. The <tt>Debug</tt> directory holds
|
||||||
file they use is modified. The <tt>Debug</tt> directory holds the object
|
the object files, library files, and executables that are used for building
|
||||||
files, library files and executables that are used for building a debug
|
a debug enabled build. The <tt>Release</tt> directory is created to
|
||||||
enabled build. The <tt>Release</tt> directory is created to hold the same
|
hold the same files when the <tt>ENABLE_OPTIMIZED=1</tt> flag is passed
|
||||||
files when the <tt>ENABLE_OPTIMIZED=1</tt> flag is passed to <tt>gmake</tt>,
|
to <tt>gmake</tt>, causing an optimized built to be performed.
|
||||||
causing an optimized built to be performed.<p>
|
<p> <!------------------------------------------------------------------------->
|
||||||
|
</p>
|
||||||
|
<h3><a name="include"><tt>llvm/include</tt></a></h3>
|
||||||
<!------------------------------------------------------------------------->
|
<!------------------------------------------------------------------------->
|
||||||
<h3><a name="include"><tt>llvm/include</tt></a></h3>
|
This directory contains public header files exported from the LLVM
|
||||||
<!------------------------------------------------------------------------->
|
library. The two main subdirectories of this directory are:
|
||||||
|
<p> </p>
|
||||||
This directory contains public header files exported from the LLVM
|
<ol>
|
||||||
library. The two main subdirectories of this directory are:<p>
|
<li><tt>llvm/include/llvm</tt> - This directory contains all of the
|
||||||
|
LLVM specific header files. This directory also has subdirectories
|
||||||
<ol>
|
for different portions of LLVM: <tt>Analysis</tt>, <tt>CodeGen</tt>,
|
||||||
<li><tt>llvm/include/llvm</tt> - This directory contains all of the LLVM
|
|
||||||
specific header files. This directory also has subdirectories for
|
|
||||||
different portions of LLVM: <tt>Analysis</tt>, <tt>CodeGen</tt>,
|
|
||||||
<tt>Reoptimizer</tt>, <tt>Target</tt>, <tt>Transforms</tt>, etc...
|
<tt>Reoptimizer</tt>, <tt>Target</tt>, <tt>Transforms</tt>, etc...
|
||||||
|
</li>
|
||||||
<li><tt>llvm/include/Support</tt> - This directory contains generic
|
<li><tt>llvm/include/Support</tt> - This directory contains generic
|
||||||
support libraries that are independant of LLVM, but are used by LLVM.
|
support libraries that are independant of LLVM, but are used by LLVM.
|
||||||
For example, some C++ STL utilities and a Command Line option processing
|
For example, some C++ STL utilities and a Command Line option processing
|
||||||
library.
|
library. </li>
|
||||||
</ol>
|
</ol>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
<h3><a name="lib"><tt>llvm/lib</tt></a></h3>
|
||||||
<h3><a name="lib"><tt>llvm/lib</tt></a></h3>
|
<!------------------------------------------------------------------------->
|
||||||
<!------------------------------------------------------------------------->
|
This directory contains most source files of LLVM system. In LLVM almost
|
||||||
|
all code exists in libraries, making it very easy to share code among
|
||||||
|
the different <a href="#tools">tools</a>.
|
||||||
|
<p> </p>
|
||||||
|
<dl compact="compact">
|
||||||
|
<dt><tt>llvm/lib/VMCore/</tt></dt>
|
||||||
|
<dd> This directory holds the core LLVM source files that implement
|
||||||
|
core classes like Instruction and BasicBlock. </dd>
|
||||||
|
<dt><tt>llvm/lib/AsmParser/</tt></dt>
|
||||||
|
<dd> This directory holds the source code for the LLVM assembly language
|
||||||
|
parser library. </dd>
|
||||||
|
<dt><tt>llvm/lib/ByteCode/</tt></dt>
|
||||||
|
<dd> This directory holds code for reading and write LLVM bytecode.
|
||||||
|
</dd>
|
||||||
|
<dt><tt>llvm/lib/CWriter/</tt></dt>
|
||||||
|
<dd> This directory implements the LLVM to C converter. </dd>
|
||||||
|
<dt><tt>llvm/lib/Analysis/</tt></dt>
|
||||||
|
<dd> This directory contains a variety of different program analyses,
|
||||||
|
such as Dominator Information, Call Graphs, Induction Variables, Interval
|
||||||
|
Identification, Natural Loop Identification, etc... </dd>
|
||||||
|
<dt><tt>llvm/lib/Transforms/</tt></dt>
|
||||||
|
<dd> This directory contains the source code for the LLVM to LLVM
|
||||||
|
program transformations, such as Aggressive Dead Code Elimination,
|
||||||
|
Sparse Conditional Constant Propagation, Inlining, Loop Invarient Code
|
||||||
|
Motion, Dead Global Elimination, Pool Allocation, and many others...
|
||||||
|
</dd>
|
||||||
|
<dt><tt>llvm/lib/Target/</tt></dt>
|
||||||
|
<dd> This directory contains files that describe various target architectures
|
||||||
|
for code generation. For example, the llvm/lib/Target/Sparc directory
|
||||||
|
holds the Sparc machine description.<br>
|
||||||
|
</dd>
|
||||||
|
<dt><tt>llvm/lib/CodeGen/</tt></dt>
|
||||||
|
<dd> This directory contains the major parts of the code generator:
|
||||||
|
Instruction Selector, Instruction Scheduling, and Register Allocation.
|
||||||
|
</dd>
|
||||||
|
<dt><tt>llvm/lib/Reoptimizer/</tt></dt>
|
||||||
|
<dd> This directory holds code related to the runtime reoptimizer
|
||||||
|
framework that is currently under development. </dd>
|
||||||
|
<dt><tt>llvm/lib/Support/</tt></dt>
|
||||||
|
<dd> This directory contains the source code that corresponds to
|
||||||
|
the header files located in <tt>llvm/include/Support/</tt>. </dd>
|
||||||
|
</dl>
|
||||||
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
This directory contains most source files of LLVM system. In LLVM almost all
|
<h3><a name="test"><tt>llvm/test</tt></a></h3>
|
||||||
code exists in libraries, making it very easy to share code among the
|
<!------------------------------------------------------------------------->
|
||||||
different <a href="#tools">tools</a>.<p>
|
|
||||||
|
|
||||||
<dl compact>
|
<p>This directory contains regression tests and source code that is used
|
||||||
<dt><tt>llvm/lib/VMCore/</tt><dd> This directory holds the core LLVM
|
to test the LLVM infrastructure...</p>
|
||||||
source files that implement core classes like Instruction and BasicBlock.
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<dt><tt>llvm/lib/AsmParser/</tt><dd> This directory holds the source code
|
<h3><a name="tools"><tt>llvm/tools</tt></a></h3>
|
||||||
for the LLVM assembly language parser library.
|
<!------------------------------------------------------------------------->
|
||||||
|
|
||||||
<dt><tt>llvm/lib/ByteCode/</tt><dd> This directory holds code for reading
|
<p>The <b>tools</b> directory contains the executables built out of the
|
||||||
and write LLVM bytecode.
|
libraries above, which form the main part of the user interface. You
|
||||||
|
can always get help for a tool by typing <tt>tool_name --help</tt>.
|
||||||
<dt><tt>llvm/lib/CWriter/</tt><dd> This directory implements the LLVM to C
|
The following is a brief introduction to the most important tools.</p>
|
||||||
converter.
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/Analysis/</tt><dd> This directory contains a variety of
|
|
||||||
different program analyses, such as Dominator Information, Call Graphs,
|
|
||||||
Induction Variables, Interval Identification, Natural Loop Identification,
|
|
||||||
etc...
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/Transforms/</tt><dd> This directory contains the source
|
|
||||||
code for the LLVM to LLVM program transformations, such as Aggressive Dead
|
|
||||||
Code Elimination, Sparse Conditional Constant Propagation, Inlining, Loop
|
|
||||||
Invarient Code Motion, Dead Global Elimination, Pool Allocation, and many
|
|
||||||
others...
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/Target/</tt><dd> This directory contains files that
|
|
||||||
describe various target architectures for code generation. For example,
|
|
||||||
the llvm/lib/Target/Sparc directory holds the Sparc machine
|
|
||||||
description.<br>
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/CodeGen/</tt><dd> This directory contains the major parts
|
|
||||||
of the code generator: Instruction Selector, Instruction Scheduling, and
|
|
||||||
Register Allocation.
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/Reoptimizer/</tt><dd> This directory holds code related
|
|
||||||
to the runtime reoptimizer framework that is currently under development.
|
|
||||||
|
|
||||||
<dt><tt>llvm/lib/Support/</tt><dd> This directory contains the source code
|
|
||||||
that corresponds to the header files located in
|
|
||||||
<tt>llvm/include/Support/</tt>.
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
<h3><a name="test"><tt>llvm/test</tt></a></h3>
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
|
|
||||||
<p>This directory contains regression tests and source code that is used to
|
|
||||||
test the LLVM infrastructure...</p>
|
|
||||||
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
<h3><a name="tools"><tt>llvm/tools</tt></a></h3>
|
|
||||||
<!------------------------------------------------------------------------->
|
|
||||||
|
|
||||||
<p>The <b>tools</b> directory contains the executables built out of the
|
|
||||||
libraries above, which form the main part of the user interface. You can
|
|
||||||
always get help for a tool by typing <tt>tool_name --help</tt>. The
|
|
||||||
following is a brief introduction to the most important tools.</p>
|
|
||||||
|
|
||||||
<dl compact>
|
|
||||||
<dt><tt><b>as</b></tt><dd>The assembler transforms the human readable
|
|
||||||
LLVM assembly to LLVM bytecode.<p>
|
|
||||||
|
|
||||||
<dt><tt><b>dis</b></tt><dd>The disassembler transforms the LLVM bytecode
|
|
||||||
to human readable LLVM assembly. Additionally it can convert LLVM
|
|
||||||
bytecode to C, which is enabled with the <tt>-c</tt> option.<p>
|
|
||||||
|
|
||||||
<dt><tt><b>lli</b></tt><dd> <tt>lli</tt> is the LLVM interpreter, which
|
|
||||||
can directly execute LLVM bytecode (although very slowly...). In addition
|
|
||||||
to a simple intepreter, <tt>lli</tt> is also has debugger and tracing
|
|
||||||
modes (entered by specifying <tt>-debug</tt> or <tt>-trace</tt> on the
|
|
||||||
command line, respectively).<p>
|
|
||||||
|
|
||||||
<dt><tt><b>llc</b></tt><dd> <tt>llc</tt> is the LLVM backend compiler,
|
|
||||||
which translates LLVM bytecode to a SPARC assembly file.<p>
|
|
||||||
|
|
||||||
<dt><tt><b>llvmgcc</b></tt><dd> <tt>llvmgcc</tt> is a GCC based C frontend
|
|
||||||
that has been retargeted to emit LLVM code as the machine code output. It
|
|
||||||
works just like any other GCC compiler, taking the typical <tt>-c, -S, -E,
|
|
||||||
-o</tt> options that are typically used. The source code for the
|
|
||||||
<tt>llvmgcc</tt> tool is currently not included in the LLVM cvs tree
|
|
||||||
because it is quite large and not very interesting.<p>
|
|
||||||
|
|
||||||
<ol>
|
|
||||||
<dt><tt><b>gccas</b></tt><dd> This tool is invoked by the
|
|
||||||
<tt>llvmgcc</tt> frontend as the "assembler" part of the compiler. This
|
|
||||||
tool actually assembles LLVM assembly to LLVM bytecode,
|
|
||||||
performs a variety of optimizations,
|
|
||||||
and outputs LLVM bytecode. Thus when you invoke <tt>llvmgcc -c x.c -o
|
|
||||||
x.o</tt>, you are causing <tt>gccas</tt> to be run, which writes the
|
|
||||||
<tt>x.o</tt> file (which is an LLVM bytecode file that can be
|
|
||||||
disassembled or manipulated just like any other bytecode file). The
|
|
||||||
command line interface to <tt>gccas</tt> is designed to be as close as
|
|
||||||
possible to the <b>system</b> '<tt>as</tt>' utility so that the gcc
|
|
||||||
frontend itself did not have to be modified to interface to a "wierd"
|
|
||||||
assembler.<p>
|
|
||||||
|
|
||||||
<dt><tt><b>gccld</b></tt><dd> <tt>gccld</tt> links together several LLVM
|
|
||||||
bytecode files into one bytecode file and does some optimization. It is
|
|
||||||
the linker invoked by the gcc frontend when multiple .o files need to be
|
|
||||||
linked together. Like <tt>gccas</tt> the command line interface of
|
|
||||||
<tt>gccld</tt> is designed to match the system linker, to aid
|
|
||||||
interfacing with the GCC frontend.<p>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<dt><tt><b>opt</b></tt><dd> <tt>opt</tt> reads LLVM bytecode, applies a
|
|
||||||
series of LLVM to LLVM transformations (which are specified on the command
|
|
||||||
line), and then outputs the resultant bytecode. The '<tt>opt --help</tt>'
|
|
||||||
command is a good way to get a list of the program transformations
|
|
||||||
available in LLVM.<p>
|
|
||||||
|
|
||||||
|
|
||||||
<dt><tt><b>analyze</b></tt><dd> <tt>analyze</tt> is used to run a specific
|
|
||||||
analysis on an input LLVM bytecode file and print out the results. It is
|
|
||||||
primarily useful for debugging analyses, or familiarizing yourself with
|
|
||||||
what an analysis does.<p>
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<!--=====================================================================-->
|
|
||||||
<h2><a name="tutorial">An example using the LLVM tool chain</h2>
|
|
||||||
<!--=====================================================================-->
|
|
||||||
|
|
||||||
|
<dl compact="compact">
|
||||||
|
<dt><tt><b>as</b></tt></dt>
|
||||||
|
<dd>The assembler transforms the human readable LLVM assembly to
|
||||||
|
LLVM bytecode.
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>dis</b></tt></dt>
|
||||||
|
<dd>The disassembler transforms the LLVM bytecode to human readable
|
||||||
|
LLVM assembly. Additionally it can convert LLVM bytecode to C, which
|
||||||
|
is enabled with the <tt>-c</tt> option.
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>lli</b></tt></dt>
|
||||||
|
<dd> <tt>lli</tt> is the LLVM interpreter, which can directly execute
|
||||||
|
LLVM bytecode (although very slowly...). In addition to a simple intepreter,
|
||||||
|
<tt>lli</tt> is also has debugger and tracing modes (entered by
|
||||||
|
specifying <tt>-debug</tt> or <tt>-trace</tt> on the command line,
|
||||||
|
respectively).
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>llc</b></tt></dt>
|
||||||
|
<dd> <tt>llc</tt> is the LLVM backend compiler, which translates
|
||||||
|
LLVM bytecode to a SPARC assembly file.
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>llvmgcc</b></tt></dt>
|
||||||
|
<dd> <tt>llvmgcc</tt> is a GCC based C frontend that has been retargeted
|
||||||
|
to emit LLVM code as the machine code output. It works just like any
|
||||||
|
other GCC compiler, taking the typical <tt>-c, -S, -E, -o</tt> options
|
||||||
|
that are typically used. The source code for the <tt>llvmgcc</tt>
|
||||||
|
tool is currently not included in the LLVM cvs tree because it is quite
|
||||||
|
large and not very interesting.
|
||||||
|
<p> </p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>First, create a simple C file, name it 'hello.c':
|
<dt><tt><b>gccas</b></tt></dt>
|
||||||
<pre>
|
<dd> This tool is invoked by the <tt>llvmgcc</tt> frontend
|
||||||
#include <stdio.h>
|
as the "assembler" part of the compiler. This tool actually assembles
|
||||||
int main() {
|
LLVM assembly to LLVM bytecode, performs a variety of optimizations,
|
||||||
printf("hello world\n");
|
and outputs LLVM bytecode. Thus when you invoke <tt>llvmgcc -c x.c
|
||||||
return 0;
|
-o x.o</tt>, you are causing <tt>gccas</tt> to be run, which writes
|
||||||
}
|
the <tt>x.o</tt> file (which is an LLVM bytecode file that can be
|
||||||
</pre>
|
disassembled or manipulated just like any other bytecode file).
|
||||||
|
The command line interface to <tt>gccas</tt> is designed to be as
|
||||||
<li>Next, compile the C file into a LLVM bytecode file:<p>
|
close as possible to the <b>system</b> '<tt>as</tt>' utility so that
|
||||||
|
the gcc frontend itself did not have to be modified to interface
|
||||||
<tt>% llvmgcc hello.c -o hello</tt><p>
|
to a "wierd" assembler.
|
||||||
|
<p> </p>
|
||||||
This will create two result files: <tt>hello</tt> and
|
</dd>
|
||||||
<tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
|
<dt><tt><b>gccld</b></tt></dt>
|
||||||
corresponds the the compiled program and the library facilities that it
|
<dd> <tt>gccld</tt> links together several LLVM bytecode files
|
||||||
required. <tt>hello</tt> is a simple shell script that runs the bytecode
|
into one bytecode file and does some optimization. It is the linker
|
||||||
file with <tt>lli</tt>, making the result directly executable.<p>
|
invoked by the gcc frontend when multiple .o files need to be linked
|
||||||
|
together. Like <tt>gccas</tt> the command line interface of <tt>gccld</tt>
|
||||||
<li>Run the program. To make sure the program ran, execute one of the
|
is designed to match the system linker, to aid interfacing with the
|
||||||
following commands:<p>
|
GCC frontend.
|
||||||
|
<p> </p>
|
||||||
<tt>% ./hello</tt><p>
|
</dd>
|
||||||
|
|
||||||
or<p>
|
|
||||||
|
|
||||||
<tt>% lli hello.bc</tt><p>
|
|
||||||
|
|
||||||
<li>Use the <tt>dis</tt> utility to take a look at the LLVM assembly
|
|
||||||
code:<p>
|
|
||||||
|
|
||||||
<tt>% dis < hello.bc | less</tt><p>
|
|
||||||
|
|
||||||
<li>Compile the program to native Sparc assembly using the code
|
|
||||||
generator:<p>
|
|
||||||
|
|
||||||
<tt>% llc hello.bc -o hello.s</tt><p>
|
|
||||||
|
|
||||||
<li>Assemble the native sparc assemble file into a program:<p>
|
|
||||||
|
|
||||||
<tt>% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc</tt><p>
|
|
||||||
|
|
||||||
<li>Execute the native sparc program:<p>
|
|
||||||
|
|
||||||
<tt>% ./hello.sparc</tt><p>
|
|
||||||
|
|
||||||
</ol>
|
</ol>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>opt</b></tt></dt>
|
||||||
|
<dd> <tt>opt</tt> reads LLVM bytecode, applies a series of LLVM to
|
||||||
|
LLVM transformations (which are specified on the command line), and
|
||||||
|
then outputs the resultant bytecode. The '<tt>opt --help</tt>' command
|
||||||
|
is a good way to get a list of the program transformations available
|
||||||
|
in LLVM.
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
<dt><tt><b>analyze</b></tt></dt>
|
||||||
|
<dd> <tt>analyze</tt> is used to run a specific analysis on an input
|
||||||
|
LLVM bytecode file and print out the results. It is primarily useful
|
||||||
|
for debugging analyses, or familiarizing yourself with what an analysis
|
||||||
|
does.
|
||||||
|
<p> </p>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
|
<h2><a name="tutorial">An example using the LLVM tool chain</a></h2>
|
||||||
|
<a name="tutorial"> <!--=====================================================================-->
|
||||||
|
</a>
|
||||||
|
<ol>
|
||||||
|
<a name="tutorial"> <li>First, create a simple C file, name it 'hello.c':
|
||||||
|
|
||||||
<!--=====================================================================-->
|
<pre> #include <stdio.h><br> int main() {<br> printf("hello world\n");<br> return 0;<br> }<br> </pre>
|
||||||
<h2><a name="links">Links</a></h2>
|
</li>
|
||||||
<!--=====================================================================-->
|
<li>Next, compile the C file into a LLVM bytecode file:
|
||||||
|
<p> <tt>% llvmgcc hello.c -o hello</tt></p>
|
||||||
|
<p> This will create two result files: <tt>hello</tt> and
|
||||||
|
<tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
|
||||||
|
corresponds the the compiled program and the library facilities that it
|
||||||
|
required. <tt>hello</tt> is a simple shell script that runs the bytecode
|
||||||
|
file with <tt>lli</tt>, making the result directly executable.</p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
<li>Run the program. To make sure the program ran, execute one of the
|
||||||
|
following commands:
|
||||||
|
<p> <tt>% ./hello</tt></p>
|
||||||
|
<p> or</p>
|
||||||
|
<p> <tt>% lli hello.bc</tt></p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
<li>Use the <tt>dis</tt> utility to take a look at the LLVM assembly
|
||||||
|
code:
|
||||||
|
<p> <tt>% dis < hello.bc | less</tt></p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
<li>Compile the program to native Sparc assembly using the code generator:
|
||||||
|
<p> <tt>% llc hello.bc -o hello.s</tt></p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
<li>Assemble the native sparc assemble file into a program:
|
||||||
|
<p> <tt>% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc</tt></p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
<li>Execute the native sparc program:
|
||||||
|
<p> <tt>% ./hello.sparc</tt></p>
|
||||||
|
<p> </p>
|
||||||
|
</li>
|
||||||
|
</a>
|
||||||
|
</ol>
|
||||||
|
<a name="tutorial"> <!--=====================================================================-->
|
||||||
|
</a>
|
||||||
|
<h2><a name="links">Links</a></h2>
|
||||||
|
<!--=====================================================================-->
|
||||||
|
|
||||||
<p>This document is just an <b>introduction</b> to how to use LLVM to do
|
<p>This document is just an <b>introduction</b> to how to use LLVM to do
|
||||||
some simple things... there are many more interesting and complicated things
|
some simple things... there are many more interesting and complicated
|
||||||
that you can do that aren't documented here (but we'll gladly accept a patch
|
things that you can do that aren't documented here (but we'll gladly
|
||||||
if you want to write something up!). For more information about LLVM, check
|
accept a patch if you want to write something up!). For more information
|
||||||
out:</p>
|
about LLVM, check out:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li>
|
<li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li>
|
||||||
<li><a href="http://llvm.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li>
|
<li><a href="http://llvm.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li>
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr>
|
</ul>
|
||||||
|
|
||||||
If you have any questions or run into any snags (or you have any
|
<hr> If you have any questions or run into any snags (or you have any
|
||||||
additions...), please send an email to
|
additions...), please send an email to <a
|
||||||
<a href="mailto:sabre@nondot.org">Chris Lattner</a>.</p>
|
href="mailto:sabre@nondot.org">Chris Lattner</a>.
|
||||||
|
<p></p>
|
||||||
<!-- Created: Mon Jul 1 02:29:02 CDT 2002 -->
|
<!-- Created: Mon Jul 1 02:29:02 CDT 2002 --> <!-- hhmts start -->
|
||||||
<!-- hhmts start -->
|
Last modified: Tue Jun 3 22:06:43 CDT 2003 <!-- hhmts end --> <br>
|
||||||
Last modified: Tue Jun 3 22:06:43 CDT 2003
|
</body>
|
||||||
<!-- hhmts end -->
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user