Skip to content

Commit 4a3e009

Browse files
authored
Merge pull request #1643 from taiki-e/s390x-asm
Add s390x to inline-assembly documentation
2 parents e4b5b61 + 5b490c3 commit 4a3e009

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/inline-assembly.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Support for inline assembly is stable on the following architectures:
1616
- AArch64
1717
- RISC-V
1818
- LoongArch
19+
- s390x
1920

2021
The compiler will emit an error if `asm!` is used on an unsupported target.
2122

@@ -249,6 +250,11 @@ Here is the list of currently supported register classes:
249250
| RISC-V | `vreg` | `v[0-31]` | Only clobbers |
250251
| LoongArch | `reg` | `$r1`, `$r[4-20]`, `$r[23,30]` | `r` |
251252
| LoongArch | `freg` | `$f[0-31]` | `f` |
253+
| s390x | `reg` | `r[0-10]`, `r[12-14]` | `r` |
254+
| s390x | `reg_addr` | `r[1-10]`, `r[12-14]` | `a` |
255+
| s390x | `freg` | `f[0-15]` | `f` |
256+
| s390x | `vreg` | `v[0-31]` | Only clobbers |
257+
| s390x | `areg` | `a[2-15]` | Only clobbers |
252258

253259
> **Notes**:
254260
> - On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.
@@ -288,6 +294,10 @@ The availability of supported types for a particular register class may depend o
288294
| RISC-V | `vreg` | N/A | Only clobbers |
289295
| LoongArch64 | `reg` | None | `i8`, `i16`, `i32`, `i64`, `f32`, `f64` |
290296
| LoongArch64 | `freg` | None | `f32`, `f64` |
297+
| s390x | `reg`, `reg_addr` | None | `i8`, `i16`, `i32`, `i64` |
298+
| s390x | `freg` | None | `f32`, `f64` |
299+
| s390x | `vreg` | N/A | Only clobbers |
300+
| s390x | `areg` | N/A | Only clobbers |
291301

292302
> **Note**: 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).
293303
@@ -372,8 +382,8 @@ Some registers cannot be used for input or output operands:
372382

373383
| Architecture | Unsupported register | Reason |
374384
| ------------ | -------------------- | ------ |
375-
| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
376-
| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `$fp` (LoongArch) | The frame pointer cannot be used as an input or output. |
385+
| All | `sp`, `r15` (s390x) | The stack pointer must be restored to its original value at the end of an asm code block. |
386+
| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `$fp` (LoongArch), `r11` (s390x) | The frame pointer cannot be used as an input or output. |
377387
| 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. |
378388
| All | `si` (x86-32), `bx` (x86-64), `r6` (ARM), `x19` (AArch64), `x9` (RISC-V), `$s8` (LoongArch) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
379389
| x86 | `ip` | This is the program counter, not a real register. |
@@ -386,6 +396,8 @@ Some registers cannot be used for input or output operands:
386396
| LoongArch | `$r0` or `$zero` | This is a constant zero register which can't be modified. |
387397
| LoongArch | `$r2` or `$tp` | This is reserved for TLS. |
388398
| LoongArch | `$r21` | This is reserved by the ABI. |
399+
| s390x | `c[0-15]` | Reserved by the kernel. |
400+
| s390x | `a[0-1]` | Reserved for system use. |
389401

390402
r[asm.register-names.fp-bp-reserved]
391403
The frame pointer and base pointer registers are reserved for internal use by LLVM. While `asm!` statements cannot explicitly specify the use of reserved registers, in some cases LLVM will allocate one of these reserved registers for `reg` operands. Assembly code making use of reserved registers should be careful since `reg` operands may use the same registers.
@@ -441,6 +453,9 @@ The supported modifiers are a subset of LLVM's (and GCC's) [asm template argumen
441453
| RISC-V | `freg` | None | `f0` | None |
442454
| LoongArch | `reg` | None | `$r1` | None |
443455
| LoongArch | `freg` | None | `$f0` | None |
456+
| s390x | `reg` | None | `%r0` | None |
457+
| s390x | `reg_addr` | None | `%r1` | None |
458+
| s390x | `freg` | None | `%f0` | None |
444459

445460
> **Notes**:
446461
> - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.
@@ -485,6 +500,7 @@ The following ABIs can be used with `clobber_abi`:
485500
| ARM | `"C"`, `"system"`, `"efiapi"`, `"aapcs"` | `r[0-3]`, `r12`, `r14`, `s[0-15]`, `d[0-7]`, `d[16-31]` |
486501
| RISC-V | `"C"`, `"system"`, `"efiapi"` | `x1`, `x[5-7]`, `x[10-17]`, `x[28-31]`, `f[0-7]`, `f[10-17]`, `f[28-31]`, `v[0-31]` |
487502
| LoongArch | `"C"`, `"system"` | `$r1`, `$r[4-20]`, `$f[0-23]` |
503+
| s390x | `"C"`, `"system"` | `r[0-5]`, `r14`, `f[0-7]`, `v[0-31]`, `a[2-15]` |
488504

489505
> Notes:
490506
> - On AArch64 `x18` only included in the clobber list if it is not considered as a reserved register on the target.
@@ -624,6 +640,8 @@ r[asm.rules.preserved-registers]
624640
- Vector extension state (`vtype`, `vl`, `vcsr`).
625641
- LoongArch
626642
- Floating-point condition flags in `$fcc[0-7]`.
643+
- s390x
644+
- The condition code register `cc`.
627645

628646
r[asm.rules.x86-df]
629647
- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.

0 commit comments

Comments
 (0)