Commit e8cccfb
committed
Auto merge of #147996 - pmur:murp/stabilize-ppc-inlineasm, r=Amanieu
Stabilize ppc inline assembly
This stabilizes inline assembly for PowerPC and PowerPC64.
Corresponding reference PR: rust-lang/reference#2056
---
From the requirements of stabilization mentioned in #93335
> Each architecture needs to be reviewed before stabilization:
> * It must have clobber_abi.
Done in #146949.
> * It must be possible to clobber every register that is normally clobbered by a function call.
Done in #131341
Similarly, `preserves_flags` is also implemented by this PR. Likewise, there is a non-code change to `preserve_flags` expectations that floating point and vector status and sticky bits are preserved. The reference manual update has more details.
> * Generally review that the exposed register classes make sense.
The followings can be used as input/output:
* reg (`r0`, `r[3-12]`, `r[14-r28]`): Any usable general-purpose register
* reg_nonzero (`r[3-12]`, `r[14-r28]`): General-purpose registers, but excludes `r0`. This is needed for instructions which define `r0` to be the value 0, such as register + immediate memory operations.
* reg/reg_nonzero `r29` on PowerPC64 targets.
* freg (`f[0-31]`): 64 bit floating pointer registers
The following are clobber-only:
* `ctr`, `lr`, `xer`: commonly clobbered special-purpose registers used in inline asm
* `cr` (`cr[0-7]`, `cr`): the condition register fields, or the entire condition register.
* `vreg` (`v[0-31]`): altivec/vmx register
* `vsreg` (`vs[0-63]`): vector-scalar register
* `spe_acc`: SPE accumulator, only available for PowerPC SPE targets.
The vreg and vsreg registers technically accept `#[repr(simd)]` types, but require the experimental `altivec` or `vsx` target features to be enabled. That work seems to be tracked here, #42743.
The following cannot be used as operands for inline asm:
* `r2`: the TOC pointer, required for most PIC code.
* `r13`: the TLS pointer
* `r[29]`: Reserved for internal usage by LLVM on PowerPC
* `r[30]`: Reserved for internal usage by LLVM on PowerPC and PowerPC64
* `r31`: the frame pointer
* `vrsave`: this is effectively an unused special-purpose register.
The `preserves_flags` behavior is updated with the following behavior (Note, this is not enforceable today due to LLVM restrictions):
* All status and sticky bits of `fpscr`, `spefscr`, and `vscr` are preserved.
The following registers are unavailable:
* `mma[0-7]`: These are new "registers" available on Power10, they are 512b registers which overlay 4x vsx registers. If needed, users can mark such clobbers as vsN*4, vsN*4+1,...,vsN*4+3.
* `ap`: This is actually a pseudo-register in gcc/llvm.
* `mq`: This register is only available on Power1 and Power2, and is not supported by llvm.
---
cc @taiki-e
r? @Amanieu
@rustbot label +A-inline-assemblyFile tree
2 files changed
+4
-39
lines changed- compiler/rustc_ast_lowering/src
- src/doc/unstable-book/src/language-features
2 files changed
+4
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
Lines changed: 2 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 33 | | |
45 | 34 | | |
46 | 35 | | |
| |||
62 | 51 | | |
63 | 52 | | |
64 | 53 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 54 | | |
70 | 55 | | |
71 | 56 | | |
| |||
80 | 65 | | |
81 | 66 | | |
82 | 67 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 68 | | |
95 | 69 | | |
96 | 70 | | |
| |||
111 | 85 | | |
112 | 86 | | |
113 | 87 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 88 | | |
119 | 89 | | |
120 | 90 | | |
| |||
153 | 123 | | |
154 | 124 | | |
155 | 125 | | |
156 | | - | |
157 | | - | |
| 126 | + | |
| 127 | + | |
158 | 128 | | |
159 | 129 | | |
160 | 130 | | |
161 | 131 | | |
162 | 132 | | |
163 | 133 | | |
164 | | - | |
165 | | - | |
166 | 134 | | |
167 | 135 | | |
168 | 136 | | |
| |||
189 | 157 | | |
190 | 158 | | |
191 | 159 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | 160 | | |
198 | 161 | | |
199 | 162 | | |
| |||
0 commit comments