Skip to content

Commit 2f98dcf

Browse files
Rollup merge of #131258 - taiki-e:s390x-stabilize-asm, r=Amanieu
Stabilize s390x inline assembly This stabilizes inline assembly for s390x (SystemZ). Corresponding reference PR: rust-lang/reference#1643 --- From the requirements of stabilization mentioned in #93335 > Each architecture needs to be reviewed before stabilization: > - It must have clobber_abi. Done in #130630. > - It must be possible to clobber every register that is normally clobbered by a function call. Done in the PR that added support for clobber_abi. > - Generally review that the exposed register classes make sense. The followings can be used as input/output: - `reg` (`r[0-10]`, `r[12-14]`): General-purpose register - `reg_addr` (`r[1-10]`, `r[12-14]`): General-purpose register except `r0` which is evaluated as zero in an address context This class is needed because `r0`, which may be allocated when using the `reg` class, cannot be used as a register in certain contexts. This is identical to the `a` constraint in LLVM and GCC. See #119431 for details. - `freg` (`f[0-15]`): Floating-point register The followings are clobber-only: - `vreg` (`v[0-31]`): Vector register Technically `vreg` should be able to accept `#[repr(simd)]` types as input/output if the unstable `vector` target feature added is enabled, but `core::arch` has no s390x vector type and both `#[repr(simd)]` and `core::simd` are unstable. Everything related is unstable, so the fact that this is currently a clobber-only should not be considered a stabilization blocker. (#130869 tracks unstable stuff here) - `areg` (`a[2-15]`): Access register All of the above register classes except `reg_addr` are needed for `clobber_abi`. The followings cannot be used as operands for inline asm (see also [getReservedRegs](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp#L258-L282) and [SystemZELFRegisters](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.h#L107-L128) in LLVM): - `r11`: frame pointer - `r15`: stack pointer - `a0`, `a1`: Reserved for system use - `c[0-15]` (control register) Reserved by the kernel Although not listed in the above requirements, `preserves_flags` is implemented in #111331. --- cc ``@uweigand`` r? ``@Amanieu`` ``@rustbot`` label +O-SystemZ +A-inline-assembly
2 parents 303fc05 + ab62a35 commit 2f98dcf

File tree

4 files changed

+5
-21
lines changed

4 files changed

