blob: f8588af6c59e969794a703dd190b9f4de619aa67 [file] [log] [blame]
Guochun Shif4688a82002-07-17 23:05:56 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
John Criswell85ed3612003-06-12 19:34:44 +00003 <head>
4 <title>Getting Started with LLVM System</title>
5 </head>
6
7 <body bgcolor=white>
8 <center><h1>Getting Started with the LLVM System<br><font size=3>By: <a
9 href="mailto:gshi1@uiuc.edu">Guochun Shi</a>,
John Criswellcb27f1e2003-07-01 21:55:57 +000010 <a href="mailto:sabre@nondot.org">Chris Lattner</a>,
Misha Brukmanc103adf2003-08-11 18:45:46 +000011 <a href="mailto:criswell@uiuc.edu">John Criswell</a>,
12 <a href="http://misha.brukman.net">Misha Brukman</a>, and
John Criswell85ed3612003-06-12 19:34:44 +000013 <a href="http://www.cs.uiuc.edu/~vadve">Vikram Adve</a>
14 </font></h1></center>
15
16 <!--=====================================================================-->
17 <h2><a name="Contents">Contents</a></h2>
18 <!--=====================================================================-->
19
20 <ul>
21 <li><a href="#overview">Overview</a>
John Criswell20d2d3e2003-10-10 14:26:14 +000022 <li><a href="#quickstart">Getting Started Quickly (A Summary)</a>
John Criswell3ab71362003-10-20 16:39:52 +000023 <li><a href="#requirements">Requirements</a>
24 <ol>
25 <li><a href="#hardware">Hardware</a>
26 <li><a href="#software">Software</a>
27 </ol>
28
John Criswellabb1b582003-10-10 16:17:19 +000029 <li><a href="#starting">Getting Started with LLVM</a>
John Criswellce760f62003-07-03 16:01:38 +000030 <ol>
John Criswell85ed3612003-06-12 19:34:44 +000031 <li><a href="#terminology">Terminology and Notation</tt></a>
John Criswell0b459202003-07-08 20:35:59 +000032 <li><a href="#environment">Setting Up Your Environment</a>
John Criswell312a68c2003-07-07 19:27:35 +000033 <li><a href="#unpack">Unpacking the LLVM Archives</a>
John Criswellce760f62003-07-03 16:01:38 +000034 <li><a href="#checkout">Checkout LLVM from CVS</a>
John Criswellabb1b582003-10-10 16:17:19 +000035 <li><a href="#installcf">Install the GCC Front End</a>
John Criswell0b459202003-07-08 20:35:59 +000036 <li><a href="#config">Local LLVM Configuration</tt></a>
John Criswellce760f62003-07-03 16:01:38 +000037 <li><a href="#compile">Compiling the LLVM Suite Source Code</a>
John Criswell0b459202003-07-08 20:35:59 +000038 <li><a href="#objfiles">The Location of LLVM Object Files</tt></a>
John Criswell85ed3612003-06-12 19:34:44 +000039 </ol>
40 <li><a href="#layout">Program layout</a>
Misha Brukmanc103adf2003-08-11 18:45:46 +000041 <ol>
42 <li><a href="#cvsdir"><tt>CVS</tt> directories</a>
43 <li><a href="#include"><tt>llvm/include</tt></a>
44 <li><a href="#lib"><tt>llvm/lib</tt></a>
John Criswellabb1b582003-10-10 16:17:19 +000045 <li><a href="#runtime"><tt>llvm/runtime</tt></a>
Misha Brukmanc103adf2003-08-11 18:45:46 +000046 <li><a href="#test"><tt>llvm/test</tt></a>
47 <li><a href="#tools"><tt>llvm/tools</tt></a>
48 <li><a href="#utils"><tt>llvm/utils</tt></a>
49 </ol>
John Criswell0b459202003-07-08 20:35:59 +000050 <li><a href="#tutorial">An Example Using the LLVM Tool Chain</a>
51 <li><a href="#problems">Common Problems</a>
John Criswell85ed3612003-06-12 19:34:44 +000052 <li><a href="#links">Links</a>
53 </ul>
54
55
56 <!--=====================================================================-->
57 <center>
58 <h2><a name="overview"><b>Overview</b></a></h2>
59 </center>
John Criswell20d2d3e2003-10-10 14:26:14 +000060 <hr>
John Criswell85ed3612003-06-12 19:34:44 +000061 <!--=====================================================================-->
62
John Criswellce760f62003-07-03 16:01:38 +000063 Welcome to LLVM! In order to get started, you first need to know some
64 basic information.
65
66 <p>
67 First, LLVM comes in two pieces. The first piece is the LLVM suite. This
68 contains all of the tools, libraries, and header files needed to use the
John Criswell3ab71362003-10-20 16:39:52 +000069 low level virtual machine. It contains an assembler, disassembler,
70 bytecode analyzer, and bytecode optimizer. It also contains a test suite
71 that can be used to test the LLVM tools and the GCC front end.
John Criswellce760f62003-07-03 16:01:38 +000072 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +000073 The second piece is the GCC front end. This component provides a version
74 of GCC that compiles C and C++ code into LLVM bytecode. Currently, the
75 GCC front end is a modified version of GCC 3.4 (we track the GCC 3.4
76 development). Once compiled into LLVM bytecode, a program can be
77 manipulated with the LLVM tools from the LLVM suite.
John Criswellce760f62003-07-03 16:01:38 +000078
79 <!--=====================================================================-->
John Criswell85ed3612003-06-12 19:34:44 +000080 <center>
John Criswell20d2d3e2003-10-10 14:26:14 +000081 <h2><a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a></h2>
John Criswell85ed3612003-06-12 19:34:44 +000082 </center>
John Criswell20d2d3e2003-10-10 14:26:14 +000083 <hr>
John Criswell85ed3612003-06-12 19:34:44 +000084 <!--=====================================================================-->
85
86 Here's the short story for getting up and running quickly with LLVM:
Chris Lattner96768ea2003-02-14 04:22:13 +000087 <ol>
John Criswell20d2d3e2003-10-10 14:26:14 +000088 <li>Install the GCC front end:
John Criswellce760f62003-07-03 16:01:38 +000089 <ol>
John Criswell0b459202003-07-08 20:35:59 +000090 <li><tt>cd <i>where-you-want-the-C-front-end-to-live</i></tt>
91 <li><tt>gunzip --stdout cfrontend.<i>platform</i>.tar.gz | tar -xvf
92 -</tt>
93 </ol>
John Criswell7a73b802003-06-30 21:59:07 +000094
John Criswell0b459202003-07-08 20:35:59 +000095 <p>
96
97 <li>Get the Source Code
98 <ul>
99 <li>With the distributed files:
100 <ol>
101 <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
102 <li><tt>gunzip --stdout llvm.tar.gz | tar -xvf -</tt>
John Criswell0b459202003-07-08 20:35:59 +0000103 <li><tt>cd llvm</tt>
104 </ol>
105
106 <p>
107
108 <li>With anonymous CVS access:
109 <ol>
Misha Brukmanc103adf2003-08-11 18:45:46 +0000110 <li>Find the path to the CVS repository containing LLVM (we'll
111 call this <i>CVSROOTDIR</i>).
John Criswell0b459202003-07-08 20:35:59 +0000112 <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
113 <li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt>
114 <li><tt>cd llvm</tt>
115 </ol>
116 </ul>
117 </ul>
118
119 <p>
120
121 <li>Configure the LLVM Build Environment
122 <ol>
John Criswell20d2d3e2003-10-10 14:26:14 +0000123 <li>Change directory to where you want to store the LLVM object
124 files and run <tt>configure</tt> to configure the Makefiles and
125 header files for the default platform.
John Criswell0b459202003-07-08 20:35:59 +0000126 Useful options include:
127 <ul>
John Criswell0b459202003-07-08 20:35:59 +0000128 <li><tt>--with-llvmgccdir=<i>directory</i></tt>
129 <br>
John Criswell20d2d3e2003-10-10 14:26:14 +0000130 Specify where the LLVM GCC frontend is installed.
John Criswellabb1b582003-10-10 16:17:19 +0000131 <p>
132
133 <li><tt>--enable-spec2000=<i>directory</i></tt>
134 <br>
135 Enable the SPEC2000 benchmarks for testing. The SPEC2000
136 benchmarks should be available in <tt><i>directory</i></tt>.
John Criswell0b459202003-07-08 20:35:59 +0000137 </ul>
138 </ol>
139
140 <p>
141
142 <li>Build the LLVM Suite
143 <ol>
144 <li>Set your LLVM_LIB_SEARCH_PATH environment variable.
145 <li><tt>gmake -k |& tee gnumake.out
John Criswellce760f62003-07-03 16:01:38 +0000146 &nbsp;&nbsp;&nbsp;# this is csh or tcsh syntax</tt>
147 </ol>
John Criswell0b459202003-07-08 20:35:59 +0000148
John Criswellce760f62003-07-03 16:01:38 +0000149 <p>
John Criswell0b459202003-07-08 20:35:59 +0000150
Chris Lattner96768ea2003-02-14 04:22:13 +0000151 </ol>
John Criswell85ed3612003-06-12 19:34:44 +0000152
John Criswell3ab71362003-10-20 16:39:52 +0000153 <p>
154 Consult the <a href="starting">Getting Started with LLVM</a> section for
155 detailed information on configuring and compiling LLVM. See
156 <a href="#environment">Setting Up Your Environment</a> for tips that
157 simplify working with the GCC front end and LLVM tools. Go to
158 <a href="#layout">Program Layout</a> to learn about the layout of the
159 source code tree.
160
161 <!--=====================================================================-->
162 <center>
163 <h2><a name="requirements"><b>Requirements</b></a></h2>
164 </center>
165 <hr>
166 <!--=====================================================================-->
167
168 Before you begin to use the LLVM system, review the requirements given
169 below. This may save you some trouble by knowing ahead of time what
170 hardware and software you will need.
171
172 <!--=====================================================================-->
173 <h3><a name="hardware"><b>Hardware</b></a></h3>
174 <!--=====================================================================-->
175 LLVM is known to work on the following platforms:
176 <ul>
177 <li> Linux on x86 (Pentium and above)
178 <ul>
179 <li> Approximately 760 MB of Free Disk Space
180 <ul>
181 <li>Source code: 30 MB
182 <li>Object code: 670 MB
183 <li>GCC front end: 60 MB
184 </ul>
185 </ul>
186
187 <p>
188
189 <li> Solaris on SparcV9 (Ultrasparc)
190 <ul>
191 <li> Approximately 1.24 GB of Free Disk Space
192 <ul>
193 <li>Source code: 30 MB
194 <li>Object code: 1000 MB
195 <li>GCC front end: 210 MB
196 </ul>
197 </ul>
198 </ul>
199
200 The LLVM suite <i>may</i> compile on other platforms, but it is not
201 guaranteed to do so. If compilation is successful, the LLVM utilities
202 should be able to assemble, disassemble, analyze, and optimize LLVM
203 bytecode. Code generation should work as well, although the generated
204 native code may not work on your platform.
205 <p>
206 The GCC front end is not very portable at the moment. If you want to get
207 it to work on another platform, you can always request
208 <a href="mailto:llvm-request@zion.cs.uiuc.edu">a copy of the source</a>
209 and try to compile it on your platform.
210 </p>
211
212 <!--=====================================================================-->
213 <h3><a name="software"><b>Software</b></a></h3>
214 <!--=====================================================================-->
215 <p>
216
217 Compiling LLVM requires that you have several software packages installed:
218
219 <ul compact>
220 <li>
221 <a href="http://gcc.gnu.org">GCC 3.x with C and C++ language support</a>
222
223 <li>
224 <a href="http://savannah.gnu.org/projects/make">GNU Make</a>
225
226 <li>
227 <a href="http://www.gnu.org/software/flex">Flex</a>
228
229 <li>
230 <a href="http://www.gnu.org/software/bison/bison.html">Bison</a>
231 </ul>
232
233 <p>
234 There are some additional tools that you may want to have when working with
235 LLVM:
236 </p>
237
238 <ul>
239 <li><A href="http://www.gnu.org/software/autoconf">GNU Autoconf</A>
240 <li><A href="http://savannah.gnu.org/projects/m4">GNU M4</A>
241 <p>
242 If you want to make changes to the configure scripts, you will need
243 GNU autoconf (2.57 or higher), and consequently, GNU M4 (version 1.4
244 or higher).
245 </p>
246
247 <li><A href="http://www.codesourcery.com/qm/qmtest">QMTest</A>
248 <li><A href="http://www.python.org">Python</A>
249 <p>
250 These are needed to use the LLVM test suite.
251 </ul>
252
253
254 <p>The remainder of this guide is meant to get you up and running with
255 LLVM and to give you some basic information about the LLVM environment.
256 A <a href="#starting">complete guide to installation</a> is provided in the
257 next section.
258
259 <p>The later sections of this guide describe the <a
260 href="#layout">general layout</a> of the the LLVM source tree, a <a
261 href="#tutorial">simple example</a> using the LLVM tool chain, and <a
262 href="#links">links</a> to find more information about LLVM or to get
263 help via e-mail.
John Criswell85ed3612003-06-12 19:34:44 +0000264
John Criswell20d2d3e2003-10-10 14:26:14 +0000265 <!--=====================================================================-->
266 <center>
267 <h2><a name="starting"><b>Getting Started with LLVM</b></a></h2>
268 </center>
269 <hr>
270 <!--=====================================================================-->
271
John Criswell85ed3612003-06-12 19:34:44 +0000272 <!------------------------------------------------------------------------->
273 <h3><a name="terminology">Terminology and Notation</a></h3>
274 <!------------------------------------------------------------------------->
275
276 <p>Throughout this manual, the following names are used to denote paths
277 specific to the local system and working environment. <i>These are not
John Criswell7a73b802003-06-30 21:59:07 +0000278 environment variables you need to set but just strings used in the rest
279 of this document below</i>. In any of the examples below, simply replace
John Criswell85ed3612003-06-12 19:34:44 +0000280 each of these names with the appropriate pathname on your local system.
Chris Lattner1db872d2002-09-06 16:26:13 +0000281 All these paths are absolute:</p>
John Criswellce760f62003-07-03 16:01:38 +0000282 <dl compact>
283 <dt>CVSROOTDIR
284 <dd>
285 This is the path for the CVS repository containing the LLVM source
286 code. Ask the person responsible for your local LLVM installation to
287 give you this path.
288 <p>
289
John Criswell20d2d3e2003-10-10 14:26:14 +0000290 <dt>SRC_ROOT
291 <dd>
292 This is the top level directory of the LLVM source tree.
293 <p>
294
John Criswellce760f62003-07-03 16:01:38 +0000295 <dt>OBJ_ROOT
296 <dd>
John Criswell20d2d3e2003-10-10 14:26:14 +0000297 This is the top level directory of the LLVM object tree (i.e. the
298 tree where object files and compiled programs will be placed. It
299 can be the same as SRC_ROOT).
John Criswellce760f62003-07-03 16:01:38 +0000300 <p>
301
302 <dt>LLVMGCCDIR
303 <dd>
John Criswell20d2d3e2003-10-10 14:26:14 +0000304 This is the where the LLVM GCC Front End is installed.
John Criswellce760f62003-07-03 16:01:38 +0000305 <p>
John Criswellabb1b582003-10-10 16:17:19 +0000306 For the pre-built GCC front end binaries, the LLVMGCCDIR is
John Criswella27028b2003-07-03 16:49:40 +0000307 <tt>cfrontend/<i>platform</i>/llvm-gcc</tt>.
John Criswellce760f62003-07-03 16:01:38 +0000308 </dl>
309
310 <!------------------------------------------------------------------------->
John Criswell0b459202003-07-08 20:35:59 +0000311 <h3><a name="environment">Setting Up Your Environment</a></h3>
John Criswellce760f62003-07-03 16:01:38 +0000312 <!------------------------------------------------------------------------->
313
314 <p>
315 In order to compile and use LLVM, you will need to set some environment
316 variables. There are also some shell aliases which you may find useful.
317 You can set these on the command line, or better yet, set them in your
318 <tt>.cshrc</tt> or <tt>.profile</tt>.
319
320 <dl compact>
321 <dt><tt>LLVM_LIB_SEARCH_PATH</tt>=<tt><i>LLVMGCCDIR</i>/llvm-gcc/bytecode-libs</tt>
322 <dd>
John Criswell20d2d3e2003-10-10 14:26:14 +0000323 This environment variable helps the LLVM GCC front end find bytecode
John Criswellce760f62003-07-03 16:01:38 +0000324 libraries that it will need for compilation.
325 <p>
326
John Criswellabb1b582003-10-10 16:17:19 +0000327 <dt>alias llvmgcc <i>LLVMGCCDIR</i><tt>/llvm-gcc/bin/gcc</tt>
328 <dt>alias llvmg++ <i>LLVMGCCDIR</i><tt>/llvm-gcc/bin/g++</tt>
John Criswellce760f62003-07-03 16:01:38 +0000329 <dd>
John Criswell20d2d3e2003-10-10 14:26:14 +0000330 This alias allows you to use the LLVM C and C++ front ends without putting
331 them in your <tt>PATH</tt> or typing in their complete pathnames.
John Criswellce760f62003-07-03 16:01:38 +0000332 </dl>
John Criswell85ed3612003-06-12 19:34:44 +0000333
334 <!------------------------------------------------------------------------->
John Criswell312a68c2003-07-07 19:27:35 +0000335 <h3><a name="unpack">Unpacking the LLVM Archives</a></h3>
336 <!------------------------------------------------------------------------->
337
338 <p>
339 If you have the LLVM distribution, you will need to unpack it before you
John Criswellabb1b582003-10-10 16:17:19 +0000340 can begin to compile it. LLVM is distributed as a set of three files. Each
John Criswell312a68c2003-07-07 19:27:35 +0000341 file is a TAR archive that is compressed with the gzip program.
342 </p>
343
John Criswellabb1b582003-10-10 16:17:19 +0000344 <p> The three files are as follows:
John Criswell312a68c2003-07-07 19:27:35 +0000345 <dl compact>
346 <dt>llvm.tar.gz
347 <dd>This is the source code to the LLVM suite.
348 <p>
349
350 <dt>cfrontend.sparc.tar.gz
John Criswell20d2d3e2003-10-10 14:26:14 +0000351 <dd>This is the binary release of the GCC front end for Solaris/Sparc.
John Criswell312a68c2003-07-07 19:27:35 +0000352 <p>
353
354 <dt>cfrontend.x86.tar.gz
John Criswell20d2d3e2003-10-10 14:26:14 +0000355 <dd>This is the binary release of the GCC front end for Linux/x86.
John Criswell312a68c2003-07-07 19:27:35 +0000356 </dl>
357
John Criswell312a68c2003-07-07 19:27:35 +0000358 <!------------------------------------------------------------------------->
John Criswell85ed3612003-06-12 19:34:44 +0000359 <h3><a name="checkout">Checkout LLVM from CVS</a></h3>
360 <!------------------------------------------------------------------------->
361
John Criswell312a68c2003-07-07 19:27:35 +0000362 <p>If you have access to our CVS repository, you can get a fresh copy of
363 the entire source code. All you need to do is check it out from CVS as
364 follows:
John Criswell85ed3612003-06-12 19:34:44 +0000365 <ul>
366 <li><tt>cd <i>where-you-want-llvm-to-live</i></tt>
367 <li><tt>cvs -d <i>CVSROOTDIR</i> checkout llvm</tt></p>
368 </ul>
369
370 <p>This will create an '<tt>llvm</tt>' directory in the current
371 directory and fully populate it with the LLVM source code, Makefiles,
372 test directories, and local copies of documentation files.</p>
373
John Criswellce760f62003-07-03 16:01:38 +0000374 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000375 Note that the GCC front end is not included in the CVS repository. You
John Criswellabb1b582003-10-10 16:17:19 +0000376 should have downloaded the binary distribution for your platform.
John Criswellce760f62003-07-03 16:01:38 +0000377 </p>
378
John Criswell85ed3612003-06-12 19:34:44 +0000379 <!------------------------------------------------------------------------->
John Criswell20d2d3e2003-10-10 14:26:14 +0000380 <h3><a name="installcf">Install the GCC Front End</a></h3>
John Criswell0b459202003-07-08 20:35:59 +0000381 <!------------------------------------------------------------------------->
382
383 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000384 Before configuring and compiling the LLVM suite, you need to extract the
385 LLVM GCC front end from the binary distribution. It is used for building the
386 bytecode libraries later used by the GCC front end for linking programs, and
387 its location must be specified when the LLVM suite is configured.
John Criswell0b459202003-07-08 20:35:59 +0000388 </p>
389
390 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000391 To install the GCC front end, do the following:
John Criswell0b459202003-07-08 20:35:59 +0000392 <ol>
393 <li><tt>cd <i>where-you-want-the-front-end-to-live</i></tt>
394 <li><tt>gunzip --stdout cfrontend.<i>platform</i>.tar.gz | tar -xvf
395 -</tt>
396 </ol>
397
398 <!------------------------------------------------------------------------->
John Criswellce760f62003-07-03 16:01:38 +0000399 <h3><a name="config">Local LLVM Configuration</a></h3>
John Criswell85ed3612003-06-12 19:34:44 +0000400 <!------------------------------------------------------------------------->
401
John Criswellce760f62003-07-03 16:01:38 +0000402 <p>Once checked out from the CVS repository, the LLVM suite source code
403 must be configured via the <tt>configure</tt> script. This script sets
404 variables in <tt>llvm/Makefile.config</tt> and
John Criswellabb1b582003-10-10 16:17:19 +0000405 <tt>llvm/include/Config/config.h</tt>. It also populates <i>OBJ_ROOT</i> with
John Criswell20d2d3e2003-10-10 14:26:14 +0000406 the Makefiles needed to build LLVM.
John Criswell7a73b802003-06-30 21:59:07 +0000407
408 <p>
John Criswell0b459202003-07-08 20:35:59 +0000409 The following environment variables are used by the <tt>configure</tt>
410 script to configure the build system:
John Criswell7a73b802003-06-30 21:59:07 +0000411 </p>
John Criswell85ed3612003-06-12 19:34:44 +0000412
John Criswell0b459202003-07-08 20:35:59 +0000413 <table border=1>
414 <tr>
415 <th>Variable</th>
416 <th>
417 Purpose
418 </th>
419 </tr>
John Criswell85ed3612003-06-12 19:34:44 +0000420
John Criswell0b459202003-07-08 20:35:59 +0000421 <tr>
422 <td>CC</td>
423 <td>
424 Tells <tt>configure</tt> which C compiler to use. By default,
John Criswellabb1b582003-10-10 16:17:19 +0000425 <tt>configure</tt> will look for the first GCC C compiler in
John Criswell0b459202003-07-08 20:35:59 +0000426 <tt>PATH</tt>. Use this variable to override
427 <tt>configure</tt>'s default behavior.
428 </td>
429 </tr>
430
431 <tr>
432 <td>CXX</td>
433 <td>
434 Tells <tt>configure</tt> which C++ compiler to use. By default,
John Criswellabb1b582003-10-10 16:17:19 +0000435 <tt>configure</tt> will look for the first GCC C++ compiler in
John Criswell0b459202003-07-08 20:35:59 +0000436 <tt>PATH</tt>. Use this variable to override
437 <tt>configure</tt>'s default behavior.
438 </td>
439 </tr>
440 </table>
441
442 <p>
John Criswell7a73b802003-06-30 21:59:07 +0000443 The following options can be used to set or enable LLVM specific options:
John Criswell0b459202003-07-08 20:35:59 +0000444 </p>
John Criswell7a73b802003-06-30 21:59:07 +0000445
John Criswellce760f62003-07-03 16:01:38 +0000446 <dl compact>
John Criswellce760f62003-07-03 16:01:38 +0000447 <dt><i>--with-llvmgccdir=LLVMGCCDIR</i>
448 <dd>
449 Path to the location where the LLVM C front end binaries and
450 associated libraries will be installed.
451 <p>
452 <dt><i>--enable-optimized</i>
453 <dd>
John Criswell623e5942003-10-10 18:51:11 +0000454 Enables optimized compilation by default (debugging symbols are removed
John Criswell20d2d3e2003-10-10 14:26:14 +0000455 and GCC optimization flags are enabled). The default is to use an
456 unoptimized build (also known as a debug build).
John Criswellce760f62003-07-03 16:01:38 +0000457 <p>
458 <dt><i>--enable-jit</i>
459 <dd>
John Criswell7a73b802003-06-30 21:59:07 +0000460 Compile the Just In Time (JIT) functionality. This is not available
John Criswellce760f62003-07-03 16:01:38 +0000461 on all platforms. The default is dependent on platform, so it is best
462 to explicitly enable it if you want it.
John Criswell20d2d3e2003-10-10 14:26:14 +0000463 <p>
464 <dt><i>--enable-spec2000</i>
465 <dt><i>--enable-spec2000=&lt;<tt>directory</tt>&gt;</i>
466 <dd>
467 Enable the use of SPEC2000 when testing LLVM. This is disabled by default
John Criswellabb1b582003-10-10 16:17:19 +0000468 (unless <tt>configure</tt> finds SPEC2000 installed). By specifying
John Criswell20d2d3e2003-10-10 14:26:14 +0000469 <tt>directory</tt>, you can tell configure where to find the SPEC2000
John Criswellabb1b582003-10-10 16:17:19 +0000470 benchmarks. If <tt>directory</tt> is left unspecified, <tt>configure</tt>
471 uses the default value
472 <tt>/home/vadve/shared/benchmarks/speccpu2000/benchspec</tt>.
John Criswellce760f62003-07-03 16:01:38 +0000473 </dl>
John Criswell7a73b802003-06-30 21:59:07 +0000474
John Criswell20d2d3e2003-10-10 14:26:14 +0000475 <p>
476 To configure LLVM, follow these steps:
477 <ol>
478 <li>Change directory into the object root directory:
479 <br>
480 <tt>cd <i>OBJ_ROOT</i></tt>
481 <p>
482
John Criswellabb1b582003-10-10 16:17:19 +0000483 <li>Run the <tt>configure</tt> script located in the LLVM source tree:
John Criswell20d2d3e2003-10-10 14:26:14 +0000484 <br>
485 <tt><i>SRC_ROOT</i>/configure</tt>
486 <p>
487 </ol>
488 </p>
489
John Criswell7a73b802003-06-30 21:59:07 +0000490 In addition to running <tt>configure</tt>, you must set the
John Criswell85ed3612003-06-12 19:34:44 +0000491 <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable in your startup scripts.
492 This environment variable is used to locate "system" libraries like
493 "<tt>-lc</tt>" and "<tt>-lm</tt>" when linking. This variable should be set
John Criswell20d2d3e2003-10-10 14:26:14 +0000494 to the absolute path for the bytecode-libs subdirectory of the GCC front end
John Criswellabb1b582003-10-10 16:17:19 +0000495 install, or <i>LLVMGCCDIR</i>/llvm-gcc/bytecode-libs. For example, one might
John Criswellce760f62003-07-03 16:01:38 +0000496 set <tt>LLVM_LIB_SEARCH_PATH</tt> to
John Criswell85ed3612003-06-12 19:34:44 +0000497 <tt>/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs</tt> for the X86
John Criswellabb1b582003-10-10 16:17:19 +0000498 version of the GCC front end on our research machines.<p>
John Criswell85ed3612003-06-12 19:34:44 +0000499
500 <!------------------------------------------------------------------------->
John Criswellce760f62003-07-03 16:01:38 +0000501 <h3><a name="compile">Compiling the LLVM Suite Source Code</a></h3>
502 <!------------------------------------------------------------------------->
503
504 Once you have configured LLVM, you can build it. There are three types of
505 builds:
506
507 <dl compact>
508 <dt>Debug Builds
509 <dd>
John Criswell20d2d3e2003-10-10 14:26:14 +0000510 These builds are the default when one types <tt>gmake</tt> (unless the
John Criswellabb1b582003-10-10 16:17:19 +0000511 <tt>--enable-optimized</tt> option was used during configuration). The
512 build system will compile the tools and libraries with debugging
513 information.
John Criswellce760f62003-07-03 16:01:38 +0000514 <p>
515
516 <dt>Release (Optimized) Builds
517 <dd>
518 These builds are enabled with the <tt>--enable-optimized</tt> option to
John Criswell20d2d3e2003-10-10 14:26:14 +0000519 <tt>configure</tt> or by specifying <tt>ENABLE_OPTIMIZED=1</tt> on the
John Criswellabb1b582003-10-10 16:17:19 +0000520 <tt>gmake</tt> command line. For these builds, the build system will
521 compile the tools and libraries with GCC optimizations enabled and strip
522 debugging information from the libraries and executables it generates.
John Criswellce760f62003-07-03 16:01:38 +0000523 <p>
524
525 <dt>Profile Builds
526 <dd>
527 These builds are for use with profiling. They compile profiling
528 information into the code for use with programs like <tt>gprof</tt>.
John Criswell20d2d3e2003-10-10 14:26:14 +0000529 Profile builds must be started by specifying <tt>ENABLE_PROFILING=1</tt>
530 on the <tt>gmake</tt> command line.
John Criswellce760f62003-07-03 16:01:38 +0000531 </dl>
532
John Criswellabb1b582003-10-10 16:17:19 +0000533 Once you have LLVM configured, you can build it by entering the
534 <i>OBJ_ROOT</i> directory and issuing the following command:
John Criswellce760f62003-07-03 16:01:38 +0000535 <p>
John Criswell0b459202003-07-08 20:35:59 +0000536 <tt>gmake</tt>
John Criswellce760f62003-07-03 16:01:38 +0000537
538 <p>
539 If you have multiple processors in your machine, you may wish to use some
540 of the parallel build options provided by GNU Make. For example, you could
541 use the command:
542 </p>
543
544 <p>
John Criswell0b459202003-07-08 20:35:59 +0000545 <tt>gmake -j2</tt>
John Criswellce760f62003-07-03 16:01:38 +0000546
547 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000548 There are several special targets which are useful when working with the LLVM
John Criswellce760f62003-07-03 16:01:38 +0000549 source code:
550
551 <dl compact>
John Criswell0b459202003-07-08 20:35:59 +0000552 <dt><tt>gmake clean</tt>
John Criswellce760f62003-07-03 16:01:38 +0000553 <dd>
554 Removes all files generated by the build. This includes object files,
555 generated C/C++ files, libraries, and executables.
556 <p>
557
John Criswell0b459202003-07-08 20:35:59 +0000558 <dt><tt>gmake distclean</tt>
John Criswellce760f62003-07-03 16:01:38 +0000559 <dd>
John Criswell0b459202003-07-08 20:35:59 +0000560 Removes everything that <tt>gmake clean</tt> does, but also removes
John Criswellce760f62003-07-03 16:01:38 +0000561 files generated by <tt>configure</tt>. It attempts to return the
562 source tree to the original state in which it was shipped.
563 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000564
565 <dt><tt>gmake install</tt>
566 <dd>
567 Installs LLVM files into the proper location. For the most part,
568 this does nothing, but it does install bytecode libraries into the
569 GCC front end's bytecode library directory. If you need to update
570 your bytecode libraries, this is the target to use once you've built
571 them.
572 <p>
573
John Criswellce760f62003-07-03 16:01:38 +0000574 </dl>
575
576 It is also possible to override default values from <tt>configure</tt> by
577 declaring variables on the command line. The following are some examples:
578
579 <dl compact>
John Criswell0b459202003-07-08 20:35:59 +0000580 <dt><tt>gmake ENABLE_OPTIMIZED=1</tt>
John Criswellce760f62003-07-03 16:01:38 +0000581 <dd>
582 Perform a Release (Optimized) build.
583 <p>
584
John Criswell0b459202003-07-08 20:35:59 +0000585 <dt><tt>gmake ENABLE_PROFILING=1</tt>
John Criswellce760f62003-07-03 16:01:38 +0000586 <dd>
587 Perform a Profiling build.
588 <p>
589
John Criswell0b459202003-07-08 20:35:59 +0000590 <dt><tt>gmake VERBOSE=1</tt>
John Criswellce760f62003-07-03 16:01:38 +0000591 <dd>
John Criswell0b459202003-07-08 20:35:59 +0000592 Print what <tt>gmake</tt> is doing on standard output.
John Criswellce760f62003-07-03 16:01:38 +0000593 <p>
594 </dl>
595
John Criswell20d2d3e2003-10-10 14:26:14 +0000596 Every directory in the LLVM object tree includes a <tt>Makefile</tt> to
John Criswellce760f62003-07-03 16:01:38 +0000597 build it and any subdirectories that it contains. Entering any directory
John Criswell20d2d3e2003-10-10 14:26:14 +0000598 inside the LLVM object tree and typing <tt>gmake</tt> should rebuild
John Criswellce760f62003-07-03 16:01:38 +0000599 anything in or below that directory that is out of date.
600
601 <!------------------------------------------------------------------------->
John Criswell0b459202003-07-08 20:35:59 +0000602 <h3><a name="objfiles">The Location of LLVM Object Files</a></h3>
John Criswell85ed3612003-06-12 19:34:44 +0000603 <!------------------------------------------------------------------------->
604
John Criswellce760f62003-07-03 16:01:38 +0000605 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000606 The LLVM build system is capable of sharing a single LLVM source tree among
607 several LLVM builds. Hence, it is possible to build LLVM for several
608 different platforms or configurations using the same source tree.
John Criswellef0096f2003-08-08 22:36:30 +0000609 <p>
John Criswell20d2d3e2003-10-10 14:26:14 +0000610 This is accomplished in the typical autoconf manner:
611 <ul>
612 <li>Change directory to where the LLVM object files should live:
613 <p>
614 <tt>cd <i>OBJ_ROOT</i></tt>
John Criswell85ed3612003-06-12 19:34:44 +0000615
John Criswell20d2d3e2003-10-10 14:26:14 +0000616 <li>Run the <tt>configure</tt> script found in the LLVM source directory:
617 <p>
618 <tt><i>SRC_ROOT</i>/configure</tt>
619 </ul>
John Criswell85ed3612003-06-12 19:34:44 +0000620
John Criswellce760f62003-07-03 16:01:38 +0000621 <p>
622 The LLVM build will place files underneath <i>OBJ_ROOT</i> in directories
623 named after the build type:
624 </p>
John Criswell85ed3612003-06-12 19:34:44 +0000625
John Criswellce760f62003-07-03 16:01:38 +0000626 <dl compact>
627 <dt>Debug Builds
628 <dd>
629 <dl compact>
630 <dt>Tools
John Criswell20d2d3e2003-10-10 14:26:14 +0000631 <dd><tt><i>OBJ_ROOT</i>/tools/Debug</tt>
John Criswellce760f62003-07-03 16:01:38 +0000632 <dt>Libraries
John Criswell20d2d3e2003-10-10 14:26:14 +0000633 <dd><tt><i>OBJ_ROOT</i>/lib/Debug</tt>
John Criswellce760f62003-07-03 16:01:38 +0000634 </dl>
635 <p>
John Criswell85ed3612003-06-12 19:34:44 +0000636
John Criswellce760f62003-07-03 16:01:38 +0000637 <dt>Release Builds
638 <dd>
639 <dl compact>
640 <dt>Tools
John Criswell20d2d3e2003-10-10 14:26:14 +0000641 <dd><tt><i>OBJ_ROOT</i>/tools/Release</tt>
John Criswellce760f62003-07-03 16:01:38 +0000642 <dt>Libraries
John Criswell20d2d3e2003-10-10 14:26:14 +0000643 <dd><tt><i>OBJ_ROOT</i>/lib/Release</tt>
John Criswellce760f62003-07-03 16:01:38 +0000644 </dl>
645 <p>
Chris Lattner7fe7f812002-07-24 19:51:14 +0000646
John Criswellce760f62003-07-03 16:01:38 +0000647 <dt>Profile Builds
648 <dd>
649 <dl compact>
650 <dt>Tools
John Criswell20d2d3e2003-10-10 14:26:14 +0000651 <dd><tt><i>OBJ_ROOT</i>/tools/Profile</tt>
John Criswellce760f62003-07-03 16:01:38 +0000652 <dt>Libraries
John Criswell20d2d3e2003-10-10 14:26:14 +0000653 <dd><tt><i>OBJ_ROOT</i>/lib/Profile</tt>
John Criswellce760f62003-07-03 16:01:38 +0000654 </dl>
655 </dl>
John Criswell85ed3612003-06-12 19:34:44 +0000656
657 <!--=====================================================================-->
658 <center>
659 <h2><a name="layout"><b>Program Layout</b></a></h2>
660 </center>
John Criswell20d2d3e2003-10-10 14:26:14 +0000661 <hr>
John Criswell85ed3612003-06-12 19:34:44 +0000662 <!--=====================================================================-->
663
John Criswell20d2d3e2003-10-10 14:26:14 +0000664 <p>
665 One useful source of information about the LLVM source base is the LLVM <a
John Criswell85ed3612003-06-12 19:34:44 +0000666 href="http://www.doxygen.org">doxygen</a> documentation, available at <tt><a
John Criswell20d2d3e2003-10-10 14:26:14 +0000667 href="http://llvm.cs.uiuc.edu/doxygen/">http://llvm.cs.uiuc.edu/doxygen/</a></tt>.
668 The following is a brief introduction to code layout:
669 </p>
John Criswell85ed3612003-06-12 19:34:44 +0000670
671 <!------------------------------------------------------------------------->
672 <h3><a name="cvsdir"><tt>CVS</tt> directories</a></h3>
673 <!------------------------------------------------------------------------->
674
675 Every directory checked out of CVS will contain a <tt>CVS</tt> directory;
676 for the most part these can just be ignored.
677
678
679 <!------------------------------------------------------------------------->
John Criswell85ed3612003-06-12 19:34:44 +0000680 <h3><a name="include"><tt>llvm/include</tt></a></h3>
681 <!------------------------------------------------------------------------->
682
683 This directory contains public header files exported from the LLVM
John Criswell7a73b802003-06-30 21:59:07 +0000684 library. The three main subdirectories of this directory are:<p>
John Criswell85ed3612003-06-12 19:34:44 +0000685
John Criswell8df90e02003-06-11 20:46:40 +0000686 <ol>
John Criswell85ed3612003-06-12 19:34:44 +0000687 <li><tt>llvm/include/llvm</tt> - This directory contains all of the LLVM
688 specific header files. This directory also has subdirectories for
689 different portions of LLVM: <tt>Analysis</tt>, <tt>CodeGen</tt>,
John Criswell20d2d3e2003-10-10 14:26:14 +0000690 <tt>Target</tt>, <tt>Transforms</tt>, etc...
John Criswell85ed3612003-06-12 19:34:44 +0000691
692 <li><tt>llvm/include/Support</tt> - This directory contains generic
John Criswellce760f62003-07-03 16:01:38 +0000693 support libraries that are independent of LLVM, but are used by LLVM.
John Criswell7a73b802003-06-30 21:59:07 +0000694 For example, some C++ STL utilities and a Command Line option processing
John Criswellabb1b582003-10-10 16:17:19 +0000695 library store their header files here.
John Criswell7a73b802003-06-30 21:59:07 +0000696
697 <li><tt>llvm/include/Config</tt> - This directory contains header files
698 configured by the <tt>configure</tt> script. They wrap "standard" UNIX
699 and C header files. Source code can include these header files which
John Criswellabb1b582003-10-10 16:17:19 +0000700 automatically take care of the conditional #includes that the
701 <tt>configure</tt> script generates.
Chris Lattner7fe7f812002-07-24 19:51:14 +0000702 </ol>
John Criswell85ed3612003-06-12 19:34:44 +0000703
704 <!------------------------------------------------------------------------->
705 <h3><a name="lib"><tt>llvm/lib</tt></a></h3>
706 <!------------------------------------------------------------------------->
707
John Criswell7a73b802003-06-30 21:59:07 +0000708 This directory contains most of the source files of the LLVM system. In
John Criswellabb1b582003-10-10 16:17:19 +0000709 LLVM, almost all
John Criswell7a73b802003-06-30 21:59:07 +0000710 code exists in libraries, making it very easy to share code among the
John Criswell85ed3612003-06-12 19:34:44 +0000711 different <a href="#tools">tools</a>.<p>
712
713 <dl compact>
714 <dt><tt>llvm/lib/VMCore/</tt><dd> This directory holds the core LLVM
715 source files that implement core classes like Instruction and BasicBlock.
716
717 <dt><tt>llvm/lib/AsmParser/</tt><dd> This directory holds the source code
718 for the LLVM assembly language parser library.
719
720 <dt><tt>llvm/lib/ByteCode/</tt><dd> This directory holds code for reading
721 and write LLVM bytecode.
722
723 <dt><tt>llvm/lib/CWriter/</tt><dd> This directory implements the LLVM to C
724 converter.
725
726 <dt><tt>llvm/lib/Analysis/</tt><dd> This directory contains a variety of
727 different program analyses, such as Dominator Information, Call Graphs,
728 Induction Variables, Interval Identification, Natural Loop Identification,
729 etc...
730
731 <dt><tt>llvm/lib/Transforms/</tt><dd> This directory contains the source
732 code for the LLVM to LLVM program transformations, such as Aggressive Dead
733 Code Elimination, Sparse Conditional Constant Propagation, Inlining, Loop
John Criswell623e5942003-10-10 18:51:11 +0000734 Invariant Code Motion, Dead Global Elimination, and many others...
John Criswell85ed3612003-06-12 19:34:44 +0000735
736 <dt><tt>llvm/lib/Target/</tt><dd> This directory contains files that
737 describe various target architectures for code generation. For example,
738 the llvm/lib/Target/Sparc directory holds the Sparc machine
739 description.<br>
740
741 <dt><tt>llvm/lib/CodeGen/</tt><dd> This directory contains the major parts
742 of the code generator: Instruction Selector, Instruction Scheduling, and
743 Register Allocation.
744
John Criswell85ed3612003-06-12 19:34:44 +0000745 <dt><tt>llvm/lib/Support/</tt><dd> This directory contains the source code
746 that corresponds to the header files located in
747 <tt>llvm/include/Support/</tt>.
748 </dl>
749
750 <!------------------------------------------------------------------------->
John Criswell20d2d3e2003-10-10 14:26:14 +0000751 <h3><a name="runtime"><tt>llvm/runtime</tt></a></h3>
752 <!------------------------------------------------------------------------->
753
754 <p>
755 This directory contains libraries which are compiled into LLVM bytecode and
756 used when linking programs with the GCC front end. Most of these libraries
757 are skeleton versions of real libraries; for example, libc is a stripped down
758 version of glibc.
759 </p>
760
761 <p>
762 Unlike the rest of the LLVM suite, this directory needs the LLVM GCC front end
763 to compile.
764 </p>
765
766 <!------------------------------------------------------------------------->
John Criswell85ed3612003-06-12 19:34:44 +0000767 <h3><a name="test"><tt>llvm/test</tt></a></h3>
768 <!------------------------------------------------------------------------->
769
770 <p>This directory contains regression tests and source code that is used to
John Criswell20d2d3e2003-10-10 14:26:14 +0000771 test the LLVM infrastructure.
772 </p>
John Criswell85ed3612003-06-12 19:34:44 +0000773
774 <!------------------------------------------------------------------------->
775 <h3><a name="tools"><tt>llvm/tools</tt></a></h3>
776 <!------------------------------------------------------------------------->
777
778 <p>The <b>tools</b> directory contains the executables built out of the
779 libraries above, which form the main part of the user interface. You can
780 always get help for a tool by typing <tt>tool_name --help</tt>. The
781 following is a brief introduction to the most important tools.</p>
782
783 <dl compact>
Misha Brukmanef0ad412003-10-06 19:23:34 +0000784 <dt>
785
786 <dt><tt><b>analyze</b></tt><dd> <tt>analyze</tt> is used to run a specific
787 analysis on an input LLVM bytecode file and print out the results. It is
788 primarily useful for debugging analyses, or familiarizing yourself with
789 what an analysis does.<p>
790
791 <dt><tt><b>bugpoint</b></tt><dd> <tt>bugpoint</tt> is used to debug
792 optimization passes or code generation backends by narrowing down the
793 given test case to the minimum number of passes and/or instructions that
794 still cause a problem, whether it is a crash or miscompilation. See <a
795 href="HowToSubmitABug.html">HowToSubmitABug.html</a> for more information
796 on using <tt>bugpoint</tt>.<p>
797
798 <dt><tt><b>llvm-ar</b></tt><dd>The archiver produces an archive containing
799 the given LLVM bytecode files, optionally with an index for faster
800 lookup.<p>
801
Misha Brukmana0a0a032003-08-28 22:02:50 +0000802 <dt><tt><b>llvm-as</b></tt><dd>The assembler transforms the human readable
John Criswell85ed3612003-06-12 19:34:44 +0000803 LLVM assembly to LLVM bytecode.<p>
804
Misha Brukmana0a0a032003-08-28 22:02:50 +0000805 <dt><tt><b>llvm-dis</b></tt><dd>The disassembler transforms the LLVM
Misha Brukmanef0ad412003-10-06 19:23:34 +0000806 bytecode to human readable LLVM assembly. Additionally, it can convert
Misha Brukmana0a0a032003-08-28 22:02:50 +0000807 LLVM bytecode to C, which is enabled with the <tt>-c</tt> option.<p>
John Criswell85ed3612003-06-12 19:34:44 +0000808
Misha Brukmanef0ad412003-10-06 19:23:34 +0000809 <dt><tt><b>llvm-link</b></tt><dd> <tt>llvm-link</tt>, not surprisingly,
810 links multiple LLVM modules into a single program.<p>
811
John Criswell85ed3612003-06-12 19:34:44 +0000812 <dt><tt><b>lli</b></tt><dd> <tt>lli</tt> is the LLVM interpreter, which
813 can directly execute LLVM bytecode (although very slowly...). In addition
Misha Brukmanef0ad412003-10-06 19:23:34 +0000814 to a simple interpreter, <tt>lli</tt> also has a tracing mode (entered by
815 specifying <tt>-trace</tt> on the command line). Finally, for
816 architectures that support it (currently only x86 and Sparc), by default,
817 <tt>lli</tt> will function as a Just-In-Time compiler (if the
818 functionality was compiled in), and will execute the code <i>much</i>
819 faster than the interpreter.<p>
John Criswell85ed3612003-06-12 19:34:44 +0000820
821 <dt><tt><b>llc</b></tt><dd> <tt>llc</tt> is the LLVM backend compiler,
Misha Brukmanc56e5822003-07-03 16:29:36 +0000822 which translates LLVM bytecode to a SPARC or x86 assembly file.<p>
John Criswell85ed3612003-06-12 19:34:44 +0000823
Misha Brukmanef0ad412003-10-06 19:23:34 +0000824 <dt><tt><b>llvmgcc</b></tt><dd> <tt>llvmgcc</tt> is a GCC-based C frontend
John Criswell85ed3612003-06-12 19:34:44 +0000825 that has been retargeted to emit LLVM code as the machine code output. It
826 works just like any other GCC compiler, taking the typical <tt>-c, -S, -E,
827 -o</tt> options that are typically used. The source code for the
828 <tt>llvmgcc</tt> tool is currently not included in the LLVM cvs tree
829 because it is quite large and not very interesting.<p>
830
831 <ol>
832 <dt><tt><b>gccas</b></tt><dd> This tool is invoked by the
833 <tt>llvmgcc</tt> frontend as the "assembler" part of the compiler. This
834 tool actually assembles LLVM assembly to LLVM bytecode,
Misha Brukmanef0ad412003-10-06 19:23:34 +0000835 performs a variety of optimizations, and outputs LLVM bytecode. Thus
836 when you invoke <tt>llvmgcc -c x.c -o x.o</tt>, you are causing
837 <tt>gccas</tt> to be run, which writes the <tt>x.o</tt> file (which is
838 an LLVM bytecode file that can be disassembled or manipulated just like
839 any other bytecode file). The command line interface to <tt>gccas</tt>
840 is designed to be as close as possible to the <b>system</b>
841 `<tt>as</tt>' utility so that the gcc frontend itself did not have to be
842 modified to interface to a "weird" assembler.<p>
John Criswell85ed3612003-06-12 19:34:44 +0000843
844 <dt><tt><b>gccld</b></tt><dd> <tt>gccld</tt> links together several LLVM
845 bytecode files into one bytecode file and does some optimization. It is
John Criswellabb1b582003-10-10 16:17:19 +0000846 the linker invoked by the GCC frontend when multiple .o files need to be
847 linked together. Like <tt>gccas</tt>, the command line interface of
John Criswell85ed3612003-06-12 19:34:44 +0000848 <tt>gccld</tt> is designed to match the system linker, to aid
849 interfacing with the GCC frontend.<p>
850 </ol>
851
852 <dt><tt><b>opt</b></tt><dd> <tt>opt</tt> reads LLVM bytecode, applies a
853 series of LLVM to LLVM transformations (which are specified on the command
854 line), and then outputs the resultant bytecode. The '<tt>opt --help</tt>'
855 command is a good way to get a list of the program transformations
856 available in LLVM.<p>
857
John Criswell85ed3612003-06-12 19:34:44 +0000858 </dl>
John Criswell0b459202003-07-08 20:35:59 +0000859
Misha Brukmanc103adf2003-08-11 18:45:46 +0000860 <!------------------------------------------------------------------------->
861 <h3><a name="utils"><tt>llvm/utils</tt></a></h3>
862 <!------------------------------------------------------------------------->
863
John Criswell623e5942003-10-10 18:51:11 +0000864 This directory contains utilities for working with LLVM source code, and some
Misha Brukmanc103adf2003-08-11 18:45:46 +0000865 of the utilities are actually required as part of the build process because
866 they are code generators for parts of LLVM infrastructure.
867
868 <dl compact>
Misha Brukmane0db8152003-08-11 19:13:12 +0000869 <td><tt><b>Burg/</b></tt><dd> <tt>Burg</tt> is an instruction selector
Misha Brukmanc103adf2003-08-11 18:45:46 +0000870 generator -- it builds trees on which it then performs pattern-matching to
871 select instructions according to the patterns the user has specified. Burg
872 is currently used in the Sparc V9 backend.<p>
873
874 <dt><tt><b>codegen-diff</b></tt><dd> <tt>codegen-diff</tt> is a script
875 that finds differences between code that LLC generates and code that LLI
876 generates. This is a useful tool if you are debugging one of them,
877 assuming that the other generates correct output. For the full user
878 manual, run <tt>`perldoc codegen-diff'</tt>.<p>
879
880 <dt><tt><b>cvsupdate</b></tt><dd> <tt>cvsupdate</tt> is a script that will
881 update your CVS tree, but produce a much cleaner and more organized output
882 than simply running <tt>`cvs up -dP'</tt> will. For example, it will group
883 together all the new and updated files and modified files in separate
884 sections, so you can see at a glance what has changed. If you are at the
885 top of your LLVM CVS tree, running <tt>utils/cvsupdate</tt> is the
886 preferred way of updating the tree.<p>
887
Misha Brukmane0db8152003-08-11 19:13:12 +0000888 <dt><tt><b>emacs/</b></tt><dd> The <tt>emacs</tt> directory contains
Misha Brukmanc103adf2003-08-11 18:45:46 +0000889 syntax-highlighting files which will work with Emacs and XEmacs editors,
890 providing syntax highlighting support for LLVM assembly files and TableGen
Misha Brukmane0db8152003-08-11 19:13:12 +0000891 description files. For information on how to use the syntax files, consult
892 the <tt>README</tt> file in that directory.<p>
Misha Brukmanc103adf2003-08-11 18:45:46 +0000893
894 <dt><tt><b>getsrcs.sh</b></tt><dd> The <tt>getsrcs.sh</tt> script finds
895 and outputs all non-generated source files, which is useful if one wishes
896 to do a lot of development across directories and does not want to
897 individually find each file. One way to use it is to run, for example:
898 <tt>xemacs `utils/getsources.sh`</tt> from the top of your LLVM source
899 tree.<p>
900
901 <dt><tt><b>makellvm</b></tt><dd> The <tt>makellvm</tt> script compiles all
902 files in the current directory and then compiles and links the tool that
903 is the first argument. For example, assuming you are in the directory
904 <tt>llvm/lib/Target/Sparc</tt>, if <tt>makellvm</tt> is in your path,
905 simply running <tt>makellvm llc</tt> will make a build of the current
906 directory, switch to directory <tt>llvm/tools/llc</tt> and build it,
907 causing a re-linking of LLC.<p>
908
909 <dt><tt><b>NightlyTest.pl</b></tt> and
910 <tt><b>NightlyTestTemplate.html</b></tt><dd> These files are used in a
911 cron script to generate nightly status reports of the functionality of
912 tools, and the results can be seen by following the appropriate link on
913 the <a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a>.<p>
914
Misha Brukmane0db8152003-08-11 19:13:12 +0000915 <dt><tt><b>TableGen/</b></tt><dd> The <tt>TableGen</tt> directory contains
Misha Brukmanc103adf2003-08-11 18:45:46 +0000916 the tool used to generate register descriptions, instruction set
Chris Lattnera8f5de32003-08-11 18:53:14 +0000917 descriptions, and even assemblers from common TableGen description
Misha Brukmanc103adf2003-08-11 18:45:46 +0000918 files.<p>
919
Misha Brukmane0db8152003-08-11 19:13:12 +0000920 <dt><tt><b>vim/</b></tt><dd> The <tt>vim</tt> directory contains
Misha Brukmanc103adf2003-08-11 18:45:46 +0000921 syntax-highlighting files which will work with the VIM editor, providing
922 syntax highlighting support for LLVM assembly files and TableGen
Misha Brukmane0db8152003-08-11 19:13:12 +0000923 description files. For information on how to use the syntax files, consult
924 the <tt>README</tt> file in that directory.<p>
Misha Brukmanc103adf2003-08-11 18:45:46 +0000925
926 </dl>
927
John Criswell85ed3612003-06-12 19:34:44 +0000928 <!--=====================================================================-->
John Criswell0b459202003-07-08 20:35:59 +0000929 <h2>
930 <center><a name="tutorial">An Example Using the LLVM Tool Chain</center>
931 </h2>
John Criswell20d2d3e2003-10-10 14:26:14 +0000932 <hr>
John Criswell85ed3612003-06-12 19:34:44 +0000933 <!--=====================================================================-->
934
935 <ol>
936 <li>First, create a simple C file, name it 'hello.c':
937 <pre>
938 #include &lt;stdio.h&gt;
939 int main() {
940 printf("hello world\n");
941 return 0;
942 }
943 </pre>
944
945 <li>Next, compile the C file into a LLVM bytecode file:<p>
946
947 <tt>% llvmgcc hello.c -o hello</tt><p>
948
949 This will create two result files: <tt>hello</tt> and
950 <tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that
951 corresponds the the compiled program and the library facilities that it
952 required. <tt>hello</tt> is a simple shell script that runs the bytecode
953 file with <tt>lli</tt>, making the result directly executable.<p>
954
955 <li>Run the program. To make sure the program ran, execute one of the
956 following commands:<p>
John Criswell8df90e02003-06-11 20:46:40 +0000957
John Criswell85ed3612003-06-12 19:34:44 +0000958 <tt>% ./hello</tt><p>
959
960 or<p>
961
962 <tt>% lli hello.bc</tt><p>
963
Misha Brukmana0a0a032003-08-28 22:02:50 +0000964 <li>Use the <tt>llvm-dis</tt> utility to take a look at the LLVM assembly
John Criswell85ed3612003-06-12 19:34:44 +0000965 code:<p>
966
Misha Brukmana0a0a032003-08-28 22:02:50 +0000967 <tt>% llvm-dis < hello.bc | less</tt><p>
John Criswell85ed3612003-06-12 19:34:44 +0000968
969 <li>Compile the program to native Sparc assembly using the code
Misha Brukmanc56e5822003-07-03 16:29:36 +0000970 generator (assuming you are currently on a Sparc system):<p>
John Criswell85ed3612003-06-12 19:34:44 +0000971
972 <tt>% llc hello.bc -o hello.s</tt><p>
973
974 <li>Assemble the native sparc assemble file into a program:<p>
975
976 <tt>% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc</tt><p>
977
978 <li>Execute the native sparc program:<p>
979
980 <tt>% ./hello.sparc</tt><p>
981
982 </ol>
983
984
985 <!--=====================================================================-->
John Criswell0b459202003-07-08 20:35:59 +0000986 <h2>
987 <center><a name="problems">Common Problems</a></center>
988 </h2>
John Criswell20d2d3e2003-10-10 14:26:14 +0000989 <hr>
John Criswellce760f62003-07-03 16:01:38 +0000990 <!--=====================================================================-->
991
John Criswellb96646f2003-10-13 16:16:25 +0000992 If you are having problems building or using LLVM, or if you have any other
993 general questions about LLVM, please consult the
John Criswellb5ca43e2003-10-13 16:19:30 +0000994 <a href="FAQ.html">Frequently Asked Questions</a> page.
John Criswellce760f62003-07-03 16:01:38 +0000995
996 <!--=====================================================================-->
John Criswell0b459202003-07-08 20:35:59 +0000997 <h2><center><a name="links">Links</a></center></h2>
John Criswell20d2d3e2003-10-10 14:26:14 +0000998 <hr>
John Criswell85ed3612003-06-12 19:34:44 +0000999 <!--=====================================================================-->
1000
1001 <p>This document is just an <b>introduction</b> to how to use LLVM to do
1002 some simple things... there are many more interesting and complicated things
1003 that you can do that aren't documented here (but we'll gladly accept a patch
1004 if you want to write something up!). For more information about LLVM, check
1005 out:</p>
1006
1007 <ul>
1008 <li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li>
1009 <li><a href="http://llvm.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li>
John Criswellce760f62003-07-03 16:01:38 +00001010 <li><a href="http://llvm.cs.uiuc.edu/docs/Projects.html">Starting a Project that Uses LLVM</a></li>
John Criswell85ed3612003-06-12 19:34:44 +00001011 </ul>
1012
1013 <hr>
1014
1015 If you have any questions or run into any snags (or you have any
1016 additions...), please send an email to
1017 <a href="mailto:sabre@nondot.org">Chris Lattner</a>.</p>
1018
1019 <!-- Created: Mon Jul 1 02:29:02 CDT 2002 -->
1020 <!-- hhmts start -->
Chris Lattnera8f5de32003-08-11 18:53:14 +00001021Last modified: Mon Aug 11 13:52:22 CDT 2003
John Criswell85ed3612003-06-12 19:34:44 +00001022<!-- hhmts end -->
1023 </body>
Guochun Shif4688a82002-07-17 23:05:56 +00001024</html>