blob: c8463c483678e4428562ee90bd6aa6ac0a2fd952 [file] [log] [blame]
Reid Spencerbe65afb2004-08-06 16:58:48 +00001=pod
2
3=head1 NAME
4
5llvmc - The LLVM Compiler Driver
6
7=head1 SYNOPSIS
8
9B<llvmc> [I<options>] [I<filenames>...]
10
11=head1 DESCRIPTION
12
13The B<llvmc> command is a configurable driver for invoking other
14LLVM (and non-LLVM) tools in order to compile, optimize and link software
15for multiple languages. For those familiar with the GNU Compiler
16Collection's B<gcc> tool, it is very similar. This tool has the
17following main goals or purposes:
18
19=over
20
21=item * A Single point of access to the LLVM tool set.
22
23=item * Hide the complexities of the LLVM tools through a single interface.
24
25=item * Make integration of existing non-LLVM tools simple.
26
27=item * Extend the capabilities of minimal front ends.
28
29=item * Make the interface for compiling consistent for all languages.
30
31=back
32
33The tool itself does nothing with a user's program. It merely invokes other
34tools to get the compilation tasks done.
35
Reid Spencerf2edda02004-08-06 22:28:47 +000036The options supported by B<llvmc> generalize the compilation process and
37provide a consistent and simple interface for multiple programming languages.
38This makes it easier for developers to get their software compiled with LLVM.
39Without B<llvmc>, developers would need to understand how to invoke the
40front-end compiler, optimizer, assembler, and linker in order to compile their
41programs. B<llvmc>'s sole mission is to trivialize that process.
42
Reid Spencerbe65afb2004-08-06 16:58:48 +000043=head2 Basic Operation
44
45B<llvmc> always takes the following basic actions:
46
47=over
48
49=item * Command line options and filenames are collected.
50
Reid Spencerf2edda02004-08-06 22:28:47 +000051The command line options provide the marching orders to B<llvmc> on what actions
52it should perform. This is the I<request> the user is making of B<llvmc> and it
53is interpreted first.
Reid Spencerbe65afb2004-08-06 16:58:48 +000054
55=item * Configuration files are read.
56
Reid Spencerf2edda02004-08-06 22:28:47 +000057Based on the options and the suffixes of the filenames presented, a set of
Reid Spencerc40ca352004-08-09 03:10:39 +000058configuration files are read to configure the actions B<llvmc> will take.
59Configuration files are provided by either LLVM or the front end compiler tools
60that B<llvmc> invokes. Users generally don't need to be concerned with the
61contents of the configuration files.
Reid Spencerbe65afb2004-08-06 16:58:48 +000062
63=item * Determine actions to take.
64
Reid Spencerf2edda02004-08-06 22:28:47 +000065The tool chain needed to complete the task is determined. This is the primary
66work of B<llvmc>. It breaks the request specified by the command line options
67into a set of basic actions to be done:
68
69=over
70
Reid Spencerc40ca352004-08-09 03:10:39 +000071=item * Pre-processing: gathering/filtering compiler input (optional).
Reid Spencerf2edda02004-08-06 22:28:47 +000072
Reid Spencerc40ca352004-08-09 03:10:39 +000073=item * Translation: source language to bytecode conversion.
Reid Spencerf2edda02004-08-06 22:28:47 +000074
Reid Spencerc40ca352004-08-09 03:10:39 +000075=item * Assembly: bytecode to native code conversion.
Reid Spencerf2edda02004-08-06 22:28:47 +000076
Reid Spencerc40ca352004-08-09 03:10:39 +000077=item * Optimization: conversion of bytecode to something that runs faster.
Reid Spencerf2edda02004-08-06 22:28:47 +000078
Reid Spencerc40ca352004-08-09 03:10:39 +000079=item * Linking: combining multiple bytecodes to produce executable program.
Reid Spencerf2edda02004-08-06 22:28:47 +000080
81=back
Reid Spencerbe65afb2004-08-06 16:58:48 +000082
83=item * Execute actions.
84
85The actions determined previously are executed sequentially and then
86B<llvmc> terminates.
87
88=back
89
Reid Spencerbe65afb2004-08-06 16:58:48 +000090=head1 OPTIONS
91
92=head2 Control Options
93
94Control options tell B<llvmc> what to do at a high level. The
95following control options are defined:
96
97=over
98
99=item B<-c> or B<--compile>
100
101This option specifies that the linking phase is not to be run. All
102previous phases, if applicable will run. This is generally how a given
103bytecode file is compiled and optimized for a source language module.
104
105=item B<-k> or B<--link> or default
106
107This option (or the lack of any control option) specifies that all stages
108of compilation, optimization, and linking should be attempted. Source files
109specified on the command line will be compiled and linked with objects and
110libraries also specified.
111
Reid Spencerd9dd3262005-04-22 02:12:41 +0000112=item B<-S>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000113
114This option specifies that compilation should end in the creation of
115an LLVM assembly file that can be later converted to an LLVM object
116file.
117
Reid Spencerd9dd3262005-04-22 02:12:41 +0000118=item B<-E>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000119
120This option specifies that no compilation or linking should be
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000121performed. Only pre-processing, if applicable to the language being
Reid Spencerbe65afb2004-08-06 16:58:48 +0000122compiled, is performed. For languages that support it, this will
123result in the output containing the raw input to the compiler.
124
125=back
126
127=head2 Optimization Options
128
129Optimization with B<llvmc> is based on goals and specified with
130the following -O options. The specific details of which
131optimizations run is controlled by the configuration files because
132each source language will have different needs.
133
134=over
135
136=item B<-O1> or B<-O0> (default, fast compilation)
137
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000138Only those optimizations that will hasten the compilation (mostly by reducing
Reid Spencerbe65afb2004-08-06 16:58:48 +0000139the output) are applied. In general these are extremely fast and simple
140optimizations that reduce emitted code size. The goal here is not to make the
141resulting program fast but to make the compilation fast. If not specified,
142this is the default level of optimization.
143
144=item B<-O2> (basic optimization)
145
146This level of optimization specifies a balance between generating good code
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000147that will execute reasonably quickly and not spending too much time optimizing
Reid Spencerbe65afb2004-08-06 16:58:48 +0000148the code to get there. For example, this level of optimization may include
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000149things like global common subexpression elimination, aggressive dead code
Reid Spencerbe65afb2004-08-06 16:58:48 +0000150elimination, and scalar replication.
151
152=item B<-O3> (aggressive optimization)
153
154This level of optimization aggressively optimizes each set of files compiled
155together. However, no link-time inter-procedural optimization is performed.
156This level implies all the optimizations of the B<-O1> and B<-O2> optimization
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000157levels, and should also provide loop optimizations and compile time
Reid Spencerbe65afb2004-08-06 16:58:48 +0000158inter-procedural optimizations. Essentially, this level tries to do as much
159as it can with the input it is given but doesn't do any link time IPO.
160
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000161=item B<-O4> (link time optimization)
Reid Spencerbe65afb2004-08-06 16:58:48 +0000162
163In addition to the previous three levels of optimization, this level of
164optimization aggressively optimizes each program at link time. It employs
165basic analysis and basic link-time inter-procedural optimizations,
166considering the program as a whole.
167
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000168=item B<-O5> (aggressive link time optimization)
Reid Spencerbe65afb2004-08-06 16:58:48 +0000169
170This is the same as B<-O4> except it employs aggressive analyses and
171aggressive inter-procedural optimization.
172
Reid Spencerf2edda02004-08-06 22:28:47 +0000173=item B<-O6> (profile guided optimization: not implemented)
Reid Spencerbe65afb2004-08-06 16:58:48 +0000174
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000175This is the same as B<-O5> except that it employs profile-guided
176re-optimization of the program after it has executed. Note that this implies
177a single level of re-optimization based on runtime profile analysis. Once
Reid Spencerbe65afb2004-08-06 16:58:48 +0000178the re-optimization has completed, the profiling instrumentation is
179removed and final optimizations are employed.
180
Reid Spencerf2edda02004-08-06 22:28:47 +0000181=item B<-O7> (lifelong optimization: not implemented)
Reid Spencerbe65afb2004-08-06 16:58:48 +0000182
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000183This is the same as B<-O5> and similar to B<-O6> except that re-optimization
Reid Spencerbe65afb2004-08-06 16:58:48 +0000184is performed through the life of the program. That is, each run will update
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000185the profile by which future re-optimizations are directed.
Reid Spencerbe65afb2004-08-06 16:58:48 +0000186
187=back
188
189=head2 Input Options
190
191=over
192
193=item B<-l> I<LIBRARY>
194
195This option instructs B<llvmc> to locate a library named I<LIBRARY> and search
196it for unresolved symbols when linking the program.
197
198=item B<-L> F<path>
199
200This option instructs B<llvmc> to add F<path> to the list of places in which
201the linker will
202
203=item B<-x> I<LANGUAGE>
204
205This option instructs B<llvmc> to regard the following input files as
206containing programs in the language I<LANGUAGE>. Normally, input file languages
207are identified by their suffix but this option will override that default
208behavior. The B<-x> option stays in effect until the end of the options or
209a new B<-x> option is encountered.
210
211=back
212
213=head2 Output Options
214
215=over
216
217=item B<-m>I<arch>
218
219This option selects the back end code generator to use. The I<arch> portion
220of the option names the back end to use.
221
222=item B<--native>
223
224Normally, B<llvmc> produces bytecode files at most stages of compilation.
225With this option, B<llvmc> will arrange for native object files to be
226generated with the B<-c> option, native assembly files to be generated
227with the B<-S> option, and native executables to be generated with the
228B<--link> option. In the case of the B<-E> option, the output will not
229differ as there is no I<native> version of pre-processed output.
230
231=item B<-o> F<filename>
232
233Specify the output file name. The contents of the file depend on other
234options.
235
236=back
237
Reid Spencerbe65afb2004-08-06 16:58:48 +0000238=head2 Information Options
239
240=over
241
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000242=item B<-n> or B<--no-op>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000243
244This option tells B<llvmc> to do everything but actually execute the
245resulting tools. In combination with the B<-v> option, this causes B<llvmc>
246to merely print out what it would have done.
247
248=item B<-v> or B<--verbose>
249
250This option will cause B<llvmc> to print out (on standard output) each of the
251actions it takes to accomplish the objective. The output will immediately
252precede the invocation of other tools.
253
254=item B<--stats>
255
256Print all statistics gathered during the compilation to the standard error.
257Note that this option is merely passed through to the sub-tools to do with
258as they please.
259
260=item B<--time-passes>
261
262Record the amount of time needed for each optimization pass and print it
263to standard error. Like B<--stats> this option is just passed through to
264the sub-tools to do with as they please.
265
266=item B<--time-programs>
267
268Record the amount of time each program (compilation tool) takes and print
269it to the standard error.
270
271=back
272
273=head2 Language Specific Options
274
275=over
276
Reid Spencerd9dd3262005-04-22 02:12:41 +0000277=item B<-T,pre>=I<options>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000278
Reid Spenceraf2f9242004-08-07 16:30:14 +0000279Pass an arbitrary option to the pre-processor.
280
281=item B<-T,opt>=I<options>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000282
283Pass an arbitrary option to the optimizer.
284
Reid Spencerd9dd3262005-04-22 02:12:41 +0000285=item B<-T,lnk>=I<options>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000286
287Pass an arbitrary option to the linker.
288
Reid Spenceraf2f9242004-08-07 16:30:14 +0000289=item B<-T,asm>=I<options>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000290
Reid Spencerf9cdefb2004-08-06 22:56:49 +0000291Pass an arbitrary option to the code generator.
Reid Spencerbe65afb2004-08-06 16:58:48 +0000292
293=back
294
Reid Spencer94c8fb42005-04-22 02:16:19 +0000295=head2 C/C++ Specific Options
Reid Spencerbe65afb2004-08-06 16:58:48 +0000296
297=over
298
Reid Spencerf2edda02004-08-06 22:28:47 +0000299=item B<-I>F<path>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000300
301This option is just passed through to a C or C++ front end compiler to tell it
302where include files can be found.
303
Reid Spencerd9dd3262005-04-22 02:12:41 +0000304=item B<-D>F<symbol>
305
306This option is just passed through to a C or C++ front end compiler to tell it
307to define a symbol.
308
Reid Spencerbe65afb2004-08-06 16:58:48 +0000309=back
310
Reid Spencerbe65afb2004-08-06 16:58:48 +0000311=head2 Miscellaneous Options
312
313=over
314
315=item B<--help>
316
317Print a summary of command line options.
318
Misha Brukman7e8a1d72005-02-18 18:00:53 +0000319=item B<--version>
Reid Spencerbe65afb2004-08-06 16:58:48 +0000320
Misha Brukman7e8a1d72005-02-18 18:00:53 +0000321This option will cause B<llvmc> to print out its version number and terminate.
Reid Spencerbe65afb2004-08-06 16:58:48 +0000322
323=back
324
Reid Spencerf2edda02004-08-06 22:28:47 +0000325=head2 Advanced Options
326
327You better know what you're doing if you use these options. Improper use
328of these options can produce drastically wrong results.
329
330=over
331
Reid Spencerd9dd3262005-04-22 02:12:41 +0000332=item B<--config-dir> F<dirname>
333
334This option tells B<llvmc> to read configuration data from the I<directory>
335named F<dirname>. Data from such directories will be read in the order
336specified on the command line after all other standard configuration files have
337been read. This allows users or groups of users to conveniently create
338their own configuration directories in addition to the standard ones to which
339they may not have write access.
340
341
342=head2 Unimplemented Options
343
344The options below are not currently implemented in B<llvmc> but will be
345eventually. They are documented here as "future design".
346
347=over
348
Reid Spencerf2edda02004-08-06 22:28:47 +0000349=item B<--show-config> I<[suffixes...]>
350
351When this option is given, the only action taken by B<llvmc> is to show its
352final configuration state in the form of a configuration file. No compilation
353tasks will be conducted when this option is given; processing will stop once
354the configuration has been printed. The optional (comma separated) list of
355suffixes controls what is printed. Without any suffixes, the configuration
356for all languages is printed. With suffixes, only the languages pertaining
357to those file suffixes will be printed. The configuration information is
358printed after all command line options and configuration files have been
359read and processed. This allows the user to verify that the correct
360configuration data has been read by B<llvmc>.
361
362=item B<--config> :I<section>:I<name>=I<value>
363
364This option instructs B<llvmc> to accept I<value> as the value for configuration
365item I<name> in the section named I<section>. This is a quick way to override
366a configuration item on the command line without resorting to changing the
367configuration files.
368
Reid Spencerf2edda02004-08-06 22:28:47 +0000369=item B<--config-only-from> F<dirname>
370
371This option tells B<llvmc> to skip the normal processing of configuration
372files and only configure from the contents of the F<dirname> directory. Multiple
373B<--config-only-from> options may be given in which case the directories are
374read in the order given on the command line.
375
Reid Spencerf2edda02004-08-06 22:28:47 +0000376=item B<--emit-raw-code>
377
378No optimization is done whatsoever. The compilers invoked by B<llvmc> with
379this option given will be instructed to produce raw, unoptimized code. This
380option is useful only to front end language developers and therefore does not
381participate in the list of B<-O> options. This is distinctly different from
382the B<-O0> option (a synonym for B<-O1>) because those optimizations will
383reduce code size to make compilation faster. With B<--emit-raw-code>, only
384the full raw code produced by the compiler will be generated.
385
386=back
387
Reid Spenceraf2f9242004-08-07 16:30:14 +0000388
Reid Spencerbe65afb2004-08-06 16:58:48 +0000389=head1 EXIT STATUS
390
391If B<llvmc> succeeds, it will exit with 0. Otherwise, if an error
392occurs, it will exit with a non-zero value and no compilation actions
393will be taken. If one of the compilation tools returns a non-zero
394status, pending actions will be discarded and B<llvmc> will return the
395same result code as the failing compilation tool.
396
397=head1 SEE ALSO
398
399L<gccas|gccas>, L<gccld|gccld>, L<llvm-as|llvm-as>, L<llvm-dis|llvm-dis>,
400L<llc|llc>, L<llvm-link|llvm-link>
401
402=head1 AUTHORS
403
Reid Spencerbd264752004-11-15 20:25:08 +0000404Maintained by the LLVM Team (L<http://llvm.cs.uiuc.edu>).
Reid Spencerbe65afb2004-08-06 16:58:48 +0000405
406=cut