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 | |
| 63 | After generating the input MIR file, you'll have to add a run line that uses |
| 64 | the ``-run-pass`` option to it. In order to test the post register allocation |
| 65 | pseudo instruction expansion pass on X86-64, a run line like the one shown |
| 66 | below can be used: |
| 67 | |
Matthias Braun | e6185b7 | 2017-04-13 22:14:45 +0000 | [diff] [blame^] | 68 | ``# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=postrapseudos | FileCheck %s`` |
Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 69 | |
| 70 | 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^] | 71 | specific test directories (``lib/CodeGen/TARGETNAME``). They also need to |
| 72 | specify a target triple or a target architecture either in the run line or in |
| 73 | the embedded LLVM IR module. |
Alex Lorenz | ea788c4 | 2015-08-21 22:58:33 +0000 | [diff] [blame] | 74 | |
| 75 | Limitations |
| 76 | ----------- |
| 77 | |
| 78 | Currently the MIR format has several limitations in terms of which state it |
| 79 | can serialize: |
| 80 | |
| 81 | - The target-specific state in the target-specific ``MachineFunctionInfo`` |
| 82 | subclasses isn't serialized at the moment. |
| 83 | |
| 84 | - The target-specific ``MachineConstantPoolValue`` subclasses (in the ARM and |
| 85 | SystemZ backends) aren't serialized at the moment. |
| 86 | |
| 87 | - The ``MCSymbol`` machine operands are only printed, they can't be parsed. |
| 88 | |
| 89 | - A lot of the state in ``MachineModuleInfo`` isn't serialized - only the CFI |
| 90 | instructions and the variable debug information from MMI is serialized right |
| 91 | now. |
| 92 | |
| 93 | These limitations impose restrictions on what you can test with the MIR format. |
| 94 | For now, tests that would like to test some behaviour that depends on the state |
| 95 | of certain ``MCSymbol`` operands or the exception handling state in MMI, can't |
| 96 | use the MIR format. As well as that, tests that test some behaviour that |
| 97 | depends on the state of the target specific ``MachineFunctionInfo`` or |
| 98 | ``MachineConstantPoolValue`` subclasses can't use the MIR format at the moment. |
| 99 | |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 100 | High Level Structure |
| 101 | ==================== |
| 102 | |
Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 103 | .. _embedded-module: |
| 104 | |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 105 | Embedded Module |
| 106 | --------------- |
| 107 | |
| 108 | When the first YAML document contains a `YAML block literal string`_, the MIR |
| 109 | parser will treat this string as an LLVM assembly language string that |
| 110 | represents an embedded LLVM IR module. |
| 111 | Here is an example of a YAML document that contains an LLVM module: |
| 112 | |
| 113 | .. code-block:: llvm |
| 114 | |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 115 | define i32 @inc(i32* %x) { |
| 116 | entry: |
| 117 | %0 = load i32, i32* %x |
| 118 | %1 = add i32 %0, 1 |
| 119 | store i32 %1, i32* %x |
| 120 | ret i32 %1 |
| 121 | } |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 122 | |
| 123 | .. _YAML block literal string: http://www.yaml.org/spec/1.2/spec.html#id2795688 |
| 124 | |
| 125 | Machine Functions |
| 126 | ----------------- |
| 127 | |
| 128 | The remaining YAML documents contain the machine functions. This is an example |
| 129 | of such YAML document: |
| 130 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 131 | .. code-block:: text |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 132 | |
| 133 | --- |
| 134 | name: inc |
| 135 | tracksRegLiveness: true |
| 136 | liveins: |
| 137 | - { reg: '%rdi' } |
Alex Lorenz | 9846167 | 2015-08-14 00:36:10 +0000 | [diff] [blame] | 138 | body: | |
| 139 | bb.0.entry: |
| 140 | liveins: %rdi |
| 141 | |
| 142 | %eax = MOV32rm %rdi, 1, _, 0, _ |
| 143 | %eax = INC32r killed %eax, implicit-def dead %eflags |
| 144 | MOV32mr killed %rdi, 1, _, 0, _, %eax |
| 145 | RETQ %eax |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 146 | ... |
| 147 | |
| 148 | The document above consists of attributes that represent the various |
| 149 | properties and data structures in a machine function. |
| 150 | |
| 151 | The attribute ``name`` is required, and its value should be identical to the |
| 152 | name of a function that this machine function is based on. |
| 153 | |
Alex Lorenz | 9846167 | 2015-08-14 00:36:10 +0000 | [diff] [blame] | 154 | The attribute ``body`` is a `YAML block literal string`_. Its value represents |
| 155 | the function's machine basic blocks and their machine instructions. |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 156 | |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 157 | Machine Instructions Format Reference |
| 158 | ===================================== |
| 159 | |
| 160 | The machine basic blocks and their instructions are represented using a custom, |
| 161 | human readable serialization language. This language is used in the |
| 162 | `YAML block literal string`_ that corresponds to the machine function's body. |
| 163 | |
| 164 | A source string that uses this language contains a list of machine basic |
| 165 | blocks, which are described in the section below. |
| 166 | |
| 167 | Machine Basic Blocks |
| 168 | -------------------- |
| 169 | |
| 170 | A machine basic block is defined in a single block definition source construct |
| 171 | that contains the block's ID. |
| 172 | The example below defines two blocks that have an ID of zero and one: |
| 173 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 174 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 175 | |
| 176 | bb.0: |
| 177 | <instructions> |
| 178 | bb.1: |
| 179 | <instructions> |
| 180 | |
| 181 | A machine basic block can also have a name. It should be specified after the ID |
| 182 | in the block's definition: |
| 183 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 184 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 185 | |
| 186 | bb.0.entry: ; This block's name is "entry" |
| 187 | <instructions> |
| 188 | |
| 189 | The block's name should be identical to the name of the IR block that this |
| 190 | machine block is based on. |
| 191 | |
| 192 | Block References |
| 193 | ^^^^^^^^^^^^^^^^ |
| 194 | |
| 195 | The machine basic blocks are identified by their ID numbers. Individual |
| 196 | blocks are referenced using the following syntax: |
| 197 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 198 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 199 | |
| 200 | %bb.<id>[.<name>] |
| 201 | |
| 202 | Examples: |
| 203 | |
| 204 | .. code-block:: llvm |
| 205 | |
| 206 | %bb.0 |
| 207 | %bb.1.then |
| 208 | |
| 209 | Successors |
| 210 | ^^^^^^^^^^ |
| 211 | |
| 212 | The machine basic block's successors have to be specified before any of the |
| 213 | instructions: |
| 214 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 215 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 216 | |
| 217 | bb.0.entry: |
| 218 | successors: %bb.1.then, %bb.2.else |
| 219 | <instructions> |
| 220 | bb.1.then: |
| 221 | <instructions> |
| 222 | bb.2.else: |
| 223 | <instructions> |
| 224 | |
| 225 | The branch weights can be specified in brackets after the successor blocks. |
| 226 | The example below defines a block that has two successors with branch weights |
| 227 | of 32 and 16: |
| 228 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 229 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 230 | |
| 231 | bb.0.entry: |
| 232 | successors: %bb.1.then(32), %bb.2.else(16) |
| 233 | |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 234 | .. _bb-liveins: |
| 235 | |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 236 | Live In Registers |
| 237 | ^^^^^^^^^^^^^^^^^ |
| 238 | |
| 239 | The machine basic block's live in registers have to be specified before any of |
| 240 | the instructions: |
| 241 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 242 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 243 | |
| 244 | bb.0.entry: |
| 245 | liveins: %edi, %esi |
| 246 | |
| 247 | The list of live in registers and successors can be empty. The language also |
| 248 | allows multiple live in register and successor lists - they are combined into |
| 249 | one list by the parser. |
| 250 | |
| 251 | Miscellaneous Attributes |
| 252 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 253 | |
| 254 | The attributes ``IsAddressTaken``, ``IsLandingPad`` and ``Alignment`` can be |
| 255 | specified in brackets after the block's definition: |
| 256 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 257 | .. code-block:: text |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 258 | |
| 259 | bb.0.entry (address-taken): |
| 260 | <instructions> |
| 261 | bb.2.else (align 4): |
| 262 | <instructions> |
| 263 | bb.3(landing-pad, align 4): |
| 264 | <instructions> |
| 265 | |
| 266 | .. TODO: Describe the way the reference to an unnamed LLVM IR block can be |
| 267 | preserved. |
| 268 | |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 269 | Machine Instructions |
| 270 | -------------------- |
| 271 | |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 272 | A machine instruction is composed of a name, |
| 273 | :ref:`machine operands <machine-operands>`, |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 274 | :ref:`instruction flags <instruction-flags>`, and machine memory operands. |
| 275 | |
| 276 | The instruction's name is usually specified before the operands. The example |
| 277 | below shows an instance of the X86 ``RETQ`` instruction with a single machine |
| 278 | operand: |
| 279 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 280 | .. code-block:: text |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 281 | |
| 282 | RETQ %eax |
| 283 | |
| 284 | However, if the machine instruction has one or more explicitly defined register |
| 285 | operands, the instruction's name has to be specified after them. The example |
| 286 | below shows an instance of the AArch64 ``LDPXpost`` instruction with three |
| 287 | defined register operands: |
| 288 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 289 | .. code-block:: text |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 290 | |
| 291 | %sp, %fp, %lr = LDPXpost %sp, 2 |
| 292 | |
| 293 | The instruction names are serialized using the exact definitions from the |
| 294 | target's ``*InstrInfo.td`` files, and they are case sensitive. This means that |
| 295 | similar instruction names like ``TSTri`` and ``tSTRi`` represent different |
| 296 | machine instructions. |
| 297 | |
| 298 | .. _instruction-flags: |
| 299 | |
| 300 | Instruction Flags |
| 301 | ^^^^^^^^^^^^^^^^^ |
| 302 | |
| 303 | The flag ``frame-setup`` can be specified before the instruction's name: |
| 304 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 305 | .. code-block:: text |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 306 | |
| 307 | %fp = frame-setup ADDXri %sp, 0, 0 |
| 308 | |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 309 | .. _registers: |
| 310 | |
| 311 | Registers |
| 312 | --------- |
| 313 | |
| 314 | Registers are one of the key primitives in the machine instructions |
| 315 | serialization language. They are primarly used in the |
| 316 | :ref:`register machine operands <register-operands>`, |
| 317 | but they can also be used in a number of other places, like the |
| 318 | :ref:`basic block's live in list <bb-liveins>`. |
| 319 | |
| 320 | The physical registers are identified by their name. They use the following |
| 321 | syntax: |
| 322 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 323 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 324 | |
| 325 | %<name> |
| 326 | |
| 327 | The example below shows three X86 physical registers: |
| 328 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 329 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 330 | |
| 331 | %eax |
| 332 | %r15 |
| 333 | %eflags |
| 334 | |
| 335 | The virtual registers are identified by their ID number. They use the following |
| 336 | syntax: |
| 337 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 338 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 339 | |
| 340 | %<id> |
| 341 | |
| 342 | Example: |
| 343 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 344 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 345 | |
| 346 | %0 |
| 347 | |
| 348 | The null registers are represented using an underscore ('``_``'). They can also be |
| 349 | represented using a '``%noreg``' named register, although the former syntax |
| 350 | is preferred. |
| 351 | |
| 352 | .. _machine-operands: |
| 353 | |
| 354 | Machine Operands |
| 355 | ---------------- |
| 356 | |
| 357 | There are seventeen different kinds of machine operands, and all of them, except |
| 358 | the ``MCSymbol`` operand, can be serialized. The ``MCSymbol`` operands are |
| 359 | just printed out - they can't be parsed back yet. |
| 360 | |
| 361 | Immediate Operands |
| 362 | ^^^^^^^^^^^^^^^^^^ |
| 363 | |
| 364 | The immediate machine operands are untyped, 64-bit signed integers. The |
| 365 | example below shows an instance of the X86 ``MOV32ri`` instruction that has an |
| 366 | immediate machine operand ``-42``: |
| 367 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 368 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 369 | |
| 370 | %eax = MOV32ri -42 |
| 371 | |
| 372 | .. TODO: Describe the CIMM (Rare) and FPIMM immediate operands. |
| 373 | |
| 374 | .. _register-operands: |
| 375 | |
| 376 | Register Operands |
| 377 | ^^^^^^^^^^^^^^^^^ |
| 378 | |
| 379 | The :ref:`register <registers>` primitive is used to represent the register |
| 380 | machine operands. The register operands can also have optional |
| 381 | :ref:`register flags <register-flags>`, |
Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 382 | :ref:`a subregister index <subregister-indices>`, |
| 383 | and a reference to the tied register operand. |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 384 | The full syntax of a register operand is shown below: |
| 385 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 386 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 387 | |
| 388 | [<flags>] <register> [ :<subregister-idx-name> ] [ (tied-def <tied-op>) ] |
| 389 | |
| 390 | This example shows an instance of the X86 ``XOR32rr`` instruction that has |
| 391 | 5 register operands with different register flags: |
| 392 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 393 | .. code-block:: text |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 394 | |
| 395 | dead %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags, implicit-def %al |
| 396 | |
| 397 | .. _register-flags: |
| 398 | |
| 399 | Register Flags |
| 400 | ~~~~~~~~~~~~~~ |
| 401 | |
| 402 | The table below shows all of the possible register flags along with the |
| 403 | corresponding internal ``llvm::RegState`` representation: |
| 404 | |
| 405 | .. list-table:: |
| 406 | :header-rows: 1 |
| 407 | |
| 408 | * - Flag |
| 409 | - Internal Value |
| 410 | |
| 411 | * - ``implicit`` |
| 412 | - ``RegState::Implicit`` |
| 413 | |
| 414 | * - ``implicit-def`` |
| 415 | - ``RegState::ImplicitDefine`` |
| 416 | |
| 417 | * - ``def`` |
| 418 | - ``RegState::Define`` |
| 419 | |
| 420 | * - ``dead`` |
| 421 | - ``RegState::Dead`` |
| 422 | |
| 423 | * - ``killed`` |
| 424 | - ``RegState::Kill`` |
| 425 | |
| 426 | * - ``undef`` |
| 427 | - ``RegState::Undef`` |
| 428 | |
| 429 | * - ``internal`` |
| 430 | - ``RegState::InternalRead`` |
| 431 | |
| 432 | * - ``early-clobber`` |
| 433 | - ``RegState::EarlyClobber`` |
| 434 | |
| 435 | * - ``debug-use`` |
| 436 | - ``RegState::Debug`` |
Alex Lorenz | 3a4a60c | 2015-08-15 01:06:06 +0000 | [diff] [blame] | 437 | |
Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 438 | .. _subregister-indices: |
| 439 | |
| 440 | Subregister Indices |
| 441 | ~~~~~~~~~~~~~~~~~~~ |
| 442 | |
| 443 | The register machine operands can reference a portion of a register by using |
| 444 | the subregister indices. The example below shows an instance of the ``COPY`` |
| 445 | pseudo instruction that uses the X86 ``sub_8bit`` subregister index to copy 8 |
| 446 | lower bits from the 32-bit virtual register 0 to the 8-bit virtual register 1: |
| 447 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 448 | .. code-block:: text |
Alex Lorenz | 37e0262 | 2015-09-08 11:39:47 +0000 | [diff] [blame] | 449 | |
| 450 | %1 = COPY %0:sub_8bit |
| 451 | |
| 452 | The names of the subregister indices are target specific, and are typically |
| 453 | defined in the target's ``*RegisterInfo.td`` file. |
| 454 | |
Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 455 | Global Value Operands |
| 456 | ^^^^^^^^^^^^^^^^^^^^^ |
| 457 | |
| 458 | The global value machine operands reference the global values from the |
| 459 | :ref:`embedded LLVM IR module <embedded-module>`. |
| 460 | The example below shows an instance of the X86 ``MOV64rm`` instruction that has |
| 461 | a global value operand named ``G``: |
| 462 | |
Renato Golin | 124f259 | 2016-07-20 12:16:38 +0000 | [diff] [blame] | 463 | .. code-block:: text |
Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 464 | |
| 465 | %rax = MOV64rm %rip, 1, _, @G, _ |
| 466 | |
| 467 | The named global values are represented using an identifier with the '@' prefix. |
| 468 | If the identifier doesn't match the regular expression |
| 469 | `[-a-zA-Z$._][-a-zA-Z$._0-9]*`, then this identifier must be quoted. |
| 470 | |
| 471 | The unnamed global values are represented using an unsigned numeric value with |
| 472 | the '@' prefix, like in the following examples: ``@0``, ``@989``. |
| 473 | |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 474 | .. TODO: Describe the parsers default behaviour when optional YAML attributes |
| 475 | are missing. |
Alex Lorenz | 8eadc3f | 2015-08-21 17:26:38 +0000 | [diff] [blame] | 476 | .. TODO: Describe the syntax for the bundled instructions. |
Alex Lorenz | b981d37 | 2015-08-21 21:17:01 +0000 | [diff] [blame] | 477 | .. TODO: Describe the syntax for virtual register YAML definitions. |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 478 | .. TODO: Describe the machine function's YAML flag attributes. |
Alex Lorenz | d4990eb | 2015-09-08 11:38:16 +0000 | [diff] [blame] | 479 | .. TODO: Describe the syntax for the external symbol and register |
Alex Lorenz | 3d31177 | 2015-08-06 22:55:19 +0000 | [diff] [blame] | 480 | mask machine operands. |
| 481 | .. TODO: Describe the frame information YAML mapping. |
| 482 | .. TODO: Describe the syntax of the stack object machine operands and their |
| 483 | YAML definitions. |
| 484 | .. TODO: Describe the syntax of the constant pool machine operands and their |
| 485 | YAML definitions. |
| 486 | .. TODO: Describe the syntax of the jump table machine operands and their |
| 487 | YAML definitions. |
| 488 | .. TODO: Describe the syntax of the block address machine operands. |
| 489 | .. TODO: Describe the syntax of the CFI index machine operands. |
| 490 | .. TODO: Describe the syntax of the metadata machine operands, and the |
| 491 | instructions debug location attribute. |
| 492 | .. TODO: Describe the syntax of the target index machine operands. |
| 493 | .. TODO: Describe the syntax of the register live out machine operands. |
| 494 | .. TODO: Describe the syntax of the machine memory operands. |