blob: ecbfbfe26d076fc18366a3123582ca4b2935e837 [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
36=head2 Basic Operation
37
38B<llvmc> always takes the following basic actions:
39
40=over
41
42=item * Command line options and filenames are collected.
43
44This provides the basic instruction to B<llvmc> on what actions it should
45take. This is the I<request> the user is making of B<llvmc>.
46
47=item * Configuration files are read.
48
49Based on the options and the suffixes of the filenames presented, a set
50of configuration files are read to configure the actions B<llvmc>
51will take (more on this later).
52
53=item * Determine actions to take.
54
55The tool chain needed to complete the task is determined. This is the
56primary work of B<llvmc>. It breaks the request specified by the
57command line options into a set of basic actions to be done:
58pre-processing, compilation, assembly, optimization, and linking.
59For each applicable action, it selects the command to be run from
60the specifications in the configuration files.
61
62=item * Execute actions.
63
64The actions determined previously are executed sequentially and then
65B<llvmc> terminates.
66
67=back
68
69=head2 Configuration Files
70
71B<llvmc> is highly configurable both on the command line and in configuration
72files. Configuration files specify the details of what commands to run
73for a given action. Each front end compiler must provide its own
74configuration file to tell B<llvmc> how to invoke that compiler. The LLVM
75toolset does not need to be configured as B<llvmc> just "knows" how to
76invoke those tools.
77
78Rest TBD.
79
80=head1 OPTIONS
81
82=head2 Control Options
83
84Control options tell B<llvmc> what to do at a high level. The
85following control options are defined:
86
87=over
88
89=item B<-c> or B<--compile>
90
91This option specifies that the linking phase is not to be run. All
92previous phases, if applicable will run. This is generally how a given
93bytecode file is compiled and optimized for a source language module.
94
95=item B<-k> or B<--link> or default
96
97This option (or the lack of any control option) specifies that all stages
98of compilation, optimization, and linking should be attempted. Source files
99specified on the command line will be compiled and linked with objects and
100libraries also specified.
101
102=item B<-S> or B<--assemble>
103
104This option specifies that compilation should end in the creation of
105an LLVM assembly file that can be later converted to an LLVM object
106file.
107
108=item B<-E> or B<--preprocess>
109
110This option specifies that no compilation or linking should be
111performed. Only pre-processing, if applicabe to the language being
112compiled, is performed. For languages that support it, this will
113result in the output containing the raw input to the compiler.
114
115=back
116
117=head2 Optimization Options
118
119Optimization with B<llvmc> is based on goals and specified with
120the following -O options. The specific details of which
121optimizations run is controlled by the configuration files because
122each source language will have different needs.
123
124=over
125
126=item B<-O1> or B<-O0> (default, fast compilation)
127
128Only those optimizations that will hasten the compilation (mostly by reducing
129the output) are applied. In general these are extremely fast and simple
130optimizations that reduce emitted code size. The goal here is not to make the
131resulting program fast but to make the compilation fast. If not specified,
132this is the default level of optimization.
133
134=item B<-O2> (basic optimization)
135
136This level of optimization specifies a balance between generating good code
137that will execute reasonably quickly and not spending too much time optimizing
138the code to get there. For example, this level of optimization may include
139things like global common subexpression elimintation, aggressive dead code
140elimination, and scalar replication.
141
142=item B<-O3> (aggressive optimization)
143
144This level of optimization aggressively optimizes each set of files compiled
145together. However, no link-time inter-procedural optimization is performed.
146This level implies all the optimizations of the B<-O1> and B<-O2> optimization
147levels, and should also provide loop optimizatiosn and compile time
148inter-procedural optimizations. Essentially, this level tries to do as much
149as it can with the input it is given but doesn't do any link time IPO.
150
151=item B<-O4> (linktime optimization)
152
153In addition to the previous three levels of optimization, this level of
154optimization aggressively optimizes each program at link time. It employs
155basic analysis and basic link-time inter-procedural optimizations,
156considering the program as a whole.
157
158=item B<-O5> (aggressive linktime optimization)
159
160This is the same as B<-O4> except it employs aggressive analyses and
161aggressive inter-procedural optimization.
162
163=item B<-O6> (profile guided optimization - not implemented)
164
165This is the same as B<-O5> except that it employes profile-guided
166reoptimization of the program after it has executed. Note that this implies
167a single level of reoptimization based on runtime profile analysis. Once
168the re-optimization has completed, the profiling instrumentation is
169removed and final optimizations are employed.
170
171=item B<-O7> (lifelong optimization - not implemented)
172
173This is the same as B<-O5> and similar to B<-O6> except that reoptimization
174is performed through the life of the program. That is, each run will update
175the profile by which future reoptimizations are directed.
176
177=back
178
179=head2 Input Options
180
181=over
182
183=item B<-l> I<LIBRARY>
184
185This option instructs B<llvmc> to locate a library named I<LIBRARY> and search
186it for unresolved symbols when linking the program.
187
188=item B<-L> F<path>
189
190This option instructs B<llvmc> to add F<path> to the list of places in which
191the linker will
192
193=item B<-x> I<LANGUAGE>
194
195This option instructs B<llvmc> to regard the following input files as
196containing programs in the language I<LANGUAGE>. Normally, input file languages
197are identified by their suffix but this option will override that default
198behavior. The B<-x> option stays in effect until the end of the options or
199a new B<-x> option is encountered.
200
201=back
202
203=head2 Output Options
204
205=over
206
207=item B<-m>I<arch>
208
209This option selects the back end code generator to use. The I<arch> portion
210of the option names the back end to use.
211
212=item B<--native>
213
214Normally, B<llvmc> produces bytecode files at most stages of compilation.
215With this option, B<llvmc> will arrange for native object files to be
216generated with the B<-c> option, native assembly files to be generated
217with the B<-S> option, and native executables to be generated with the
218B<--link> option. In the case of the B<-E> option, the output will not
219differ as there is no I<native> version of pre-processed output.
220
221=item B<-o> F<filename>
222
223Specify the output file name. The contents of the file depend on other
224options.
225
226=back
227
228=head2 Configuration Options
229
230=over
231
232=item B<--show-config> I<[suffixes...]>
233
234When this option is given, the only action taken by B<llvmc> is to show its
235final configuration state in the form of a configuration file. No compilation
236tasks will be conducted when this option is given; processing will stop once
237the configuration has been printed. The optional (comma separated) list of
238suffixes controls what is printed. Without any suffixes, the configuration
239for all languages is printed. With suffixes, only the languages pertaining
240to those file suffixes will be printed. The configuration information is
241printed after all command line options and configuration files have been
242read and processed. This allows the user to verify that the correct
243configuration data has been read by B<llvmc>.
244
245=item B<--config> :I<section>:I<name>=I<value>
246
247This option instructs B<llvmc> to accept I<value> as the value for configuration
248item I<name> in the section named I<section>. This is a quick way to override
249a configuration item on the command line without resorting to changing the
250configuration files.
251
252=item B<--config-file> F<dirname>
253
254This option tells B<llvmc> to read configuration data from the I<directory>
255named F<dirname>. Data from such directories will be read in the order
256specified on the command line after all other standard config files have
257been read. This allows users or groups of users to conveniently create
258their own configuration directories in addition to the standard ones to which
259they may not have write access.
260
261=item B<--config-only-from> F<dirname>
262
263This option tells B<llvmc> to skip the normal processing of configuration
264files and only configure from the contents of the F<dirname> directory. Multiple
265B<--config-only-from> options may be given in which case the directories are
266read in the order given on the command line.
267
268=back
269
270=head2 Information Options
271
272=over
273
274=item B<-n> or B<--noop>
275
276This option tells B<llvmc> to do everything but actually execute the
277resulting tools. In combination with the B<-v> option, this causes B<llvmc>
278to merely print out what it would have done.
279
280=item B<-v> or B<--verbose>
281
282This option will cause B<llvmc> to print out (on standard output) each of the
283actions it takes to accomplish the objective. The output will immediately
284precede the invocation of other tools.
285
286=item B<--stats>
287
288Print all statistics gathered during the compilation to the standard error.
289Note that this option is merely passed through to the sub-tools to do with
290as they please.
291
292=item B<--time-passes>
293
294Record the amount of time needed for each optimization pass and print it
295to standard error. Like B<--stats> this option is just passed through to
296the sub-tools to do with as they please.
297
298=item B<--time-programs>
299
300Record the amount of time each program (compilation tool) takes and print
301it to the standard error.
302
303=back
304
305=head2 Language Specific Options
306
307=over
308
309
310=item B<-Tool,opt>=I<options>
311
312Pass an arbitrary option to the optimizer.
313
314=item B<-Tool,link>=I<options>
315
316Pass an arbitrary option to the linker.
317
318=item B<-Tool,asm>=I<options>
319
320Pass an arbitrary optionsto the code generator.
321
322=back
323
324=head3 C/C++ Specific Options
325
326=over
327
328=item B<-I>F<path> (C/C++ Only)
329
330This option is just passed through to a C or C++ front end compiler to tell it
331where include files can be found.
332
333=back
334
335=head2 Advanced Options
336
337=over
338
339=item B<--emit-raw-code>
340
341No optimization is done whatsoever. The compilers invoked by B<llvmc> with
342this option given will be instructed to produce raw, unoptimized code. This
343option is useful only to front end language developers and therefore does not
344participate in the list of B<-O> options. This is distinctly different from
345the B<-O0> option (a synonym for B<-O1>) because those optimizations will
346reduce code size to make compilation faster. With B<--emit-raw-code>, only
347the full raw code produced by the compiler will be generated.
348
349=back
350
351=head2 Miscellaneous Options
352
353=over
354
355=item B<--help>
356
357Print a summary of command line options.
358
359=item B<-V> or B<--version>
360
361This option will cause B<llvmc> to print out its version number
362and terminate.
363
364=back
365
366=head1 EXIT STATUS
367
368If B<llvmc> succeeds, it will exit with 0. Otherwise, if an error
369occurs, it will exit with a non-zero value and no compilation actions
370will be taken. If one of the compilation tools returns a non-zero
371status, pending actions will be discarded and B<llvmc> will return the
372same result code as the failing compilation tool.
373
374=head1 SEE ALSO
375
376L<gccas|gccas>, L<gccld|gccld>, L<llvm-as|llvm-as>, L<llvm-dis|llvm-dis>,
377L<llc|llc>, L<llvm-link|llvm-link>
378
379=head1 AUTHORS
380
381Reid Spencer
382
383=cut