You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -161,9 +161,8 @@ Here is the list of currently supported register classes:
161
161
| AArch64 |`vreg`|`v[0-31]`|`w`|
162
162
| AArch64 |`vreg_low16`|`v[0-15]`|`x`|
163
163
| AArch64 |`preg`|`p[0-15]`, `ffr`| Only clobbers |
164
-
| ARM |`reg`|`r[0-12]`, `r14`|`r`|
165
-
| ARM (Thumb) |`reg_thumb`|`r[0-r7]`|`l`|
166
-
| ARM (ARM) |`reg_thumb`|`r[0-r12]`, `r14`|`l`|
164
+
| ARM (ARM/Thumb2) |`reg`|`r[0-12]`, `r14`|`r`|
165
+
| ARM (Thumb1) |`reg`|`r[0-7]`|`r`|
167
166
| ARM |`sreg`|`s[0-31]`|`t`|
168
167
| ARM |`sreg_low16`|`s[0-15]`|`x`|
169
168
| ARM |`dreg`|`d[0-31]`|`w`|
@@ -284,21 +283,16 @@ Some registers cannot be used for input or output operands:
284
283
| All |`si` (x86-32), `bx` (x86-64), `r6` (ARM), `x19` (AArch64), `x9` (RISC-V) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
285
284
| x86 |`k0`| This is a constant zero register which can't be modified. |
286
285
| x86 |`ip`| This is the program counter, not a real register. |
287
-
| x86 |`mm[0-7]`| MMX registers are not currently supported (but may be in the future). |
288
-
| x86 |`st([0-7])`| x87 registers are not currently supported (but may be in the future). |
289
286
| AArch64 |`xzr`| This is a constant zero register which can't be modified. |
287
+
| AArch64 |`x18`| This is a reserved register on some AArch64 targets. |
290
288
| ARM |`pc`| This is the program counter, not a real register. |
291
289
| ARM |`r9`| This is a reserved register on some ARM targets. |
292
290
| RISC-V |`x0`| This is a constant zero register which can't be modified. |
293
291
| RISC-V |`gp`, `tp`| These registers are reserved and cannot be used as inputs or outputs. |
294
292
295
293
In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified.
296
294
Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers.
297
-
298
-
These reserved registers are:
299
-
- The frame pointer and LLVM base pointer on all architectures.
300
-
-`r9` on ARM.
301
-
-`x18` on AArch64.
295
+
Reserved registers that can sometimes be allocated are the frame pointer and base pointer in the list above.
302
296
303
297
## Template modifiers
304
298
@@ -362,6 +356,8 @@ If all references to an operand already have modifiers then the warning is suppr
362
356
The `clobber_abi` keyword can be used to apply a default set of clobbers to an `asm!` block.
363
357
This will automatically insert the necessary clobber constraints as needed for calling a function with a particular calling convention: if the calling convention does not fully preserve the value of a register across a call then a `lateout("reg") _` is implicitly added to the operands list.
364
358
359
+
`clobber_abi` may be specified any number of times. It will insert a clobber for all unique registers in the union of all specified calling conventions.
360
+
365
361
Generic register class outputs are disallowed by the compiler when `clobber_abi` is used: all outputs must specify an explicit register.
366
362
Explicit register outputs have precedence over the implicit clobbers inserted by `clobber_abi`: a clobber will only be inserted for a register if that register is not used as an output.
367
363
The following ABIs can be used with `clobber_abi`:
@@ -371,10 +367,13 @@ The following ABIs can be used with `clobber_abi`:
> - On AArch64 `x18` only included in the clobber list if it is not considered as a reserved register on the target.
376
+
378
377
The list of clobbered registers for each ABI is updated in rustc as architectures gain new registers: this ensures that `asm!` clobbers will continue to be correct when LLVM starts using these new registers in its generated code.
379
378
380
379
## Options
@@ -469,5 +468,7 @@ To avoid undefined behavior, these rules must be followed when using function-sc
469
468
- The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.
470
469
- You cannot assume that an `asm!` block will appear exactly once in the output binary.
471
470
The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.
471
+
- On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler.
472
+
- The compiler is currently unable to detect this due to the way inline assembly is compiled, but may catch and reject this in the future.
472
473
473
474
> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.
0 commit comments