Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 1 | llc - LLVM static compiler |
| 2 | ========================== |
| 3 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 4 | SYNOPSIS |
| 5 | -------- |
| 6 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 7 | :program:`llc` [*options*] [*filename*] |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 8 | |
| 9 | DESCRIPTION |
| 10 | ----------- |
| 11 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 12 | The :program:`llc` command compiles LLVM source inputs into assembly language |
| 13 | for a specified architecture. The assembly language output can then be passed |
| 14 | through a native assembler and linker to generate a native executable. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 15 | |
| 16 | The choice of architecture for the output assembly code is automatically |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 17 | determined from the input file, unless the :option:`-march` option is used to |
| 18 | override the default. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 19 | |
| 20 | OPTIONS |
| 21 | ------- |
| 22 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 23 | If ``filename`` is "``-``" or omitted, :program:`llc` reads from standard input. |
| 24 | Otherwise, it will from ``filename``. Inputs can be in either the LLVM assembly |
| 25 | language format (``.ll``) or the LLVM bitcode format (``.bc``). |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 26 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 27 | If the :option:`-o` option is omitted, then :program:`llc` will send its output |
| 28 | to standard output if the input is from standard input. If the :option:`-o` |
| 29 | option specifies "``-``", then the output will also be sent to standard output. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 30 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 31 | If no :option:`-o` option is specified and an input file other than "``-``" is |
| 32 | specified, then :program:`llc` creates the output filename by taking the input |
| 33 | filename, removing any existing ``.bc`` extension, and adding a ``.s`` suffix. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 34 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 35 | Other :program:`llc` options are described below. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 36 | |
| 37 | End-user Options |
| 38 | ~~~~~~~~~~~~~~~~ |
| 39 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 40 | .. option:: -help |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 41 | |
| 42 | Print a summary of command line options. |
| 43 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 44 | .. option:: -O=uint |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 45 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 46 | Generate code at different optimization levels. These correspond to the |
| 47 | ``-O0``, ``-O1``, ``-O2``, and ``-O3`` optimization levels used by |
| 48 | :program:`llvm-gcc` and :program:`clang`. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 49 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 50 | .. option:: -mtriple=<target triple> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 51 | |
| 52 | Override the target triple specified in the input file with the specified |
| 53 | string. |
| 54 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 55 | .. option:: -march=<arch> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 56 | |
| 57 | Specify the architecture for which to generate assembly, overriding the target |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 58 | encoded in the input file. See the output of ``llc -help`` for a list of |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 59 | valid architectures. By default this is inferred from the target triple or |
| 60 | autodetected to the current architecture. |
| 61 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 62 | .. option:: -mcpu=<cpuname> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 63 | |
| 64 | Specify a specific chip in the current architecture to generate code for. |
| 65 | By default this is inferred from the target triple and autodetected to |
| 66 | the current architecture. For a list of available CPUs, use: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 67 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 68 | .. code-block:: none |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 69 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 70 | llvm-as < /dev/null | llc -march=xyz -mcpu=help |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 71 | |
Eli Bendersky | 72590d5 | 2013-04-22 17:16:35 +0000 | [diff] [blame^] | 72 | .. option:: -filetype=<output file type> |
| 73 | |
| 74 | Specify what kind of output ``llc`` should generated. Options are: ``asm`` |
| 75 | for textual assembly ( ``'.s'``), ``obj`` for native object files (``'.o'``) |
| 76 | and ``null`` for not emitting anything (for performance testing). |
| 77 | |
| 78 | Note that not all targets support all options. |
| 79 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 80 | .. option:: -mattr=a1,+a2,-a3,... |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 81 | |
| 82 | Override or control specific attributes of the target, such as whether SIMD |
| 83 | operations are enabled or not. The default set of attributes is set by the |
| 84 | current CPU. For a list of available attributes, use: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 85 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 86 | .. code-block:: none |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 87 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 88 | llvm-as < /dev/null | llc -march=xyz -mattr=help |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 89 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 90 | .. option:: --disable-fp-elim |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 91 | |
| 92 | Disable frame pointer elimination optimization. |
| 93 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 94 | .. option:: --disable-excess-fp-precision |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 95 | |
| 96 | Disable optimizations that may produce excess precision for floating point. |
| 97 | Note that this option can dramatically slow down code on some systems |
| 98 | (e.g. X86). |
| 99 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 100 | .. option:: --enable-no-infs-fp-math |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 101 | |
| 102 | Enable optimizations that assume no Inf values. |
| 103 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 104 | .. option:: --enable-no-nans-fp-math |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 105 | |
| 106 | Enable optimizations that assume no NAN values. |
| 107 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 108 | .. option:: --enable-unsafe-fp-math |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 109 | |
| 110 | Enable optimizations that make unsafe assumptions about IEEE math (e.g. that |
| 111 | addition is associative) or may not work for all input ranges. These |
| 112 | optimizations allow the code generator to make use of some instructions which |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 113 | would otherwise not be usable (such as ``fsin`` on X86). |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 114 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 115 | .. option:: --enable-correct-eh-support |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 116 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 117 | Instruct the **lowerinvoke** pass to insert code for correct exception |
| 118 | handling support. This is expensive and is by default omitted for efficiency. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 119 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 120 | .. option:: --stats |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 121 | |
| 122 | Print statistics recorded by code-generation passes. |
| 123 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 124 | .. option:: --time-passes |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 125 | |
| 126 | Record the amount of time needed for each pass and print a report to standard |
| 127 | error. |
| 128 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 129 | .. option:: --load=<dso_path> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 130 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 131 | Dynamically load ``dso_path`` (a path to a dynamically shared object) that |
| 132 | implements an LLVM target. This will permit the target name to be used with |
| 133 | the :option:`-march` option so that code can be generated for that target. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 134 | |
| 135 | Tuning/Configuration Options |
| 136 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 137 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 138 | .. option:: --print-machineinstrs |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 139 | |
| 140 | Print generated machine code between compilation phases (useful for debugging). |
| 141 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 142 | .. option:: --regalloc=<allocator> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 143 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 144 | Specify the register allocator to use. The default ``allocator`` is *local*. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 145 | Valid register allocators are: |
| 146 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 147 | *simple* |
| 148 | |
| 149 | Very simple "always spill" register allocator |
| 150 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 151 | *local* |
| 152 | |
| 153 | Local register allocator |
| 154 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 155 | *linearscan* |
| 156 | |
| 157 | Linear scan global register allocator |
| 158 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 159 | *iterativescan* |
| 160 | |
| 161 | Iterative scan global register allocator |
| 162 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 163 | .. option:: --spiller=<spiller> |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 164 | |
| 165 | Specify the spiller to use for register allocators that support it. Currently |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 166 | this option is used only by the linear scan register allocator. The default |
| 167 | ``spiller`` is *local*. Valid spillers are: |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 168 | |
| 169 | *simple* |
| 170 | |
| 171 | Simple spiller |
| 172 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 173 | *local* |
| 174 | |
| 175 | Local spiller |
| 176 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 177 | Intel IA-32-specific Options |
| 178 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 179 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 180 | .. option:: --x86-asm-syntax=[att|intel] |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 181 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 182 | Specify whether to emit assembly code in AT&T syntax (the default) or Intel |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 183 | syntax. |
| 184 | |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 185 | EXIT STATUS |
| 186 | ----------- |
| 187 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 188 | If :program:`llc` succeeds, it will exit with 0. Otherwise, if an error |
| 189 | occurs, it will exit with a non-zero value. |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 190 | |
| 191 | SEE ALSO |
| 192 | -------- |
| 193 | |
Dmitri Gribenko | dff966c | 2012-11-29 18:16:11 +0000 | [diff] [blame] | 194 | lli |
Daniel Dunbar | 3b709d5 | 2012-05-08 16:50:35 +0000 | [diff] [blame] | 195 | |