about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-11 03:52:12 +0000
committerbors <bors@rust-lang.org>2021-12-11 03:52:12 +0000
commitc185610ebc19a0fc22e68472483dc69ea10b92fd (patch)
tree6efde3cd2f3283600d3bd97a54a5b87ce3b21f37 /src/doc
parent82575a1d6f02a3932fcfa36562368f5e095d93ba (diff)
parent637859b26ef431b2533d257184bd7a74ae278f8c (diff)
downloadrust-c185610ebc19a0fc22e68472483dc69ea10b92fd.tar.gz
rust-c185610ebc19a0fc22e68472483dc69ea10b92fd.zip
Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #91668 (Remove the match on `ErrorKind::Other`)
 - #91678 (Add tests fixed by #90023)
 - #91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs)
 - #91681 (fix typo in `intrinsics::raw_eq` docs)
 - #91686 (Fix `Vec::reserve_exact` documentation)
 - #91697 (Delete Utf8Lossy::from_str)
 - #91706 (Add unstable book entries for parts of asm that are not being stabilized)
 - #91709 (Replace iterator-based set construction by *Set::From<[T; N]>)
 - #91716 (Improve x.py logging and defaults a bit more)
 - #91747 (Add pierwill to .mailmap)
 - #91755 (Fix since attribute for const_linked_list_new feature)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/asm-const.md11
