Skip to content

Commit f3d9a43

Browse files
committed
Document ppc inline asm support
1 parent 182f2c6 commit f3d9a43

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/inline-assembly.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Support for inline assembly is stable on the following architectures:
1717
- RISC-V
1818
- LoongArch
1919
- s390x
20+
- PowerPC and PowerPC64
2021

2122
The compiler will emit an error if an assembly macro is used on an unsupported target.
2223

@@ -602,6 +603,15 @@ Here is the list of currently supported register classes:
602603
| s390x | `freg` | `f[0-15]` | `f` |
603604
| s390x | `vreg` | `v[0-31]` | Only clobbers |
604605
| s390x | `areg` | `a[2-15]` | Only clobbers |
606+
| PowerPC/PowerPC64 | `reg` | `r0`, `r[3-12]`, `r[14-28]` | `r` |
607+
| PowerPC/PowerPC64 | `reg_nonzero` | `r[3-12]`, `r[14-28]` | `b` |
608+
| PowerPC/PowerPC64 | `freg` | `f[0-31]` | `f` |
609+
| PowerPC/PowerPC64 | `vreg` | `v[0-31]` | `v` |
610+
| PowerPC/PowerPC64 | `vsreg` | `vs[0-63]` | `wa` |
611+
| PowerPC/PowerPC64 | `cr` | `cr[0-7]`, `cr` | Only clobbers |
612+
| PowerPC/PowerPC64 | `ctr` | `ctr` | Only clobbers |
613+
| PowerPC/PowerPC64 | `lr` | `lr` | Only clobbers |
614+
| PowerPC/PowerPC64 | `xer` | `xer` | Only clobbers |
605615

606616
> [!NOTE]
607617
> - On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.
@@ -649,6 +659,16 @@ The availability of supported types for a particular register class may depend o
649659
| s390x | `freg` | None | `f32`, `f64` |
650660
| s390x | `vreg` | N/A | Only clobbers |
651661
| s390x | `areg` | N/A | Only clobbers |
662+
| PowerPC/PowerPC64 | `reg` | None | `i8`, `i16`, `i32`, `i64` (PowerPC64 only) |
663+
| PowerPC/PowerPC64 | `reg_nonzero` | None | `i8`, `i16`, `i32`, `i64` (PowerPC64 only) |
664+
| PowerPC/PowerPC64 | `freg` | None | `f32`, `f64` |
665+
| PowerPC/PowerPC64 | `vreg` | `altivec` | `i8x16`, `i16x8`, `i32x4`, `f32x4` |
666+
| PowerPC/PowerPC64 | `vreg` | `vsx` | `f32`, `f64`, `i64x2`, `f64x2` |
667+
| PowerPC/PowerPC64 | `vsreg` | `vsx` | The union of vsx and altivec vreg types |
668+
| PowerPC/PowerPC64 | `cr` | None | Only clobbers |
669+
| PowerPC/PowerPC64 | `ctr` | None | Only clobbers |
670+
| PowerPC/PowerPC64 | `lr` | None | Only clobbers |
671+
| PowerPC/PowerPC64 | `xer` | None | Only clobbers |
652672

653673
> [!NOTE]
654674
> For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target).
@@ -790,6 +810,10 @@ Here is the list of all supported register aliases:
790810
| LoongArch | `$f[0-7]` | `$fa[0-7]` |
791811
| LoongArch | `$f[8-23]` | `$ft[0-15]` |
792812
| LoongArch | `$f[24-31]` | `$fs[0-7]` |
813+
| PowerPC/PowerPC64 | `r1` | `sp` |
814+
| PowerPC/PowerPC64 | `r31` | `fp` |
815+
| PowerPC/PowerPC64 | `r[0-31]` | `[0-31]` |
816+
| PowerPC/PowerPC64 | `f[0-31]` | `fr[0-31]`|
793817

794818
```rust
795819
# #[cfg(target_arch = "x86_64")] {
@@ -804,10 +828,10 @@ Some registers cannot be used for input or output operands:
804828

805829
| Architecture | Unsupported register | Reason |
806830
| ------------ | -------------------- | ------ |
807-
| All | `sp`, `r15` (s390x) | The stack pointer must be restored to its original value at the end of the assembly code or before jumping to a `label` block. |
808-
| All | `bp` (x86), `x29` (AArch64 and Arm64EC), `x8` (RISC-V), `$fp` (LoongArch), `r11` (s390x) | The frame pointer cannot be used as an input or output. |
831+
| All | `sp`, `r15` (s390x), `r1` (PowerPC and PowerPC64) | The stack pointer must be restored to its original value at the end of the assembly code or before jumping to a `label` block. |
832+
| All | `bp` (x86), `x29` (AArch64 and Arm64EC), `x8` (RISC-V), `$fp` (LoongArch), `r11` (s390x), `fp` (PowerPC and PowerPC64) | The frame pointer cannot be used as an input or output. |
809833
| 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. |
810-
| All | `si` (x86-32), `bx` (x86-64), `r6` (ARM), `x19` (AArch64 and Arm64EC), `x9` (RISC-V), `$s8` (LoongArch) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
834+
| All | `si` (x86-32), `bx` (x86-64), `r6` (ARM), `x19` (AArch64 and Arm64EC), `x9` (RISC-V), `$s8` (LoongArch), `r29` and `r30` (PowerPC and PowerPC64) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
811835
| x86 | `ip` | This is the program counter, not a real register. |
812836
| AArch64 | `xzr` | This is a constant zero register which can't be modified. |
813837
| AArch64 | `x18` | This is an OS-reserved register on some AArch64 targets. |
@@ -823,6 +847,8 @@ Some registers cannot be used for input or output operands:
823847
| LoongArch | `$r21` | This is reserved by the ABI. |
824848
| s390x | `c[0-15]` | Reserved by the kernel. |
825849
| s390x | `a[0-1]` | Reserved for system use. |
850+
| PowerPC/PowerPC64 | `r2`, `r13` | These are system reserved registers. |
851+
| PowerPC/PowerPC64 | `vrsave` | The vrsave register cannot be used as an input or output. |
826852

827853
```rust,compile_fail
828854
# #[cfg(target_arch = "x86_64")] {
@@ -898,6 +924,11 @@ The supported modifiers are a subset of LLVM's (and GCC's) [asm template argumen
898924
| s390x | `reg` | None | `%r0` | None |
899925
| s390x | `reg_addr` | None | `%r1` | None |
900926
| s390x | `freg` | None | `%f0` | None |
927+
| PowerPC/PowerPC64 | `reg` | None | `0` | None |
928+
| PowerPC/PowerPC64 | `reg_nonzero` | None | `3` | None |
929+
| PowerPC/PowerPC64 | `freg` | None | `0` | None |
930+
| PowerPC/PowerPC64 | `vreg` | None | `0` | None |
931+
| PowerPC/PowerPC64 | `vsreg` | None | `0` | None |
901932

902933
> [!NOTE]
903934
> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.

0 commit comments

Comments
 (0)