MIRLangRef.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. ========================================
  2. Machine IR (MIR) Format Reference Manual
  3. ========================================
  4. .. contents::
  5. :local:
  6. .. warning::
  7. This is a work in progress.
  8. Introduction
  9. ============
  10. This document is a reference manual for the Machine IR (MIR) serialization
  11. format. MIR is a human readable serialization format that is used to represent
  12. LLVM's :ref:`machine specific intermediate representation
  13. <machine code representation>`.
  14. The MIR serialization format is designed to be used for testing the code
  15. generation passes in LLVM.
  16. Overview
  17. ========
  18. The MIR serialization format uses a YAML container. YAML is a standard
  19. data serialization language, and the full YAML language spec can be read at
  20. `yaml.org
  21. <http://www.yaml.org/spec/1.2/spec.html#Introduction>`_.
  22. A MIR file is split up into a series of `YAML documents`_. The first document
  23. can contain an optional embedded LLVM IR module, and the rest of the documents
  24. contain the serialized machine functions.
  25. .. _YAML documents: http://www.yaml.org/spec/1.2/spec.html#id2800132
  26. MIR Testing Guide
  27. =================
  28. You can use the MIR format for testing in two different ways:
  29. - You can write MIR tests that invoke a single code generation pass using the
  30. ``-run-pass`` option in llc.
  31. - You can use llc's ``-stop-after`` option with existing or new LLVM assembly
  32. tests and check the MIR output of a specific code generation pass.
  33. Testing Individual Code Generation Passes
  34. -----------------------------------------
  35. The ``-run-pass`` option in llc allows you to create MIR tests that invoke just
  36. a single code generation pass. When this option is used, llc will parse an
  37. input MIR file, run the specified code generation pass(es), and output the
  38. resulting MIR code.
  39. You can generate an input MIR file for the test by using the ``-stop-after`` or
  40. ``-stop-before`` option in llc. For example, if you would like to write a test
  41. for the post register allocation pseudo instruction expansion pass, you can
  42. specify the machine copy propagation pass in the ``-stop-after`` option, as it
  43. runs just before the pass that we are trying to test:
  44. ``llc -stop-after=machine-cp bug-trigger.ll > test.mir``
  45. If the same pass is run multiple times, a run index can be included
  46. after the name with a comma.
  47. ``llc -stop-after=dead-mi-elimination,1 bug-trigger.ll > test.mir``
  48. After generating the input MIR file, you'll have to add a run line that uses
  49. the ``-run-pass`` option to it. In order to test the post register allocation
  50. pseudo instruction expansion pass on X86-64, a run line like the one shown
  51. below can be used:
  52. ``# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=postrapseudos | FileCheck %s``
  53. The MIR files are target dependent, so they have to be placed in the target
  54. specific test directories (``lib/CodeGen/TARGETNAME``). They also need to
  55. specify a target triple or a target architecture either in the run line or in
  56. the embedded LLVM IR module.
  57. Simplifying MIR files
  58. ^^^^^^^^^^^^^^^^^^^^^
  59. The MIR code coming out of ``-stop-after``/``-stop-before`` is very verbose;
  60. Tests are more accessible and future proof when simplified:
  61. - Use the ``-simplify-mir`` option with llc.
  62. - Machine function attributes often have default values or the test works just
  63. as well with default values. Typical candidates for this are: `alignment:`,
  64. `exposesReturnsTwice`, `legalized`, `regBankSelected`, `selected`.
  65. The whole `frameInfo` section is often unnecessary if there is no special
  66. frame usage in the function. `tracksRegLiveness` on the other hand is often
  67. necessary for some passes that care about block livein lists.
  68. - The (global) `liveins:` list is typically only interesting for early
  69. instruction selection passes and can be removed when testing later passes.
  70. The per-block `liveins:` on the other hand are necessary if
  71. `tracksRegLiveness` is true.
  72. - Branch probability data in block `successors:` lists can be dropped if the
  73. test doesn't depend on it. Example:
  74. `successors: %bb.1(0x40000000), %bb.2(0x40000000)` can be replaced with
  75. `successors: %bb.1, %bb.2`.
  76. - MIR code contains a whole IR module. This is necessary because there are
  77. no equivalents in MIR for global variables, references to external functions,
  78. function attributes, metadata, debug info. Instead some MIR data references
  79. the IR constructs. You can often remove them if the test doesn't depend on
  80. them.
  81. - Alias Analysis is performed on IR values. These are referenced by memory
  82. operands in MIR. Example: `:: (load 8 from %ir.foobar, !alias.scope !9)`.
  83. If the test doesn't depend on (good) alias analysis the references can be
  84. dropped: `:: (load 8)`
  85. - MIR blocks can reference IR blocks for debug printing, profile information
  86. or debug locations. Example: `bb.42.myblock` in MIR references the IR block
  87. `myblock`. It is usually possible to drop the `.myblock` reference and simply
  88. use `bb.42`.
  89. - If there are no memory operands or blocks referencing the IR then the
  90. IR function can be replaced by a parameterless dummy function like
  91. `define @func() { ret void }`.
  92. - It is possible to drop the whole IR section of the MIR file if it only
  93. contains dummy functions (see above). The .mir loader will create the
  94. IR functions automatically in this case.
  95. .. _limitations:
  96. Limitations
  97. -----------
  98. Currently the MIR format has several limitations in terms of which state it
  99. can serialize:
  100. - The target-specific state in the target-specific ``MachineFunctionInfo``
  101. subclasses isn't serialized at the moment.
  102. - The target-specific ``MachineConstantPoolValue`` subclasses (in the ARM and
  103. SystemZ backends) aren't serialized at the moment.
  104. - The ``MCSymbol`` machine operands don't support temporary or local symbols.
  105. - A lot of the state in ``MachineModuleInfo`` isn't serialized - only the CFI
  106. instructions and the variable debug information from MMI is serialized right
  107. now.
  108. These limitations impose restrictions on what you can test with the MIR format.
  109. For now, tests that would like to test some behaviour that depends on the state
  110. of temporary or local ``MCSymbol`` operands or the exception handling state in
  111. MMI, can't use the MIR format. As well as that, tests that test some behaviour
  112. that depends on the state of the target specific ``MachineFunctionInfo`` or
  113. ``MachineConstantPoolValue`` subclasses can't use the MIR format at the moment.
  114. High Level Structure
  115. ====================
  116. .. _embedded-module:
  117. Embedded Module
  118. ---------------
  119. When the first YAML document contains a `YAML block literal string`_, the MIR
  120. parser will treat this string as an LLVM assembly language string that
  121. represents an embedded LLVM IR module.
  122. Here is an example of a YAML document that contains an LLVM module:
  123. .. code-block:: llvm
  124. define i32 @inc(i32* %x) {
  125. entry:
  126. %0 = load i32, i32* %x
  127. %1 = add i32 %0, 1
  128. store i32 %1, i32* %x
  129. ret i32 %1
  130. }
  131. .. _YAML block literal string: http://www.yaml.org/spec/1.2/spec.html#id2795688
  132. Machine Functions
  133. -----------------
  134. The remaining YAML documents contain the machine functions. This is an example
  135. of such YAML document:
  136. .. code-block:: text
  137. ---
  138. name: inc
  139. tracksRegLiveness: true
  140. liveins:
  141. - { reg: '$rdi' }
  142. callSites:
  143. - { bb: 0, offset: 3, fwdArgRegs:
  144. - { arg: 0, reg: '$edi' } }
  145. body: |
  146. bb.0.entry:
  147. liveins: $rdi
  148. $eax = MOV32rm $rdi, 1, _, 0, _
  149. $eax = INC32r killed $eax, implicit-def dead $eflags
  150. MOV32mr killed $rdi, 1, _, 0, _, $eax
  151. CALL64pcrel32 @foo <regmask...>
  152. RETQ $eax
  153. ...
  154. The document above consists of attributes that represent the various
  155. properties and data structures in a machine function.
  156. The attribute ``name`` is required, and its value should be identical to the
  157. name of a function that this machine function is based on.
  158. The attribute ``body`` is a `YAML block literal string`_. Its value represents
  159. the function's machine basic blocks and their machine instructions.
  160. The attribute ``callSites`` is a representation of call site information which
  161. keeps track of call instructions and registers used to transfer call arguments.
  162. Machine Instructions Format Reference
  163. =====================================
  164. The machine basic blocks and their instructions are represented using a custom,
  165. human readable serialization language. This language is used in the
  166. `YAML block literal string`_ that corresponds to the machine function's body.
  167. A source string that uses this language contains a list of machine basic
  168. blocks, which are described in the section below.
  169. Machine Basic Blocks
  170. --------------------
  171. A machine basic block is defined in a single block definition source construct
  172. that contains the block's ID.
  173. The example below defines two blocks that have an ID of zero and one:
  174. .. code-block:: text
  175. bb.0:
  176. <instructions>
  177. bb.1:
  178. <instructions>
  179. A machine basic block can also have a name. It should be specified after the ID
  180. in the block's definition:
  181. .. code-block:: text
  182. bb.0.entry: ; This block's name is "entry"
  183. <instructions>
  184. The block's name should be identical to the name of the IR block that this
  185. machine block is based on.
  186. .. _block-references:
  187. Block References
  188. ^^^^^^^^^^^^^^^^
  189. The machine basic blocks are identified by their ID numbers. Individual
  190. blocks are referenced using the following syntax:
  191. .. code-block:: text
  192. %bb.<id>
  193. Example:
  194. .. code-block:: llvm
  195. %bb.0
  196. The following syntax is also supported, but the former syntax is preferred for
  197. block references:
  198. .. code-block:: text
  199. %bb.<id>[.<name>]
  200. Example:
  201. .. code-block:: llvm
  202. %bb.1.then
  203. Successors
  204. ^^^^^^^^^^
  205. The machine basic block's successors have to be specified before any of the
  206. instructions:
  207. .. code-block:: text
  208. bb.0.entry:
  209. successors: %bb.1.then, %bb.2.else
  210. <instructions>
  211. bb.1.then:
  212. <instructions>
  213. bb.2.else:
  214. <instructions>
  215. The branch weights can be specified in brackets after the successor blocks.
  216. The example below defines a block that has two successors with branch weights
  217. of 32 and 16:
  218. .. code-block:: text
  219. bb.0.entry:
  220. successors: %bb.1.then(32), %bb.2.else(16)
  221. .. _bb-liveins:
  222. Live In Registers
  223. ^^^^^^^^^^^^^^^^^
  224. The machine basic block's live in registers have to be specified before any of
  225. the instructions:
  226. .. code-block:: text
  227. bb.0.entry:
  228. liveins: $edi, $esi
  229. The list of live in registers and successors can be empty. The language also
  230. allows multiple live in register and successor lists - they are combined into
  231. one list by the parser.
  232. Miscellaneous Attributes
  233. ^^^^^^^^^^^^^^^^^^^^^^^^
  234. The attributes ``IsAddressTaken``, ``IsLandingPad`` and ``Alignment`` can be
  235. specified in brackets after the block's definition:
  236. .. code-block:: text
  237. bb.0.entry (address-taken):
  238. <instructions>
  239. bb.2.else (align 4):
  240. <instructions>
  241. bb.3(landing-pad, align 4):
  242. <instructions>
  243. .. TODO: Describe the way the reference to an unnamed LLVM IR block can be
  244. preserved.
  245. ``Alignment`` is specified in bytes, and must be a power of two.
  246. Machine Instructions
  247. --------------------
  248. A machine instruction is composed of a name,
  249. :ref:`machine operands <machine-operands>`,
  250. :ref:`instruction flags <instruction-flags>`, and machine memory operands.
  251. The instruction's name is usually specified before the operands. The example
  252. below shows an instance of the X86 ``RETQ`` instruction with a single machine
  253. operand:
  254. .. code-block:: text
  255. RETQ $eax
  256. However, if the machine instruction has one or more explicitly defined register
  257. operands, the instruction's name has to be specified after them. The example
  258. below shows an instance of the AArch64 ``LDPXpost`` instruction with three
  259. defined register operands:
  260. .. code-block:: text
  261. $sp, $fp, $lr = LDPXpost $sp, 2
  262. The instruction names are serialized using the exact definitions from the
  263. target's ``*InstrInfo.td`` files, and they are case sensitive. This means that
  264. similar instruction names like ``TSTri`` and ``tSTRi`` represent different
  265. machine instructions.
  266. .. _instruction-flags:
  267. Instruction Flags
  268. ^^^^^^^^^^^^^^^^^
  269. The flag ``frame-setup`` or ``frame-destroy`` can be specified before the
  270. instruction's name:
  271. .. code-block:: text
  272. $fp = frame-setup ADDXri $sp, 0, 0
  273. .. code-block:: text
  274. $x21, $x20 = frame-destroy LDPXi $sp
  275. .. _registers:
  276. Bundled Instructions
  277. ^^^^^^^^^^^^^^^^^^^^
  278. The syntax for bundled instructions is the following:
  279. .. code-block:: text
  280. BUNDLE implicit-def $r0, implicit-def $r1, implicit $r2 {
  281. $r0 = SOME_OP $r2
  282. $r1 = ANOTHER_OP internal $r0
  283. }
  284. The first instruction is often a bundle header. The instructions between ``{``
  285. and ``}`` are bundled with the first instruction.
  286. Registers
  287. ---------
  288. Registers are one of the key primitives in the machine instructions
  289. serialization language. They are primarily used in the
  290. :ref:`register machine operands <register-operands>`,
  291. but they can also be used in a number of other places, like the
  292. :ref:`basic block's live in list <bb-liveins>`.
  293. The physical registers are identified by their name and by the '$' prefix sigil.
  294. They use the following syntax:
  295. .. code-block:: text
  296. $<name>
  297. The example below shows three X86 physical registers:
  298. .. code-block:: text
  299. $eax
  300. $r15
  301. $eflags
  302. The virtual registers are identified by their ID number and by the '%' sigil.
  303. They use the following syntax:
  304. .. code-block:: text
  305. %<id>
  306. Example:
  307. .. code-block:: text
  308. %0
  309. The null registers are represented using an underscore ('``_``'). They can also be
  310. represented using a '``$noreg``' named register, although the former syntax
  311. is preferred.
  312. .. _machine-operands:
  313. Machine Operands
  314. ----------------
  315. There are seventeen different kinds of machine operands, and all of them can be
  316. serialized.
  317. Immediate Operands
  318. ^^^^^^^^^^^^^^^^^^
  319. The immediate machine operands are untyped, 64-bit signed integers. The
  320. example below shows an instance of the X86 ``MOV32ri`` instruction that has an
  321. immediate machine operand ``-42``:
  322. .. code-block:: text
  323. $eax = MOV32ri -42
  324. An immediate operand is also used to represent a subregister index when the
  325. machine instruction has one of the following opcodes:
  326. - ``EXTRACT_SUBREG``
  327. - ``INSERT_SUBREG``
  328. - ``REG_SEQUENCE``
  329. - ``SUBREG_TO_REG``
  330. In case this is true, the Machine Operand is printed according to the target.
  331. For example:
  332. In AArch64RegisterInfo.td:
  333. .. code-block:: text
  334. def sub_32 : SubRegIndex<32>;
  335. If the third operand is an immediate with the value ``15`` (target-dependent
  336. value), based on the instruction's opcode and the operand's index the operand
  337. will be printed as ``%subreg.sub_32``:
  338. .. code-block:: text
  339. %1:gpr64 = SUBREG_TO_REG 0, %0, %subreg.sub_32
  340. For integers > 64bit, we use a special machine operand, ``MO_CImmediate``,
  341. which stores the immediate in a ``ConstantInt`` using an ``APInt`` (LLVM's
  342. arbitrary precision integers).
  343. .. TODO: Describe the FPIMM immediate operands.
  344. .. _register-operands:
  345. Register Operands
  346. ^^^^^^^^^^^^^^^^^
  347. The :ref:`register <registers>` primitive is used to represent the register
  348. machine operands. The register operands can also have optional
  349. :ref:`register flags <register-flags>`,
  350. :ref:`a subregister index <subregister-indices>`,
  351. and a reference to the tied register operand.
  352. The full syntax of a register operand is shown below:
  353. .. code-block:: text
  354. [<flags>] <register> [ :<subregister-idx-name> ] [ (tied-def <tied-op>) ]
  355. This example shows an instance of the X86 ``XOR32rr`` instruction that has
  356. 5 register operands with different register flags:
  357. .. code-block:: text
  358. dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al
  359. .. _register-flags:
  360. Register Flags
  361. ~~~~~~~~~~~~~~
  362. The table below shows all of the possible register flags along with the
  363. corresponding internal ``llvm::RegState`` representation:
  364. .. list-table::
  365. :header-rows: 1
  366. * - Flag
  367. - Internal Value
  368. * - ``implicit``
  369. - ``RegState::Implicit``
  370. * - ``implicit-def``
  371. - ``RegState::ImplicitDefine``
  372. * - ``def``
  373. - ``RegState::Define``
  374. * - ``dead``
  375. - ``RegState::Dead``
  376. * - ``killed``
  377. - ``RegState::Kill``
  378. * - ``undef``
  379. - ``RegState::Undef``
  380. * - ``internal``
  381. - ``RegState::InternalRead``
  382. * - ``early-clobber``
  383. - ``RegState::EarlyClobber``
  384. * - ``debug-use``
  385. - ``RegState::Debug``
  386. * - ``renamable``
  387. - ``RegState::Renamable``
  388. .. _subregister-indices:
  389. Subregister Indices
  390. ~~~~~~~~~~~~~~~~~~~
  391. The register machine operands can reference a portion of a register by using
  392. the subregister indices. The example below shows an instance of the ``COPY``
  393. pseudo instruction that uses the X86 ``sub_8bit`` subregister index to copy 8
  394. lower bits from the 32-bit virtual register 0 to the 8-bit virtual register 1:
  395. .. code-block:: text
  396. %1 = COPY %0:sub_8bit
  397. The names of the subregister indices are target specific, and are typically
  398. defined in the target's ``*RegisterInfo.td`` file.
  399. Constant Pool Indices
  400. ^^^^^^^^^^^^^^^^^^^^^
  401. A constant pool index (CPI) operand is printed using its index in the
  402. function's ``MachineConstantPool`` and an offset.
  403. For example, a CPI with the index 1 and offset 8:
  404. .. code-block:: text
  405. %1:gr64 = MOV64ri %const.1 + 8
  406. For a CPI with the index 0 and offset -12:
  407. .. code-block:: text
  408. %1:gr64 = MOV64ri %const.0 - 12
  409. A constant pool entry is bound to a LLVM IR ``Constant`` or a target-specific
  410. ``MachineConstantPoolValue``. When serializing all the function's constants the
  411. following format is used:
  412. .. code-block:: text
  413. constants:
  414. - id: <index>
  415. value: <value>
  416. alignment: <alignment>
  417. isTargetSpecific: <target-specific>
  418. where:
  419. - ``<index>`` is a 32-bit unsigned integer;
  420. - ``<value>`` is a `LLVM IR Constant
  421. <https://www.llvm.org/docs/LangRef.html#constants>`_;
  422. - ``<alignment>`` is a 32-bit unsigned integer specified in bytes, and must be
  423. power of two;
  424. - ``<target-specific>`` is either true or false.
  425. Example:
  426. .. code-block:: text
  427. constants:
  428. - id: 0
  429. value: 'double 3.250000e+00'
  430. alignment: 8
  431. - id: 1
  432. value: 'g-(LPC0+8)'
  433. alignment: 4
  434. isTargetSpecific: true
  435. Global Value Operands
  436. ^^^^^^^^^^^^^^^^^^^^^
  437. The global value machine operands reference the global values from the
  438. :ref:`embedded LLVM IR module <embedded-module>`.
  439. The example below shows an instance of the X86 ``MOV64rm`` instruction that has
  440. a global value operand named ``G``:
  441. .. code-block:: text
  442. $rax = MOV64rm $rip, 1, _, @G, _
  443. The named global values are represented using an identifier with the '@' prefix.
  444. If the identifier doesn't match the regular expression
  445. `[-a-zA-Z$._][-a-zA-Z$._0-9]*`, then this identifier must be quoted.
  446. The unnamed global values are represented using an unsigned numeric value with
  447. the '@' prefix, like in the following examples: ``@0``, ``@989``.
  448. Target-dependent Index Operands
  449. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  450. A target index operand is a target-specific index and an offset. The
  451. target-specific index is printed using target-specific names and a positive or
  452. negative offset.
  453. For example, the ``amdgpu-constdata-start`` is associated with the index ``0``
  454. in the AMDGPU backend. So if we have a target index operand with the index 0
  455. and the offset 8:
  456. .. code-block:: text
  457. $sgpr2 = S_ADD_U32 _, target-index(amdgpu-constdata-start) + 8, implicit-def _, implicit-def _
  458. Jump-table Index Operands
  459. ^^^^^^^^^^^^^^^^^^^^^^^^^
  460. A jump-table index operand with the index 0 is printed as following:
  461. .. code-block:: text
  462. tBR_JTr killed $r0, %jump-table.0
  463. A machine jump-table entry contains a list of ``MachineBasicBlocks``. When serializing all the function's jump-table entries, the following format is used:
  464. .. code-block:: text
  465. jumpTable:
  466. kind: <kind>
  467. entries:
  468. - id: <index>
  469. blocks: [ <bbreference>, <bbreference>, ... ]
  470. where ``<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>`.
  471. Example:
  472. .. code-block:: text
  473. jumpTable:
  474. kind: inline
  475. entries:
  476. - id: 0
  477. blocks: [ '%bb.3', '%bb.9', '%bb.4.d3' ]
  478. - id: 1
  479. blocks: [ '%bb.7', '%bb.7', '%bb.4.d3', '%bb.5' ]
  480. External Symbol Operands
  481. ^^^^^^^^^^^^^^^^^^^^^^^^^
  482. An external symbol operand is represented using an identifier with the ``&``
  483. prefix. The identifier is surrounded with ""'s and escaped if it has any
  484. special non-printable characters in it.
  485. Example:
  486. .. code-block:: text
  487. CALL64pcrel32 &__stack_chk_fail, csr_64, implicit $rsp, implicit-def $rsp
  488. MCSymbol Operands
  489. ^^^^^^^^^^^^^^^^^
  490. A MCSymbol operand is holding a pointer to a ``MCSymbol``. For the limitations
  491. of this operand in MIR, see :ref:`limitations <limitations>`.
  492. The syntax is:
  493. .. code-block:: text
  494. EH_LABEL <mcsymbol Ltmp1>
  495. CFIIndex Operands
  496. ^^^^^^^^^^^^^^^^^
  497. A CFI Index operand is holding an index into a per-function side-table,
  498. ``MachineFunction::getFrameInstructions()``, which references all the frame
  499. instructions in a ``MachineFunction``. A ``CFI_INSTRUCTION`` may look like it
  500. contains multiple operands, but the only operand it contains is the CFI Index.
  501. The other operands are tracked by the ``MCCFIInstruction`` object.
  502. The syntax is:
  503. .. code-block:: text
  504. CFI_INSTRUCTION offset $w30, -16
  505. which may be emitted later in the MC layer as:
  506. .. code-block:: text
  507. .cfi_offset w30, -16
  508. IntrinsicID Operands
  509. ^^^^^^^^^^^^^^^^^^^^
  510. An Intrinsic ID operand contains a generic intrinsic ID or a target-specific ID.
  511. The syntax for the ``returnaddress`` intrinsic is:
  512. .. code-block:: text
  513. $x0 = COPY intrinsic(@llvm.returnaddress)
  514. Predicate Operands
  515. ^^^^^^^^^^^^^^^^^^
  516. A Predicate operand contains an IR predicate from ``CmpInst::Predicate``, like
  517. ``ICMP_EQ``, etc.
  518. For an int eq predicate ``ICMP_EQ``, the syntax is:
  519. .. code-block:: text
  520. %2:gpr(s32) = G_ICMP intpred(eq), %0, %1
  521. .. TODO: Describe the parsers default behaviour when optional YAML attributes
  522. are missing.
  523. .. TODO: Describe the syntax for virtual register YAML definitions.
  524. .. TODO: Describe the machine function's YAML flag attributes.
  525. .. TODO: Describe the syntax for the register mask machine operands.
  526. .. TODO: Describe the frame information YAML mapping.
  527. .. TODO: Describe the syntax of the stack object machine operands and their
  528. YAML definitions.
  529. .. TODO: Describe the syntax of the block address machine operands.
  530. .. TODO: Describe the syntax of the metadata machine operands, and the
  531. instructions debug location attribute.
  532. .. TODO: Describe the syntax of the register live out machine operands.
  533. .. TODO: Describe the syntax of the machine memory operands.