Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ Language changes in Rust 1.93.0
- No change: this bug was not documented in FLS

- `Stabilize asm_cfg <https://github.com/rust-lang/rust/pull/147736>`_

- Changed syntax: :s:`AssemblyCodeBlock`, :s:`AsmArguments`, :s:`GlobalAsmArguments`
- New syntax: :s:`AssemblyTemplate`, :s:`AssemblyAttributeRegisterArgument`, :s:`AssemblyAttributeAbiClobber`, :s:`AssemblyAttributeAssemblyOption`
- New glossary entry: :t:`inline assembly argument`

- New paragraphs:

- :p:`fls_tKj18krZ1pSt`
- :p:`fls_nLBhw2w6uznH`
- :p:`fls_cTEiqjf6haEg`

- `During const-evaluation, support copying pointers byte-by-byte <https://github.com/rust-lang/rust/pull/148259>`_

* No change: Already covered by the classification of :t:`[constant expression]s`.
Expand Down
8 changes: 8 additions & 0 deletions src/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,14 @@ inline assembly
:dt:`Inline assembly` is hand-written assembly code that is integrated into a
Rust program.

.. _fls_K1MwUj4jqd0F:

inline assembly argument
^^^^^^^^^^^^^^^^^^^^^^^^

:dp:`fls_Q7qnUo0GskSV`
An :dt:`inline assembly argument` is either an :t:`assembly instruction`, a :t:`register argument`, an :t:`ABI clobber`, or an :t:`assembly option`.

.. _fls_c54lmkluwbwr:

inline module
Expand Down
41 changes: 38 additions & 3 deletions src/inline-assembly.rst
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,10 @@ Assembly Instructions
.. syntax::

AssemblyCodeBlock ::=
AssemblyInstruction ($$,$$ AssemblyInstruction)*
AssemblyTemplate ($$,$$ AssemblyTemplate)*

AssemblyTemplate ::=
OuterAttribute* AssemblyInstruction

AssemblyInstruction ::=
StringLiteral
Expand Down Expand Up @@ -1625,10 +1628,19 @@ Macros: asm, global_asm, and naked_asm
.. syntax::

AsmArguments ::=
$$($$ AssemblyCodeBlock ($$,$$ LabelBlock)? ($$,$$ RegisterArgument)* ($$,$$ AbiClobber)* ($$,$$ AssemblyOption)* $$,$$? $$)$$
$$($$ AssemblyCodeBlock ($$,$$ LabelBlock)? ($$,$$ AssemblyAttributeRegisterArgument)* ($$,$$ AssemblyAttributeAbiClobber)* ($$,$$ AssemblyAttributeAssemblyOption)* $$,$$? $$)$$

GlobalAsmArguments ::=
$$($$ AssemblyCodeBlock ($$,$$ RegisterArgument)* ($$,$$ AssemblyOption)* $$,$$? $$)$$
$$($$ AssemblyCodeBlock ($$,$$ AssemblyAttributeRegisterArgument)* ($$,$$ AssemblyAttributeAssemblyOption)* $$,$$? $$)$$

AssemblyAttributeRegisterArgument ::=
OuterAttribute* RegisterArgument

AssemblyAttributeAbiClobber ::=
OuterAttribute* AbiClobber

AssemblyAttributeAssemblyOption ::=
OuterAttribute* AssemblyOption

LabelBlock ::=
$$block$$ $${$$ StatementList $$}$$
Expand All @@ -1641,6 +1653,15 @@ Macros: asm, global_asm, and naked_asm
:std:`core::arch::global_asm`, and
:std:`core::arch::naked_asm`.

:dp:`fls_tKj18krZ1pSt`
An :t:`inline assembly argument` is either an :t:`assembly instruction`, a :t:`register argument`, an :t:`ABI clobber`, or an :t:`assembly option`.

:dp:`fls_nLBhw2w6uznH`
Only :t:`attribute` :c:`cfg` and :t:`attribute` :c:`cfg_attr` shall decorate :t:`[inline assembly arguments]s` in :s:`AsmArguments` and :s:`GlobalAsmArguments`.

:dp:`fls_cTEiqjf6haEg`
It is a static error for a :t:`register argument`, :t:`ABI clobber`, or :t:`assembly option` to appear before the first :t:`assembly instruction`, including when that :t:`inline assembly argument` is subject to :t:`attribute` :c:`cfg` or :t:`attribute` :c:`cfg_attr` where the related :t:`configuration predicate` evaluates to ``false``.

:dp:`fls_1ikzov7cxic1`
When invoking :t:`macro` :std:`core::arch::asm`, the :s:`DelimitedTokenTree` of
the related :t:`macro invocation` shall follow the syntax of :s:`AsmArguments`.
Expand Down Expand Up @@ -1698,6 +1719,20 @@ The :t:`execution` of an :t:`assembly code block` produced by

.. rubric:: Examples

.. code-block:: rust

unsafe {
core::arch::asm!(
"nop",
#[cfg(target_feature = "sse2")]
"nop",
#[cfg(target_feature = "sse2")]
in(reg) 0_u32,
#[cfg(target_feature = "sse2")]
options(nomem, nostack),
);
}

.. code-block:: rust

fn asm_example() -> u32 {
Expand Down