diff --git a/src/changelog.rst b/src/changelog.rst index 87ebd213..9a6cbfc2 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -35,6 +35,17 @@ Language changes in Rust 1.93.0 - No change: this bug was not documented in FLS - `Stabilize asm_cfg `_ + + - 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 `_ * No change: Already covered by the classification of :t:`[constant expression]s`. diff --git a/src/glossary.rst b/src/glossary.rst index 50c7fcf4..ca8b05ed 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -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 diff --git a/src/inline-assembly.rst b/src/inline-assembly.rst index b54cb9c0..b2ddc0fc 100644 --- a/src/inline-assembly.rst +++ b/src/inline-assembly.rst @@ -963,7 +963,10 @@ Assembly Instructions .. syntax:: AssemblyCodeBlock ::= - AssemblyInstruction ($$,$$ AssemblyInstruction)* + AssemblyTemplate ($$,$$ AssemblyTemplate)* + + AssemblyTemplate ::= + OuterAttribute* AssemblyInstruction AssemblyInstruction ::= StringLiteral @@ -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 $$}$$ @@ -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`. @@ -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 {