-rw-r--r--src/doc/unstable-book/src/language-features/asm-experimental-arch.md117
-rw-r--r--src/doc/unstable-book/src/language-features/asm-sym.md13
-rw-r--r--src/doc/unstable-book/src/language-features/asm-unwind.md9
4 files changed, 150 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/asm-const.md b/src/doc/unstable-book/src/language-features/asm-const.md
new file mode 100644
index 00000000000..1063c23b6df
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/asm-const.md
@@ -0,0 +1,11 @@
+# `asm_const`
+
+The tracking issue for this feature is: [#72016]
+
+[#72016]: https://github.com/rust-lang/rust/issues/72016
+
+------------------------
+
+This feature adds a `const <expr>` operand type to `asm!` and `global_asm!`.
+- `<expr>` must be an integer constant expression.
+- The value of the expression is formatted as a string and substituted directly into the asm template string.
diff --git a/src/doc/unstable-book/src/language-features/asm-experimental-arch.md b/src/doc/unstable-book/src/language-features/asm-experimental-arch.md
new file mode 100644
index 00000000000..ec97eaa8b2b
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/asm-experimental-arch.md
@@ -0,0 +1,117 @@
+# `asm_experimental_arch`
+
+The tracking issue for this feature is: [#72016]
+
+[#72016]: https://github.com/rust-lang/rust/issues/72016
+
+------------------------
+
+This feature tracks `asm!` and `global_asm!` support for the following architectures:
+- NVPTX
+- PowerPC
+- Hexagon
+- MIPS32r2 and MIPS64r2
+- wasm32
+- BPF
+- SPIR-V
+- AVR
+
+## Register classes
+
+| Architecture | Register class | Registers                          | LLVM constraint code |
+| ------------ | -------------- | ---------------------------------- | -------------------- |
+| MIPS         | `reg`          | `$[2-25]`                          | `r`                  |
+| MIPS         | `freg`         | `$f[0-31]`                         | `f`                  |
+| NVPTX        | `reg16`        | None\*                             | `h`                  |
+| NVPTX        | `reg32`        | None\*                             | `r`                  |
+| NVPTX        | `reg64`        | None\*                             | `l`                  |
+| Hexagon      | `reg`          | `r[0-28]`                          | `r`                  |
+| PowerPC      | `reg`          | `r[0-31]`                          | `r`                  |
+| PowerPC      | `reg_nonzero`  | `r[1-31]`                          | `b`                  |
+| PowerPC      | `freg`         | `f[0-31]`                          | `f`                  |
+| PowerPC      | `cr`           | `cr[0-7]`, `cr`                    | Only clobbers        |
+| PowerPC      | `xer`          | `xer`                              | Only clobbers        |
+| wasm32       | `local`        | None\*                             | `r`                  |
+| BPF          | `reg`          | `r[0-10]`                          | `r`                  |
+| BPF          | `wreg`         | `w[0-10]`                          | `w`                  |
+| AVR          | `reg`          | `r[2-25]`, `XH`, `XL`, `ZH`, `ZL`  | `r`                  |
+| AVR          | `reg_upper`    | `r[16-25]`, `XH`, `XL`, `ZH`, `ZL` | `d`                  |
+| AVR          | `reg_pair`     | `r3r2` .. `r25r24`, `X`, `Z`       | `r`                  |
+| AVR          | `reg_iw`       | `r25r24`, `X`, `Z`                 | `w`                  |
+| AVR          | `reg_ptr`      | `X`, `Z`                           | `e`                  |
+
+> **Notes**:
+> - NVPTX doesn't have a fixed register set, so named registers are not supported.
+>
+> - WebAssembly doesn't have registers, so named registers are not supported.
+
+# Register class supported types
+
+| Architecture | Register class                  | Target feature | Allowed types                           |
+| ------------ | ------------------------------- | -------------- | --------------------------------------- |
+| MIPS32       | `reg`                           | None           | `i8`, `i16`, `i32`, `f32`               |
+| MIPS32       | `freg`                          | None           | `f32`, `f64`                            |
+| MIPS64       | `reg`                           | None           | `i8`, `i16`, `i32`, `i64`, `f32`, `f64` |
+| MIPS64       | `freg`                          | None           | `f32`, `f64`                            |
+| NVPTX        | `reg16`                         | None           | `i8`, `i16`                             |
+| NVPTX        | `reg32`                         | None           | `i8`, `i16`, `i32`, `f32`               |
+| NVPTX        | `reg64`                         | None           | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |
+| Hexagon      | `reg`                           | None           | `i8`, `i16`, `i32`, `f32`               |
+| PowerPC      | `reg`                           | None           | `i8`, `i16`, `i32`                      |
+| PowerPC      | `reg_nonzero`                   | None           | `i8`, `i16`, `i32`                      |
+| PowerPC      | `freg`                          | None           | `f32`, `f64`                            |
+| PowerPC      | `cr`                            | N/A            | Only clobbers                           |
+| PowerPC      | `xer`                           | N/A            | Only clobbers                           |
+| wasm32       | `local`                         | None           | `i8` `i16` `i32` `i64` `f32` `f64`      |
+| BPF          | `reg`                           | None           | `i8` `i16` `i32` `i64`                  |
+| BPF          | `wreg`                          | `alu32`        | `i8` `i16` `i32`                        |
+| AVR          | `reg`, `reg_upper`              | None           | `i8`                                    |
+| AVR          | `reg_pair`, `reg_iw`, `reg_ptr` | None           | `i16`                                   |
+
+## Register aliases
+
+| Architecture | Base register | Aliases   |
+| ------------ | ------------- | --------- |
+| Hexagon      | `r29`         | `sp`      |
+| Hexagon      | `r30`         | `fr`      |
+| Hexagon      | `r31`         | `lr`      |
+| BPF          | `r[0-10]`     | `w[0-10]` |
+| AVR          | `XH`          | `r27`     |
+| AVR          | `XL`          | `r26`     |
+| AVR          | `ZH`          | `r31`     |
+| AVR          | `ZL`          | `r30`     |
+
+## Unsupported registers
+
+| Architecture | Unsupported register                    | Reason                                                                                                                                                                              |
+| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| All          | `sp`                                    | The stack pointer must be restored to its original value at the end of an asm code block.                                                                                           |
+| All          | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR) | The frame pointer cannot be used as an input or output.                                                                                                                             |
+| All          | `r19` (Hexagon)                         | This is used internally by LLVM as a "base pointer" for functions with complex stack frames.                                                                                        |
+| MIPS         | `$0` or `$zero`                         | This is a constant zero register which can't be modified.                                                                                                                           |
+| MIPS         | `$1` or `$at`                           | Reserved for assembler.                                                                                                                                                             |
+| MIPS         | `$26`/`$k0`, `$27`/`$k1`                | OS-reserved registers.                                                                                                                                                              |
+| MIPS         | `$28`/`$gp`                             | Global pointer cannot be used as inputs or outputs.                                                                                                                                 |
+| MIPS         | `$ra`                                   | Return address cannot be used as inputs or outputs.                                                                                                                                 |
+| Hexagon      | `lr`                                    | This is the link register which cannot be used as an input or output.                                                                                                               |
+| AVR          | `r0`, `r1`, `r1r0`                      | Due to an issue in LLVM, the `r0` and `r1` registers cannot be used as inputs or outputs.  If modified, they must be restored to their original values before the end of the block. |
+
+## Template modifiers
+
+| Architecture | Register class | Modifier | Example output | LLVM modifier |
+| ------------ | -------------- | -------- | -------------- | ------------- |
+| MIPS         | `reg`          | None     | `$2`           | None          |
+| MIPS         | `freg`         | None     | `$f0`          | None          |
+| NVPTX        | `reg16`        | None     | `rs0`          | None          |
+| NVPTX        | `reg32`        | None     | `r0`           | None          |
+| NVPTX        | `reg64`        | None     | `rd0`          | None          |
+| Hexagon      | `reg`          | None     | `r0`           | None          |
+| PowerPC      | `reg`          | None     | `0`            | None          |
+| PowerPC      | `reg_nonzero`  | None     | `3`            | `b`           |
+| PowerPC      | `freg`         | None     | `0`            | None          |
+
+# Flags covered by `preserves_flags`
+
+These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:
+- AVR
+  - The status register `SREG`.
diff --git a/src/doc/unstable-book/src/language-features/asm-sym.md b/src/doc/unstable-book/src/language-features/asm-sym.md
new file mode 100644
index 00000000000..7544e20807e
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/asm-sym.md
@@ -0,0 +1,13 @@
+# `asm_sym`
+
+The tracking issue for this feature is: [#72016]
+
+[#72016]: https://github.com/rust-lang/rust/issues/72016
+
+------------------------
+
+This feature adds a `sym <path>` operand type to `asm!` and `global_asm!`.
+- `<path>` must refer to a `fn` or `static`.
+- A mangled symbol name referring to the item is substituted into the asm template string.
+- The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).
+- `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.
diff --git a/src/doc/unstable-book/src/language-features/asm-unwind.md b/src/doc/unstable-book/src/language-features/asm-unwind.md
new file mode 100644
index 00000000000..414193fe801
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/asm-unwind.md
@@ -0,0 +1,9 @@
+# `asm_unwind`
+
+The tracking issue for this feature is: [#72016]
+
+[#72016]: https://github.com/rust-lang/rust/issues/72016
+
+------------------------
+
+This feature adds a `may_unwind` option to `asm!` which allows an `asm` block to unwind stack and be part of the stack unwinding process. This option is only supported by the LLVM backend right now.