| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 1 | ======================================== |
| 2 | Machine IR (MIR) Format Reference Manual |
| 3 | ======================================== |
| 4 | |
| 5 | .. contents:: |
| 6 | :local: |
| 7 | |
| 8 | .. warning:: |
| 9 | This is a work in progress. |
| 10 | |
| 11 | Introduction |
| 12 | ============ |
| 13 | |
| 14 | This document is a reference manual for the Machine IR (MIR) serialization |
| 15 | format. MIR is a human readable serialization format that is used to represent |
| 16 | LLVM's :ref:`machine specific intermediate representation |
| 17 | <machine code representation>`. |
| 18 | |
| 19 | The MIR serialization format is designed to be used for testing the code |
| 20 | generation passes in LLVM. |
| 21 | |
| 22 | Overview |
| 23 | ======== |
| 24 | |
| 25 | The MIR serialization format uses a YAML container. YAML is a standard |
| 26 | data 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 | |
| 30 | A MIR file is split up into a series of `YAML documents`_. The first document |
| 31 | can contain an optional embedded LLVM IR module, and the rest of the documents |
| 32 | contain the serialized machine functions. |
| 33 | |
| 34 | .. _YAML documents: http://www.yaml.org/spec/1.2/spec.html#id2800132 |
| 35 | |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 36 | MIR Testing Guide |
| 37 | ================= |
| 38 | |
| 39 | You 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 Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 42 | ``-run-pass`` option in llc. |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 43 | |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 44 | - You can use llc's ``-stop-after`` option with existing or new LLVM assembly |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 45 | tests and check the MIR output of a specific code generation pass. |
| 46 | |
| 47 | Testing Individual Code Generation Passes |
| 48 | ----------------------------------------- |
| 49 | |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 50 | The ``-run-pass`` option in llc allows you to create MIR tests that invoke just |
| 51 | a single code generation pass. When this option is used, llc will parse an |
| 52 | input MIR file, run the specified code generation pass(es), and output the |
| 53 | resulting MIR code. |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 54 | |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 55 | You 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 |
| 57 | for the post register allocation pseudo instruction expansion pass, you can |
| 58 | specify the machine copy propagation pass in the ``-stop-after`` option, as it |
| 59 | runs just before the pass that we are trying to test: |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 60 | |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 61 | ``llc -stop-after=machine-cp bug-trigger.ll > test.mir`` |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 62 | |
| Matt Arsenault | 4315302 | 2018-12-04 17:45:12 +0000 | [diff] [blame] | 63 | If the same pass is run multiple times, a run index can be included |
| 64 | after the name with a comma. |
| 65 | |
| 66 | ``llc -stop-after=dead-mi-elimination,1 bug-trigger.ll > test.mir`` |
| 67 | |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 68 | After generating the input MIR file, you'll have to add a run line that uses |
| 69 | the ``-run-pass`` option to it. In order to test the post register allocation |
| 70 | pseudo instruction expansion pass on X86-64, a run line like the one shown |
| 71 | below can be used: |
| 72 | |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 73 | ``# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=postrapseudos | FileCheck %s`` |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 74 | |
| 75 | The MIR files are target dependent, so they have to be placed in the target |
| Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame] | 76 | specific test directories (``lib/CodeGen/TARGETNAME``). They also need to |
| 77 | specify a target triple or a target architecture either in the run line or in |
| 78 | the embedded LLVM IR module. |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 79 | |
| Matthias Braun | 836c383 | 2017-04-13 23:45:14 +0000 | [diff] [blame] | 80 | Simplifying MIR files |
| 81 | ^^^^^^^^^^^^^^^^^^^^^ |
| 82 | |
| 83 | The MIR code coming out of ``-stop-after``/``-stop-before`` is very verbose; |
| 84 | Tests are more accessible and future proof when simplified: |
| 85 | |
| Matthias Braun | 8940114 | 2017-05-05 21:09:30 +0000 | [diff] [blame] | 86 | - Use the ``-simplify-mir`` option with llc. |
| 87 | |
| Matthias Braun | 836c383 | 2017-04-13 23:45:14 +0000 | [diff] [blame] | 88 | - Machine function attributes often have default values or the test works just |
| 89 | as well with default values. Typical candidates for this are: `alignment:`, |
| 90 | `exposesReturnsTwice`, `legalized`, `regBankSelected`, `selected`. |
| 91 | The whole `frameInfo` section is often unnecessary if there is no special |
| 92 | frame usage in the function. `tracksRegLiveness` on the other hand is often |
| 93 | necessary for some passes that care about block livein lists. |
| 94 | |
| 95 | - The (global) `liveins:` list is typically only interesting for early |
| 96 | instruction selection passes and can be removed when testing later passes. |
| 97 | The per-block `liveins:` on the other hand are necessary if |
| 98 | `tracksRegLiveness` is true. |
| 99 | |
| 100 | - Branch probability data in block `successors:` lists can be dropped if the |
| 101 | test doesn't depend on it. Example: |
| 102 | `successors: %bb.1(0x40000000), %bb.2(0x40000000)` can be replaced with |
| 103 | `successors: %bb.1, %bb.2`. |
| 104 | |
| 105 | - MIR code contains a whole IR module. This is necessary because there are |
| 106 | no equivalents in MIR for global variables, references to external functions, |
| 107 | function attributes, metadata, debug info. Instead some MIR data references |
| 108 | the IR constructs. You can often remove them if the test doesn't depend on |
| 109 | them. |
| 110 | |
| 111 | - Alias Analysis is performed on IR values. These are referenced by memory |
| 112 | operands in MIR. Example: `:: (load 8 from %ir.foobar, !alias.scope !9)`. |
| 113 | If the test doesn't depend on (good) alias analysis the references can be |
| 114 | dropped: `:: (load 8)` |
| 115 | |
| 116 | - MIR blocks can reference IR blocks for debug printing, profile information |
| 117 | or debug locations. Example: `bb.42.myblock` in MIR references the IR block |
| 118 | `myblock`. It is usually possible to drop the `.myblock` reference and simply |
| 119 | use `bb.42`. |
| 120 | |
| 121 | - If there are no memory operands or blocks referencing the IR then the |
| 122 | IR function can be replaced by a parameterless dummy function like |
| 123 | `define @func() { ret void }`. |
| 124 | |
| 125 | - It is possible to drop the whole IR section of the MIR file if it only |
| 126 | contains dummy functions (see above). The .mir loader will create the |
| 127 | IR functions automatically in this case. |
| 128 | |
| Francis Visoiu Mistrih | 3c99371 | 2017-12-14 10:03:23 +0000 | [diff] [blame] | 129 | .. _limitations: |
| 130 | |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 131 | Limitations |
| 132 | ----------- |
| 133 | |
| 134 | Currently the MIR format has several limitations in terms of which state it |
| 135 | can serialize: |
| 136 | |
| 137 | - The target-specific state in the target-specific ``MachineFunctionInfo`` |
| 138 | subclasses isn't serialized at the moment. |
| 139 | |
| 140 | - The target-specific ``MachineConstantPoolValue`` subclasses (in the ARM and |
| 141 | SystemZ backends) aren't serialized at the moment. |
| 142 | |
| Chandler Carruth | 75ca6be | 2018-08-16 23:11:05 +0000 | [diff] [blame] | 143 | - The ``MCSymbol`` machine operands don't support temporary or local symbols. |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 144 | |
| 145 | - A lot of the state in ``MachineModuleInfo`` isn't serialized - only the CFI |
| 146 | instructions and the variable debug information from MMI is serialized right |
| 147 | now. |
| 148 | |
| 149 | These limitations impose restrictions on what you can test with the MIR format. |
| 150 | For now, tests that would like to test some behaviour that depends on the state |
| Chandler Carruth | 75ca6be | 2018-08-16 23:11:05 +0000 | [diff] [blame] | 151 | of temporary or local ``MCSymbol`` operands or the exception handling state in |
| 152 | MMI, can't use the MIR format. As well as that, tests that test some behaviour |
| 153 | that depends on the state of the target specific ``MachineFunctionInfo`` or |
| Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 154 | ``MachineConstantPoolValue`` subclasses can't use the MIR format at the moment. |
| 155 | |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 156 | High Level Structure |
| 157 | ==================== |
| 158 | |
| Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 159 | .. _embedded-module: |
| 160 | |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 161 | Embedded Module |
| 162 | --------------- |
| 163 | |
| 164 | When the first YAML document contains a `YAML block literal string`_, the MIR |
| 165 | parser will treat this string as an LLVM assembly language string that |
| 166 | represents an embedded LLVM IR module. |
| 167 | Here is an example of a YAML document that contains an LLVM module: |
| 168 | |
| 169 | .. code-block:: llvm |
| 170 | |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 171 | define i32 @inc(i32* %x) { |
| 172 | entry: |
| 173 | %0 = load i32, i32* %x |
| 174 | %1 = add i32 %0, 1 |
| 175 | store i32 %1, i32* %x |
| 176 | ret i32 %1 |
| 177 | } |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 178 | |
| 179 | .. _YAML block literal string: http://www.yaml.org/spec/1.2/spec.html#id2795688 |
| 180 | |
| 181 | Machine Functions |
| 182 | ----------------- |
| 183 | |
| 184 | The remaining YAML documents contain the machine functions. This is an example |
| 185 | of such YAML document: |
| 186 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 187 | .. code-block:: text |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 188 | |
| 189 | --- |
| 190 | name: inc |
| 191 | tracksRegLiveness: true |
| 192 | liveins: |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 193 | - { reg: '$rdi' } |
| Djordje Todorovic | a7cde10 | 2019-06-27 07:48:06 +0000 | [diff] [blame] | 194 | callSites: |
| 195 | - { bb: 0, offset: 3, fwdArgRegs: |
| 196 | - { arg: 0, reg: '$edi' } } |
| Alex Lorenz | 9846167 | 2015-08-14 00:36:10 +0000 | [diff] [blame] | 197 | body: | |
| 198 | bb.0.entry: |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 199 | liveins: $rdi |
| Alex Lorenz | 9846167 | 2015-08-14 00:36:10 +0000 | [diff] [blame] | 200 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 201 | $eax = MOV32rm $rdi, 1, _, 0, _ |
| 202 | $eax = INC32r killed $eax, implicit-def dead $eflags |
| 203 | MOV32mr killed $rdi, 1, _, 0, _, $eax |
| Djordje Todorovic | a7cde10 | 2019-06-27 07:48:06 +0000 | [diff] [blame] | 204 | CALL64pcrel32 @foo <regmask...> |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 205 | RETQ $eax |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 206 | ... |
| 207 | |
| 208 | The document above consists of attributes that represent the various |
| 209 | properties and data structures in a machine function. |
| 210 | |
| 211 | The attribute ``name`` is required, and its value should be identical to the |
| 212 | name of a function that this machine function is based on. |
| 213 | |
| Alex Lorenz | 9846167 | 2015-08-14 00:36:10 +0000 | [diff] [blame] | 214 | The attribute ``body`` is a `YAML block literal string`_. Its value represents |
| 215 | the function's machine basic blocks and their machine instructions. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 216 | |
| Djordje Todorovic | a7cde10 | 2019-06-27 07:48:06 +0000 | [diff] [blame] | 217 | The attribute ``callSites`` is a representation of call site information which |
| 218 | keeps track of call instructions and registers used to transfer call arguments. |
| 219 | |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 220 | Machine Instructions Format Reference |
| 221 | ===================================== |
| 222 | |
| 223 | The machine basic blocks and their instructions are represented using a custom, |
| 224 | human readable serialization language. This language is used in the |
| 225 | `YAML block literal string`_ that corresponds to the machine function's body. |
| 226 | |
| 227 | A source string that uses this language contains a list of machine basic |
| 228 | blocks, which are described in the section below. |
| 229 | |
| 230 | Machine Basic Blocks |
| 231 | -------------------- |
| 232 | |
| 233 | A machine basic block is defined in a single block definition source construct |
| 234 | that contains the block's ID. |
| 235 | The example below defines two blocks that have an ID of zero and one: |
| 236 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 237 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 238 | |
| 239 | bb.0: |
| 240 | <instructions> |
| 241 | bb.1: |
| 242 | <instructions> |
| 243 | |
| 244 | A machine basic block can also have a name. It should be specified after the ID |
| 245 | in the block's definition: |
| 246 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 247 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 248 | |
| 249 | bb.0.entry: ; This block's name is "entry" |
| 250 | <instructions> |
| 251 | |
| 252 | The block's name should be identical to the name of the IR block that this |
| 253 | machine block is based on. |
| 254 | |
| Francis Visoiu Mistrih | b41dbbe | 2017-12-13 10:30:59 +0000 | [diff] [blame] | 255 | .. _block-references: |
| 256 | |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 257 | Block References |
| 258 | ^^^^^^^^^^^^^^^^ |
| 259 | |
| 260 | The machine basic blocks are identified by their ID numbers. Individual |
| 261 | blocks are referenced using the following syntax: |
| 262 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 263 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 264 | |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 265 | %bb.<id> |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 266 | |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 267 | Example: |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 268 | |
| 269 | .. code-block:: llvm |
| 270 | |
| 271 | %bb.0 |
| Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 272 | |
| 273 | The following syntax is also supported, but the former syntax is preferred for |
| 274 | block references: |
| 275 | |
| 276 | .. code-block:: text |
| 277 | |
| 278 | %bb.<id>[.<name>] |
| 279 | |
| 280 | Example: |
| 281 | |
| 282 | .. code-block:: llvm |
| 283 | |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 284 | %bb.1.then |
| 285 | |
| 286 | Successors |
| 287 | ^^^^^^^^^^ |
| 288 | |
| 289 | The machine basic block's successors have to be specified before any of the |
| 290 | instructions: |
| 291 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 292 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 293 | |
| 294 | bb.0.entry: |
| 295 | successors: %bb.1.then, %bb.2.else |
| 296 | <instructions> |
| 297 | bb.1.then: |
| 298 | <instructions> |
| 299 | bb.2.else: |
| 300 | <instructions> |
| 301 | |
| 302 | The branch weights can be specified in brackets after the successor blocks. |
| 303 | The example below defines a block that has two successors with branch weights |
| 304 | of 32 and 16: |
| 305 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 306 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 307 | |
| 308 | bb.0.entry: |
| 309 | successors: %bb.1.then(32), %bb.2.else(16) |
| 310 | |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 311 | .. _bb-liveins: |
| 312 | |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 313 | Live In Registers |
| 314 | ^^^^^^^^^^^^^^^^^ |
| 315 | |
| 316 | The machine basic block's live in registers have to be specified before any of |
| 317 | the instructions: |
| 318 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 319 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 320 | |
| 321 | bb.0.entry: |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 322 | liveins: $edi, $esi |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 323 | |
| 324 | The list of live in registers and successors can be empty. The language also |
| 325 | allows multiple live in register and successor lists - they are combined into |
| 326 | one list by the parser. |
| 327 | |
| 328 | Miscellaneous Attributes |
| 329 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 330 | |
| 331 | The attributes ``IsAddressTaken``, ``IsLandingPad`` and ``Alignment`` can be |
| 332 | specified in brackets after the block's definition: |
| 333 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 334 | .. code-block:: text |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 335 | |
| 336 | bb.0.entry (address-taken): |
| 337 | <instructions> |
| 338 | bb.2.else (align 4): |
| 339 | <instructions> |
| 340 | bb.3(landing-pad, align 4): |
| 341 | <instructions> |
| 342 | |
| 343 | .. TODO: Describe the way the reference to an unnamed LLVM IR block can be |
| 344 | preserved. |
| 345 | |
| Guillaume Chatelet | aff45e4 | 2019-09-05 10:00:22 +0000 | [diff] [blame] | 346 | ``Alignment`` is specified in bytes, and must be a power of two. |
| 347 | |
| Daniel Sanders | ad0dfb0 | 2019-11-05 15:10:00 -0800 | [diff] [blame] | 348 | .. _mir-instructions: |
| 349 | |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 350 | Machine Instructions |
| 351 | -------------------- |
| 352 | |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 353 | A machine instruction is composed of a name, |
| 354 | :ref:`machine operands <machine-operands>`, |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 355 | :ref:`instruction flags <instruction-flags>`, and machine memory operands. |
| 356 | |
| 357 | The instruction's name is usually specified before the operands. The example |
| 358 | below shows an instance of the X86 ``RETQ`` instruction with a single machine |
| 359 | operand: |
| 360 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 361 | .. code-block:: text |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 362 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 363 | RETQ $eax |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 364 | |
| 365 | However, if the machine instruction has one or more explicitly defined register |
| 366 | operands, the instruction's name has to be specified after them. The example |
| 367 | below shows an instance of the AArch64 ``LDPXpost`` instruction with three |
| 368 | defined register operands: |
| 369 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 370 | .. code-block:: text |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 371 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 372 | $sp, $fp, $lr = LDPXpost $sp, 2 |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 373 | |
| 374 | The instruction names are serialized using the exact definitions from the |
| 375 | target's ``*InstrInfo.td`` files, and they are case sensitive. This means that |
| 376 | similar instruction names like ``TSTri`` and ``tSTRi`` represent different |
| 377 | machine instructions. |
| 378 | |
| 379 | .. _instruction-flags: |
| 380 | |
| 381 | Instruction Flags |
| 382 | ^^^^^^^^^^^^^^^^^ |
| 383 | |
| Francis Visoiu Mistrih | dbf2c48 | 2018-01-09 11:33:22 +0000 | [diff] [blame] | 384 | The flag ``frame-setup`` or ``frame-destroy`` can be specified before the |
| 385 | instruction's name: |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 386 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 387 | .. code-block:: text |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 388 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 389 | $fp = frame-setup ADDXri $sp, 0, 0 |
| Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 390 | |
| Francis Visoiu Mistrih | dbf2c48 | 2018-01-09 11:33:22 +0000 | [diff] [blame] | 391 | .. code-block:: text |
| 392 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 393 | $x21, $x20 = frame-destroy LDPXi $sp |
| Francis Visoiu Mistrih | dbf2c48 | 2018-01-09 11:33:22 +0000 | [diff] [blame] | 394 | |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 395 | .. _registers: |
| 396 | |
| Francis Visoiu Mistrih | 5836790 | 2018-01-10 17:53:16 +0000 | [diff] [blame] | 397 | Bundled Instructions |
| 398 | ^^^^^^^^^^^^^^^^^^^^ |
| 399 | |
| 400 | The syntax for bundled instructions is the following: |
| 401 | |
| 402 | .. code-block:: text |
| 403 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 404 | BUNDLE implicit-def $r0, implicit-def $r1, implicit $r2 { |
| 405 | $r0 = SOME_OP $r2 |
| 406 | $r1 = ANOTHER_OP internal $r0 |
| Francis Visoiu Mistrih | 5836790 | 2018-01-10 17:53:16 +0000 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | The first instruction is often a bundle header. The instructions between ``{`` |
| 410 | and ``}`` are bundled with the first instruction. |
| 411 | |
| Daniel Sanders | ad0dfb0 | 2019-11-05 15:10:00 -0800 | [diff] [blame] | 412 | .. _mir-registers: |
| 413 | |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 414 | Registers |
| 415 | --------- |
| 416 | |
| 417 | Registers are one of the key primitives in the machine instructions |
| Hiroshi Inoue | c36a1f1 | 2018-06-15 05:10:09 +0000 | [diff] [blame] | 418 | serialization language. They are primarily used in the |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 419 | :ref:`register machine operands <register-operands>`, |
| 420 | but they can also be used in a number of other places, like the |
| 421 | :ref:`basic block's live in list <bb-liveins>`. |
| 422 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 423 | The physical registers are identified by their name and by the '$' prefix sigil. |
| 424 | They use the following syntax: |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 425 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 426 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 427 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 428 | $<name> |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 429 | |
| 430 | The example below shows three X86 physical registers: |
| 431 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 432 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 433 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 434 | $eax |
| 435 | $r15 |
| 436 | $eflags |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 437 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 438 | The virtual registers are identified by their ID number and by the '%' sigil. |
| 439 | They use the following syntax: |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 440 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 441 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 442 | |
| 443 | %<id> |
| 444 | |
| 445 | Example: |
| 446 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 447 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 448 | |
| 449 | %0 |
| 450 | |
| 451 | The null registers are represented using an underscore ('``_``'). They can also be |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 452 | represented using a '``$noreg``' named register, although the former syntax |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 453 | is preferred. |
| 454 | |
| 455 | .. _machine-operands: |
| 456 | |
| 457 | Machine Operands |
| 458 | ---------------- |
| 459 | |
| Chandler Carruth | 75ca6be | 2018-08-16 23:11:05 +0000 | [diff] [blame] | 460 | There are seventeen different kinds of machine operands, and all of them can be |
| 461 | serialized. |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 462 | |
| 463 | Immediate Operands |
| 464 | ^^^^^^^^^^^^^^^^^^ |
| 465 | |
| 466 | The immediate machine operands are untyped, 64-bit signed integers. The |
| 467 | example below shows an instance of the X86 ``MOV32ri`` instruction that has an |
| 468 | immediate machine operand ``-42``: |
| 469 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 470 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 471 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 472 | $eax = MOV32ri -42 |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 473 | |
| Francis Visoiu Mistrih | 440f69c | 2017-12-08 22:53:21 +0000 | [diff] [blame] | 474 | An immediate operand is also used to represent a subregister index when the |
| 475 | machine instruction has one of the following opcodes: |
| 476 | |
| 477 | - ``EXTRACT_SUBREG`` |
| 478 | |
| 479 | - ``INSERT_SUBREG`` |
| 480 | |
| 481 | - ``REG_SEQUENCE`` |
| 482 | |
| 483 | - ``SUBREG_TO_REG`` |
| 484 | |
| 485 | In case this is true, the Machine Operand is printed according to the target. |
| 486 | |
| 487 | For example: |
| 488 | |
| 489 | In AArch64RegisterInfo.td: |
| 490 | |
| 491 | .. code-block:: text |
| 492 | |
| 493 | def sub_32 : SubRegIndex<32>; |
| 494 | |
| 495 | If the third operand is an immediate with the value ``15`` (target-dependent |
| 496 | value), based on the instruction's opcode and the operand's index the operand |
| 497 | will be printed as ``%subreg.sub_32``: |
| 498 | |
| 499 | .. code-block:: text |
| 500 | |
| 501 | %1:gpr64 = SUBREG_TO_REG 0, %0, %subreg.sub_32 |
| 502 | |
| Francis Visoiu Mistrih | 6c4ca71 | 2017-12-08 11:40:06 +0000 | [diff] [blame] | 503 | For integers > 64bit, we use a special machine operand, ``MO_CImmediate``, |
| 504 | which stores the immediate in a ``ConstantInt`` using an ``APInt`` (LLVM's |
| 505 | arbitrary precision integers). |
| 506 | |
| 507 | .. TODO: Describe the FPIMM immediate operands. |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 508 | |
| 509 | .. _register-operands: |
| 510 | |
| 511 | Register Operands |
| 512 | ^^^^^^^^^^^^^^^^^ |
| 513 | |
| 514 | The :ref:`register <registers>` primitive is used to represent the register |
| 515 | machine operands. The register operands can also have optional |
| 516 | :ref:`register flags <register-flags>`, |
| Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 517 | :ref:`a subregister index <subregister-indices>`, |
| 518 | and a reference to the tied register operand. |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 519 | The full syntax of a register operand is shown below: |
| 520 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 521 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 522 | |
| 523 | [<flags>] <register> [ :<subregister-idx-name> ] [ (tied-def <tied-op>) ] |
| 524 | |
| 525 | This example shows an instance of the X86 ``XOR32rr`` instruction that has |
| 526 | 5 register operands with different register flags: |
| 527 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 528 | .. code-block:: text |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 529 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 530 | dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 531 | |
| 532 | .. _register-flags: |
| 533 | |
| 534 | Register Flags |
| 535 | ~~~~~~~~~~~~~~ |
| 536 | |
| 537 | The table below shows all of the possible register flags along with the |
| 538 | corresponding internal ``llvm::RegState`` representation: |
| 539 | |
| 540 | .. list-table:: |
| 541 | :header-rows: 1 |
| 542 | |
| 543 | * - Flag |
| 544 | - Internal Value |
| 545 | |
| 546 | * - ``implicit`` |
| 547 | - ``RegState::Implicit`` |
| 548 | |
| 549 | * - ``implicit-def`` |
| 550 | - ``RegState::ImplicitDefine`` |
| 551 | |
| 552 | * - ``def`` |
| 553 | - ``RegState::Define`` |
| 554 | |
| 555 | * - ``dead`` |
| 556 | - ``RegState::Dead`` |
| 557 | |
| 558 | * - ``killed`` |
| 559 | - ``RegState::Kill`` |
| 560 | |
| 561 | * - ``undef`` |
| 562 | - ``RegState::Undef`` |
| 563 | |
| 564 | * - ``internal`` |
| 565 | - ``RegState::InternalRead`` |
| 566 | |
| 567 | * - ``early-clobber`` |
| 568 | - ``RegState::EarlyClobber`` |
| 569 | |
| 570 | * - ``debug-use`` |
| 571 | - ``RegState::Debug`` |
| Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 572 | |
| Geoff Berry | 60c4310 | 2017-12-12 17:53:59 +0000 | [diff] [blame] | 573 | * - ``renamable`` |
| 574 | - ``RegState::Renamable`` |
| 575 | |
| Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 576 | .. _subregister-indices: |
| 577 | |
| 578 | Subregister Indices |
| 579 | ~~~~~~~~~~~~~~~~~~~ |
| 580 | |
| 581 | The register machine operands can reference a portion of a register by using |
| 582 | the subregister indices. The example below shows an instance of the ``COPY`` |
| 583 | pseudo instruction that uses the X86 ``sub_8bit`` subregister index to copy 8 |
| 584 | lower bits from the 32-bit virtual register 0 to the 8-bit virtual register 1: |
| 585 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 586 | .. code-block:: text |
| Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 587 | |
| 588 | %1 = COPY %0:sub_8bit |
| 589 | |
| 590 | The names of the subregister indices are target specific, and are typically |
| 591 | defined in the target's ``*RegisterInfo.td`` file. |
| 592 | |
| Francis Visoiu Mistrih | 26ae8a6 | 2017-12-13 10:30:45 +0000 | [diff] [blame] | 593 | Constant Pool Indices |
| 594 | ^^^^^^^^^^^^^^^^^^^^^ |
| 595 | |
| 596 | A constant pool index (CPI) operand is printed using its index in the |
| 597 | function's ``MachineConstantPool`` and an offset. |
| 598 | |
| 599 | For example, a CPI with the index 1 and offset 8: |
| 600 | |
| 601 | .. code-block:: text |
| 602 | |
| 603 | %1:gr64 = MOV64ri %const.1 + 8 |
| 604 | |
| 605 | For a CPI with the index 0 and offset -12: |
| 606 | |
| 607 | .. code-block:: text |
| 608 | |
| 609 | %1:gr64 = MOV64ri %const.0 - 12 |
| 610 | |
| 611 | A constant pool entry is bound to a LLVM IR ``Constant`` or a target-specific |
| 612 | ``MachineConstantPoolValue``. When serializing all the function's constants the |
| 613 | following format is used: |
| 614 | |
| 615 | .. code-block:: text |
| 616 | |
| 617 | constants: |
| 618 | - id: <index> |
| 619 | value: <value> |
| 620 | alignment: <alignment> |
| 621 | isTargetSpecific: <target-specific> |
| 622 | |
| Guillaume Chatelet | aff45e4 | 2019-09-05 10:00:22 +0000 | [diff] [blame] | 623 | where: |
| 624 | - ``<index>`` is a 32-bit unsigned integer; |
| 625 | - ``<value>`` is a `LLVM IR Constant |
| 626 | <https://www.llvm.org/docs/LangRef.html#constants>`_; |
| 627 | - ``<alignment>`` is a 32-bit unsigned integer specified in bytes, and must be |
| 628 | power of two; |
| 629 | - ``<target-specific>`` is either true or false. |
| Francis Visoiu Mistrih | 26ae8a6 | 2017-12-13 10:30:45 +0000 | [diff] [blame] | 630 | |
| 631 | Example: |
| 632 | |
| 633 | .. code-block:: text |
| 634 | |
| 635 | constants: |
| 636 | - id: 0 |
| 637 | value: 'double 3.250000e+00' |
| 638 | alignment: 8 |
| 639 | - id: 1 |
| 640 | value: 'g-(LPC0+8)' |
| 641 | alignment: 4 |
| 642 | isTargetSpecific: true |
| 643 | |
| Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 644 | Global Value Operands |
| 645 | ^^^^^^^^^^^^^^^^^^^^^ |
| 646 | |
| 647 | The global value machine operands reference the global values from the |
| 648 | :ref:`embedded LLVM IR module <embedded-module>`. |
| 649 | The example below shows an instance of the X86 ``MOV64rm`` instruction that has |
| 650 | a global value operand named ``G``: |
| 651 | |
| Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 652 | .. code-block:: text |
| Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 653 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 654 | $rax = MOV64rm $rip, 1, _, @G, _ |
| Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 655 | |
| 656 | The named global values are represented using an identifier with the '@' prefix. |
| 657 | If the identifier doesn't match the regular expression |
| 658 | `[-a-zA-Z$._][-a-zA-Z$._0-9]*`, then this identifier must be quoted. |
| 659 | |
| 660 | The unnamed global values are represented using an unsigned numeric value with |
| 661 | the '@' prefix, like in the following examples: ``@0``, ``@989``. |
| 662 | |
| Francis Visoiu Mistrih | b3a0d51 | 2017-12-13 10:30:51 +0000 | [diff] [blame] | 663 | Target-dependent Index Operands |
| 664 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 665 | |
| 666 | A target index operand is a target-specific index and an offset. The |
| 667 | target-specific index is printed using target-specific names and a positive or |
| 668 | negative offset. |
| 669 | |
| 670 | For example, the ``amdgpu-constdata-start`` is associated with the index ``0`` |
| 671 | in the AMDGPU backend. So if we have a target index operand with the index 0 |
| 672 | and the offset 8: |
| 673 | |
| 674 | .. code-block:: text |
| 675 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 676 | $sgpr2 = S_ADD_U32 _, target-index(amdgpu-constdata-start) + 8, implicit-def _, implicit-def _ |
| Francis Visoiu Mistrih | b3a0d51 | 2017-12-13 10:30:51 +0000 | [diff] [blame] | 677 | |
| Francis Visoiu Mistrih | b41dbbe | 2017-12-13 10:30:59 +0000 | [diff] [blame] | 678 | Jump-table Index Operands |
| 679 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 680 | |
| 681 | A jump-table index operand with the index 0 is printed as following: |
| 682 | |
| 683 | .. code-block:: text |
| 684 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 685 | tBR_JTr killed $r0, %jump-table.0 |
| Francis Visoiu Mistrih | b41dbbe | 2017-12-13 10:30:59 +0000 | [diff] [blame] | 686 | |
| 687 | A machine jump-table entry contains a list of ``MachineBasicBlocks``. When serializing all the function's jump-table entries, the following format is used: |
| 688 | |
| 689 | .. code-block:: text |
| 690 | |
| 691 | jumpTable: |
| 692 | kind: <kind> |
| 693 | entries: |
| 694 | - id: <index> |
| 695 | blocks: [ <bbreference>, <bbreference>, ... ] |
| 696 | |
| 697 | 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>`. |
| 698 | |
| 699 | Example: |
| 700 | |
| 701 | .. code-block:: text |
| 702 | |
| 703 | jumpTable: |
| 704 | kind: inline |
| 705 | entries: |
| 706 | - id: 0 |
| 707 | blocks: [ '%bb.3', '%bb.9', '%bb.4.d3' ] |
| 708 | - id: 1 |
| 709 | blocks: [ '%bb.7', '%bb.7', '%bb.4.d3', '%bb.5' ] |
| 710 | |
| Francis Visoiu Mistrih | e76c5fc | 2017-12-14 10:02:58 +0000 | [diff] [blame] | 711 | External Symbol Operands |
| 712 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 713 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 714 | An external symbol operand is represented using an identifier with the ``&`` |
| Francis Visoiu Mistrih | e76c5fc | 2017-12-14 10:02:58 +0000 | [diff] [blame] | 715 | prefix. The identifier is surrounded with ""'s and escaped if it has any |
| 716 | special non-printable characters in it. |
| 717 | |
| 718 | Example: |
| 719 | |
| 720 | .. code-block:: text |
| 721 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 722 | CALL64pcrel32 &__stack_chk_fail, csr_64, implicit $rsp, implicit-def $rsp |
| Francis Visoiu Mistrih | e76c5fc | 2017-12-14 10:02:58 +0000 | [diff] [blame] | 723 | |
| Francis Visoiu Mistrih | 3c99371 | 2017-12-14 10:03:23 +0000 | [diff] [blame] | 724 | MCSymbol Operands |
| 725 | ^^^^^^^^^^^^^^^^^ |
| 726 | |
| 727 | A MCSymbol operand is holding a pointer to a ``MCSymbol``. For the limitations |
| 728 | of this operand in MIR, see :ref:`limitations <limitations>`. |
| 729 | |
| 730 | The syntax is: |
| 731 | |
| 732 | .. code-block:: text |
| 733 | |
| 734 | EH_LABEL <mcsymbol Ltmp1> |
| Francis Visoiu Mistrih | e76c5fc | 2017-12-14 10:02:58 +0000 | [diff] [blame] | 735 | |
| Francis Visoiu Mistrih | 874ae6f | 2017-12-19 16:51:52 +0000 | [diff] [blame] | 736 | CFIIndex Operands |
| 737 | ^^^^^^^^^^^^^^^^^ |
| 738 | |
| 739 | A CFI Index operand is holding an index into a per-function side-table, |
| 740 | ``MachineFunction::getFrameInstructions()``, which references all the frame |
| 741 | instructions in a ``MachineFunction``. A ``CFI_INSTRUCTION`` may look like it |
| 742 | contains multiple operands, but the only operand it contains is the CFI Index. |
| 743 | The other operands are tracked by the ``MCCFIInstruction`` object. |
| 744 | |
| 745 | The syntax is: |
| 746 | |
| 747 | .. code-block:: text |
| 748 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 749 | CFI_INSTRUCTION offset $w30, -16 |
| Francis Visoiu Mistrih | 874ae6f | 2017-12-19 16:51:52 +0000 | [diff] [blame] | 750 | |
| 751 | which may be emitted later in the MC layer as: |
| 752 | |
| 753 | .. code-block:: text |
| 754 | |
| 755 | .cfi_offset w30, -16 |
| 756 | |
| Francis Visoiu Mistrih | bbd610a | 2017-12-19 21:47:05 +0000 | [diff] [blame] | 757 | IntrinsicID Operands |
| 758 | ^^^^^^^^^^^^^^^^^^^^ |
| 759 | |
| 760 | An Intrinsic ID operand contains a generic intrinsic ID or a target-specific ID. |
| 761 | |
| 762 | The syntax for the ``returnaddress`` intrinsic is: |
| 763 | |
| 764 | .. code-block:: text |
| 765 | |
| Puyan Lotfi | 5bd46b0 | 2018-03-12 14:51:19 +0000 | [diff] [blame] | 766 | $x0 = COPY intrinsic(@llvm.returnaddress) |
| Francis Visoiu Mistrih | bbd610a | 2017-12-19 21:47:05 +0000 | [diff] [blame] | 767 | |
| Francis Visoiu Mistrih | cb2683d | 2017-12-19 21:47:10 +0000 | [diff] [blame] | 768 | Predicate Operands |
| 769 | ^^^^^^^^^^^^^^^^^^ |
| 770 | |
| 771 | A Predicate operand contains an IR predicate from ``CmpInst::Predicate``, like |
| 772 | ``ICMP_EQ``, etc. |
| 773 | |
| 774 | For an int eq predicate ``ICMP_EQ``, the syntax is: |
| 775 | |
| 776 | .. code-block:: text |
| 777 | |
| 778 | %2:gpr(s32) = G_ICMP intpred(eq), %0, %1 |
| 779 | |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 780 | .. TODO: Describe the parsers default behaviour when optional YAML attributes |
| 781 | are missing. |
| Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 782 | .. TODO: Describe the syntax for virtual register YAML definitions. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 783 | .. TODO: Describe the machine function's YAML flag attributes. |
| Francis Visoiu Mistrih | e76c5fc | 2017-12-14 10:02:58 +0000 | [diff] [blame] | 784 | .. TODO: Describe the syntax for the register mask machine operands. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 785 | .. TODO: Describe the frame information YAML mapping. |
| 786 | .. TODO: Describe the syntax of the stack object machine operands and their |
| 787 | YAML definitions. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 788 | .. TODO: Describe the syntax of the block address machine operands. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 789 | .. TODO: Describe the syntax of the metadata machine operands, and the |
| 790 | instructions debug location attribute. |
| Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 791 | .. TODO: Describe the syntax of the register live out machine operands. |
| 792 | .. TODO: Describe the syntax of the machine memory operands. |