Skip to content

Commit c122ac3

Browse files
authored
Rollup merge of rust-lang#111331 - taiki-e:s390x-asm-cc, r=Amanieu
Mark s390x condition code register as clobbered in inline assembly Various s390x instructions (arithmetic operations, logical operations, comparisons, etc. see also "Condition Codes" section in [z/Architecture Reference Summary](https://www.ibm.com/support/pages/zarchitecture-reference-summary)) modify condition code register `cc`, but AFAIK there is currently no way to mark it as clobbered in `asm!`. `cc` register definition in LLVM: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L320 This PR also updates asm_experimental_arch docs in the unstable-book to mention s390x registers. cc `@uweigand` r? `@Amanieu`
2 parents 28b9696 + e61bb88 commit c122ac3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
238238
InlineAsmArch::Hexagon => {}
239239
InlineAsmArch::LoongArch64 => {}
240240
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
241-
InlineAsmArch::S390x => {}
241+
InlineAsmArch::S390x => {
242+
constraints.push("~{cc}".to_string());
243+
}
242244
InlineAsmArch::SpirV => {}
243245
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {}
244246
InlineAsmArch::Bpf => {}

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
1818
- MSP430
1919
- M68k
2020
- LoongArch
21+
- s390x
2122

2223
## Register classes
2324

@@ -48,6 +49,8 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
4849
| M68k | `reg_addr` | `a[0-3]` | `a` |
4950
| LoongArch | `reg` | `$r1`, `$r[4-20]`, `$r[23,30]` | `r` |
5051
| LoongArch | `freg` | `$f[0-31]` | `f` |
52+
| s390x | `reg` | `r[0-10]`, `r[12-14]` | `r` |
53+
| s390x | `freg` | `f[0-15]` | `f` |
5154

5255
> **Notes**:
5356
> - NVPTX doesn't have a fixed register set, so named registers are not supported.
@@ -81,6 +84,8 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
8184
| M68k | `reg_data` | None | `i8`, `i16`, `i32` |
8285
| LoongArch64 | `reg` | None | `i8`, `i16`, `i32`, `i64`, `f32`, `f64` |
8386
| LoongArch64 | `freg` | None | `f32`, `f64` |
87+
| s390x | `reg` | None | `i8`, `i16`, `i32`, `i64` |
88+
| s390x | `freg` | None | `f32`, `f64` |
8489

8590
## Register aliases
8691

@@ -115,8 +120,8 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
115120

116121
| Architecture | Unsupported register | Reason |
117122
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
118-
| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
119-
| All | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `$fp` (LoongArch) | The frame pointer cannot be used as an input or output. |
123+
| All | `sp`, `r15` (s390x) | The stack pointer must be restored to its original value at the end of an asm code block. |
124+
| All | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR), `r4` (MSP430), `a6` (M68k), `$fp` (LoongArch), `r11` (s390x) | The frame pointer cannot be used as an input or output. |
120125
| All | `r19` (Hexagon) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
121126
| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
122127
| MIPS | `$1` or `$at` | Reserved for assembler. |
@@ -147,6 +152,8 @@ This feature tracks `asm!` and `global_asm!` support for the following architect
147152
| PowerPC | `freg` | None | `0` | None |
148153
| LoongArch | `reg` | None | `$r2` | None |
149154
| LoongArch | `freg` | None | `$f0` | None |
155+
| s390x | `reg` | None | `%r0` | None |
156+
| s390x | `freg` | None | `%f0` | None |
150157

151158
# Flags covered by `preserves_flags`
152159

@@ -157,3 +164,5 @@ These flags registers must be restored upon exiting the asm block if the `preser
157164
- The status register `r2`.
158165
- M68k
159166
- The condition code register `ccr`.
167+
- s390x
168+
- The condition code register `cc`.

0 commit comments

Comments
 (0)