1 llvm-mc - LLVM Machine Code Playground
2 ======================================
9 :program:`llvm-mc` [*options*] [*filename*]
14 The :program:`llvm-mc` command take input as the assembly code for a specified
15 architecture and generate object file or executable as a output for a specified
18 :program:`llvm-mc` provide powerful set of the tool for working with the
19 machine code such as encoding of their instruction and their internal
20 representation, disassemble string to bytes etc.
22 The choice of architecture for the output assembly code is automatically
23 determined from the input file, unless the :option:`--arch` option is used to
29 If the :option:`-o` option is omitted, then :program:`llvm-mc` will send its
30 output to standard output if the input is from standard input. If the
31 :option:`-o` option specifies "``-``", then the output will also be sent to
34 If no :option:`-o` option is specified and an input file other than "``-``" is
35 specified, then :program:`llvm-mc` creates the output filename by taking the
36 input filename, removing any existing ``.s`` extension, and adding a ``.o``
39 Other :program:`llvm-mc` options are described below.
46 Display available options (--help-hidden for more).
48 .. option:: -o <filename>
50 Use ``<filename>`` as the output filename. See the summary above for more
53 .. option:: --arch=<string>
55 Target arch to assemble for, see -version for available targets.
59 Apply the assemblers "lexer" to break the input into tokens and print each of
60 them out. This is intended to help develop and test an assembler
63 .. option:: --assemble
65 Assemble assembly file (default), and print the result to assembly. This is
66 useful to design and test instruction parsers, and can be a useful tool when
67 combined with other llvm-mc flags. For example, this option may be useful to
68 transcode assembly from different dialects, e.g. on Intel where you can use
69 -output-asm-variant=1 to translate from AT&T to Intel assembly syntax. It can
70 also be combined with --show-encoding to understand how instructions are
73 .. option:: --disassemble
75 Parse a series of hex bytes, and print the result out as assembly syntax.
79 Marked up disassembly of string of hex bytes.
83 Colored disassembly of string of hex bytes.
85 .. option:: --filetype=[asm,null,obj]
87 Sets the output filetype. Setting this flag to `asm` will make the tool output
88 text assembly. Setting this flag to `obj` will make the tool output an object
89 file. Setting it to `null` causes no output to be created and can be used for
90 timing purposes. The default value is `asm`.
94 Generate DWARF debugging info for assembly source files.
96 .. option:: --large-code-model
98 Create CFI directives that assume the code might be more than 2 GB.
100 .. option:: --main-file-name=<string>
102 Specify the name we should consider the input file.
105 .. option:: --masm-hexfloats
107 Enable MASM-style hex float initializers (3F800000r).
110 .. option:: -mattr=a1,+a2,-a3,...
111 Target specific attributes (-mattr=help for details).
113 .. option:: --mcpu=<cpu-name>
115 Target a specific cpu type (-mcpu=help for details).
117 .. option:: --triple=<string>
119 Target triple to assemble for, see -version for available targets.
121 .. option:: --split-dwarf-file=<filename>
125 .. option:: --show-inst-operands
127 Show instructions operands as parsed.
129 .. option:: --show-inst
131 Show internal instruction representation.
133 .. option:: --show-encoding
135 Show instruction encodings.
137 .. option:: --save-temp-labels
139 Don't discard temporary labels.
141 .. option:: --relax-relocations
143 Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL.
145 .. option:: --print-imm-hex
147 Prefer hex format for immediate values.
149 .. option:: --preserve-comments
151 Preserve Comments in outputted assembly.
153 .. option:: --output-asm-variant=<uint>
155 Syntax variant to use for output printing. For example, on x86 targets
156 --output-asm-variant=0 prints in AT&T syntax, and --output-asm-variant=1
157 prints in Intel/MASM syntax.
159 .. option:: --compress-debug-sections=[none|zlib|zstd]
161 Choose DWARF debug sections compression.
167 If :program:`llvm-mc` succeeds, it will exit with 0. Otherwise, if an error
168 occurs, it will exit with a non-zero value.