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