blob: 14ac63bbd9d2716118f442e6b8e3d73d79fdad52 [file] [log] [blame]
Alex Lorenz3d311772015-08-06 22:55:19 +00001========================================
2Machine IR (MIR) Format Reference Manual
3========================================
4
5.. contents::
6 :local:
7
8.. warning::
9 This is a work in progress.
10
11Introduction
12============
13
14This document is a reference manual for the Machine IR (MIR) serialization
15format. MIR is a human readable serialization format that is used to represent
16LLVM's :ref:`machine specific intermediate representation
17<machine code representation>`.
18
19The MIR serialization format is designed to be used for testing the code
20generation passes in LLVM.
21
22Overview
23========
24
25The MIR serialization format uses a YAML container. YAML is a standard
26data serialization language, and the full YAML language spec can be read at
27`yaml.org
28<http://www.yaml.org/spec/1.2/spec.html#Introduction>`_.
29
30A MIR file is split up into a series of `YAML documents`_. The first document
31can contain an optional embedded LLVM IR module, and the rest of the documents
32contain the serialized machine functions.
33
34.. _YAML documents: http://www.yaml.org/spec/1.2/spec.html#id2800132
35
Alex Lorenzea788c42015-08-21 22:58:33 +000036MIR Testing Guide
37=================
38
39You can use the MIR format for testing in two different ways:
40
41- You can write MIR tests that invoke a single code generation pass using the
Matthias Braune6185b72017-04-13 22:14:45 +000042 ``-run-pass`` option in llc.
Alex Lorenzea788c42015-08-21 22:58:33 +000043
Matthias Braune6185b72017-04-13 22:14:45 +000044- You can use llc's ``-stop-after`` option with existing or new LLVM assembly
Alex Lorenzea788c42015-08-21 22:58:33 +000045 tests and check the MIR output of a specific code generation pass.
46
47Testing Individual Code Generation Passes
48-----------------------------------------
49
Matthias Braune6185b72017-04-13 22:14:45 +000050The ``-run-pass`` option in llc allows you to create MIR tests that invoke just
51a single code generation pass. When this option is used, llc will parse an
52input MIR file, run the specified code generation pass(es), and output the
53resulting MIR code.
Alex Lorenzea788c42015-08-21 22:58:33 +000054
Matthias Braune6185b72017-04-13 22:14:45 +000055You can generate an input MIR file for the test by using the ``-stop-after`` or
56``-stop-before`` option in llc. For example, if you would like to write a test
57for the post register allocation pseudo instruction expansion pass, you can
58specify the machine copy propagation pass in the ``-stop-after`` option, as it
59runs just before the pass that we are trying to test:
Alex Lorenzea788c42015-08-21 22:58:33 +000060
Matthias Braune6185b72017-04-13 22:14:45 +000061 ``llc -stop-after=machine-cp bug-trigger.ll > test.mir``
Alex Lorenzea788c42015-08-21 22:58:33 +000062
63After generating the input MIR file, you'll have to add a run line that uses
64the ``-run-pass`` option to it. In order to test the post register allocation
65pseudo instruction expansion pass on X86-64, a run line like the one shown
66below can be used:
67
Matthias Braune6185b72017-04-13 22:14:45 +000068 ``# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=postrapseudos | FileCheck %s``
Alex Lorenzea788c42015-08-21 22:58:33 +000069
70The MIR files are target dependent, so they have to be placed in the target
Matthias Braune6185b72017-04-13 22:14:45 +000071specific test directories (``lib/CodeGen/TARGETNAME``). They also need to
72specify a target triple or a target architecture either in the run line or in
73the embedded LLVM IR module.
Alex Lorenzea788c42015-08-21 22:58:33 +000074
Matthias Braun836c3832017-04-13 23:45:14 +000075Simplifying MIR files
76^^^^^^^^^^^^^^^^^^^^^
77
78The MIR code coming out of ``-stop-after``/``-stop-before`` is very verbose;
79Tests are more accessible and future proof when simplified:
80
Matthias Braun89401142017-05-05 21:09:30 +000081- Use the ``-simplify-mir`` option with llc.
82
Matthias Braun836c3832017-04-13 23:45:14 +000083- Machine function attributes often have default values or the test works just
84 as well with default values. Typical candidates for this are: `alignment:`,
85 `exposesReturnsTwice`, `legalized`, `regBankSelected`, `selected`.
86 The whole `frameInfo` section is often unnecessary if there is no special
87 frame usage in the function. `tracksRegLiveness` on the other hand is often
88 necessary for some passes that care about block livein lists.
89
90- The (global) `liveins:` list is typically only interesting for early
91 instruction selection passes and can be removed when testing later passes.
92 The per-block `liveins:` on the other hand are necessary if
93 `tracksRegLiveness` is true.
94
95- Branch probability data in block `successors:` lists can be dropped if the
96 test doesn't depend on it. Example:
97 `successors: %bb.1(0x40000000), %bb.2(0x40000000)` can be replaced with
98 `successors: %bb.1, %bb.2`.
99
100- MIR code contains a whole IR module. This is necessary because there are
101 no equivalents in MIR for global variables, references to external functions,
102 function attributes, metadata, debug info. Instead some MIR data references
103 the IR constructs. You can often remove them if the test doesn't depend on
104 them.
105
106- Alias Analysis is performed on IR values. These are referenced by memory
107 operands in MIR. Example: `:: (load 8 from %ir.foobar, !alias.scope !9)`.
108 If the test doesn't depend on (good) alias analysis the references can be
109 dropped: `:: (load 8)`
110
111- MIR blocks can reference IR blocks for debug printing, profile information
112 or debug locations. Example: `bb.42.myblock` in MIR references the IR block
113 `myblock`. It is usually possible to drop the `.myblock` reference and simply
114 use `bb.42`.
115
116- If there are no memory operands or blocks referencing the IR then the
117 IR function can be replaced by a parameterless dummy function like
118 `define @func() { ret void }`.
119
120- It is possible to drop the whole IR section of the MIR file if it only
121 contains dummy functions (see above). The .mir loader will create the
122 IR functions automatically in this case.
123
Alex Lorenzea788c42015-08-21 22:58:33 +0000124Limitations
125-----------
126
127Currently the MIR format has several limitations in terms of which state it
128can serialize:
129
130- The target-specific state in the target-specific ``MachineFunctionInfo``
131 subclasses isn't serialized at the moment.
132
133- The target-specific ``MachineConstantPoolValue`` subclasses (in the ARM and
134 SystemZ backends) aren't serialized at the moment.
135
136- The ``MCSymbol`` machine operands are only printed, they can't be parsed.
137
138- A lot of the state in ``MachineModuleInfo`` isn't serialized - only the CFI
139 instructions and the variable debug information from MMI is serialized right
140 now.
141
142These limitations impose restrictions on what you can test with the MIR format.
143For now, tests that would like to test some behaviour that depends on the state
144of certain ``MCSymbol`` operands or the exception handling state in MMI, can't
145use the MIR format. As well as that, tests that test some behaviour that
146depends on the state of the target specific ``MachineFunctionInfo`` or
147``MachineConstantPoolValue`` subclasses can't use the MIR format at the moment.
148
Alex Lorenz3d311772015-08-06 22:55:19 +0000149High Level Structure
150====================
151
Alex Lorenzd4990eb2015-09-08 11:38:16 +0000152.. _embedded-module:
153
Alex Lorenz3d311772015-08-06 22:55:19 +0000154Embedded Module
155---------------
156
157When the first YAML document contains a `YAML block literal string`_, the MIR
158parser will treat this string as an LLVM assembly language string that
159represents an embedded LLVM IR module.
160Here is an example of a YAML document that contains an LLVM module:
161
162.. code-block:: llvm
163
Alex Lorenz3d311772015-08-06 22:55:19 +0000164 define i32 @inc(i32* %x) {
165 entry:
166 %0 = load i32, i32* %x
167 %1 = add i32 %0, 1
168 store i32 %1, i32* %x
169 ret i32 %1
170 }
Alex Lorenz3d311772015-08-06 22:55:19 +0000171
172.. _YAML block literal string: http://www.yaml.org/spec/1.2/spec.html#id2795688
173
174Machine Functions
175-----------------
176
177The remaining YAML documents contain the machine functions. This is an example
178of such YAML document:
179
Renato Golin124f2592016-07-20 12:16:38 +0000180.. code-block:: text
Alex Lorenz3d311772015-08-06 22:55:19 +0000181
182 ---
183 name: inc
184 tracksRegLiveness: true
185 liveins:
186 - { reg: '%rdi' }
Alex Lorenz98461672015-08-14 00:36:10 +0000187 body: |
188 bb.0.entry:
189 liveins: %rdi
190
191 %eax = MOV32rm %rdi, 1, _, 0, _
192 %eax = INC32r killed %eax, implicit-def dead %eflags
193 MOV32mr killed %rdi, 1, _, 0, _, %eax
194 RETQ %eax
Alex Lorenz3d311772015-08-06 22:55:19 +0000195 ...
196
197The document above consists of attributes that represent the various
198properties and data structures in a machine function.
199
200The attribute ``name`` is required, and its value should be identical to the
201name of a function that this machine function is based on.
202
Alex Lorenz98461672015-08-14 00:36:10 +0000203The attribute ``body`` is a `YAML block literal string`_. Its value represents
204the function's machine basic blocks and their machine instructions.
Alex Lorenz3d311772015-08-06 22:55:19 +0000205
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000206Machine Instructions Format Reference
207=====================================
208
209The machine basic blocks and their instructions are represented using a custom,
210human readable serialization language. This language is used in the
211`YAML block literal string`_ that corresponds to the machine function's body.
212
213A source string that uses this language contains a list of machine basic
214blocks, which are described in the section below.
215
216Machine Basic Blocks
217--------------------
218
219A machine basic block is defined in a single block definition source construct
220that contains the block's ID.
221The example below defines two blocks that have an ID of zero and one:
222
Renato Golin124f2592016-07-20 12:16:38 +0000223.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000224
225 bb.0:
226 <instructions>
227 bb.1:
228 <instructions>
229
230A machine basic block can also have a name. It should be specified after the ID
231in the block's definition:
232
Renato Golin124f2592016-07-20 12:16:38 +0000233.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000234
235 bb.0.entry: ; This block's name is "entry"
236 <instructions>
237
238The block's name should be identical to the name of the IR block that this
239machine block is based on.
240
Francis Visoiu Mistrihb41dbbe2017-12-13 10:30:59 +0000241.. _block-references:
242
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000243Block References
244^^^^^^^^^^^^^^^^
245
246The machine basic blocks are identified by their ID numbers. Individual
247blocks are referenced using the following syntax:
248
Renato Golin124f2592016-07-20 12:16:38 +0000249.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000250
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +0000251 %bb.<id>
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000252
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +0000253Example:
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000254
255.. code-block:: llvm
256
257 %bb.0
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +0000258
259The following syntax is also supported, but the former syntax is preferred for
260block references:
261
262.. code-block:: text
263
264 %bb.<id>[.<name>]
265
266Example:
267
268.. code-block:: llvm
269
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000270 %bb.1.then
271
272Successors
273^^^^^^^^^^
274
275The machine basic block's successors have to be specified before any of the
276instructions:
277
Renato Golin124f2592016-07-20 12:16:38 +0000278.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000279
280 bb.0.entry:
281 successors: %bb.1.then, %bb.2.else
282 <instructions>
283 bb.1.then:
284 <instructions>
285 bb.2.else:
286 <instructions>
287
288The branch weights can be specified in brackets after the successor blocks.
289The example below defines a block that has two successors with branch weights
290of 32 and 16:
291
Renato Golin124f2592016-07-20 12:16:38 +0000292.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000293
294 bb.0.entry:
295 successors: %bb.1.then(32), %bb.2.else(16)
296
Alex Lorenzb981d372015-08-21 21:17:01 +0000297.. _bb-liveins:
298
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000299Live In Registers
300^^^^^^^^^^^^^^^^^
301
302The machine basic block's live in registers have to be specified before any of
303the instructions:
304
Renato Golin124f2592016-07-20 12:16:38 +0000305.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000306
307 bb.0.entry:
308 liveins: %edi, %esi
309
310The list of live in registers and successors can be empty. The language also
311allows multiple live in register and successor lists - they are combined into
312one list by the parser.
313
314Miscellaneous Attributes
315^^^^^^^^^^^^^^^^^^^^^^^^
316
317The attributes ``IsAddressTaken``, ``IsLandingPad`` and ``Alignment`` can be
318specified in brackets after the block's definition:
319
Renato Golin124f2592016-07-20 12:16:38 +0000320.. code-block:: text
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000321
322 bb.0.entry (address-taken):
323 <instructions>
324 bb.2.else (align 4):
325 <instructions>
326 bb.3(landing-pad, align 4):
327 <instructions>
328
329.. TODO: Describe the way the reference to an unnamed LLVM IR block can be
330 preserved.
331
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000332Machine Instructions
333--------------------
334
Alex Lorenzb981d372015-08-21 21:17:01 +0000335A machine instruction is composed of a name,
336:ref:`machine operands <machine-operands>`,
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000337:ref:`instruction flags <instruction-flags>`, and machine memory operands.
338
339The instruction's name is usually specified before the operands. The example
340below shows an instance of the X86 ``RETQ`` instruction with a single machine
341operand:
342
Renato Golin124f2592016-07-20 12:16:38 +0000343.. code-block:: text
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000344
345 RETQ %eax
346
347However, if the machine instruction has one or more explicitly defined register
348operands, the instruction's name has to be specified after them. The example
349below shows an instance of the AArch64 ``LDPXpost`` instruction with three
350defined register operands:
351
Renato Golin124f2592016-07-20 12:16:38 +0000352.. code-block:: text
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000353
354 %sp, %fp, %lr = LDPXpost %sp, 2
355
356The instruction names are serialized using the exact definitions from the
357target's ``*InstrInfo.td`` files, and they are case sensitive. This means that
358similar instruction names like ``TSTri`` and ``tSTRi`` represent different
359machine instructions.
360
361.. _instruction-flags:
362
363Instruction Flags
364^^^^^^^^^^^^^^^^^
365
366The flag ``frame-setup`` can be specified before the instruction's name:
367
Renato Golin124f2592016-07-20 12:16:38 +0000368.. code-block:: text
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000369
370 %fp = frame-setup ADDXri %sp, 0, 0
371
Alex Lorenzb981d372015-08-21 21:17:01 +0000372.. _registers:
373
374Registers
375---------
376
377Registers are one of the key primitives in the machine instructions
378serialization language. They are primarly used in the
379:ref:`register machine operands <register-operands>`,
380but they can also be used in a number of other places, like the
381:ref:`basic block's live in list <bb-liveins>`.
382
383The physical registers are identified by their name. They use the following
384syntax:
385
Renato Golin124f2592016-07-20 12:16:38 +0000386.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000387
388 %<name>
389
390The example below shows three X86 physical registers:
391
Renato Golin124f2592016-07-20 12:16:38 +0000392.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000393
394 %eax
395 %r15
396 %eflags
397
398The virtual registers are identified by their ID number. They use the following
399syntax:
400
Renato Golin124f2592016-07-20 12:16:38 +0000401.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000402
403 %<id>
404
405Example:
406
Renato Golin124f2592016-07-20 12:16:38 +0000407.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000408
409 %0
410
411The null registers are represented using an underscore ('``_``'). They can also be
412represented using a '``%noreg``' named register, although the former syntax
413is preferred.
414
415.. _machine-operands:
416
417Machine Operands
418----------------
419
420There are seventeen different kinds of machine operands, and all of them, except
421the ``MCSymbol`` operand, can be serialized. The ``MCSymbol`` operands are
422just printed out - they can't be parsed back yet.
423
424Immediate Operands
425^^^^^^^^^^^^^^^^^^
426
427The immediate machine operands are untyped, 64-bit signed integers. The
428example below shows an instance of the X86 ``MOV32ri`` instruction that has an
429immediate machine operand ``-42``:
430
Renato Golin124f2592016-07-20 12:16:38 +0000431.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000432
433 %eax = MOV32ri -42
434
Francis Visoiu Mistrih440f69c2017-12-08 22:53:21 +0000435An immediate operand is also used to represent a subregister index when the
436machine instruction has one of the following opcodes:
437
438- ``EXTRACT_SUBREG``
439
440- ``INSERT_SUBREG``
441
442- ``REG_SEQUENCE``
443
444- ``SUBREG_TO_REG``
445
446In case this is true, the Machine Operand is printed according to the target.
447
448For example:
449
450In AArch64RegisterInfo.td:
451
452.. code-block:: text
453
454 def sub_32 : SubRegIndex<32>;
455
456If the third operand is an immediate with the value ``15`` (target-dependent
457value), based on the instruction's opcode and the operand's index the operand
458will be printed as ``%subreg.sub_32``:
459
460.. code-block:: text
461
462 %1:gpr64 = SUBREG_TO_REG 0, %0, %subreg.sub_32
463
Francis Visoiu Mistrih6c4ca712017-12-08 11:40:06 +0000464For integers > 64bit, we use a special machine operand, ``MO_CImmediate``,
465which stores the immediate in a ``ConstantInt`` using an ``APInt`` (LLVM's
466arbitrary precision integers).
467
468.. TODO: Describe the FPIMM immediate operands.
Alex Lorenzb981d372015-08-21 21:17:01 +0000469
470.. _register-operands:
471
472Register Operands
473^^^^^^^^^^^^^^^^^
474
475The :ref:`register <registers>` primitive is used to represent the register
476machine operands. The register operands can also have optional
477:ref:`register flags <register-flags>`,
Alex Lorenz37e02622015-09-08 11:39:47 +0000478:ref:`a subregister index <subregister-indices>`,
479and a reference to the tied register operand.
Alex Lorenzb981d372015-08-21 21:17:01 +0000480The full syntax of a register operand is shown below:
481
Renato Golin124f2592016-07-20 12:16:38 +0000482.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000483
484 [<flags>] <register> [ :<subregister-idx-name> ] [ (tied-def <tied-op>) ]
485
486This example shows an instance of the X86 ``XOR32rr`` instruction that has
4875 register operands with different register flags:
488
Renato Golin124f2592016-07-20 12:16:38 +0000489.. code-block:: text
Alex Lorenzb981d372015-08-21 21:17:01 +0000490
491 dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags, implicit-def %al
492
493.. _register-flags:
494
495Register Flags
496~~~~~~~~~~~~~~
497
498The table below shows all of the possible register flags along with the
499corresponding internal ``llvm::RegState`` representation:
500
501.. list-table::
502 :header-rows: 1
503
504 * - Flag
505 - Internal Value
506
507 * - ``implicit``
508 - ``RegState::Implicit``
509
510 * - ``implicit-def``
511 - ``RegState::ImplicitDefine``
512
513 * - ``def``
514 - ``RegState::Define``
515
516 * - ``dead``
517 - ``RegState::Dead``
518
519 * - ``killed``
520 - ``RegState::Kill``
521
522 * - ``undef``
523 - ``RegState::Undef``
524
525 * - ``internal``
526 - ``RegState::InternalRead``
527
528 * - ``early-clobber``
529 - ``RegState::EarlyClobber``
530
531 * - ``debug-use``
532 - ``RegState::Debug``
Alex Lorenz3a4a60c2015-08-15 01:06:06 +0000533
Geoff Berry60c43102017-12-12 17:53:59 +0000534 * - ``renamable``
535 - ``RegState::Renamable``
536
Alex Lorenz37e02622015-09-08 11:39:47 +0000537.. _subregister-indices:
538
539Subregister Indices
540~~~~~~~~~~~~~~~~~~~
541
542The register machine operands can reference a portion of a register by using
543the subregister indices. The example below shows an instance of the ``COPY``
544pseudo instruction that uses the X86 ``sub_8bit`` subregister index to copy 8
545lower bits from the 32-bit virtual register 0 to the 8-bit virtual register 1:
546
Renato Golin124f2592016-07-20 12:16:38 +0000547.. code-block:: text
Alex Lorenz37e02622015-09-08 11:39:47 +0000548
549 %1 = COPY %0:sub_8bit
550
551The names of the subregister indices are target specific, and are typically
552defined in the target's ``*RegisterInfo.td`` file.
553
Francis Visoiu Mistrih26ae8a62017-12-13 10:30:45 +0000554Constant Pool Indices
555^^^^^^^^^^^^^^^^^^^^^
556
557A constant pool index (CPI) operand is printed using its index in the
558function's ``MachineConstantPool`` and an offset.
559
560For example, a CPI with the index 1 and offset 8:
561
562.. code-block:: text
563
564 %1:gr64 = MOV64ri %const.1 + 8
565
566For a CPI with the index 0 and offset -12:
567
568.. code-block:: text
569
570 %1:gr64 = MOV64ri %const.0 - 12
571
572A constant pool entry is bound to a LLVM IR ``Constant`` or a target-specific
573``MachineConstantPoolValue``. When serializing all the function's constants the
574following format is used:
575
576.. code-block:: text
577
578 constants:
579 - id: <index>
580 value: <value>
581 alignment: <alignment>
582 isTargetSpecific: <target-specific>
583
584where ``<index>`` is a 32-bit unsigned integer, ``<value>`` is a `LLVM IR Constant
585<https://www.llvm.org/docs/LangRef.html#constants>`_, alignment is a 32-bit
586unsigned integer, and ``<target-specific>`` is either true or false.
587
588Example:
589
590.. code-block:: text
591
592 constants:
593 - id: 0
594 value: 'double 3.250000e+00'
595 alignment: 8
596 - id: 1
597 value: 'g-(LPC0+8)'
598 alignment: 4
599 isTargetSpecific: true
600
Alex Lorenzd4990eb2015-09-08 11:38:16 +0000601Global Value Operands
602^^^^^^^^^^^^^^^^^^^^^
603
604The global value machine operands reference the global values from the
605:ref:`embedded LLVM IR module <embedded-module>`.
606The example below shows an instance of the X86 ``MOV64rm`` instruction that has
607a global value operand named ``G``:
608
Renato Golin124f2592016-07-20 12:16:38 +0000609.. code-block:: text
Alex Lorenzd4990eb2015-09-08 11:38:16 +0000610
611 %rax = MOV64rm %rip, 1, _, @G, _
612
613The named global values are represented using an identifier with the '@' prefix.
614If the identifier doesn't match the regular expression
615`[-a-zA-Z$._][-a-zA-Z$._0-9]*`, then this identifier must be quoted.
616
617The unnamed global values are represented using an unsigned numeric value with
618the '@' prefix, like in the following examples: ``@0``, ``@989``.
619
Francis Visoiu Mistrihb3a0d512017-12-13 10:30:51 +0000620Target-dependent Index Operands
621^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
622
623A target index operand is a target-specific index and an offset. The
624target-specific index is printed using target-specific names and a positive or
625negative offset.
626
627For example, the ``amdgpu-constdata-start`` is associated with the index ``0``
628in the AMDGPU backend. So if we have a target index operand with the index 0
629and the offset 8:
630
631.. code-block:: text
632
633 %sgpr2 = S_ADD_U32 _, target-index(amdgpu-constdata-start) + 8, implicit-def _, implicit-def _
634
Francis Visoiu Mistrihb41dbbe2017-12-13 10:30:59 +0000635Jump-table Index Operands
636^^^^^^^^^^^^^^^^^^^^^^^^^
637
638A jump-table index operand with the index 0 is printed as following:
639
640.. code-block:: text
641
642 tBR_JTr killed %r0, %jump-table.0
643
644A machine jump-table entry contains a list of ``MachineBasicBlocks``. When serializing all the function's jump-table entries, the following format is used:
645
646.. code-block:: text
647
648 jumpTable:
649 kind: <kind>
650 entries:
651 - id: <index>
652 blocks: [ <bbreference>, <bbreference>, ... ]
653
654where ``<kind>`` is describing how the jump table is represented and emitted (plain address, relocations, PIC, etc.), and each ``<index>`` is a 32-bit unsigned integer and ``blocks`` contains a list of :ref:`machine basic block references <block-references>`.
655
656Example:
657
658.. code-block:: text
659
660 jumpTable:
661 kind: inline
662 entries:
663 - id: 0
664 blocks: [ '%bb.3', '%bb.9', '%bb.4.d3' ]
665 - id: 1
666 blocks: [ '%bb.7', '%bb.7', '%bb.4.d3', '%bb.5' ]
667
Francis Visoiu Mistrihe76c5fc2017-12-14 10:02:58 +0000668External Symbol Operands
669^^^^^^^^^^^^^^^^^^^^^^^^^
670
671An external symbol operand is represented using an identifier with the ``$``
672prefix. The identifier is surrounded with ""'s and escaped if it has any
673special non-printable characters in it.
674
675Example:
676
677.. code-block:: text
678
679 CALL64pcrel32 $__stack_chk_fail, csr_64, implicit %rsp, implicit-def %rsp
680
681
Alex Lorenz3d311772015-08-06 22:55:19 +0000682.. TODO: Describe the parsers default behaviour when optional YAML attributes
683 are missing.
Alex Lorenz8eadc3f2015-08-21 17:26:38 +0000684.. TODO: Describe the syntax for the bundled instructions.
Alex Lorenzb981d372015-08-21 21:17:01 +0000685.. TODO: Describe the syntax for virtual register YAML definitions.
Alex Lorenz3d311772015-08-06 22:55:19 +0000686.. TODO: Describe the machine function's YAML flag attributes.
Francis Visoiu Mistrihe76c5fc2017-12-14 10:02:58 +0000687.. TODO: Describe the syntax for the register mask machine operands.
Alex Lorenz3d311772015-08-06 22:55:19 +0000688.. TODO: Describe the frame information YAML mapping.
689.. TODO: Describe the syntax of the stack object machine operands and their
690 YAML definitions.
Alex Lorenz3d311772015-08-06 22:55:19 +0000691.. TODO: Describe the syntax of the block address machine operands.
692.. TODO: Describe the syntax of the CFI index machine operands.
693.. TODO: Describe the syntax of the metadata machine operands, and the
694 instructions debug location attribute.
Alex Lorenz3d311772015-08-06 22:55:19 +0000695.. TODO: Describe the syntax of the register live out machine operands.
696.. TODO: Describe the syntax of the machine memory operands.