+5
-21
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
4848
| asm::InlineAsmArch::RiscV32
4949
| asm::InlineAsmArch::RiscV64
5050
| asm::InlineAsmArch::LoongArch64
51+
| asm::InlineAsmArch::S390x
5152
);
5253
if !is_stable && !self.tcx.features().asm_experimental_arch() {
5354
feature_err(

src/doc/unstable-book/src/language-features/asm-experimental-arch.md

+2-19
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
1818
- MSP430
1919
- M68k
2020
- CSKY
21-
- s390x
2221
- Arm64EC
2322
- SPARC
2423

@@ -52,11 +51,6 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
5251
| M68k | `reg_addr` | `a[0-3]` | `a` |
5352
| CSKY | `reg` | `r[0-31]` | `r` |
5453
| CSKY | `freg` | `f[0-31]` | `f` |
55-
| s390x | `reg` | `r[0-10]`, `r[12-14]` | `r` |
56-
| s390x | `reg_addr` | `r[1-10]`, `r[12-14]` | `a` |
57-
| s390x | `freg` | `f[0-15]` | `f` |
58-
| s390x | `vreg` | `v[0-31]` | Only clobbers |
59-
| s390x | `areg` | `a[2-15]` | Only clobbers |
6054
| SPARC | `reg` | `r[2-29]` | `r` |
6155
| SPARC | `yreg` | `y` | Only clobbers |
6256
| Arm64EC | `reg` | `x[0-12]`, `x[15-22]`, `x[25-27]`, `x30` | `r` |
@@ -96,10 +90,6 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
9690
| M68k | `reg_data` | None | `i8`, `i16`, `i32` |
9791
| CSKY | `reg` | None | `i8`, `i16`, `i32` |
9892
| CSKY | `freg` | None | `f32`, |
99-
| s390x | `reg`, `reg_addr` | None | `i8`, `i16`, `i32`, `i64` |
100-
| s390x | `freg` | None | `f32`, `f64` |
101-
| s390x | `vreg` | N/A | Only clobbers |
102-
| s390x | `areg` | N/A | Only clobbers |
10393
| SPARC | `reg` | None | `i8`, `i16`, `i32`, `i64` (SPARC64 only) |
10494
| SPARC | `yreg` | N/A | Only clobbers |
10595
| Arm64EC | `reg` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |
@@ -159,8 +149,8 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
159149

160150
| Architecture | Unsupported register | Reason |
161151
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
162-
| All | `sp`, `r15` (s390x), `r14`/`o6` (SPARC) | The stack pointer must be restored to its original value at the end of an asm code block. |
163-
| All | `fr` (Hexagon), `fp` (PowerPC), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `r11` (s390x), `r30`/`i6` (SPARC), `x29` (Arm64EC) | The frame pointer cannot be used as an input or output. |
152+
| All | `sp`, `r14`/`o6` (SPARC) | The stack pointer must be restored to its original value at the end of an asm code block. |
153+
| All | `fr` (Hexagon), `fp` (PowerPC), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `r30`/`i6` (SPARC), `x29` (Arm64EC) | The frame pointer cannot be used as an input or output. |
164154
| All | `r19` (Hexagon), `r29` (PowerPC), `r30` (PowerPC), `x19` (Arm64EC) | These are used internally by LLVM as "base pointer" for functions with complex stack frames. |
165155
| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
166156
| MIPS | `$1` or `$at` | Reserved for assembler. |
@@ -181,8 +171,6 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
181171
| CSKY | `r15` | This is the link register. |
182172
| CSKY | `r[26-30]` | Reserved by its ABI. |
183173
| CSKY | `r31` | This is the TLS register. |
184-
| s390x | `c[0-15]` | Reserved by the kernel. |
185-
| s390x | `a[0-1]` | Reserved for system use. |
186174
| SPARC | `r0`/`g0` | This is always zero and cannot be used as inputs or outputs. |
187175
| SPARC | `r1`/`g1` | Used internally by LLVM. |
188176
| SPARC | `r5`/`g5` | Reserved for system. (SPARC32 only) |
@@ -206,9 +194,6 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
206194
| PowerPC | `reg` | None | `0` | None |
207195
| PowerPC | `reg_nonzero` | None | `3` | None |
208196
| PowerPC | `freg` | None | `0` | None |
209-
| s390x | `reg` | None | `%r0` | None |
210-
| s390x | `reg_addr` | None | `%r1` | None |
211-
| s390x | `freg` | None | `%f0` | None |
212197
| SPARC | `reg` | None | `%o0` | None |
213198
| CSKY | `reg` | None | `r0` | None |
214199
| CSKY | `freg` | None | `f0` | None |
@@ -232,8 +217,6 @@ These flags registers must be restored upon exiting the asm block if the `preser
232217
- The status register `r2`.
233218
- M68k
234219
- The condition code register `ccr`.
235-
- s390x
236-
- The condition code register `cc`.
237220
- SPARC
238221
- Integer condition codes (`icc` and `xcc`)
239222
- Floating-point condition codes (`fcc[0-3]`)

tests/assembly/asm/s390x-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@[s390x] needs-llvm-components: systemz
55
//@ compile-flags: -Zmerge-functions=disabled
66

7-
#![feature(no_core, lang_items, rustc_attrs, repr_simd, asm_experimental_arch)]
7+
#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
88
#![crate_type = "rlib"]
99
#![no_core]
1010
#![allow(asm_sub_register, non_camel_case_types)]

tests/codegen/asm/s390x-clobbers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@[s390x] needs-llvm-components: systemz
44

55
#![crate_type = "rlib"]
6-
#![feature(no_core, rustc_attrs, lang_items, asm_experimental_arch)]
6+
#![feature(no_core, rustc_attrs, lang_items)]
77
#![no_core]
88

99
#[lang = "sized"]

0 commit comments

Comments
 (0)