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