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
Auto merge of rust-lang#84658 - Amanieu:reserved_regs, r=petrochenkov
Be stricter about rejecting LLVM reserved registers in asm!
LLVM will silently produce incorrect code if these registers are used as operands.
cc `@rust-lang/wg-inline-asm`
| x86 |`xmm_reg`|`xmm[0-7]` (x86) `xmm[0-15]` (x86-64) |`x`|
543
543
| x86 |`ymm_reg`|`ymm[0-7]` (x86) `ymm[0-15]` (x86-64) |`x`|
544
544
| x86 |`zmm_reg`|`zmm[0-7]` (x86) `zmm[0-31]` (x86-64) |`v`|
545
545
| x86 |`kreg`|`k[1-7]`|`Yk`|
546
-
| AArch64 |`reg`|`x[0-28]`, `x30`|`r`|
546
+
| AArch64 |`reg`|`x[0-30]`|`r`|
547
547
| AArch64 |`vreg`|`v[0-31]`|`w`|
548
548
| AArch64 |`vreg_low16`|`v[0-15]`|`x`|
549
-
| ARM |`reg`|`r[0-5]``r7`\*, `r[8-10]`, `r11`\*, `r12`, `r14`|`r`|
549
+
| ARM |`reg`|`r[0-12]`, `r14`|`r`|
550
550
| ARM (Thumb) |`reg_thumb`|`r[0-r7]`|`l`|
551
-
| ARM (ARM) |`reg_thumb`|`r[0-r10]`, `r12`, `r14`|`l`|
551
+
| ARM (ARM) |`reg_thumb`|`r[0-r12]`, `r14`|`l`|
552
552
| ARM |`sreg`|`s[0-31]`|`t`|
553
553
| ARM |`sreg_low16`|`s[0-15]`|`x`|
554
554
| ARM |`dreg`|`d[0-31]`|`w`|
@@ -573,9 +573,7 @@ Here is the list of currently supported register classes:
573
573
>
574
574
> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.
575
575
>
576
-
> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform.
577
-
>
578
-
> Note #5: WebAssembly doesn't have registers, so named registers are not supported.
576
+
> Note #4: WebAssembly doesn't have registers, so named registers are not supported.
579
577
580
578
Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc).
581
579
@@ -677,13 +675,14 @@ Some registers cannot be used for input or output operands:
677
675
| All |`sp`| The stack pointer must be restored to its original value at the end of an asm code block. |
678
676
| All |`bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon), `$fp` (MIPS) | The frame pointer cannot be used as an input or output. |
679
677
| ARM |`r7` or `r11`| On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. |
680
-
|ARM|`r6`|`r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. |
678
+
|All|`si` (x86-32), `bx` (x86-64), `r6`(ARM), `x19` (AArch64), `r19` (Hexagon), `x9` (RISC-V) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
681
679
| x86 |`k0`| This is a constant zero register which can't be modified. |
682
680
| x86 |`ip`| This is the program counter, not a real register. |
683
681
| x86 |`mm[0-7]`| MMX registers are not currently supported (but may be in the future). |
684
682
| x86 |`st([0-7])`| x87 registers are not currently supported (but may be in the future). |
685
683
| AArch64 |`xzr`| This is a constant zero register which can't be modified. |
686
684
| ARM |`pc`| This is the program counter, not a real register. |
685
+
| ARM |`r9`| This is a reserved register on some ARM targets. |
687
686
| MIPS |`$0` or `$zero`| This is a constant zero register which can't be modified. |
@@ -693,9 +692,10 @@ Some registers cannot be used for input or output operands:
693
692
| RISC-V |`gp`, `tp`| These registers are reserved and cannot be used as inputs or outputs. |
694
693
| Hexagon |`lr`| This is the link register which cannot be used as an input or output. |
695
694
696
-
In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified. Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers. Reserved registers are:
697
-
- The frame pointer on all architectures.
698
-
-`r6` on ARM.
695
+
In some cases LLVM will allocate a "reserved register" for `reg` operands even though this register cannot be explicitly specified. Assembly code making use of reserved registers should be careful since `reg` operands may alias with those registers. Reserved registers are the frame pointer and base pointer
696
+
- The frame pointer and LLVM base pointer on all architectures.
0 commit comments