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
10 changes: 10 additions & 0 deletions src/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ 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 paragraphs:

- :p:`fls_nLBhw2w6uznH`
- :p:`fls_xzDPz2zfRfoI`
- :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
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_nLBhw2w6uznH`
Only :t:`attribute` :c:`cfg` and :t:`attribute` :c:`cfg_attr` shall decorate :t:`[assembly instruction]s`, :t:`[register argument]s`, :t:`[ABI clobber]s`, and :t:`[assembly option]s` in :s:`AsmArguments` and :s:`GlobalAsmArguments`; all other :t:`[attribute]s` shall be rejected.

:dp:`fls_xzDPz2zfRfoI`
If a :t:`assembly instruction`, :t:`register argument`, :t:`ABI clobber`, or :t:`assembly option` in :s:`AsmArguments` or :s:`GlobalAsmArguments` is subject to :t:`attribute` :c:`cfg` or :t:`attribute` :c:`cfg_attr` where the related :t:`configuration predicate` evaluates to ``false``, then that construct is not considered part of the related :s:`AsmArguments` or :s:`GlobalAsmArguments`, consistent with :t:`conditional compilation`.

: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 construct 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