Skip to content

Commit 3d7b4ff

Browse files
committed
Apply review feedback
1 parent c41b359 commit 3d7b4ff

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/inline-assembly.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Inline assembly
22

3-
Rust provides support for inline assembly via the `asm!` and `global_asm!` macros.
3+
Support for inline assembly is provided via the [`asm!`] and [`global_asm!`] macros.
44
It can be used to embed handwritten assembly in the assembly output generated by the compiler.
55

6+
[`asm!`]: ../core/arch/macro.asm.html
7+
[`global_asm!`]: ../core/arch/macro.global_asm.html
8+
69
The following ABNF specifies the general syntax:
710

811
```text
@@ -24,7 +27,7 @@ Support for inline assembly is stable on the following architectures:
2427
- AArch64
2528
- RISC-V
2629

27-
Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.
30+
The compiler will emit an error if `asm!` is used on an unsupported target.
2831

2932
## Scope
3033

@@ -40,15 +43,15 @@ The assembler template uses the same syntax as [format strings][format-syntax] (
4043

4144
An `asm!` invocation may have one or more template string arguments; an `asm!` with multiple template string arguments is treated as if all the strings were concatenated with a `\n` between them. The expected usage is for each template string argument to correspond to a line of assembly code. All template string arguments must appear before any other arguments.
4245

43-
As with format strings, named arguments must appear after positional arguments. Explicit register operands must appear at the end of the operand list, after named arguments if any.
46+
As with format strings, named arguments must appear after positional arguments. Explicit [register operands](#register-operands) must appear at the end of the operand list, after named arguments if any.
4447

4548
Explicit register operands cannot be used by placeholders in the template string. All other named and positional operands must appear at least once in the template string, otherwise a compiler error is generated.
4649

4750
The exact assembly code syntax is target-specific and opaque to the compiler except for the way operands are substituted into the template string to form the code passed to the assembler.
4851

4952
Currently, all supported targets follow the assembly code syntax used by LLVM's internal assembler which usually corresponds to that of the GNU assembler (GAS). On x86, the `.intel_syntax noprefix` mode of GAS is used by default. On ARM, the `.syntax unified` mode is used. These targets impose an additional restriction on the assembly code: any assembler state (e.g. the current section which can be changed with `.section`) must be restored to its original value at the end of the asm string. Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.
5053

51-
[format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax
54+
[format-syntax]: ../std/fmt/#syntax
5255
[rfc-2795]: https://github.com/rust-lang/rfcs/pull/2795
5356

5457
## Operand type
@@ -137,8 +140,6 @@ Here is the list of currently supported register classes:
137140
>
138141
> - Some register classes are marked as "Only clobbers" which means that they cannot be used for inputs or outputs, only clobbers of the form `out("reg") _` or `lateout("reg") _`.
139142
140-
Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc).
141-
142143
Each register class has constraints on which value types they can be used with. This is necessary because the way a value is loaded into a register depends on its type. For example, on big-endian systems, loading a `i32x4` and a `i8x16` into a SIMD register may result in different register contents even if the byte-wise memory representation of both values is identical. The availability of supported types for a particular register class may depend on what target features are currently enabled.
143144

144145
| Architecture | Register class | Target feature | Allowed types |

0 commit comments

Comments
 (0)