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